Skip to content

Commit aaaac77

Browse files
simonmarmeta-codesync[bot]
authored andcommitted
Fix CI (#177)
Summary: The OSS build needs the `thrift/` annotation tree to be visible from inside `compiler/` and `lib/`, because each is a separate Cabal package and Cabal cannot reference files outside a package's own directory. The annotation files are resolved by the literal path `thrift/annotation/...`, so the name has to be exactly that. These symlinks can't be committed: `lib/` and `compiler/` already contain a `Thrift/` directory, and fbsource rejects paths that differ only in case, so pushrebase fails with: ``` Case conflict found: fbcode/common/hs/thrift/lib/Thrift conflicts with fbcode/common/hs/thrift/lib/thrift ``` So they are generated at build time instead, via a `symlinks` Make target that `compiler` and `thrift-hs` depend on. `ci-getdeps.yml` also invokes `make symlinks` explicitly before `cabal sdist`, since `thrift-compiler.cabal` globs `thrift/**/*.thrift` into the source distribution and CI runs `cabal sdist` directly rather than through the Makefile. The generated symlinks are added to `.gitignore`. Pull Request resolved: #177 Reviewed By: helfper Differential Revision: D116622224 Pulled By: CatherineGasnier fbshipit-source-id: c9570f1126e0c96828d3f8c5f4910f542b1cbe2a
1 parent 7d3f945 commit aaaac77

4 files changed

Lines changed: 37 additions & 19 deletions

File tree

.github/workflows/ci-getdeps.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ jobs:
157157
name: Generate C++ code from thrift files
158158
run: make thrift-cpp
159159

160+
# thrift-compiler.cabal globs thrift/**/*.thrift into the sdist, so this
161+
# has to run before `cabal sdist`, not just before the Makefile codegen.
162+
- name: Create the thrift/ symlinks
163+
run: make symlinks
164+
160165
- name: Build everything up to thrift-compiler
161166
run: cabal $CABAL_CONFIG_FLAGS build exe:thrift-compiler
162167

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ gen-hs2/
55
gen-cpp2/
66
lib/gen-hs2/
77
lib/if/gen-cpp2/
8+
lib/thrift
9+
compiler/thrift
810
folly-clib/folly
911
folly-clib/folly-clib.cabal
1012
folly-clib/fast_float*

Makefile

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ THRIFT_INCLUDE := -I $(HSTHRIFT_PREFIX)/include
1616

1717
all:: compiler thrift-hs thrift-cpp server thrift-http
1818

19-
compiler::
19+
# Cabal packages can't reference files outside their own directory, and the
20+
# annotation files are resolved by the literal path "thrift/annotation/...",
21+
# so the name has to be exactly this. Generated rather than committed because
22+
# lib/ and compiler/ also contain a Thrift/, and fbsource rejects paths
23+
# differing only in case.
24+
.PHONY: symlinks
25+
symlinks::
26+
ln -sfn ../thrift lib/thrift
27+
ln -sfn ../thrift compiler/thrift
28+
29+
compiler:: symlinks
2030
$(CABAL) build exe:thrift-compiler
2131

2232
server::
@@ -30,47 +40,47 @@ thrift-http::
3040

3141
thrift:: thrift-cpp thrift-hs
3242

33-
thrift-hs:: compiler
43+
thrift-hs:: compiler symlinks
3444
( \
3545
THRIFT_COMPILE=$$($(CABAL) -v0 list-bin exe:thrift-compiler); \
3646
(cd lib && $${THRIFT_COMPILE} --hs \
3747
if/RpcOptions.thrift); \
3848
(cd lib && $${THRIFT_COMPILE} --hs \
3949
if/ApplicationException.thrift); \
40-
$${THRIFT_COMPILE} --hs \
50+
(cd lib && $${THRIFT_COMPILE} --hs \
4151
thrift/annotation/thrift.thrift \
42-
-o lib/test; \
43-
$${THRIFT_COMPILE} --hs \
52+
-o test); \
53+
(cd lib && $${THRIFT_COMPILE} --hs \
4454
thrift/annotation/scope.thrift \
45-
-o lib/test; \
55+
-o test); \
4656
(cd lib && $${THRIFT_COMPILE} --hs --use-int \
4757
test/if/math.thrift \
4858
-o test); \
4959
mkdir -p cpp-channel/test/if; \
50-
$${THRIFT_COMPILE} --hs \
60+
(cd lib && $${THRIFT_COMPILE} --hs \
5161
thrift/annotation/thrift.thrift \
52-
-o cpp-channel/test; \
53-
$${THRIFT_COMPILE} --hs \
62+
-o ../cpp-channel/test); \
63+
(cd lib && $${THRIFT_COMPILE} --hs \
5464
thrift/annotation/scope.thrift \
55-
-o cpp-channel/test; \
65+
-o ../cpp-channel/test); \
5666
(cd lib && $${THRIFT_COMPILE} --hs --use-int \
5767
test/if/math.thrift \
5868
-o ../cpp-channel/test/if); \
59-
$${THRIFT_COMPILE} --hs \
69+
(cd lib && $${THRIFT_COMPILE} --hs \
6070
thrift/annotation/thrift.thrift \
61-
-o server/test; \
62-
$${THRIFT_COMPILE} --hs \
71+
-o ../server/test); \
72+
(cd lib && $${THRIFT_COMPILE} --hs \
6373
thrift/annotation/scope.thrift \
64-
-o server/test; \
74+
-o ../server/test); \
6575
(cd lib && $${THRIFT_COMPILE} --hs --use-int \
6676
test/if/math.thrift \
6777
-o ../server/test); \
68-
$${THRIFT_COMPILE} --hs \
78+
(cd lib && $${THRIFT_COMPILE} --hs \
6979
thrift/annotation/thrift.thrift \
70-
-o http/test; \
71-
$${THRIFT_COMPILE} --hs \
80+
-o ../http/test); \
81+
(cd lib && $${THRIFT_COMPILE} --hs \
7282
thrift/annotation/scope.thrift \
73-
-o http/test; \
83+
-o ../http/test); \
7484
(cd lib && $${THRIFT_COMPILE} --hs --use-int \
7585
test/if/math.thrift \
7686
-o ../http/test); \

compiler/thrift-compiler.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ extra-source-files: test/fixtures/**/*.ast,
1919
test/fixtures/gen-hs2/**/*.hs,
2020
test/if/*.thrift,
2121
tests/**/*.thrift,
22-
tests/**/*.hs
22+
tests/**/*.hs,
23+
thrift/**/*.thrift
2324

2425
description:
2526
A compiler from the Thrift Interface Definition Language (IDL) to Haskell.

0 commit comments

Comments
 (0)