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

Commit 6d5a4b9

Browse files
committed
Merge branch 'master' into release
2 parents 253e94c + 0c15843 commit 6d5a4b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1544
-793
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ TAGS
3232
# Ninja output
3333
.ninja_deps
3434
.ninja_log
35+
36+
# Visual Studio Code project files
37+
/.vscode/

.travis.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
matrix:
2+
include:
3+
- os: linux
4+
compiler: gcc
5+
- os: linux
6+
compiler: clang
7+
- os: osx
18
sudo: false
29
language: cpp
3-
compiler:
4-
- gcc
5-
- clang
6-
script: ./configure.py --bootstrap && ./ninja all && ./ninja_test --gtest_filter=-SubprocessTest.SetWithLots && ./misc/ninja_syntax_test.py
10+
script:
11+
- ./configure.py --bootstrap
12+
- ./ninja all
13+
- ./ninja_test --gtest_filter=-SubprocessTest.SetWithLots
14+
- ./misc/ninja_syntax_test.py
15+
- ./misc/output_test.py

HACKING.md

+43-15
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,50 @@ run `ninja_test` when developing.
1313
Ninja is built using itself. To bootstrap the first binary, run the
1414
configure script as `./configure.py --bootstrap`. This first compiles
1515
all non-test source files together, then re-builds Ninja using itself.
16-
You should end up with a `ninja` binary (or `ninja.exe`) in the source root.
16+
You should end up with a `ninja` binary (or `ninja.exe`) in the project root.
1717

1818
#### Windows
1919

2020
On Windows, you'll need to install Python to run `configure.py`, and
2121
run everything under a Visual Studio Tools Command Prompt (or after
22-
running `vcvarsall` in a normal command prompt). See below if you
23-
want to use mingw or some other compiler instead of Visual Studio.
22+
running `vcvarsall` in a normal command prompt).
23+
24+
For other combinations such as gcc/clang you will need the compiler
25+
(gcc/cl) in your PATH and you will have to set the appropriate
26+
platform configuration script.
27+
28+
See below if you want to use mingw or some other compiler instead of
29+
Visual Studio.
30+
31+
##### Using Visual Studio
32+
Assuming that you now have Python installed, then the steps for building under
33+
Windows using Visual Studio are:
34+
35+
Clone and checkout the latest release (or whatever branch you want). You
36+
can do this in either a command prompt or by opening a git bash prompt:
37+
38+
```
39+
$ git clone git://github.com/ninja-build/ninja.git && cd ninja
40+
$ git checkout release
41+
```
42+
43+
Then:
44+
45+
1. Open a Windows command prompt in the folder where you checked out ninja.
46+
2. Select the Microsoft build environment by running
47+
`vcvarsall.bat` with the appropriate environment.
48+
3. Build ninja and test it.
49+
50+
The steps for a Visual Studio 2015 64-bit build are outlined here:
51+
52+
```
53+
> "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
54+
> python configure.py --bootstrap
55+
> ninja --help
56+
```
57+
Copy the ninja executable to another location, if desired, e.g. C:\local\Ninja.
58+
59+
Finally add the path where ninja.exe is to the PATH variable.
2460

2561
### Adjusting build flags
2662

@@ -73,17 +109,9 @@ build "all" before committing to verify the other source still works!
73109

74110
## Testing performance impact of changes
75111

76-
If you have a Chrome build handy, it's a good test case. Otherwise,
77-
[the github downoads page](https://github.com/ninja-build/ninja/releases)
78-
has a copy of the Chrome build files (and depfiles). You can untar
79-
that, then run
80-
81-
path/to/my/ninja chrome
82-
83-
and compare that against a baseline Ninja.
84-
85-
There's a script at `misc/measure.py` that repeatedly runs a command like
86-
the above (to address variance) and summarizes its runtime. E.g.
112+
If you have a Chrome build handy, it's a good test case. There's a
113+
script at `misc/measure.py` that repeatedly runs a command (to address
114+
variance) and summarizes its runtime. E.g.
87115

88116
path/to/misc/measure.py path/to/my/ninja chrome
89117

@@ -95,7 +123,7 @@ and run that directly on some representative input files.
95123
Generally it's the [Google C++ coding style][], but in brief:
96124

97125
* Function name are camelcase.
98-
* Member methods are camelcase, expect for trivial getters which are
126+
* Member methods are camelcase, except for trivial getters which are
99127
underscore separated.
100128
* Local variables are underscore separated.
101129
* Member variables are underscore separated and suffixed by an extra

RELEASING

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
Notes to myself on all the steps to make for a Ninja release.
22

33
Push new release branch:
4-
1. Consider sending a heads-up to the ninja-build mailing list first
5-
2. Make sure branches 'master' and 'release' are synced up locally
6-
3. update src/version.cc with new version (with ".git"), then
4+
1. Run afl-fuzz for a day or so (see HACKING.md) and run ninja_test
5+
2. Consider sending a heads-up to the ninja-build mailing list first
6+
3. Make sure branches 'master' and 'release' are synced up locally
7+
4. Update src/version.cc with new version (with ".git"), then
78
git commit -am 'mark this 1.5.0.git'
8-
4. git checkout release; git merge master
9-
5. fix version number in src/version.cc (it will likely conflict in the above)
10-
6. fix version in doc/manual.asciidoc (exists only on release branch)
11-
7. commit, tag, push (don't forget to push --tags)
9+
5. git checkout release; git merge master
10+
6. Fix version number in src/version.cc (it will likely conflict in the above)
11+
7. Fix version in doc/manual.asciidoc (exists only on release branch)
12+
8. commit, tag, push (don't forget to push --tags)
1213
git commit -am v1.5.0; git push origin release
1314
git tag v1.5.0; git push --tags
1415
# Push the 1.5.0.git change on master too:
1516
git checkout master; git push origin master
16-
8. construct release notes from prior notes
17+
9. Construct release notes from prior notes
1718
credits: git shortlog -s --no-merges REV..
1819

1920
Release on github:

appveyor.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: 1.0.{build}
2+
image: Visual Studio 2017
3+
4+
environment:
5+
CLICOLOR_FORCE: 1
6+
CHERE_INVOKING: 1 # Tell Bash to inherit the current working directory
7+
matrix:
8+
- MSYSTEM: MINGW64
9+
- MSYSTEM: MSVC
10+
11+
for:
12+
-
13+
matrix:
14+
only:
15+
- MSYSTEM: MINGW64
16+
build_script:
17+
ps: "C:\\msys64\\usr\\bin\\bash -lc @\"\n
18+
pacman -S --quiet --noconfirm --needed re2c 2>&1\n
19+
sed -i 's|cmd /c $ar cqs $out.tmp $in && move /Y $out.tmp $out|$ar crs $out $in|g' configure.py\n
20+
./configure.py --bootstrap --platform mingw 2>&1\n
21+
./ninja all\n
22+
./ninja_test 2>&1\n
23+
./misc/ninja_syntax_test.py 2>&1\n\"@"
24+
-
25+
matrix:
26+
only:
27+
- MSYSTEM: MSVC
28+
build_script:
29+
- cmd: >-
30+
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
31+
32+
python configure.py --bootstrap
33+
34+
ninja.bootstrap.exe all
35+
36+
ninja_test
37+
38+
python misc/ninja_syntax_test.py
39+
40+
test: off

configure.py

+26-10
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def is_aix(self):
9898
return self._platform == 'aix'
9999

100100
def uses_usr_local(self):
101-
return self._platform in ('freebsd', 'openbsd', 'bitrig', 'dragonfly')
101+
return self._platform in ('freebsd', 'openbsd', 'bitrig', 'dragonfly', 'netbsd')
102102

103103
def supports_ppoll(self):
104104
return self._platform in ('freebsd', 'linux', 'openbsd', 'bitrig',
@@ -256,7 +256,7 @@ def _run_command(self, cmdline):
256256
if '--bootstrap' in configure_args:
257257
configure_args.remove('--bootstrap')
258258
n.variable('configure_args', ' '.join(configure_args))
259-
env_keys = set(['CXX', 'AR', 'CFLAGS', 'LDFLAGS'])
259+
env_keys = set(['CXX', 'AR', 'CFLAGS', 'CXXFLAGS', 'LDFLAGS'])
260260
configure_env = dict((k, os.environ[k]) for k in os.environ if k in env_keys)
261261
if configure_env:
262262
config_str = ' '.join([k + '=' + pipes.quote(configure_env[k])
@@ -356,6 +356,11 @@ def binary(name):
356356
if platform.uses_usr_local():
357357
cflags.append('-I/usr/local/include')
358358
ldflags.append('-L/usr/local/lib')
359+
if platform.is_aix():
360+
# printf formats for int64_t, uint64_t; large file support
361+
cflags.append('-D__STDC_FORMAT_MACROS')
362+
cflags.append('-D_LARGE_FILES')
363+
359364

360365
libs = []
361366

@@ -397,6 +402,10 @@ def shell_escape(str):
397402

398403
if 'CFLAGS' in configure_env:
399404
cflags.append(configure_env['CFLAGS'])
405+
ldflags.append(configure_env['CFLAGS'])
406+
if 'CXXFLAGS' in configure_env:
407+
cflags.append(configure_env['CXXFLAGS'])
408+
ldflags.append(configure_env['CXXFLAGS'])
400409
n.variable('cflags', ' '.join(shell_escape(flag) for flag in cflags))
401410
if 'LDFLAGS' in configure_env:
402411
ldflags.append(configure_env['LDFLAGS'])
@@ -405,7 +414,7 @@ def shell_escape(str):
405414

406415
if platform.is_msvc():
407416
n.rule('cxx',
408-
command='$cxx $cflags -c $in /Fo$out',
417+
command='$cxx $cflags -c $in /Fo$out /Fd' + built('$pdb'),
409418
description='CXX $out',
410419
deps='msvc' # /showIncludes is included in $cflags.
411420
)
@@ -476,6 +485,9 @@ def has_re2c():
476485
n.newline()
477486

478487
n.comment('Core source files all build into ninja library.')
488+
cxxvariables = []
489+
if platform.is_msvc():
490+
cxxvariables = [('pdb', 'ninja.pdb')]
479491
for name in ['build',
480492
'build_log',
481493
'clean',
@@ -496,15 +508,15 @@ def has_re2c():
496508
'string_piece_util',
497509
'util',
498510
'version']:
499-
objs += cxx(name)
511+
objs += cxx(name, variables=cxxvariables)
500512
if platform.is_windows():
501513
for name in ['subprocess-win32',
502514
'includes_normalize-win32',
503515
'msvc_helper-win32',
504516
'msvc_helper_main-win32']:
505-
objs += cxx(name)
517+
objs += cxx(name, variables=cxxvariables)
506518
if platform.is_msvc():
507-
objs += cxx('minidump-win32')
519+
objs += cxx('minidump-win32', variables=cxxvariables)
508520
objs += cc('getopt')
509521
else:
510522
objs += cxx('subprocess-posix')
@@ -527,7 +539,7 @@ def has_re2c():
527539
all_targets = []
528540

529541
n.comment('Main executable is library plus main() function.')
530-
objs = cxx('ninja')
542+
objs = cxx('ninja', variables=cxxvariables)
531543
ninja = n.build(binary('ninja'), 'link', objs, implicit=ninja_lib,
532544
variables=[('libs', libs)])
533545
n.newline()
@@ -542,6 +554,8 @@ def has_re2c():
542554
n.comment('Tests all build into ninja_test executable.')
543555

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

546560
for name in ['build_log_test',
547561
'build_test',
@@ -560,10 +574,10 @@ def has_re2c():
560574
'subprocess_test',
561575
'test',
562576
'util_test']:
563-
objs += cxx(name)
577+
objs += cxx(name, variables=cxxvariables)
564578
if platform.is_windows():
565579
for name in ['includes_normalize_test', 'msvc_helper_test']:
566-
objs += cxx(name)
580+
objs += cxx(name, variables=cxxvariables)
567581

568582
ninja_test = n.build(binary('ninja_test'), 'link', objs, implicit=ninja_lib,
569583
variables=[('libs', libs)])
@@ -579,7 +593,9 @@ def has_re2c():
579593
'hash_collision_bench',
580594
'manifest_parser_perftest',
581595
'clparser_perftest']:
582-
objs = cxx(name)
596+
if platform.is_msvc():
597+
cxxvariables = [('pdb', name + '.pdb')]
598+
objs = cxx(name, variables=cxxvariables)
583599
all_targets += n.build(binary(name), 'link', objs,
584600
implicit=ninja_lib, variables=[('libs', libs)])
585601

doc/manual.asciidoc

+6-6
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,10 @@ design is quite clever.
155155
Ninja's benefit comes from using it in conjunction with a smarter
156156
meta-build system.
157157
158-
http://code.google.com/p/gyp/[gyp]:: The meta-build system used to
158+
https://gn.googlesource.com/gn/[gn]:: The meta-build system used to
159159
generate build files for Google Chrome and related projects (v8,
160-
node.js). gyp can generate Ninja files for all platforms supported by
161-
Chrome. See the
162-
https://chromium.googlesource.com/chromium/src/+/master/docs/ninja_build.md[Chromium Ninja documentation for more details].
160+
node.js), as well as Google Fuschia. gn can generate Ninja files for
161+
all platforms supported by Chrome.
163162
164163
https://cmake.org/[CMake]:: A widely used meta-build system that
165164
can generate Ninja files on Linux as of CMake version 2.8.8. Newer versions
@@ -594,7 +593,7 @@ Ninja supports this processing in two forms.
594593
to its stdout. Ninja then filters these lines from the displayed
595594
output. No `depfile` attribute is necessary, but the localized string
596595
in front of the the header file path. For instance
597-
`msvc_deps_prefix = Note: including file: `
596+
`msvc_deps_prefix = Note: including file:`
598597
for a English Visual Studio (the default). Should be globally defined.
599598
+
600599
----
@@ -881,7 +880,8 @@ quoting rules are deterimined by the called program, which on Windows
881880
are usually provided by the C library. If you need shell
882881
interpretation of the command (such as the use of `&&` to chain
883882
multiple commands), make the command execute the Windows shell by
884-
prefixing the command with `cmd /c`.
883+
prefixing the command with `cmd /c`. Ninja may error with "invalid parameter"
884+
which usually indicates that the command line length has been exceeded.
885885

886886
[[ref_outputs]]
887887
Build outputs

misc/ninja-mode.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
(save-excursion
5757
(goto-char (line-end-position 0))
5858
(or
59-
;; If we're continuting the previous line, it's not a
59+
;; If we're continuing the previous line, it's not a
6060
;; comment.
6161
(not (eq ?$ (char-before)))
6262
;; Except if the previous line is a comment as well, as the

misc/ninja.vim

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
" ninja build file syntax.
22
" Language: ninja build file as described at
33
" http://ninja-build.org/manual.html
4-
" Version: 1.4
5-
" Last Change: 2014/05/13
4+
" Version: 1.5
5+
" Last Change: 2018/04/05
66
" Maintainer: Nicolas Weber <nicolasweber@gmx.de>
77
" Version 1.4 of this script is in the upstream vim repository and will be
88
" included in the next vim release. If you change this, please send your change
@@ -21,7 +21,10 @@ set cpo&vim
2121

2222
syn case match
2323

24-
syn match ninjaComment /#.*/ contains=@Spell
24+
" Comments are only matched when the # is at the beginning of the line (with
25+
" optional whitespace), as long as the prior line didn't end with a $
26+
" continuation.
27+
syn match ninjaComment /\(\$\n\)\@<!\_^\s*#.*$/ contains=@Spell
2528

2629
" Toplevel statements are the ones listed here and
2730
" toplevel variable assignments (ident '=' value).
@@ -38,12 +41,13 @@ syn match ninjaKeyword "^subninja\>"
3841
" limited set of magic variables, 'build' allows general
3942
" let assignments.
4043
" manifest_parser.cc, ParseRule()
41-
syn region ninjaRule start="^rule" end="^\ze\S" contains=ALL transparent
42-
syn keyword ninjaRuleCommand contained command deps depfile description generator
44+
syn region ninjaRule start="^rule" end="^\ze\S" contains=TOP transparent
45+
syn keyword ninjaRuleCommand contained containedin=ninjaRule command
46+
\ deps depfile description generator
4347
\ pool restat rspfile rspfile_content
4448

45-
syn region ninjaPool start="^pool" end="^\ze\S" contains=ALL transparent
46-
syn keyword ninjaPoolCommand contained depth
49+
syn region ninjaPool start="^pool" end="^\ze\S" contains=TOP transparent
50+
syn keyword ninjaPoolCommand contained containedin=ninjaPool depth
4751

4852
" Strings are parsed as follows:
4953
" lexer.in.cc, ReadEvalString()

0 commit comments

Comments
 (0)