Skip to content

Commit 3ec11d4

Browse files
SamChou19815facebook-github-bot
authored andcommitted
[flow] Switch dune build to ocaml 5.2 (facebook#9170)
Summary: Pull Request resolved: facebook#9170 - The new OCaml 5 setup requires opam 2.2.0-beta3, so I updated the action.yml to install that instead. On the windows side, I used `winget` to install it. - I bumped the package versions for OCaml 5. The versions are chosen based on the internal buck build's versions. - In the Makefile of fuzzy-path: we need to explicitly set the `CC` and `CPP` env var that's previously implicitly set by the windows opam fork. Reviewed By: pieterv Differential Revision: D58630448 fbshipit-source-id: e5ae2fc43164f038a58aa8fe041a794cc26aa8af
1 parent 0d0c5c8 commit 3ec11d4

File tree

11 files changed

+43
-37
lines changed

11 files changed

+43
-37
lines changed

.github/actions/install-opam-linux/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ runs:
1111
run: |-
1212
if ! [ -x "$(command -v opam)" ]; then
1313
echo "Downloading opam..."
14-
curl -sL -o "$RUNNER_TEMP/opam" "https://github.com/ocaml/opam/releases/download/2.1.3/opam-2.1.3-${{ inputs.arch }}-linux"
14+
curl -sL -o "$RUNNER_TEMP/opam" "https://github.com/ocaml/opam/releases/download/2.2.0-beta3/opam-2.2.0-beta3-${{ inputs.arch }}-linux"
1515
echo "Installing opam..."
1616
sudo install -m 755 "$RUNNER_TEMP/opam" "/usr/local/bin/opam"
1717
echo "Removing opam temp file..."

.github/actions/install-opam-mac/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ runs:
1111
run: |-
1212
if ! [ -x "$(command -v opam)" ]; then
1313
echo "Downloading opam..."
14-
curl -sL -o "$RUNNER_TEMP/opam" "https://github.com/ocaml/opam/releases/download/2.1.3/opam-2.1.3-${{ inputs.arch }}-macos"
14+
curl -sL -o "$RUNNER_TEMP/opam" "https://github.com/ocaml/opam/releases/download/2.2.0-beta3/opam-2.2.0-beta3-${{ inputs.arch }}-macos"
1515
echo "Installing opam..."
1616
install -m 755 "$RUNNER_TEMP/opam" "/usr/local/bin/opam"
1717
echo "Removing opam temp file..."

.github/workflows/build_and_test.yml

+19-8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ jobs:
4343
run: make deps-js
4444
- name: Build flow.js
4545
run: opam exec -- make js
46+
- name: Test flow.js
47+
run: opam exec -- make do-test-js
4648
- name: Build flow_parser.js
4749
run: opam exec -- make -C src/parser js
4850
- name: Create artifacts
@@ -278,9 +280,11 @@ jobs:
278280
perl
279281
mingw64-x86_64-gcc-core
280282
mingw64-x86_64-gcc-g++
281-
mingw-w64-x86_64-gcc-libs
283+
mingw64-x86_64-gcc-libs
282284
coreutils
283285
moreutils
286+
- name: Install winget
287+
uses: Cyberboss/install-winget@v1
284288
- name: Install opam
285289
run: .\scripts\windows\install_opam.ps1
286290
shell: pwsh
@@ -292,24 +296,31 @@ jobs:
292296
$Env:HOME/.opam
293297
_opam
294298
- name: Init opam
295-
run: opam init default 'https://github.com/ocaml-opam/opam-repository-mingw.git#opam2' --bare --disable-sandboxing --no-setup
296-
shell: C:\cygwin\bin\bash.exe -leo pipefail '{0}'
299+
run: opam init --bare --disable-sandboxing --no-setup --yes
300+
shell: C:\cygwin\bin\bash.exe '{0}'
301+
env:
302+
PATH: /usr/local/bin:/usr/bin:/cygdrive/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0
303+
- name: Git Safe Directory
304+
run: git config --global --add safe.directory /cygdrive/d/a/flow/flow
305+
shell: C:\cygwin\bin\bash.exe '{0}'
306+
env:
307+
PATH: /usr/local/bin:/usr/bin:/cygdrive/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0
297308
- name: Create opam switch
298-
run: |-
299-
make deps
309+
run: make deps
300310
shell: C:\cygwin\bin\bash.exe '{0}'
301311
env:
302-
PATH: /usr/local/bin:/usr/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0
312+
PATH: /usr/local/bin:/usr/bin:/cygdrive/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0
303313
- name: Build flow.exe
304314
run: >-
305315
cd ${GITHUB_WORKSPACE} ;
316+
echo $(opam env) ;
306317
eval $(opam env) ;
307318
make bin/flow.exe dist/flow.zip ;
308319
mkdir -p bin/win64 && cp bin/flow.exe bin/win64/flow.exe ;
309320
cp dist/flow.zip dist/flow-win64.zip
310321
shell: C:\cygwin\bin\bash.exe -leo pipefail '{0}'
311322
env:
312-
PATH: /usr/local/bin:/usr/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0
323+
PATH: /usr/local/bin:/usr/bin:/cygdrive/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0
313324
- name: Build parser test runner
314325
run: >-
315326
cd ${GITHUB_WORKSPACE} ;
@@ -318,7 +329,7 @@ jobs:
318329
cp _build/default/src/parser/test/run_tests.exe bin/win64/run_parser_tests.exe
319330
shell: C:\cygwin\bin\bash.exe -leo pipefail '{0}'
320331
env:
321-
PATH: /usr/local/bin:/usr/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0
332+
PATH: /usr/local/bin:/usr/bin:/cygdrive/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0
322333
- uses: actions/[email protected]
323334
with:
324335
name: build_win_bin

Makefile

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99

1010
ifeq ($(OS), Windows_NT)
1111
EXE=.exe
12-
SWITCH=ocaml-variants.4.14.0+mingw64c
1312
else
1413
EXE=
15-
SWITCH=ocaml-base-compiler.4.14.0
1614
endif
1715

18-
JS_OF_OCAML_VERSION=5.5.2
19-
OUNIT_VERSION=2.2.2.4
16+
SWITCH=ocaml-variants.5.2.0+options
17+
JS_OF_OCAML_VERSION=5.7.2
18+
OUNIT_VERSION=2.2.2.6
2019

2120
# set FLOW_RELEASE=[1|true] or CI=true for an optimized build; otherwise,
2221
# defaults to dev mode that builds faster but is less efficient at runtime.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Flow-typed JavaScript can use this to generate Flow's syntax tree with annotated
5555

5656
## Building Flow from source
5757

58-
Flow is written in OCaml (OCaml 4.14.0 is required).
58+
Flow is written in OCaml (OCaml 5.2.0 is required).
5959

6060
1. Install system dependencies:
6161

@@ -107,7 +107,7 @@ Flow is written in OCaml (OCaml 4.14.0 is required).
107107
6. Build `flow.js` (optional):
108108
109109
```sh
110-
opam install -y js_of_ocaml.5.5.2
110+
opam install -y js_of_ocaml.5.7.2
111111
make js
112112
```
113113

dune

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
(flags
44
(:standard -w @a-4-29-35-41-42-44-45-48-50-58-70))
55
(js_of_ocaml
6-
(flags --disable genprim --Werror))))
6+
(flags --disable genprim))))

flow_parser.opam

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ license: "MIT"
99

1010
build: ["dune" "build" "-p" name "-j" jobs]
1111
depends: [
12-
"ocaml" {>= "4.14.0"}
12+
"ocaml" {>= "5.2.0"}
1313
"dune" {>= "3.2"}
14-
"base" {>= "v0.14.1"}
15-
"ppxlib" {>= "0.26.0"}
14+
"base" {>= "v0.16.3"}
15+
"ppxlib" {>= "0.32.1"}
1616
"ppx_deriving" {build}
1717
"ppx_gen_rec" {build}
1818
"wtf8"

flowtype.opam

+8-6
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@ homepage: "https://flow.org"
88
doc: "https://flow.org/en/docs/getting-started/"
99
bug-reports: "https://github.com/facebook/flow/issues"
1010
depends: [
11-
"ocaml" {>= "4.14.0"}
12-
"base" {>= "v0.14.1"}
11+
"ocaml" {>= "5.2.0"}
12+
"base" {>= "v0.16.3"}
1313
"base-unix"
1414
"base-bytes"
15+
"camlp-streams" {>= "5.0.1"}
1516
"dtoa" {>= "0.3.2"}
16-
"fileutils" {>= "0.6.3"}
17+
"fileutils" {>= "0.6.4"}
1718
"flow_parser" {= "0.238.1"}
1819
"inotify" {os = "linux" & >= "2.4.1"}
1920
"ounit2" {with-test}
20-
"lwt" {>= "5.4.0"}
21+
"lwt" {>= "5.7.0"}
2122
"lwt_log" {>= "1.1.1"}
22-
"lwt_ppx"
23-
"ppxlib" {= "0.28.0"}
23+
"lwt_ppx" {>= "2.1.0"}
24+
"ppxlib" {>= "0.32.1"}
25+
"ppx_expect" {>= "0.17.0"}
2426
"ppx_expect" {>= "0.17.0"}
2527
"ppx_let" {>= "0.14.0"}
2628
"ppx_deriving" {build}

scripts/windows/install_opam.ps1

+1-10
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,4 @@ if (!$cygwin_root) {
1313
echo "Found cygwin in $cygwin_root"
1414
}
1515

16-
$install_dir = "$Env:TEMP\flow\opam_installer"
17-
New-Item -ErrorAction Ignore -ItemType Directory $install_dir
18-
echo "Downloading opam64.tar.xz to $install_dir\opam64.tar.xz"
19-
(New-Object System.Net.WebClient).DownloadFile("https://github.com/fdopen/opam-repository-mingw/releases/download/0.0.0.2/opam64.tar.xz", "$install_dir\opam64.tar.xz")
20-
$out_dir = "$install_dir".Replace("\", "/")
21-
echo "Extracting opam64.tar.xz"
22-
& $cygwin_root\bin\bash.exe -l -c "tar -x --force-local -f '$install_dir\opam64.tar.xz' -C '$out_dir'"
23-
echo "Installing opam"
24-
& $cygwin_root\bin\bash.exe -l "$install_dir\opam64\install.sh"
25-
echo "Done"
16+
winget install opam --disable-interactivity --accept-source-agreements --location $cygwin_root

src/third-party/fuzzy-path/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22
ifeq ($(OS), Windows_NT)
3+
CC:=x86_64-w64-mingw32-gcc.exe
4+
CPP:=x86_64-w64-mingw32-cpp.exe
35
CXX:=x86_64-w64-mingw32-g++
46
AR:=x86_64-w64-mingw32-gcc-ar
57
endif

src/third-party/ocaml-vlq/src/dune

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
(library
22
(name flow_third_party_vlq)
3-
(wrapped false))
3+
(wrapped false)
4+
(libraries camlp-streams))

0 commit comments

Comments
 (0)