Created
November 6, 2017 17:27
-
-
Save MartyLake/787cb9fe3b7fb973686f6b757833fd1b to your computer and use it in GitHub Desktop.
makefile uses an embedded python script to populate a local variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#from https://stackoverflow.com/questions/17125269/embed-python-in-makefile-to-set-make-variables | |
define NEWLINE | |
endef | |
define DETECT_SDK | |
import os | |
locations = [ | |
"../google_appengine", | |
"/usr/local/google_appengine", | |
"../.locally/google_appengine", | |
] | |
for path in locations: | |
if os.path.exists(path): | |
print(path) | |
break | |
endef | |
SDK_PATH ?= $(shell echo '$(subst $(NEWLINE),@NEWLINE@,${DETECT_SDK})' | sed 's/@NEWLINE@/\n/g' | python -) | |
default: | |
@echo 'SDK Path Detected: $(SDK_PATH)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment