|
1 |
| -GENEREATORS = chains cctpDomains |
2 |
| -chains_TARGET = ../src/constants/Chains.sol |
3 |
| -cctpDomains_TARGET = ../src/constants/CCTPDomains.sol |
| 1 | +GENERATORS = chains cctpDomains |
| 2 | +chains_TARGET = constants/Chains.sol |
| 3 | +cctpDomains_TARGET = constants/CCTPDomains.sol |
4 | 4 |
|
5 |
| -TEST_WRAPPERS = BytesParsing |
6 |
| -BytesParsing_BASE_PATH = libraries |
| 5 | +fnGeneratorTarget = ../src/$($(1)_TARGET) |
| 6 | +GENERATOR_TARGETS = $(foreach generator,$(GENERATORS),$(call fnGeneratorTarget,$(generator))) |
| 7 | + |
| 8 | +TEST_WRAPPERS = BytesParsing QueryResponse |
7 | 9 |
|
8 | 10 | fnTestWrapperTarget = ../test/generated/$(1)TestWrapper.sol
|
9 | 11 | TEST_WRAPPER_TARGETS =\
|
10 |
| - $(foreach wrapper, $(TEST_WRAPPERS), $(call fnTestWrapperTarget,$(wrapper))) |
| 12 | + $(foreach wrapper,$(TEST_WRAPPERS),$(call fnTestWrapperTarget,$(wrapper))) |
| 13 | + |
| 14 | +.DEFAULT_GOAL = build |
| 15 | +.PHONY: build clean FORCE |
11 | 16 |
|
12 |
| -.PHONY: generate $(GENEREATORS) |
| 17 | +build: $(GENERATOR_TARGETS) $(TEST_WRAPPER_TARGETS) |
13 | 18 |
|
14 |
| -build: $(GENEREATORS) $(TEST_WRAPPER_TARGETS) |
| 19 | +clean: |
| 20 | + rm -rf node_modules fork_changed testing.env |
15 | 21 |
|
16 |
| -$(GENEREATORS): node_modules |
17 |
| - npx ts-node $@.ts > $($@_TARGET) |
| 22 | +FORCE: |
18 | 23 |
|
19 |
| -node_modules: package-lock.json |
20 |
| - npm ci |
| 24 | +node_modules: |
| 25 | + npm i |
| 26 | + |
| 27 | +define ruleGenerator |
| 28 | +$(call fnGeneratorTarget,$(1)): node_modules $(1).ts |
| 29 | + npx ts-node $(1).ts > $$@ |
| 30 | +endef |
| 31 | +$(foreach generator,$(GENERATORS),$(eval $(call ruleGenerator,$(generator)))) |
21 | 32 |
|
22 | 33 | define ruleTestWrapper
|
23 |
| -$(call fnTestWrapperTarget,$(1)): ../src/$($(1)_BASE_PATH)/$(1).sol |
24 |
| - npx ts-node libraryTestWrapper.ts $($(1)_BASE_PATH)/$(1) > $(call fnTestWrapperTarget,$(1)) |
| 34 | +$(call fnTestWrapperTarget,$(1)): ../src/libraries/$(1).sol libraryTestWrapper.ts |
| 35 | + npx ts-node libraryTestWrapper.ts libraries/$(1) > $$@ |
25 | 36 | endef
|
26 | 37 | $(foreach wrapper,$(TEST_WRAPPERS),$(eval $(call ruleTestWrapper,$(wrapper))))
|
27 | 38 |
|
| 39 | +ifneq ($(TEST_FORK), $(shell cat fork_changed 2>/dev/null)) |
| 40 | +#if a different chain/network for testing was supplied last time then force an update |
| 41 | +fork_changed: FORCE |
| 42 | +endif |
| 43 | + |
| 44 | +testing.env: node_modules fork_changed testingEnv.ts |
| 45 | + @echo "Generating testing.env for $(TEST_FORK)" |
| 46 | + npx ts-node testingEnv.ts $(TEST_FORK) > $@ |
28 | 47 |
|
| 48 | +fork_changed: |
| 49 | + @echo $(TEST_FORK) > fork_changed |
0 commit comments