Skip to content

Commit

Permalink
Fix older VS compatibility issues and PDB files generation issue. (#1435
Browse files Browse the repository at this point in the history
)

Fixes #1411.
  • Loading branch information
ikifof authored and jhasse committed Nov 7, 2018
1 parent cf51ff5 commit 0db30f2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
23 changes: 15 additions & 8 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def shell_escape(str):

if platform.is_msvc():
n.rule('cxx',
command='$cxx $cflags -c $in /Fo$out',
command='$cxx $cflags -c $in /Fo$out /Fd' + built('$pdb'),
description='CXX $out',
deps='msvc' # /showIncludes is included in $cflags.
)
Expand Down Expand Up @@ -485,6 +485,9 @@ def has_re2c():
n.newline()

n.comment('Core source files all build into ninja library.')
cxxvariables = []
if platform.is_msvc():
cxxvariables = [('pdb', 'ninja.pdb')]
for name in ['build',
'build_log',
'clean',
Expand All @@ -505,15 +508,15 @@ def has_re2c():
'string_piece_util',
'util',
'version']:
objs += cxx(name)
objs += cxx(name, variables=cxxvariables)
if platform.is_windows():
for name in ['subprocess-win32',
'includes_normalize-win32',
'msvc_helper-win32',
'msvc_helper_main-win32']:
objs += cxx(name)
objs += cxx(name, variables=cxxvariables)
if platform.is_msvc():
objs += cxx('minidump-win32')
objs += cxx('minidump-win32', variables=cxxvariables)
objs += cc('getopt')
else:
objs += cxx('subprocess-posix')
Expand All @@ -536,7 +539,7 @@ def has_re2c():
all_targets = []

n.comment('Main executable is library plus main() function.')
objs = cxx('ninja')
objs = cxx('ninja', variables=cxxvariables)
ninja = n.build(binary('ninja'), 'link', objs, implicit=ninja_lib,
variables=[('libs', libs)])
n.newline()
Expand All @@ -551,6 +554,8 @@ def has_re2c():
n.comment('Tests all build into ninja_test executable.')

objs = []
if platform.is_msvc():
cxxvariables = [('pdb', 'ninja_test.pdb')]

for name in ['build_log_test',
'build_test',
Expand All @@ -569,10 +574,10 @@ def has_re2c():
'subprocess_test',
'test',
'util_test']:
objs += cxx(name)
objs += cxx(name, variables=cxxvariables)
if platform.is_windows():
for name in ['includes_normalize_test', 'msvc_helper_test']:
objs += cxx(name)
objs += cxx(name, variables=cxxvariables)

ninja_test = n.build(binary('ninja_test'), 'link', objs, implicit=ninja_lib,
variables=[('libs', libs)])
Expand All @@ -588,7 +593,9 @@ def has_re2c():
'hash_collision_bench',
'manifest_parser_perftest',
'clparser_perftest']:
objs = cxx(name)
if platform.is_msvc():
cxxvariables = [('pdb', name + '.pdb')]
objs = cxx(name, variables=cxxvariables)
all_targets += n.build(binary(name), 'link', objs,
implicit=ninja_lib, variables=[('libs', libs)])

Expand Down
3 changes: 3 additions & 0 deletions src/build_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
#include "graph.h"
#include "metrics.h"
#include "util.h"
#if defined(_MSC_VER) && (_MSC_VER < 1800)
#define strtoll _strtoi64
#endif

// Implementation details:
// Each run's log appends to the log file.
Expand Down
3 changes: 3 additions & 0 deletions src/deps_log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include <string.h>
#ifndef _WIN32
#include <unistd.h>
#elif defined(_MSC_VER) && (_MSC_VER < 1900)
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
#endif

#include "graph.h"
Expand Down

0 comments on commit 0db30f2

Please sign in to comment.