windows: more build fixes

This commit is contained in:
Scott Graham 2012-01-04 14:18:17 -08:00 committed by Evan Martin
parent 4a09acf125
commit f4df3f731a
6 changed files with 31 additions and 13 deletions

View File

@ -43,8 +43,9 @@ except OSError, e:
with open('src/browse.py') as browse_py:
with open('build/browse_py.h', 'w') as browse_py_h:
run(['./src/inline.sh', 'kBrowsePy'],
stdin=browse_py, stdout=browse_py_h)
hex_str = ''.join([hex(ord(c)) for c in browse_py.read()])
src = "const char %s[]=\"\n%s\n\";" % ('kBrowsePy', hex_str)
browse_py_h.write(src)
sources = []
for src in glob.glob('src/*.cc'):
@ -52,7 +53,7 @@ for src in glob.glob('src/*.cc'):
continue
if sys.platform.startswith('win32'):
if src.endswith('/browse.cc') or src.endswith('/subprocess.cc'):
if src.endswith('\\browse.cc') or src.endswith('\\subprocess.cc'):
continue
else:
if src.endswith('-win32.cc'):
@ -60,15 +61,25 @@ for src in glob.glob('src/*.cc'):
sources.append(src)
args = [os.environ.get('CXX', 'g++'), '-Wno-deprecated',
'-DNINJA_PYTHON="' + sys.executable + '"']
if sys.platform.startswith('win32'):
sources.append('src/getopt.c')
vcdir = os.environ.get('VCINSTALLDIR')
if vcdir:
args = [os.path.join(vcdir, 'bin', 'cl.exe'), '/nologo', '/EHsc', '/DWIN32']
else:
args = [os.environ.get('CXX', 'g++'), '-Wno-deprecated',
'-DNINJA_PYTHON="' + sys.executable + '"']
args.extend(cflags)
args.extend(ldflags)
binary = 'ninja.bootstrap'
if sys.platform.startswith('win32'):
binary = 'ninja.bootstrap.exe'
args.extend(['-o', binary])
args.extend(sources)
if vcdir:
args.extend(['/link', '/out:' + binary])
else:
args.extend(['-o', binary])
run(args)
print 'Building ninja using itself...'

View File

@ -140,7 +140,7 @@ n.newline()
if platform == 'windows':
n.rule('cxx',
command='$cxx $cflags -c $in /Fo $out',
command='$cxx $cflags -c $in /Fo$out',
depfile='$out.d',
description='CXX $out')
else:

View File

@ -396,17 +396,17 @@ getopt (int argc, char **argv, char *optstring)
}
int
getopt_long (int argc, char **argv, char *shortopts,
GETOPT_LONG_OPTION_T * longopts, int *longind)
getopt_long (int argc, char **argv, const char *shortopts,
const GETOPT_LONG_OPTION_T * longopts, int *longind)
{
return getopt_internal (argc, argv, shortopts, longopts, longind, 0);
return getopt_internal (argc, argv, (char*)shortopts, (GETOPT_LONG_OPTION_T*)longopts, longind, 0);
}
int
getopt_long_only (int argc, char **argv, char *shortopts,
GETOPT_LONG_OPTION_T * longopts, int *longind)
getopt_long_only (int argc, char **argv, const char *shortopts,
const GETOPT_LONG_OPTION_T * longopts, int *longind)
{
return getopt_internal (argc, argv, shortopts, longopts, longind, 1);
return getopt_internal (argc, argv, (char*)shortopts, (GETOPT_LONG_OPTION_T*)longopts, longind, 1);
}
/* end of file GETOPT.C */

View File

@ -18,6 +18,7 @@
#include <stdio.h>
#include "eval_env.h"
#include "util.h"
bool Lexer::Error(const string& message, string* err) {
// Compute line/column.

View File

@ -14,6 +14,11 @@
#include "string_piece.h"
// Windows may #define ERROR.
#ifdef ERROR
#undef ERROR
#endif
struct EvalString;
struct Lexer {

View File

@ -17,6 +17,7 @@
#include <stdio.h>
#include "eval_env.h"
#include "util.h"
bool Lexer::Error(const string& message, string* err) {
// Compute line/column.