Commit Graph

43 Commits

Author SHA1 Message Date
Allan Odgaard
610624ca5a Improve variable handling when rebuilding build.ninja
Variables which are not referencing other variables are no longer provided with their literal value. Variables which do reference other variables have the reference escaped, so that ninja won’t expand the reference when rebuilding build.ninja.

There is still some redundancy in that APP_VERSION has the major + tag part stated both at the top and as a command line argument, haven’t yet figured out how to best deal with this.
2013-04-11 10:24:47 +07:00
Allan Odgaard
c54360fce3 Don’t expand APP_* variables in build.ninja
This makes it simpler to edit the generated file as one only need to edit the top variable section.
2013-04-01 13:22:41 +07:00
Allan Odgaard
f4f0e073d3 Use ‘alpha’ prefix instead of ‘r’ 2013-03-17 17:08:54 +01:00
Allan Odgaard
687d0ee9e4 Ensure we use /usr/bin/mktemp
It appears some variants of mktemp require the template parameter to contain a minimum number of X’es.
2013-03-01 16:30:10 +01:00
Allan Odgaard
ccf63ae206 Use proper PCH for tests
We previously passed an array to ‘pch_for’ where we should have passed a source path, though it appear to have worked.
2013-02-25 15:28:37 +01:00
Allan Odgaard
01417054cb Add test system supporting grand central dispatch
The motivation for introducing a new test generator is that CxxTest cannot be used with tests that (indirectly) schedule code to run in the main queue.

There are a few other advantages of breaking with CxxTest:

 1. Less boilerplate: A test file need only contain a
    function named with a ‘test_’ prefix. No classes,
    inheritance, or similar. If you need fixtures, use the
    multitude of ways that C/C++ allows that (constructor
    functions or non-POD types with static storage).

 2. Concurrent tests: Test functions are scheduled with
    ‘dispatch_apply’ and will thus run concurrently. If
    you need serial execution you can wrap your tests in a
    block and schedule that to run in the main queue.
    Though you should catch exceptions and re-throw these
    in the test’s original queue, as the test assertions
    are using exceptions.

 3. Easier output of custom types: The assertion macros
    will call ‘to_s’ on the arguments given, so the only
    thing required to make these output nicely is to
    provide a ‘to_s’ overload for your custom type /
    enumeration. I know that the standard way to do this
    is overloading operator<< for a stream, but the
    TextMate code-base already uses the ‘to_s’
    convention.

Long-term I can see a few other advantages, like calling preprocessor on the input files to support #if/#else/#endif to disable tests, better support for Cocoa code (NSRunLoop), and introducing test timeouts.
2013-02-21 15:54:37 +01:00
Allan Odgaard
a1b9c305da Move version knowledge outside upload script 2013-02-18 16:11:12 +01:00
Allan Odgaard
66350b6492 Remove ‘after_bump’ phony rule
Turns out a phony rule in ninja isn’t exactly the same as an alias. When the file the phony rule is supposed to be an alias of already exist when calling ‘ninja’ then rules depending on the alias are not considered out-of-date even if the aliased file is of newer date.

Build rules that previously depended on ‘after_bump’ should instead depend on ‘builddir/revision.$APP_REVISION’.
2013-02-16 10:43:55 +01:00
Allan Odgaard
2df0f7aa51 Revert "Do not timestamp our code signing"
Some users have reported issues opening TextMate: Finder tells them the program is corrupt and should be moved to trash. If the user adds his own (ah hoc) signature, then no such dialog is shown.

This reverts commit 1c164e3ce0.
2013-01-29 15:31:10 +01:00
Allan Odgaard
08eace5a47 Do not remove old targets if ninja failed 2013-01-28 22:08:17 +01:00
Allan Odgaard
8066344806 Don’t include $USER.ninja when username is ‘build’
Since our master build file is named ‘build.ninja’, including the user build file in this case would read the master file twice.
2013-01-25 11:01:57 +01:00
Allan Odgaard
1c164e3ce0 Do not timestamp our code signing
This means that the signature will be invalid when the certificate expires, though it also means that codesign runs faster, and as my certificate is valid for another 4 years, people shouldn’t be using the builds released today when the certificate expires.
2013-01-22 19:23:15 +01:00
Allan Odgaard
3c92d2aeb9 Introduce ‘after_bump’ build target
This target is solely intended for other targets to depend on, and will cause the dependents to be rebuilt after the APP_REVISION has been increased.

For example ‘Contributions.md’ technically depend on commit history (and online lookups), but in practice we can’t specify this in its dependencies, so previously we had to manually touch the file, if we wanted the HTML to be regenerated.

Now we can have it done automatically after each ‘bump’ by adding this rule:

    build path/to/Contributions.md: touch | after_bump

For the records, I bump the revision *before* I do ‘ninja deploy’. This ensures that deployed versions do not share revision number with a custom build (I do another ‘ninja bump’ after a successful deploy and ./configure will also set APP_REVISION to ‘current + 1’).
2013-01-22 08:03:07 +01:00
Allan Odgaard
725b9613dd When recreating build file, don’t expand APP_REVISION
This is just to make “bumping” the revision safer. Previously the revision number would be two places in the generated build file, and both needed to be bumped. Now there is only one instance. Generally the revision is bumped with ‘ninja bump’ so the user shouldn’t care about it, but sometimes manual intervention is required.
2013-01-22 08:03:07 +01:00
Allan Odgaard
e19686c9d8 Handle targets with no dependencies
These would not be added to the dependency graph and thus no build instructions were generated for them.
2013-01-21 15:03:52 +01:00
Allan Odgaard
5f635aa026 Build: Convert *.strings files to UTF-16 if needed
If the *.strings file does not contain an UTF-16 byte order mark (either big or little endian) then it is assumed to be UTF-8.
2013-01-02 01:46:48 +01:00
Allan Odgaard
71be61cbbb Enable ARC by default
We now explicitly disable it for targets that hasn’t yet been upgraded to ARC. This way, it’s easier to get an overview of which targets hasn’t yet been upgraded and ensures new targets has ARC enabled.
2012-12-19 19:42:36 +01:00
Allan Odgaard
2ae8d9371e Apply custom build flags last
This allows using RAVE_FLAGS to override the more general compiler flags.
2012-12-19 19:42:36 +01:00
Allan Odgaard
6e228b69aa Fix typo 2012-12-19 19:42:36 +01:00
Allan Odgaard
a7e70de9dd Help book index: Enable verbose output
This seems to be the only way to learn of problems creating the help index, as parsing errors are otherwise silently ignored.
2012-12-19 19:42:34 +01:00
Allan Odgaard
df6c6f5f8b Avoid using ‘-q’ with pgrep
The version installed via MacPorts does not have such option so relaunching TextMate (after successful build) would not work.
2012-09-29 00:16:07 +02:00
Allan Odgaard
c77c6fc4e2 Let gen_build support TM_NINJA
This is for when building from TextMate and PATH has not been setup to contain the directory containing ninja.
2012-09-28 16:36:37 +02:00
Allan Odgaard
7d50b4db92 Change version bumping rules
We no longer do an implicit bump after deploy — this should be done, but as we also want to do a bump before deploy (so deployment builds do not share revision with any custom builds) we need the bump rule to be usable by itself.

Also fix issue with bumping APP_REVISION in build.ninja not affecting APP_VERSION after rebuilding build.ninja.

And additionally include user file after main build.ninja.
2012-09-25 01:41:07 +02:00
Allan Odgaard
50217a73ba Let precompiled headers depend on compiler 2012-09-24 20:58:43 +02:00
Allan Odgaard
de3a1ee2f0 Build tests with same compiler flags as their sources
We link the test’s .o with the .o objects from the library being tested, rather than link it with a potential dylib, hence why some flags matter.
2012-09-24 20:58:43 +02:00
Allan Odgaard
ed7a93af93 Allow enabling ARC per target
The issue is that the precompiled header must also be created with ARC enabled, so now we use different precompiled headers depending on wether or not the file to be compiled has -fobjc-arc enabled.

The way this is done is hardcoded for the ARC options, it might be nice to abstract it so that the PCH dependency had a name derived from the PCH-sensitive compiler options.
2012-09-22 13:23:40 +02:00
Allan Odgaard
ebbd58c513 Improve build file dependency tracking
Previously if we did something like:

    CP_Resources = resources/*

The build file would correctly depend on the ‘resources’ directory, but a change, as in, adding, removing, or renaming a file, in a directory below ‘resources’ (e.g. adding ‘resources/English.lproj/NewWindow.xib’) would not correctly update the build file to include the new resource.
2012-09-17 16:42:42 +02:00
Allan Odgaard
e721e6e0d6 Ensure builddir doesn’t contain removed files
If e.g. we rename “image.tiff” → “image.png” then the build files are correctly updated to copy “image.png” to the build directory, but until this commit, the old tiff image would stay in the build directory until manually removing it / cleaning the build directory.
2012-09-14 17:14:56 +02:00
Allan Odgaard
15bfe9fc9c Let build rules depend on their tool 2012-08-27 01:03:17 +02:00
Allan Odgaard
c0de81d943 Label the build.ninja target
This is to prettify the build output (for the cases where build.ninja needs to be regenerated).
2012-08-25 02:06:22 +02:00
Allan Odgaard
12a1d86735 Add upload targets for executables
This is to make it easy to push test programs.
2012-08-22 18:24:41 +02:00
Allan Odgaard
69196f58f3 Add missing dependencies to debug targets 2012-08-21 20:24:06 +02:00
Allan Odgaard
d737efd7e1 Generalize bin/upload
It now takes key path and destination (github repostiory) as arguments. The generated build.ninja assumes the user local build.ninja sets these variables.
2012-08-20 15:44:47 +02:00
Allan Odgaard
95a9ab8561 Improve error reporting in gen_build
This is for the case where the user is missing targets (e.g. did not checkout submodules).
2012-08-20 15:44:47 +02:00
Allan Odgaard
a463e8f621 Let build.ninja include $USER.ninja (if it exists)
User specific settings and rules can go into this file.
2012-08-20 15:44:47 +02:00
Allan Odgaard
7f177f1345 Introduce test targets that always run
This means having a test file open (in TextMate) and using ⌘B, the test will always run, even if it has previously succeeded and none of the test’s dependencies have been updated.
2012-08-18 15:30:24 +02:00
Allan Odgaard
218551185b Add gdb targets to build.ninja
Since ninja run each build job with its own stdin/out/err we can’t launch gdb itself in a build job, so we use osascript to launch gdb in a new window.

I used Terminal for this only because it is simpler to script than iTerm2.
2012-08-15 23:23:24 +02:00
Allan Odgaard
b7174fafa0 Add phoney target for deploying
The nightly builds still require me to manually run the ‘TextMate/deploy’ target, so if we can make it 9 characters shorter, it’s totally worth it! :)
2012-08-15 00:33:33 +02:00
Allan Odgaard
0cedb7f3ab Specifically call platform’s tsort.
This fixes issue #102 where user has a ‘tsort’ not supporting the ‘-q’ option in his PATH (before the platform version).
2012-08-12 22:30:49 +02:00
Allan Odgaard
2ff7684eda Order build rules based on dependencies.
Previously we wrote out the build rules alphabetically and grouped by target type. So e.g. the build rule for a framework would be created before that of an application bundle.

While it worked, it didn’t allow e.g. the preferences framework to depend on the mate executables (for copying to its resources section) since the build rules for mate would be created after that of the preferences framework.

We now do a topological sort on the dependency graph (by shelling out to ‘tsort’) to make the build system more flexible.
2012-08-12 16:07:29 +02:00
Allan Odgaard
e8bad0d669 Quote compiler variables.
This is incase user has clang installed e.g. under /Applications/Xcode 4.5.app/…

Fixes issue #29.
2012-08-09 22:33:18 +02:00
Aaron Brethorst
0462b4a18b Hardcode Ruby scripts to use the Apple-provided version of MRI 1.8 since rdoc/usage is missing in 1.9 2012-08-09 10:04:23 -07:00
Allan Odgaard
9894969e67 Initial commit 2012-08-09 16:25:56 +02:00