aboutsummaryrefslogtreecommitdiff
path: root/ninja.cc
Commit message (Collapse)AuthorAgeFilesLines
* Allow rules to specify custom ninja poolsDan Willemsen2016-11-051-1/+6
| | | | | | | | Setting .KATI_NINJA_POOL as a rule variable will set the corresponding pool variable in the ninja file. There's no way to define custom pools in Kati, Android is planning on scaling the pool depth in a parent ninja file without re-running Kati.
* Optimize findleaves regen checkDan Willemsen2016-10-191-0/+5
| | | | | | | | | | | | | | | | If we've found all possible files in a leaf directory, we don't need to re-run findleaves every time the leaf directory's timestamp changes, we just need to make sure the file(s) that we found still exist. This saves a few seconds every time an atomic write is done in a source directory next to an Android.mk file. (Atomic writes use renames, so they always change the directory's timestamp) With the last commit that finds out/Android.mk and out/CleanSpec.mk, it turns out that the output directory's timestamp was changing every build, causing the global Android.mk & CleanSpec.mk findleaves.py command to be executed every regen check. TEST_FIND_EMULATOR still passes after this change.
* Merge pull request #97 from danw/file_funcDan Willemsen2016-10-041-20/+16
|\ | | | | Implement the `file` function to read and write files
| * Implement the `file` function to read and write filesDan Willemsen2016-10-031-20/+16
| | | | | | | | | | | | | | This allows us to do file reading and writing without $(shell). Besides being simpler, this also allows faster regen times, since we can just stat the files to be read, or directly write to the files that need to be written.
* | Optimize RunCommand by removing /bin/sh wrapper when possibleDan Willemsen2016-10-011-0/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | For every $(shell echo "test: $PATH") command, when SHELL is /bin/bash, we essentially run: (each arg wrapped in []) [/bin/sh] [-c] [/bin/bash -c "echo \"test: \$PATH\""] This is redundant, since we can just use SHELL, and then we don't need to do an extra level of shell escaping either. This change makes us run this instead: [/bin/bash] [-c] [echo "test: $PATH"] If SHELL is more complicated than an absolute path to a binary, then we'll fall back to /bin/sh. Using the benchmark introduced in the last change, this reduces a minimal RunCommand execution with a simple SHELL from 3.7ms to 1.3ms. For a more complex benchmark (though less normalized), for an AOSP Android build, this change shrinks the average time spent in $(shell) functions from 4.5ms to 3ms. Change-Id: I622116e33565e58bb123ee9e9bdd302616a6609c
* ninja: Don't emit special targets (.*)Dan Willemsen2016-09-191-0/+3
| | | | | These aren't meant to be called directly, so there's no point putting them in the ninja file.
* Allow NULL filename for -d flagShinichiro Hamaji2016-05-181-2/+4
|
* [C++] Add -d flag to make debugging slightly easierShinichiro Hamaji2016-05-121-0/+2
|
* [C++] Handle .POSIX at eval timeShinichiro Hamaji2016-04-271-3/+4
| | | | | .POSIX pseudo target should change the behavior of $(shell). This also implements .POSIX for ckati's non-ninja mode.
* [C++] Store SHELL value in command resultStefan Becker2016-04-121-0/+1
| | | | | | | | | | | $(shell ...) command lines are executed using $(SHELL). We need to use the same shell during regeneration check instead of hard-coding /bin/sh or otherwise the results might be different when $(SHELL) is redefined in the makefile. Fixes https://github.com/google/kati/issues/53 Change-Id: I1f9809106f29f7e806324a82e2323a2f8df64b63
* [C++] Add support for .POSIX:Stefan Becker2016-04-121-1/+3
| | | | | | | | | | Add a global flag that is set to "true" when .POSIX: is encountered. The flag will switch the bash flags from "-c" to "-ec", i.e. enable correct error handling of shell command lines. Fixes https://github.com/google/kati/issues/48 Change-Id: Ieea386742b05b52d209b74e640e14212f0e2da88
* [C++] Use USE_GOMA variable to see goma will be usedShinichiro Hamaji2016-04-091-10/+4
|
* Put a whitespace for subshell before a close parenShinichiro Hamaji2016-03-171-2/+2
| | | | instead of after an open paren.
* Add a whitespace after an open paren for subshellShinichiro Hamaji2016-03-171-1/+1
|
* Fix https://github.com/google/kati/issues/47Shinichiro Hamaji2016-03-151-9/+3
|
* Use subshell even when a command starts with '('Shinichiro Hamaji2016-03-151-3/+0
|
* Detect depfiles only when --detect_depfiles is specifiedShinichiro Hamaji2016-03-151-0/+2
| | | | This makes generation time ~5% faster.
* [C++] Use C++11's threading library againShinichiro Hamaji2016-02-261-2/+2
| | | | | It seems we can use it even for -static build with -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -ldl
* [C++] Remove --gen_regen_ruleShinichiro Hamaji2016-02-191-22/+2
| | | | No one uses this.
* [C++] Escape $(SHELL) in ninjaShinichiro Hamaji2016-02-191-5/+9
|
* [C++] Handle multi-word SHELL in $(shell)Shinichiro Hamaji2016-02-181-30/+0
|
* [C++] Rename mutex related classesShinichiro Hamaji2016-02-161-2/+2
| | | | | libc++'s sstream indirectly includes mutex, which conflicts with ours.
* [C++] Set CPU affinityShinichiro Hamaji2016-02-161-25/+23
| | | | | Sticking to a single processor improves the performance while we are running only a single thread.
* [C++] Use per-task buffer for EmitNodeShinichiro Hamaji2016-02-151-26/+26
|
* [C++] Run EmitNode in parallelShinichiro Hamaji2016-02-151-28/+49
|
* [C++] Introduce NinjaNode for two phase ninja generationShinichiro Hamaji2016-02-151-32/+57
|
* [C++] Ninja: Detect and drop mkdir -p $(dir $@)Dan Willemsen2016-02-101-5/+29
| | | | | | | Ninja automatically creates the necessary output directories. This also fixes the logic to remove the empty '(true) &&' that was added for echo -> description detection.
* [C++] Move NeedsRegen from ninja.cc to regen.ccShinichiro Hamaji2016-01-201-294/+23
|
* [C++] Introduce .KATI_DEPFILE againShinichiro Hamaji2016-01-201-6/+19
| | | | | Unlike other target specific variables, this variable must not be propagated to other targets.
* Revert "[C++] Introduce .KATI_DEPFILE target specific variable"Shinichiro Hamaji2016-01-201-25/+7
| | | | This reverts commit bee26c1a805c45cdbf2372e17a09766ecd02579f.
* [C++] Introduce .KATI_DEPFILE target specific variableShinichiro Hamaji2016-01-201-7/+25
| | | | | If this variable is specified for a target, the target in output ninja file will have depfile attribute.
* Force regen if ninja file is missingShinichiro Hamaji2015-12-121-9/+20
| | | | For issue #39.
* [C++] Regenerate build.ninja when PATH was changedShinichiro Hamaji2015-12-091-1/+4
|
* Set local_pool after a command with gomacc is foundShinichiro Hamaji2015-11-261-1/+11
| | | | This is a temporary workaround. See TODO for detail.
* [C++] Do not crash when .kati_stamp is missingShinichiro Hamaji2015-11-171-2/+5
|
* Add --no_ignore_dirty flagColin Cross2015-11-121-2/+3
| | | | | | | | Android needs to ignore dirty files under out/ when deciding to rebuild, except for the soong-generated out/Android.mk. Add a --no_ignore_dirty flag to override the pattern provided in --ignore_dirty. Change-Id: I8810963f4dff07b51187868c7afedb10c6a4cb2e
* [C++] separate ninja shell script into twoColin Cross2015-11-091-2/+20
| | | | | | | | Separate the environment variables out of the ninja shell script so that the caller can source the environment script and then manually call ninja. Change-Id: If977a8316dceae955d71c32d528232d8b3f3aeef
* [C++] Remove gen_all_phony_targets flagShinichiro Hamaji2015-11-091-2/+1
|
* [C++] Regenerate ninja files when symlink was changedShinichiro Hamaji2015-10-151-2/+15
|
* [C++] Make the fast pass of EscapeShell consistent with the restShinichiro Hamaji2015-10-091-1/+1
|
* [C++] Do not escape ! in a shell scriptShinichiro Hamaji2015-10-091-1/+0
|
* [C++] Add .KATI_RESTAT builtin targetShinichiro Hamaji2015-10-021-0/+3
| | | | | | | | | | | | | | This is an experimental kati-specific expansion for GNU make. Targets specified by this will have "restat = 1" in generated ninja files. Even with this change, kati should be still compatible with GNU make. GNU make will ignore this but this only means GNU make will do some extra unnecessary builds. This different should not change the final output as long as .KATI_RESTAT is used appropriately. TODO: Implement the same feature in exec.cc and add a test.
* [C++] Do not have multiple default statements in a ninja fileShinichiro Hamaji2015-10-011-6/+10
| | | | | We have the first target as default only when --gen_all_targets or --gen_all_phony_targets.
* Add support for default targets in ninja outputColin Cross2015-09-291-5/+9
| | | | | | | | | make treats the first target it sees as the default target if no goals are passed on the commmand line. When generating a ninja file, mark this target with "default" to make it build if no goals are passed to ninja. Change-Id: I11befa4f88b8ca8734fdc7dd470c2a0a3722410d
* [C++] Always emit default statement in ninjaShinichiro Hamaji2015-09-291-8/+12
| | | | | Otherwise, build.ninja generated with --gen_all_(phony_|)targets runs unnecessary build targets if no target is specified.
* [C++] Use g_flags instead of passing flags to ninja.ccShinichiro Hamaji2015-09-281-64/+35
|
* [C++] A minor style fixShinichiro Hamaji2015-09-281-2/+3
|
* Write .kati_stamp file atomicallyColin Cross2015-09-141-1/+13
| | | | | | | | | | | | | | | | | It is possible to get a mismatch between the .kati_stamp file and the build.ninja file by exiting due to error or interrupt after the ninja file is written but before the stamp file is written. If the change that caused the previous stamp file verification to fail are then reverted, for example an environment variable set back to what it was in the stamp file, the next run of kati could see the old stamp file and not rewrite the non-matching ninja file. To avoid stamp and ninja file mismatches, delete the old stamp file just before starting to write any new files. To avoid a partially written stamp file write the stamp file to .kati_stamp.tmp, and then atomically rename it to .kati_stamp. Change-Id: Id5c7d7ab2b7f051a430ebbf919b8535b219ca290
* Do not use local_pool when goma is not enabledShinichiro Hamaji2015-09-111-1/+1
|
* [C++] A global refactoring for command line flagsShinichiro Hamaji2015-09-091-12/+12
| | | | So we will be able to use the command line parser for sub-makes.