Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 0db30f2

Browse files
ikifofjhasse
authored andcommitted
Fix older VS compatibility issues and PDB files generation issue. (ninja-build#1435)
Fixes ninja-build#1411.
1 parent cf51ff5 commit 0db30f2

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

configure.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def shell_escape(str):
414414

415415
if platform.is_msvc():
416416
n.rule('cxx',
417-
command='$cxx $cflags -c $in /Fo$out',
417+
command='$cxx $cflags -c $in /Fo$out /Fd' + built('$pdb'),
418418
description='CXX $out',
419419
deps='msvc' # /showIncludes is included in $cflags.
420420
)
@@ -485,6 +485,9 @@ def has_re2c():
485485
n.newline()
486486

487487
n.comment('Core source files all build into ninja library.')
488+
cxxvariables = []
489+
if platform.is_msvc():
490+
cxxvariables = [('pdb', 'ninja.pdb')]
488491
for name in ['build',
489492
'build_log',
490493
'clean',
@@ -505,15 +508,15 @@ def has_re2c():
505508
'string_piece_util',
506509
'util',
507510
'version']:
508-
objs += cxx(name)
511+
objs += cxx(name, variables=cxxvariables)
509512
if platform.is_windows():
510513
for name in ['subprocess-win32',
511514
'includes_normalize-win32',
512515
'msvc_helper-win32',
513516
'msvc_helper_main-win32']:
514-
objs += cxx(name)
517+
objs += cxx(name, variables=cxxvariables)
515518
if platform.is_msvc():
516-
objs += cxx('minidump-win32')
519+
objs += cxx('minidump-win32', variables=cxxvariables)
517520
objs += cc('getopt')
518521
else:
519522
objs += cxx('subprocess-posix')
@@ -536,7 +539,7 @@ def has_re2c():
536539
all_targets = []
537540

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

553556
objs = []
557+
if platform.is_msvc():
558+
cxxvariables = [('pdb', 'ninja_test.pdb')]
554559

555560
for name in ['build_log_test',
556561
'build_test',
@@ -569,10 +574,10 @@ def has_re2c():
569574
'subprocess_test',
570575
'test',
571576
'util_test']:
572-
objs += cxx(name)
577+
objs += cxx(name, variables=cxxvariables)
573578
if platform.is_windows():
574579
for name in ['includes_normalize_test', 'msvc_helper_test']:
575-
objs += cxx(name)
580+
objs += cxx(name, variables=cxxvariables)
576581

577582
ninja_test = n.build(binary('ninja_test'), 'link', objs, implicit=ninja_lib,
578583
variables=[('libs', libs)])
@@ -588,7 +593,9 @@ def has_re2c():
588593
'hash_collision_bench',
589594
'manifest_parser_perftest',
590595
'clparser_perftest']:
591-
objs = cxx(name)
596+
if platform.is_msvc():
597+
cxxvariables = [('pdb', name + '.pdb')]
598+
objs = cxx(name, variables=cxxvariables)
592599
all_targets += n.build(binary(name), 'link', objs,
593600
implicit=ninja_lib, variables=[('libs', libs)])
594601

src/build_log.cc

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
#include "graph.h"
3636
#include "metrics.h"
3737
#include "util.h"
38+
#if defined(_MSC_VER) && (_MSC_VER < 1800)
39+
#define strtoll _strtoi64
40+
#endif
3841

3942
// Implementation details:
4043
// Each run's log appends to the log file.

src/deps_log.cc

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#include <string.h>
2121
#ifndef _WIN32
2222
#include <unistd.h>
23+
#elif defined(_MSC_VER) && (_MSC_VER < 1900)
24+
typedef __int32 int32_t;
25+
typedef unsigned __int32 uint32_t;
2326
#endif
2427

2528
#include "graph.h"

0 commit comments

Comments
 (0)