build: add ninja support to Makefile
authorBen Noordhuis <info@bnoordhuis.nl>
Tue, 4 Sep 2012 14:03:01 +0000 (16:03 +0200)
committerBen Noordhuis <info@bnoordhuis.nl>
Tue, 4 Sep 2012 14:04:01 +0000 (16:04 +0200)
Makefile
configure

index cae2a23..664fafd 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,7 @@
 
 BUILDTYPE ?= Release
 PYTHON ?= python
+NINJA ?= ninja
 DESTDIR ?=
 SIGN ?=
 
@@ -22,22 +23,34 @@ endif
 # to check for changes.
 .PHONY: node node_g
 
+ifeq ($(USE_NINJA),1)
+node: config.gypi
+       $(NINJA) -C out/Release/
+       ln -fs out/Release/node node
+
+node_g: config.gypi
+       $(NINJA) -C out/Debug/
+       ln -fs out/Debug/node $@
+else
 node: config.gypi out/Makefile
        $(MAKE) -C out BUILDTYPE=Release V=$(V)
        ln -fs out/Release/node node
 
 node_g: config.gypi out/Makefile
        $(MAKE) -C out BUILDTYPE=Debug V=$(V)
-       ln -fs out/Debug/node node_g
-
-config.gypi: configure
-       ./configure
-
-out/Debug/node:
-       $(MAKE) -C out BUILDTYPE=Debug V=$(V)
+       ln -fs out/Debug/node $@
+endif
 
 out/Makefile: common.gypi deps/uv/uv.gyp deps/http_parser/http_parser.gyp deps/zlib/zlib.gyp deps/v8/build/common.gypi deps/v8/tools/gyp/v8.gyp node.gyp config.gypi
+ifeq ($(USE_NINJA),1)
+       touch out/Makefile
+       $(PYTHON) tools/gyp_node -f ninja
+else
        $(PYTHON) tools/gyp_node -f make
+endif
+
+config.gypi: configure
+       ./configure
 
 install: all
        $(PYTHON) tools/install.py $@ $(DESTDIR)
index 3bf9b04..50f265b 100755 (executable)
--- a/configure
+++ b/configure
@@ -167,7 +167,7 @@ parser.add_option("--with-arm-float-abi",
 
 parser.add_option("--ninja",
     action="store_true",
-    dest="ninja_build",
+    dest="use_ninja",
     help="Generate files for the ninja build system")
 
 (options, args) = parser.parse_args()
@@ -459,10 +459,16 @@ def write(filename, data):
 write('config.gypi', "# Do not edit. Generated by the configure script.\n" +
   pprint.pformat(output, indent=2) + "\n")
 
-write('config.mk', "# Do not edit. Generated by the configure script.\n" +
-  ("BUILDTYPE=%s\n" % ('Debug' if options.debug else 'Release')))
+config = {
+  'BUILDTYPE': 'Debug' if options.debug else 'Release',
+  'USE_NINJA': str(int(options.use_ninja or 0)),
+}
+config = '\n'.join(map('='.join, config.iteritems())) + '\n'
+
+write('config.mk',
+      '# Do not edit. Generated by the configure script.\n' + config)
 
-if options.ninja_build:
+if options.use_ninja:
   gyp_args = ['-f', 'ninja']
 elif os.name == 'nt':
   gyp_args = ['-f', 'msvs', '-G', 'msvs_version=2010']