diff options
-rw-r--r-- | Makefile | 14 | ||||
-rwxr-xr-x | gyp_skia | 32 |
2 files changed, 37 insertions, 9 deletions
@@ -27,6 +27,7 @@ # # See https://sites.google.com/site/skiadocs/ for complete documentation. +SKIA_OUT ?= out BUILDTYPE ?= Debug CWD := $(shell pwd) @@ -72,6 +73,9 @@ all: everything .PHONY: clean clean: rm -rf out xcodebuild +ifneq (out, $(SKIA_OUT)) + rm -rf $(SKIA_OUT) +endif # Run gyp no matter what. .PHONY: gyp @@ -90,13 +94,13 @@ gyp: .PHONY: gyp_if_needed gyp_if_needed: ifneq (,$(findstring Linux, $(uname))) - $(MAKE) out/Makefile + $(MAKE) $(SKIA_OUT)/Makefile endif ifneq (,$(findstring Darwin, $(uname))) $(CWD)/gyp_skia endif -out/Makefile: +$(SKIA_OUT)/Makefile: $(CWD)/gyp_skia # For all specific targets: run gyp if necessary, and then pass control to @@ -106,9 +110,11 @@ out/Makefile: .PHONY: $(VALID_TARGETS) $(VALID_TARGETS):: gyp_if_needed ifneq (,$(findstring skia_os=android, $(GYP_DEFINES))) - $(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE) + $(MAKE) -C $(SKIA_OUT) $@ BUILDTYPE=$(BUILDTYPE) else ifneq (,$(findstring Linux, $(uname))) - $(MAKE) -C out $@ BUILDTYPE=$(BUILDTYPE) + $(MAKE) -C $(SKIA_OUT) $@ BUILDTYPE=$(BUILDTYPE) +else ifneq (,$(findstring make, $(GYP_GENERATORS))) + $(MAKE) -C $(SKIA_OUT) $@ BUILDTYPE=$(BUILDTYPE) else ifneq (,$(findstring Darwin, $(uname))) rm -f out/$(BUILDTYPE) || if test -d out/$(BUILDTYPE); then echo "run 'make clean' or otherwise delete out/$(BUILDTYPE)"; exit 1; fi xcodebuild -project out/gyp/$@.xcodeproj -configuration $(BUILDTYPE) @@ -11,6 +11,7 @@ import glob import os +import platform import shlex import sys @@ -22,10 +23,6 @@ gyp_source_dir = os.path.join(script_dir, 'third_party', 'externals', 'gyp') # Directory within which we can find most of Skia's gyp configuration files. gyp_config_dir = os.path.join(script_dir, 'gyp') -# Directory within which we want all generated files (including Makefiles) -# to be written. -output_dir = os.path.join(os.path.abspath(script_dir), 'out') - # Ensure we import our current gyp source's module, not any version # pre-installed in your PYTHONPATH. sys.path.insert(0, os.path.join(gyp_source_dir, 'pylib')) @@ -54,6 +51,31 @@ def additional_include_files(args=[]): return result +# Return the directory where all generated files (including Makefiles) are to +# be written. +def get_output_dir(): + + # SKIA_OUT can be any directory either as a child of the standard out/ + # directory or any given location on the file system (e.g. /tmp/skia) + output_dir = os.getenv('SKIA_OUT') + + if not output_dir: + return os.path.join(os.path.abspath(script_dir), 'out') + + if (os.name != 'posix' or + (sys.platform.startswith('darwin') and + (not os.getenv('GYP_GENERATORS') or + 'make' not in os.getenv('GYP_GENERATORS')))): + print 'ERROR: variable SKIA_OUT is not valid on Mac (using xcodebuild)' \ + ' or Windows' + sys.exit(-1); + + if os.path.isabs(output_dir): + return output_dir + else: + return os.path.join(os.path.abspath(script_dir), output_dir) + + if __name__ == '__main__': args = sys.argv[1:] @@ -83,7 +105,7 @@ if __name__ == '__main__': args.extend(['--depth', '.']) # Tell gyp to write the Makefiles into output_dir - args.extend(['--generator-output', os.path.abspath(output_dir)]) + args.extend(['--generator-output', os.path.abspath(get_output_dir())]) # Tell make to write its output into the same dir args.extend(['-Goutput_dir=.']) |