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'):
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'):
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...'
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:
}
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 */
#include <stdio.h>
#include "eval_env.h"
+#include "util.h"
bool Lexer::Error(const string& message, string* err) {
// Compute line/column.
#include "string_piece.h"
+// Windows may #define ERROR.
+#ifdef ERROR
+#undef ERROR
+#endif
+
struct EvalString;
struct Lexer {
#include <stdio.h>
#include "eval_env.h"
+#include "util.h"
bool Lexer::Error(const string& message, string* err) {
// Compute line/column.