Skip to content

Commit d2bde96

Browse files
lf-meta-codesync[bot]
authored andcommitted
Makefile: allow injecting prebuilt thrift compiler (#617)
Summary: This is required for Nix builds. I also switched pwd to be resolved from PATH because /bin/pwd is not a thing on NixOS. Pull Request resolved: #617 Reviewed By: kbojarczuk Differential Revision: D93098872 Pulled By: aahanaggarwal fbshipit-source-id: 7f79698cbc380307b9dce8a4fdfcaf19fed97cb5
1 parent 2eb9533 commit d2bde96

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

Makefile

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
#
6464

6565
CABAL_BIN=cabal
66-
PWD := $(shell /bin/pwd)
66+
PWD := $(shell pwd)
6767

6868
# There's a lot of parallelism in the schema-generated code
6969
# If you have >=16G and >=4 cores, trying passing these:
@@ -99,6 +99,11 @@ BYTECODE_SRCS= \
9999
$(wildcard glean/bytecode/*/Glean/Bytecode/*/*.hs) \
100100
$(wildcard glean/bytecode/Glean/Bytecode/*.hs)
101101

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+
102107
all:: glean.cabal thrift $(BYTECODE_GEN) gen-schema thrift-schema-hs glean
103108

104109
.PHONY: cabal-update
@@ -146,7 +151,7 @@ gen-bytecode: $(BYTECODE_GEN)
146151

147152
# Note we don't rsync here because we have actual dependencies
148153
$(BYTECODE_GEN) &: $(BYTECODE_SRCS) glean.cabal
149-
$(CABAL) run gen-bytecode-hs -- --install_dir=glean/hs
154+
$(GEN_BYTECODE) --install_dir=glean/hs
150155

151156
.PHONY: test
152157
test:: glean.cabal
@@ -243,19 +248,31 @@ thrift:: thrift-compiler thrift-hs
243248
thrift-hs:: thrift-hsthrift-hs thrift-glean-hs
244249

245250
.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
246254
thrift-compiler::
247255
(cd hsthrift && make CABAL="$(CABAL)" compiler)
248256
$(eval THRIFT_COMPILE := $$(shell $$(CABAL) -v0 list-bin exe:thrift-compiler))
257+
else
258+
thrift-compiler::
259+
# no-op
260+
endif
249261

250262
.PHONY: thrift-hsthrift-hs
263+
ifndef THRIFT_COMPILE
251264
thrift-hsthrift-hs::
252265
(cd hsthrift && make CABAL="$(CABAL)" thrift-hs)
266+
else
267+
thrift-hsthrift-hs::
268+
# no-op
269+
endif
253270

254271
.PHONY: gen-schema
255272
gen-schema :: glean.cabal cxx-libraries
256273
rm -rf $(CODEGEN_DIR)/$@
257274
mkdir -p $(CODEGEN_DIR)/$@
258-
$(CABAL) run glean:gen-schema -- \
275+
$(GEN_SCHEMA) \
259276
--install_dir $(CODEGEN_DIR)/$@ \
260277
--dir glean/schema/source \
261278
--thrift glean/schema \

0 commit comments

Comments
 (0)