summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2015-07-05 15:53:28 -0700
committerNico Weber <nicolasweber@gmx.de>2015-07-05 15:53:28 -0700
commit4e6fbd9e4ef59d46bb40bfec5a28b272fa85284f (patch)
treea89d339f8cda3ff3fa2028db8ed44894461b6963
parentc81c127a0c2a20d6c6e05ed5710fc6002565e401 (diff)
parent5d4473d548ec839ee2c5acc006db682afad0bd15 (diff)
downloadninja-4e6fbd9e4ef59d46bb40bfec5a28b272fa85284f.tar.gz
Merge pull request #979 from stinb/bootstrap-out-of-source
Bootstrap out of source
-rwxr-xr-xconfigure.py26
-rw-r--r--src/browse.cc2
2 files changed, 19 insertions, 9 deletions
diff --git a/configure.py b/configure.py
index 2eacbfe..7413659 100755
--- a/configure.py
+++ b/configure.py
@@ -28,7 +28,8 @@ import string
import subprocess
import sys
-sys.path.insert(0, 'misc')
+sourcedir = os.path.dirname(os.path.realpath(__file__))
+sys.path.insert(0, os.path.join(sourcedir, 'misc'))
import ninja_syntax
@@ -155,12 +156,16 @@ class Bootstrap:
def _expand_paths(self, paths):
"""Expand $vars in an array of paths, e.g. from a 'build' block."""
paths = ninja_syntax.as_list(paths)
- return ' '.join(map(self._expand, paths))
+ return ' '.join(map(self._shell_escape, (map(self._expand, paths))))
def _expand(self, str, local_vars={}):
"""Expand $vars in a string."""
return ninja_syntax.expand(str, self.vars, local_vars)
+ def _shell_escape(self, path):
+ """Quote paths containing spaces."""
+ return '"%s"' % path if ' ' in path else path
+
def _run_command(self, cmdline):
"""Run a subcommand, quietly. Prints the full command on error."""
try:
@@ -251,11 +256,11 @@ if platform.is_msvc():
objext = '.obj'
def src(filename):
- return os.path.join('src', filename)
+ return os.path.join('$sourcedir', 'src', filename)
def built(filename):
return os.path.join('$builddir', filename)
def doc(filename):
- return os.path.join('doc', filename)
+ return os.path.join('$sourcedir', 'doc', filename)
def cc(name, **kwargs):
return n.build(built(name + objext), 'cxx', src(name + '.c'), **kwargs)
def cxx(name, **kwargs):
@@ -267,6 +272,7 @@ def binary(name):
return exe
return name
+n.variable('sourcedir', sourcedir)
n.variable('builddir', 'build')
n.variable('cxx', CXX)
if platform.is_msvc():
@@ -353,6 +359,9 @@ if platform.supports_ppoll() and not options.force_pselect:
if platform.supports_ninja_browse():
cflags.append('-DNINJA_HAVE_BROWSE')
+# Search for generated headers relative to build dir.
+cflags.append('-I.')
+
def shell_escape(str):
"""Escape str such that it's interpreted as a single argument by
the shell."""
@@ -415,10 +424,10 @@ objs = []
if platform.supports_ninja_browse():
n.comment('browse_py.h is used to inline browse.py.')
n.rule('inline',
- command='src/inline.sh $varname < $in > $out',
+ command='"%s"' % src('inline.sh') + ' $varname < $in > $out',
description='INLINE $out')
n.build(built('browse_py.h'), 'inline', src('browse.py'),
- implicit='src/inline.sh',
+ implicit=src('inline.sh'),
variables=[('varname', 'kBrowsePy')])
n.newline()
@@ -591,11 +600,12 @@ n.newline()
if not host.is_mingw():
n.comment('Regenerate build files if build script changes.')
n.rule('configure',
- command='${configure_env}%s configure.py $configure_args' %
+ command='${configure_env}%s $sourcedir/configure.py $configure_args' %
options.with_python,
generator=True)
n.build('build.ninja', 'configure',
- implicit=['configure.py', os.path.normpath('misc/ninja_syntax.py')])
+ implicit=['$sourcedir/configure.py',
+ os.path.normpath('$sourcedir/misc/ninja_syntax.py')])
n.newline()
n.default(ninja)
diff --git a/src/browse.cc b/src/browse.cc
index 83bfe43..8673919 100644
--- a/src/browse.cc
+++ b/src/browse.cc
@@ -18,7 +18,7 @@
#include <stdlib.h>
#include <unistd.h>
-#include "../build/browse_py.h"
+#include "build/browse_py.h"
void RunBrowsePython(State* state, const char* ninja_command,
const char* initial_target) {