README.md
1# flex and bison binaries
2
3This folder contains the flex and bison binaries. We use these binaries to
4generate the ANGLE translator's lexer and parser.
5
6Use the script [`update_flex_bison_binaries.py`](update_flex_bison_binaries.py)
7to update the versions of these binaries in cloud storage. It must be run on
8Linux or Windows. It will update the SHAs for your platform. After running the
9script run `git commit` and then `git cl upload` to code review using the normal
10review process. You will also want to run
11[`scripts/run_code_generation.py`](../../scripts/run_code_generation.py) to
12update the generated files.
13
14Please update Windows, Linux and Mac binaries at the same time. Start with
15Windows, then merge your work into a single CL that updates all binaries
16simultaneously.
17
18If you get authentication errors while uploading, try running:
19```
20$ download_from_google_storage --config
21```
22
23Contact syoussefi for any help with updating the binaries.
24
25## Updating flex and bison binaries
26
27This is expected to be a rare operation, and is currently done based on the
28following instructions. Note: get the binaries first on windows, as only a
29single option is available, then build the binaries for the same version on
30Linux/Mac.
31
32### On Windows
33
34Install MSys2 (x86_64) from http://www.msys2.org/ on Windows. `flex` should
35already be installed. Install bison:
36
37```
38$ pacman -S bison
39```
40
41Note the versions of flex and bison, so you can build the exact same versions on Linux.
42For example:
43
44```
45$ flex --version
46flex 2.6.4
47
48$ bison --version
49bison (GNU Bison) 3.8.2
50```
51
52The only dependencies outside /Windows/ from MSys2 should be the following:
53
54```
55msys-intl-8.dll
56msys-iconv-2.dll
57msys-2.0.dll
58```
59
60This can be verified with:
61
62```
63$ ldd /usr/bin/flex
64$ ldd /usr/bin/bison
65```
66
67Additionally, we need the binary for m4 at `/usr/bin/m4`.
68
69Copy all these 5 files to this directory:
70
71```
72$ cd angle/
73$ cp /usr/bin/flex.exe \
74 /usr/bin/bison.exe \
75 /usr/bin/m4.exe \
76 /usr/bin/msys-intl-8.dll \
77 /usr/bin/msys-iconv-2.dll \
78 /usr/bin/msys-2.0.dll \
79 tools/flex-bison/windows/
80```
81
82Upload the binaries:
83
84```
85$ cd angle/
86$ py tools/flex-bison/update_flex_bison_binaries.py
87```
88
89### On Linux
90
91```
92# Get the source of flex
93$ git clone https://github.com/westes/flex.git
94$ cd flex/
95# Checkout the same version as msys2 on windows
96$ git checkout v2.6.4
97# Build
98$ autoreconf -i
99$ mkdir build && cd build
100$ ../configure CFLAGS="-O2 -D_GNU_SOURCE"
101$ make -j
102```
103
104```
105# Get the source of bison
106$ curl http://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.xz | tar -xJ
107$ cd bison-3.8.2
108# Build
109$ mkdir build && cd build
110$ ../configure CFLAGS="-O2"
111$ make -j
112```
113
114Note: Bison's [home page][Bison] lists ftp server and other mirrors. If the
115above link is broken, replace with a mirror.
116
117Copy the 2 executables to this directory:
118
119```
120$ cd angle/
121$ cp /path/to/flex/build/src/flex \
122 /path/to/bison/build/src/bison \
123 tools/flex-bison/linux/
124```
125
126Upload the binaries:
127
128```
129$ cd angle/
130$ ./tools/flex-bison/update_flex_bison_binaries.py
131```
132
133### On Mac
134
135Use homebrew to install flex and bison:
136```
137$ brew install flex bison
138```
139
140Find the install locations using `brew info`:
141```
142$ brew info bison
143...
144/opt/homebrew/Cellar/bison/3.8.2 (100 files, 3.7MB)
145...
146```
147
148Copy the 2 executables to this directory:
149
150```
151$ cd angle/
152$ cp -r \
153 /path/to/bison/install/bin \
154 /path/to/flex/install/bin \
155 tools/flex-bison/mac/
156```
157
158Upload the binaries:
159
160```
161$ cd angle/
162$ ./tools/flex-bison/update_flex_bison_binaries.py
163```
164
165[Bison]: https://www.gnu.org/software/bison/
166