Skip to content

Commit

Permalink
v1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nico committed Jun 29, 2015
2 parents 3309498 + d18eda4 commit 484c163
Show file tree
Hide file tree
Showing 66 changed files with 1,197 additions and 551 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.pyc
*.obj
*.exe
*.pdb
*.ilk
Expand Down
46 changes: 46 additions & 0 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,49 @@ The trick is to install just the compilers, and not all of Visual Studio,
by following [these instructions][win7sdk].

[win7sdk]: http://www.kegel.com/wine/cl-howto-win7sdk.html

### Using gcov

Do a clean debug build with the right flags:

CFLAGS=-coverage LDFLAGS=-coverage ./configure.py --debug
ninja -t clean ninja_test && ninja ninja_test

Run the test binary to generate `.gcda` and `.gcno` files in the build
directory, then run gcov on the .o files to generate `.gcov` files in the
root directory:

./ninja_test
gcov build/*.o

Look at the generated `.gcov` files directly, or use your favorit gcov viewer.

### Using afl-fuzz

Build with afl-clang++:

CXX=path/to/afl-1.20b/afl-clang++ ./configure.py
ninja

Then run afl-fuzz like so:

afl-fuzz -i misc/afl-fuzz -o /tmp/afl-fuzz-out ./ninja -n -f @@

You can pass `-x misc/afl-fuzz-tokens` to use the token dictionary. In my
testing, that did not seem more effective though.

#### Using afl-fuzz with asan

If you want to use asan (the `isysroot` bit is only needed on OS X; if clang
can't find C++ standard headers make sure your LLVM checkout includes a libc++
checkout and has libc++ installed in the build directory):

CFLAGS="-fsanitize=address -isysroot $(xcrun -show-sdk-path)" \
LDFLAGS=-fsanitize=address CXX=path/to/afl-1.20b/afl-clang++ \
./configure.py
AFL_CXX=path/to/clang++ ninja

Make sure ninja can find the asan runtime:

DYLD_LIBRARY_PATH=path/to//lib/clang/3.7.0/lib/darwin/ \
afl-fuzz -i misc/afl-fuzz -o /tmp/afl-fuzz-out ./ninja -n -f @@
9 changes: 6 additions & 3 deletions RELEASING
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Make announcement on mailing list:
1. copy old mail

Update website:
(note to self: website is now in github.com/martine/martine.github.io)
1. rebuild manual, put in place on website
2. update home page mention of latest version.
1. Make sure your ninja checkout is on the v1.5.0 tag
2. Clone https://github.com/martine/martine.github.io
3. In that repo, `cd ninja && ./update-docs.sh`
4. Update index.html with newest version and link to release notes
5. git commit -m 'run update-docs.sh, 1.5.0 release'
6. git push origin master
32 changes: 24 additions & 8 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ class is used to execute all the commands to build an executable.
It also proxies all calls to an underlying ninja_syntax.Writer, to
behave like non-bootstrap mode.
"""
def __init__(self, writer):
def __init__(self, writer, verbose=False):
self.writer = writer
self.verbose = verbose
# Map of variable name => expanded variable value.
self.vars = {}
# Map of rule name => dict of rule attributes.
Expand Down Expand Up @@ -163,8 +164,10 @@ def _expand(self, str, local_vars={}):
def _run_command(self, cmdline):
"""Run a subcommand, quietly. Prints the full command on error."""
try:
if self.verbose:
print(cmdline)
subprocess.check_call(cmdline, shell=True)
except subprocess.CalledProcessError, e:
except subprocess.CalledProcessError:
print('when running: ', cmdline)
raise

Expand All @@ -173,6 +176,8 @@ def _run_command(self, cmdline):
profilers = ['gmon', 'pprof']
parser.add_option('--bootstrap', action='store_true',
help='bootstrap a ninja binary from nothing')
parser.add_option('--verbose', action='store_true',
help='enable verbose build')
parser.add_option('--platform',
help='target platform (' +
'/'.join(Platform.known_platforms()) + ')',
Expand Down Expand Up @@ -217,7 +222,7 @@ def _run_command(self, cmdline):
# Wrap ninja_writer with the Bootstrapper, which also executes the
# commands.
print('bootstrapping ninja...')
n = Bootstrap(n)
n = Bootstrap(n, verbose=options.verbose)

n.comment('This file is used to build ninja itself.')
n.comment('It is generated by ' + os.path.basename(__file__) + '.')
Expand Down Expand Up @@ -279,12 +284,13 @@ def binary(name):
'/wd4512', '/wd4800', '/wd4702', '/wd4819',
# Disable warnings about passing "this" during initialization.
'/wd4355',
# Disable warnings about ignored typedef in DbgHelp.h
'/wd4091',
'/GR-', # Disable RTTI.
# Disable size_t -> int truncation warning.
# We never have strings or arrays larger than 2**31.
'/wd4267',
'/DNOMINMAX', '/D_CRT_SECURE_NO_WARNINGS',
'/D_VARIADIC_MAX=10',
'/DNINJA_PYTHON="%s"' % options.with_python]
if options.bootstrap:
# In bootstrap mode, we have no ninja process to catch /showIncludes
Expand All @@ -310,8 +316,14 @@ def binary(name):
cflags.remove('-fno-rtti') # Needed for above pedanticness.
else:
cflags += ['-O2', '-DNDEBUG']
if 'clang' in os.path.basename(CXX):
cflags += ['-fcolor-diagnostics']
try:
proc = subprocess.Popen(
[CXX, '-fdiagnostics-color', '-c', '-x', 'c++', '/dev/null'],
stdout=open(os.devnull, 'wb'), stderr=subprocess.STDOUT)
if proc.wait() == 0:
cflags += ['-fdiagnostics-color']
except:
pass
if platform.is_mingw():
cflags += ['-D_WIN32_WINNT=0x0501']
ldflags = ['-L$builddir']
Expand Down Expand Up @@ -602,13 +614,17 @@ def has_re2c():
n.close()
print('wrote %s.' % BUILD_FILENAME)

verbose = ''
if options.verbose:
verbose = ' -v'

if options.bootstrap:
print('bootstrap complete. rebuilding...')
if platform.is_windows():
bootstrap_exe = 'ninja.bootstrap.exe'
if os.path.exists(bootstrap_exe):
os.unlink(bootstrap_exe)
os.rename('ninja.exe', bootstrap_exe)
subprocess.check_call('ninja.bootstrap.exe', shell=True)
subprocess.check_call('ninja.bootstrap.exe%s' % verbose, shell=True)
else:
subprocess.check_call('./ninja', shell=True)
subprocess.check_call('./ninja%s' % verbose, shell=True)
13 changes: 11 additions & 2 deletions doc/manual.asciidoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Ninja
=====
Evan Martin <martine@danga.com>
v1.5.3, Nov 2014
v1.6.0, Jun 2015


Introduction
Expand Down Expand Up @@ -181,6 +181,12 @@ Run `ninja`. By default, it looks for a file named `build.ninja` in
the current directory and builds all out-of-date targets. You can
specify which targets (files) to build as command line arguments.
There is also a special syntax `target^` for specifying a target
as the first output of some rule containing the source you put in
the command line, if one exists. For example, if you specify target as
`foo.c^` then `foo.o` will get built (assuming you have those targets
in your build files).
`ninja -h` prints help output. Many of Ninja's flags intentionally
match those of Make; e.g `ninja -C build -j 20` changes into the
`build` directory and runs 20 build commands in parallel. (Note that
Expand Down Expand Up @@ -915,9 +921,12 @@ Evaluation and scoping

Top-level variable declarations are scoped to the file they occur in.

Rule declarations are also scoped to the file they occur in.
_(Available since Ninja 1.6)_

The `subninja` keyword, used to include another `.ninja` file,
introduces a new scope. The included `subninja` file may use the
variables from the parent file, and shadow their values for the file's
variables and rules from the parent file, and shadow their values for the file's
scope, but it won't affect values of the variables in the parent.

To include another `.ninja` file in the current scope, much like a C
Expand Down
1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/kw_build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/kw_default
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default
1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/kw_include
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include
1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/kw_pool
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pool
1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/kw_rule
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rule
1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/kw_subninja
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
subninja
1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/misc_a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a
1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/misc_b
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b
1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/misc_colon
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:
1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/misc_cont
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$
1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/misc_dollar
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$
1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/misc_eq
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
=
1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/misc_indent
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/misc_pipe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
|
1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/misc_pipepipe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
||
1 change: 1 addition & 0 deletions misc/afl-fuzz-tokens/misc_space
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

5 changes: 5 additions & 0 deletions misc/afl-fuzz/build.ninja
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rule b
command = clang -MMD -MF $out.d -o $out -c $in
description = building $out

build a.o: b a.c
43 changes: 21 additions & 22 deletions misc/ninja-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,27 @@

(defun ninja-syntax-propertize (start end)
(save-match-data
(save-excursion
(goto-char start)
(while (search-forward "#" end t)
(let ((match-pos (match-beginning 0)))
(when (and
;; Is it the first non-white character on the line?
(eq match-pos (save-excursion (back-to-indentation) (point)))
(save-excursion
(goto-char (line-end-position 0))
(or
;; If we're continuting the previous line, it's not a
;; comment.
(not (eq ?$ (char-before)))
;; Except if the previous line is a comment as well, as the
;; continuation dollar is ignored then.
(nth 4 (syntax-ppss)))))
(put-text-property match-pos (1+ match-pos) 'syntax-table '(11))
(let ((line-end (line-end-position)))
;; Avoid putting properties past the end of the buffer.
;; Otherwise we get an `args-out-of-range' error.
(unless (= line-end (1+ (buffer-size)))
(put-text-property line-end (1+ line-end) 'syntax-table '(12))))))))))
(goto-char start)
(while (search-forward "#" end t)
(let ((match-pos (match-beginning 0)))
(when (and
;; Is it the first non-white character on the line?
(eq match-pos (save-excursion (back-to-indentation) (point)))
(save-excursion
(goto-char (line-end-position 0))
(or
;; If we're continuting the previous line, it's not a
;; comment.
(not (eq ?$ (char-before)))
;; Except if the previous line is a comment as well, as the
;; continuation dollar is ignored then.
(nth 4 (syntax-ppss)))))
(put-text-property match-pos (1+ match-pos) 'syntax-table '(11))
(let ((line-end (line-end-position)))
;; Avoid putting properties past the end of the buffer.
;; Otherwise we get an `args-out-of-range' error.
(unless (= line-end (1+ (buffer-size)))
(put-text-property line-end (1+ line-end) 'syntax-table '(12)))))))))

;;;###autoload
(define-derived-mode ninja-mode prog-mode "ninja"
Expand Down
2 changes: 1 addition & 1 deletion misc/zsh-completion
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ __get_tools() {
}

__get_modes() {
ninja -d list 2>/dev/null | while read -r a b; do echo $a; done | tail -n +2 | head -n -1
ninja -d list 2>/dev/null | while read -r a b; do echo $a; done | tail -n +2 | sed '$d'
}

__modes() {
Expand Down
Loading

0 comments on commit 484c163

Please sign in to comment.