|
63 | 63 | # |
64 | 64 |
|
65 | 65 | CABAL_BIN=cabal |
66 | | -PWD := $(shell /bin/pwd) |
| 66 | +PWD := $(shell pwd) |
67 | 67 |
|
68 | 68 | # There's a lot of parallelism in the schema-generated code |
69 | 69 | # If you have >=16G and >=4 cores, trying passing these: |
@@ -99,6 +99,11 @@ BYTECODE_SRCS= \ |
99 | 99 | $(wildcard glean/bytecode/*/Glean/Bytecode/*/*.hs) \ |
100 | 100 | $(wildcard glean/bytecode/Glean/Bytecode/*.hs) |
101 | 101 |
|
| 102 | +# Code generators. May be injected by external build systems if those are |
| 103 | +# managing the build. |
| 104 | +GEN_SCHEMA = $(CABAL) run glean:gen-schema -- |
| 105 | +GEN_BYTECODE = $(CABAL) run glean:gen-bytecode-hs -- |
| 106 | + |
102 | 107 | all:: glean.cabal thrift $(BYTECODE_GEN) gen-schema thrift-schema-hs glean |
103 | 108 |
|
104 | 109 | .PHONY: cabal-update |
@@ -146,7 +151,7 @@ gen-bytecode: $(BYTECODE_GEN) |
146 | 151 |
|
147 | 152 | # Note we don't rsync here because we have actual dependencies |
148 | 153 | $(BYTECODE_GEN) &: $(BYTECODE_SRCS) glean.cabal |
149 | | - $(CABAL) run gen-bytecode-hs -- --install_dir=glean/hs |
| 154 | + $(GEN_BYTECODE) --install_dir=glean/hs |
150 | 155 |
|
151 | 156 | .PHONY: test |
152 | 157 | test:: glean.cabal |
@@ -243,19 +248,31 @@ thrift:: thrift-compiler thrift-hs |
243 | 248 | thrift-hs:: thrift-hsthrift-hs thrift-glean-hs |
244 | 249 |
|
245 | 250 | .PHONY: thrift-compiler |
| 251 | +# Allow injecting a prebuilt thrift compiler by setting THRIFT_COMPILE in |
| 252 | +# environment (e.g. with Nix). |
| 253 | +ifndef THRIFT_COMPILE |
246 | 254 | thrift-compiler:: |
247 | 255 | (cd hsthrift && make CABAL="$(CABAL)" compiler) |
248 | 256 | $(eval THRIFT_COMPILE := $$(shell $$(CABAL) -v0 list-bin exe:thrift-compiler)) |
| 257 | +else |
| 258 | +thrift-compiler:: |
| 259 | + # no-op |
| 260 | +endif |
249 | 261 |
|
250 | 262 | .PHONY: thrift-hsthrift-hs |
| 263 | +ifndef THRIFT_COMPILE |
251 | 264 | thrift-hsthrift-hs:: |
252 | 265 | (cd hsthrift && make CABAL="$(CABAL)" thrift-hs) |
| 266 | +else |
| 267 | +thrift-hsthrift-hs:: |
| 268 | + # no-op |
| 269 | +endif |
253 | 270 |
|
254 | 271 | .PHONY: gen-schema |
255 | 272 | gen-schema :: glean.cabal cxx-libraries |
256 | 273 | rm -rf $(CODEGEN_DIR)/$@ |
257 | 274 | mkdir -p $(CODEGEN_DIR)/$@ |
258 | | - $(CABAL) run glean:gen-schema -- \ |
| 275 | + $(GEN_SCHEMA) \ |
259 | 276 | --install_dir $(CODEGEN_DIR)/$@ \ |
260 | 277 | --dir glean/schema/source \ |
261 | 278 | --thrift glean/schema \ |
|
0 commit comments