11# These are a few rules to help build the open-source hsthrift. This
22# file will hopefully go away in due course.
33#
4+ # If you are integrating this Makefile into another build system like Nix,
5+ # consider setting the environment/Make variables:
6+ # - THRIFT_COMPILE: location of a built hsthrift compiler binary
7+ # - EXTERNAL_FOLLY_CLIB: when set, assumes folly-clib is already provided in the environment
48
59CABAL_BIN := cabal
610
@@ -26,93 +30,104 @@ thrift-http::
2630
2731thrift :: thrift-cpp thrift-hs
2832
29- thrift-hs :: compiler
33+ .PHONY : thrift-compiler
34+ # Allow injecting a prebuilt thrift compiler by setting THRIFT_COMPILE in
35+ # environment (e.g. with Nix).
36+ ifndef THRIFT_COMPILE
37+ thrift-compiler :: compiler
38+ (cd hsthrift && make CABAL=" $( CABAL) " compiler)
39+ $(eval THRIFT_COMPILE := $$(shell $$(CABAL ) -v0 list-bin exe:thrift-compiler) )
40+ else
41+ thrift-compiler ::
42+ # no-op
43+ endif
44+
45+ thrift-hs :: thrift-compiler
3046 ( \
31- THRIFT_COMPILE=$$($(CABAL ) -v0 list-bin exe:thrift-compiler) ; \
32- (cd lib && $$ {THRIFT_COMPILE} --hs \
47+ (cd lib && $( THRIFT_COMPILE) --hs \
3348 if/RpcOptions.thrift); \
34- (cd lib && $$ { THRIFT_COMPILE} --hs \
49+ (cd lib && $( THRIFT_COMPILE) --hs \
3550 if/ApplicationException.thrift); \
36- (cd lib && $$ { THRIFT_COMPILE} --hs --use-int \
51+ (cd lib && $( THRIFT_COMPILE) --hs --use-int \
3752 test/if/math.thrift \
3853 -o test); \
3954 mkdir -p cpp-channel/test/if; \
40- (cd lib && $$ { THRIFT_COMPILE} --hs --use-int \
55+ (cd lib && $( THRIFT_COMPILE) --hs --use-int \
4156 test/if/math.thrift \
4257 -o ../cpp-channel/test/if); \
43- (cd lib && $$ { THRIFT_COMPILE} --hs --use-int \
58+ (cd lib && $( THRIFT_COMPILE) --hs --use-int \
4459 test/if/math.thrift \
4560 -o ../server/test); \
46- (cd lib && $$ { THRIFT_COMPILE} --hs --use-int \
61+ (cd lib && $( THRIFT_COMPILE) --hs --use-int \
4762 test/if/math.thrift \
4863 -o ../http/test); \
49- (cd lib && $$ { THRIFT_COMPILE} --hs --use-int \
64+ (cd lib && $( THRIFT_COMPILE) --hs --use-int \
5065 test/if/echoer.thrift \
5166 -o test); \
52- (cd lib && $$ { THRIFT_COMPILE} --hs --use-int \
67+ (cd lib && $( THRIFT_COMPILE) --hs --use-int \
5368 test/if/echoer.thrift \
5469 -o ../server/test); \
55- (cd lib && $$ { THRIFT_COMPILE} --hs --use-int \
70+ (cd lib && $( THRIFT_COMPILE) --hs --use-int \
5671 test/if/echoer.thrift \
5772 -o ../http/test); \
58- (cd server && $$ { THRIFT_COMPILE} --hs \
73+ (cd server && $( THRIFT_COMPILE) --hs \
5974 test/if/hash_map.thrift \
6075 -o test); \
61- (cd tests && $$ { THRIFT_COMPILE} --hs \
76+ (cd tests && $( THRIFT_COMPILE) --hs \
6277 if/hs_prefix.thrift); \
63- (cd tests && $$ { THRIFT_COMPILE} --hs \
78+ (cd tests && $( THRIFT_COMPILE) --hs \
6479 if/foo.thrift); \
65- (cd tests && $$ { THRIFT_COMPILE} --hs \
80+ (cd tests && $( THRIFT_COMPILE) --hs \
6681 if/constants.thrift); \
67- (cd tests && $$ { THRIFT_COMPILE} --hs \
82+ (cd tests && $( THRIFT_COMPILE) --hs \
6883 --duplicate-names \
6984 if/duplicate.thrift); \
70- (cd tests && $$ { THRIFT_COMPILE} --hs \
85+ (cd tests && $( THRIFT_COMPILE) --hs \
7186 if/EnumConst.thrift); \
72- (cd tests && $$ { THRIFT_COMPILE} --hs \
87+ (cd tests && $( THRIFT_COMPILE) --hs \
7388 if/enum.thrift); \
74- (cd tests && $$ { THRIFT_COMPILE} --hs \
89+ (cd tests && $( THRIFT_COMPILE) --hs \
7590 if/exception.thrift); \
76- (cd tests && $$ { THRIFT_COMPILE} --hs \
91+ (cd tests && $( THRIFT_COMPILE) --hs \
7792 --use-int --use-hash-map --use-hash-set \
7893 if/flags.thrift); \
79- (cd tests && $$ { THRIFT_COMPILE} --hs \
94+ (cd tests && $( THRIFT_COMPILE) --hs \
8095 --extra-hasfields \
8196 if/hasfield.thrift); \
82- (cd tests && $$ { THRIFT_COMPILE} --hs \
97+ (cd tests && $( THRIFT_COMPILE) --hs \
8398 if/A.thrift); \
84- (cd tests && $$ { THRIFT_COMPILE} --hs \
99+ (cd tests && $( THRIFT_COMPILE) --hs \
85100 if/B.thrift); \
86- (cd tests && $$ { THRIFT_COMPILE} --hs \
101+ (cd tests && $( THRIFT_COMPILE) --hs \
87102 if/C.thrift); \
88- (cd tests && $$ { THRIFT_COMPILE} --hs \
103+ (cd tests && $( THRIFT_COMPILE) --hs \
89104 if/D.thrift); \
90- (cd tests && $$ { THRIFT_COMPILE} --hs \
105+ (cd tests && $( THRIFT_COMPILE) --hs \
91106 if/E.thrift); \
92- (cd tests && $$ { THRIFT_COMPILE} --hs \
107+ (cd tests && $( THRIFT_COMPILE) --hs \
93108 if/versions.thrift); \
94- (cd tests && $$ { THRIFT_COMPILE} --hs \
109+ (cd tests && $( THRIFT_COMPILE) --hs \
95110 if/monoid.thrift); \
96- (cd tests && $$ { THRIFT_COMPILE} --hs \
111+ (cd tests && $( THRIFT_COMPILE) --hs \
97112 if/hs_test.thrift); \
98- (cd tests && $$ { THRIFT_COMPILE} --hs \
113+ (cd tests && $( THRIFT_COMPILE) --hs \
99114 if/hs_test.thrift -o ../lib/test); \
100- (cd tests && $$ { THRIFT_COMPILE} --hs \
115+ (cd tests && $( THRIFT_COMPILE) --hs \
101116 if/map.thrift); \
102- (cd tests && $$ { THRIFT_COMPILE} --hs \
117+ (cd tests && $( THRIFT_COMPILE) --hs \
103118 if/messed_up_case.thrift); \
104- (cd tests && $$ { THRIFT_COMPILE} --hs \
119+ (cd tests && $( THRIFT_COMPILE) --hs \
105120 if/namespace.thrift); \
106- (cd tests && $$ { THRIFT_COMPILE} --hs \
121+ (cd tests && $( THRIFT_COMPILE) --hs \
107122 if/namespace_included.thrift); \
108- (cd tests && $$ { THRIFT_COMPILE} --hs \
123+ (cd tests && $( THRIFT_COMPILE) --hs \
109124 if/parens.thrift); \
110- (cd tests && $$ { THRIFT_COMPILE} --hs \
125+ (cd tests && $( THRIFT_COMPILE) --hs \
111126 --required-symbols " A,B,C,X,weNeedThis" \
112127 if/huge.thrift); \
113- (cd tests && $$ { THRIFT_COMPILE} --hs \
128+ (cd tests && $( THRIFT_COMPILE) --hs \
114129 if/scoped_enums.thrift); \
115- (cd tests && $$ { THRIFT_COMPILE} --hs \
130+ (cd tests && $( THRIFT_COMPILE) --hs \
116131 if/service.thrift); \
117132 )
118133 # those files are required for thrift-compiler's tests
@@ -147,6 +162,7 @@ install::
147162# Unpack the correct revisions of folly and fast_float under hsthrift/folly,
148163# and run cmake to generate folly-config.h.
149164.PHONY : setup-folly
165+ ifndef EXTERNAL_FOLLY_CLIB
150166setup-folly ::
151167 rm -rf folly-clib/folly folly-clib/fast_float* folly-clib/v* .tar.gz
152168 (cd folly-clib && \
@@ -191,5 +207,12 @@ setup-folly-0::
191207 sed " s|__CPP_FILES__||;s|__H_FILES__||" < folly-clib/folly-clib.cabal.in | grep -v ' ^\s*install-includes' | grep -v ' \.h$$' > folly-clib/folly-clib.cabal
192208 sed -i " s/^version:\(\s*\).*$$ /version:\10.0/" folly-clib/folly-clib.cabal
193209
210+ else
211+ setup-folly ::
212+ .PHONY : setup-folly-version setup-folly-0
213+ setup-folly-version ::
214+ setup-folly-0 ::
215+ endif
216+
194217setup-meta ::
195218 ln -s cabal-meta.project cabal.project
0 commit comments