Support non-standard Python executable names
authorElliott Hird <penguinofthegods@gmail.com>
Wed, 14 Dec 2011 20:43:19 +0000 (20:43 +0000)
committerElliott Hird <penguinofthegods@gmail.com>
Wed, 14 Dec 2011 20:46:55 +0000 (20:46 +0000)
Closes #154.

configure.py
src/browse.cc

index 0267290..4c49f40 100755 (executable)
@@ -39,6 +39,9 @@ parser.add_option('--profile', metavar='TYPE',
                   help='enable profiling (' + '/'.join(profilers) + ')',)
 parser.add_option('--with-gtest', metavar='PATH',
                   help='use gtest built in directory PATH')
+parser.add_option('--with-python', metavar='EXE',
+                  help='use EXE as the Python interpreter',
+                  default=os.path.basename(sys.executable))
 (options, args) = parser.parse_args()
 
 platform = options.platform
@@ -79,7 +82,8 @@ cflags = ['-g', '-Wall', '-Wextra',
           '-Wno-deprecated',
           '-Wno-unused-parameter',
           '-fno-exceptions',
-          '-fvisibility=hidden', '-pipe']
+          '-fvisibility=hidden', '-pipe',
+          "'-DNINJA_PYTHON=\"%s\"'" % (options.with_python,)]
 if not options.debug:
     cflags += ['-O2', '-DNDEBUG']
 ldflags = ['-L$builddir']
@@ -250,7 +254,7 @@ n.newline()
 if platform != 'mingw':
     n.comment('Regenerate build files if build script changes.')
     n.rule('configure',
-           command='./configure.py $configure_args',
+           command=options.with_python + ' configure.py $configure_args',
            generator=True)
     n.build('build.ninja', 'configure',
             implicit=['configure.py', 'misc/ninja_syntax.py'])
index bab3f36..83bfe43 100644 (file)
@@ -46,7 +46,7 @@ void RunBrowsePython(State* state, const char* ninja_command,
 
       // exec Python, telling it to run the program from stdin.
       const char* command[] = {
-        "python", "-", ninja_command, initial_target, NULL
+        NINJA_PYTHON, "-", ninja_command, initial_target, NULL
       };
       execvp(command[0], (char**)command);
       perror("ninja: execvp");