Skip to content

Commit

Permalink
Add --windows option to bootstrap.py
Browse files Browse the repository at this point in the history
Makes it possible to make a native Windows build when using Cygwin Python.
  • Loading branch information
azuk committed Nov 9, 2012
1 parent 93e5094 commit 489cc06
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
help='enable verbose build',)
parser.add_option('--x64', action='store_true',
help='force 64-bit build (Windows)',)
parser.add_option('--windows', action='store_true',
help='force native Windows build (when using Cygwin Python)',
default=sys.platform.startswith('win32'))
(options, conf_args) = parser.parse_args()

def run(*args, **kwargs):
Expand Down Expand Up @@ -66,7 +69,7 @@ def run(*args, **kwargs):
if filename == 'browse.cc': # Depends on generated header.
continue

if sys.platform.startswith('win32'):
if options.windows:
if src.endswith('-posix.cc'):
continue
else:
Expand All @@ -75,7 +78,7 @@ def run(*args, **kwargs):

sources.append(src)

if sys.platform.startswith('win32'):
if options.windows:
sources.append('src/getopt.c')

vcdir = os.environ.get('VCINSTALLDIR')
Expand All @@ -90,14 +93,14 @@ def run(*args, **kwargs):
cflags.extend(['-Wno-deprecated',
'-DNINJA_PYTHON="' + sys.executable + '"',
'-DNINJA_BOOTSTRAP'])
if sys.platform.startswith('win32'):
if options.windows:
cflags.append('-D_WIN32_WINNT=0x0501')
if options.x64:
cflags.append('-m64')
args.extend(cflags)
args.extend(ldflags)
binary = 'ninja.bootstrap'
if sys.platform.startswith('win32'):
if options.windows:
binary = 'ninja.bootstrap.exe'
args.extend(sources)
if vcdir:
Expand All @@ -118,7 +121,7 @@ def run(*args, **kwargs):
if options.verbose:
verbose = ['-v']

if sys.platform.startswith('win32'):
if options.windows:
print('Building ninja using itself...')
run([sys.executable, 'configure.py', '--with-ninja=%s' % binary] +
conf_args)
Expand Down

0 comments on commit 489cc06

Please sign in to comment.