Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: tfarina/ninja
...
head fork: tfarina/ninja
Checking mergeability… Don't worry, you can still create the pull request.
  • 16 commits
  • 6 files changed
  • 0 commit comments
  • 8 contributors
Commits on Feb 17, 2013
@lht lht Fix typo in manual 5f3429b
Commits on Feb 19, 2013
@mo mo Fix typo, s/verison/version/ 1d6e670
Commits on Feb 20, 2013
@benvanik benvanik Add a check for the VC++ 2012-style 64-bit path.
In VS2012 the path to the 64-bit tools has changed to
VCINSTALLDIR\bin\x86_amd64\cl.exe. This change will make the bootstrap
check there to see if it exists before falling back to the old amd64 path.
5f36d10
Commits on Mar 04, 2013
@fifoforlifo fifoforlifo NINJA_STATUS now takes %e for elapsed time. bec60b9
@fifoforlifo fifoforlifo Made %e purely a number. dce14e8
Commits on Mar 08, 2013
@dabrahams dabrahams Bring in declaration of atoi
./bootstrap.py fails on some platforms without this include
4115b3f
Commits on Mar 10, 2013
@martine martine Merge pull request #514 from dabrahams/patch-1
Bring in declaration of atoi
7b09e14
@martine martine Merge pull request #504 from benvanik/master
Add a check for the VC++ 2012-style 64-bit path.
6befa12
@martine martine Merge pull request #503 from mo/fix_typo_20130219
Fix typo, s/verison/version/
5cb9bf6
@martine martine Merge pull request #499 from lht/patch-1
Fix typo in manual
dad0649
@pcc pcc Add compdb tool
This tool helps convert Ninja build files to a compilation database
of the form used by Clang tooling.
e99c493
@martine martine Merge pull request #512 from pcc/compilation-database
Add compdb tool
a3bf38c
Commits on Mar 11, 2013
@fifoforlifo fifoforlifo Added %e to manual.asciidoc, fixed brace style. 5c132de
@martine martine Merge pull request #513 from fifoforlifo/master
Adding elapsed time (%e) to NINJA_STATUS.
ecc876e
Commits on Mar 14, 2013
@syntheticpp syntheticpp Posix symbols are not enabled by default for MSVC ee8431a
@martine martine Merge pull request #518 from syntheticpp/max-patch
Posix symbols are not enabled by default for MSVC
091cf48
View
4 bootstrap.py
@@ -85,7 +85,9 @@ def run(*args, **kwargs):
vcdir = os.environ.get('VCINSTALLDIR')
if vcdir:
if options.x64:
- cl = [os.path.join(vcdir, 'bin', 'amd64', 'cl.exe')]
+ cl = [os.path.join(vcdir, 'bin', 'x86_amd64', 'cl.exe')]
+ if not os.path.exists(cl[0]):
+ cl = [os.path.join(vcdir, 'bin', 'amd64', 'cl.exe')]
else:
cl = [os.path.join(vcdir, 'bin', 'cl.exe')]
args = cl + ['/nologo', '/EHsc', '/DNOMINMAX']
View
15 doc/manual.asciidoc
@@ -222,6 +222,7 @@ Several placeholders are available:
`%f`:: The number of finished edges.
`%o`:: Overall rate of finished edges per second
`%c`:: Current rate of finished edges per second (average over builds specified by -j or its default)
+`%e`:: Elapsed time in seconds. _(Available since Ninja 1.2.)_
`%%`:: A plain `%` character.
The default progress status is `"[%s/%t] "` (note the trailing space
@@ -283,6 +284,12 @@ Files created but not referenced in the graph are not removed. This
tool takes in account the +-v+ and the +-n+ options (note that +-n+
implies +-v+).
+`compdb`:: given a list of rules, each of which is expected to be a
+C family language compiler rule whose first input is the name of the
+source file, prints on standard output a compilation database in the
+http://clang.llvm.org/docs/JSONCompilationDatabase.html[JSON format] expected
+by the Clang tooling interface.
+_Available since Ninja 1.2._
Writing your own Ninja files
@@ -391,7 +398,7 @@ rule cc
# If left unspecified, builds get the outer $cflags.
build foo.o: cc foo.c
-# But you can can shadow variables like cflags for a particular build.
+# But you can shadow variables like cflags for a particular build.
build special.o: cc special.c
cflags = -Wall
@@ -628,7 +635,7 @@ across a line break).
paths, where a space would otherwise separate filenames. See below.)
`$:` :: a colon. (This is only necessary in `build` lines, where a colon
-would otherwise terminate the list of inputs.)
+would otherwise terminate the list of outputs.)
`$$`:: a literal `$`.
@@ -668,7 +675,7 @@ Two variables are significant when declared in the outermost file scope.
discussion of the build log>>. (You can also store other build output
in this directory.)
-`ninja_required_version`:: the minimum verison of Ninja required to process
+`ninja_required_version`:: the minimum version of Ninja required to process
the build correctly. See <<ref_versioning,the discussion of versioning>>.
@@ -684,7 +691,7 @@ keys.
$variables are expanded) is passed directly to `sh -c` without
interpretation by Ninja. Each `rule` may have only one `command`
declaration. To specify multiple commands use `&&` (or similar) to
- concatenate operations.
+ concatenate operations.
`depfile`:: path to an optional `Makefile` that contains extra
_implicit dependencies_ (see <<ref_dependencies,the reference on
View
7 src/build.cc
@@ -238,6 +238,13 @@ string BuildStatus::FormatProgressStatus(
out += buf;
break;
+ case 'e': {
+ double elapsed = overall_rate_.Elapsed();
+ snprintf(buf, sizeof(buf), "%.3f", elapsed);
+ out += buf;
+ break;
+ }
+
default:
Fatal("unknown placeholder '%%%c' in $NINJA_STATUS", *s);
return "";
View
1  src/build.h
@@ -220,6 +220,7 @@ struct BuildStatus {
RateInfo() : rate_(-1) {}
void Restart() { stopwatch_.Restart(); }
+ double Elapsed() const { return stopwatch_.Elapsed(); }
double rate() { return rate_; }
void UpdateRate(int edges) {
View
46 src/ninja.cc
@@ -15,6 +15,7 @@
#include <errno.h>
#include <limits.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -485,6 +486,49 @@ int ToolClean(Globals* globals, int argc, char* argv[]) {
}
}
+void EncodeJSONString(const char *str) {
+ while (*str) {
+ if (*str == '"' || *str == '\\')
+ putchar('\\');
+ putchar(*str);
+ str++;
+ }
+}
+
+int ToolCompilationDatabase(Globals* globals, int argc, char* argv[]) {
+ bool first = true;
+ char cwd[PATH_MAX];
+
+ if (!getcwd(cwd, PATH_MAX)) {
+ Error("cannot determine working directory: %s", strerror(errno));
+ return 1;
+ }
+
+ putchar('[');
+ for (vector<Edge*>::iterator e = globals->state->edges_.begin();
+ e != globals->state->edges_.end(); ++e) {
+ for (int i = 0; i != argc; ++i) {
+ if ((*e)->rule_->name() == argv[i]) {
+ if (!first)
+ putchar(',');
+
+ printf("\n {\n \"directory\": \"");
+ EncodeJSONString(cwd);
+ printf("\",\n \"command\": \"");
+ EncodeJSONString((*e)->EvaluateCommand().c_str());
+ printf("\",\n \"file\": \"");
+ EncodeJSONString((*e)->inputs_[0]->path().c_str());
+ printf("\"\n }");
+
+ first = false;
+ }
+ }
+ }
+
+ puts("\n]");
+ return 0;
+}
+
int ToolUrtle(Globals* globals, int argc, char** argv) {
// RLE encoded.
const char* urtle =
@@ -533,6 +577,8 @@ int ChooseTool(const string& tool_name, const Tool** tool_out) {
Tool::RUN_AFTER_LOAD, ToolQuery },
{ "targets", "list targets by their rule or depth in the DAG",
Tool::RUN_AFTER_LOAD, ToolTargets },
+ { "compdb", "dump JSON compilation database to stdout",
+ Tool::RUN_AFTER_LOAD, ToolCompilationDatabase },
{ "urtle", NULL,
Tool::RUN_AFTER_FLAGS, ToolUrtle },
{ NULL, NULL, Tool::RUN_AFTER_FLAGS, NULL }
View
2  src/util.h
@@ -76,6 +76,8 @@ string ElideMiddle(const string& str, size_t width);
#define unlink _unlink
#define chdir _chdir
#define strtoull _strtoui64
+#define getcwd _getcwd
+#define PATH_MAX _MAX_PATH
#endif
#ifdef _WIN32

No commit comments for this range

Something went wrong with that request. Please try again.