aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorTeddy Wing2018-09-24 21:34:35 +0200
committerTeddy Wing2018-09-24 21:34:35 +0200
commit8c363688ac173d34c865b8271ade8c845b67fa24 (patch)
tree7404c294388a51ff36ccea1925bdd43360d0b107 /Makefile
parent2eb65dbc919cdf4a55e958f2fbd9e42d9a940a48 (diff)
downloadDomeKey-8c363688ac173d34c865b8271ade8c845b67fa24.tar.bz2
Makefile: Only run `xcodebuild` when there are changes
Previously, Make would always run `xcodebuild`. I couldn't figure out why, but after some looking around and experimenting, it looked to be due to the `$(RUST_LIB)` prerequisite. Putting it in the order-only dependencies list seems to fix the never-up-to-date problem. Also use `:=` instead of `=` when defining `SOURCE_FILES`. During my research, I came across this recommendation: > always use := not = for shell (and wildcard, for that matter) for > performance reasons. From MadScientist (https://stackoverflow.com/users/939557/madscientist) on Stack Overflow: https://stackoverflow.com/questions/26694249/makefiles-using-wildcard-vs-find-for-specifying-source-files/26694693#26694693 Move the `DomeKey` debug product executable path into a variable and use it as a target to clarify the build target and also allow us to substitute the variable in the `run` task. Now finally, `make run` won't re-build the project if no changes have been made, it'll just run the executable.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile10
1 files changed, 7 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 1a1f35c..687d70a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-SOURCE_FILES = $(shell find DomeKey lib \
+SOURCE_FILES := $(shell find DomeKey lib \
-type f \
-name '*.h' \
-or -name '*.m' \
@@ -7,9 +7,13 @@ SOURCE_FILES = $(shell find DomeKey lib \
RUST_DIR := lib/dome-key-map
RUST_LIB := target/debug/libdome_key_map.a
+DEBUG_PRODUCT := ~/Library/Developer/Xcode/DerivedData/DomeKey-*/Build/Products/Debug/DomeKey
+
.PHONY: build
-build: $(SOURCE_FILES) $(RUST_LIB)
+build: $(DEBUG_PRODUCT)
+
+$(DEBUG_PRODUCT): $(SOURCE_FILES) | $(RUST_LIB)
xcodebuild -scheme DomeKey -configuration Debug
$(RUST_LIB):
@@ -17,4 +21,4 @@ $(RUST_LIB):
.PHONY: run
run: build
- ~/Library/Developer/Xcode/DerivedData/DomeKey-*/Build/Products/Debug/DomeKey
+ $(DEBUG_PRODUCT)