Commit graph

1430 commits

Author SHA1 Message Date
Jamie Gennis
7d5b2f82ce Simplify module and singleton registration.
This change eliminates blueprint.ModuleType and replaces it with simple factory
functions.  Rather than using the explicitly provided ModuleType names to
essentially identify the Go factory function in the generated Ninja files, we
now use the actual factory function name.

Change-Id: Ib7813e850322a82cc35cdc56bebff7d580a5c6ec
2015-01-23 13:41:46 -08:00
Romain Guy
285296519a Add support for targets in Blueprints.
The default target selector uses the name of the host OS.
Modules can implement their own target selector by implementing
the context.TargetSelector interface and its unique selectTarget()
method.

Targets are defined this way in Blueprint files:

cc_library {
    name:  "libmylib",
    deps:  ["libmath", "libutils"],
    zones: ["frontend"],
    srcs:  ["main.cpp"],
    targets: {
        darwin: {
            moduleCflags: "-framework OpenGL -framework GLUT",
        },
        linux:  {
            deps: ["libx11headers", "libglu"],
        },
    },
}

In this example, a set of C flags are defined on OS X only and on
Linux, two new dependencies are added.

When a target is selected, its properties are merged with the properties
of the modules:
- a list is appended to the original list (see deps above)
- a string is concatenated to the original string
- a bool replaces the original bool
- a map adds or replaces the key/value pairs of the original map

Change-Id: Ic627d47f795d6a4ff56ca5f6f099cad157621af1
2014-08-12 17:50:11 -07:00
Romain Guy
2476f81d84 Add support for map properties
Example:

foo {
  // string property
  name: "hello",
  // map property
  translations: {
    ge: "guten tag",
    fr: "bonjour",
  },
}

Change-Id: Ib9e6570cb6f355677b4ba0235e8fb4186e40f5f8
2014-07-25 17:01:20 -07:00
Romain Guy
5f7ef51f7a Add support for raw strings
Change-Id: Ib68f1a08c8707b8c955d25bf0a7fd6f491c0b470
2014-07-24 15:29:42 -07:00
Jamie Gennis
ae4430cd9e Stop processing modules when one fails.
This change causes Blueprint to stop calling GenerateBuildActions on modules
when one such call results in errors being generated.  If a module has failed
for some reason and another module depends on it, then processing the dependee
could end up trying to use the failed module, which may be in an invalid state.

Change-Id: I5cc165b7f4e169f90e9570ec7b2a5f9baac2895a
2014-07-23 14:37:21 -07:00
Jamie Gennis
6a40c19e1c Add some ModuleContext error functionality.
Change-Id: I0635de0440da27e1d7cf7e155f268e6f958047eb
2014-07-02 16:40:31 -07:00
Jamie Gennis
0ed63eff29 Fix scoping logic to respect the caller's package.
This change makes the ModuleContext and SingletonContext methods respect the
caller's Go package when performing name lookups.  It does this by re-parenting
the module or singleton's scope to the scope of the caller's package, thus
allowing a Module or Singleton to pass its context to a function defined in
another Go package and have the called function access variables and rules
defined in its own Go package.

Change-Id: Ifdec87ba3095a453b36fb00e38c0bb3a928a2b9b
2014-06-30 18:26:28 -07:00
Christopher Horvath
3159cb7673 Added extra ninja file dependencies (optional) to Main
This facilitates dependencies on extra files, such as global build configuration
files

Change-Id: I928688ad8b9867066d37dec2c00710755fae921e
2014-06-27 08:18:14 -07:00
Mathias Agopian
5b8477d423 add support for module generated ninja-file dependencies
Change-Id: I54b6d240adc89591fbe41ed1f9d63db9a791999a
2014-06-25 17:21:54 -07:00
Jamie Gennis
d4c53d8a50 A few minor changes.
- Make module 'new' functions return slices of properties structs rather than
  just one.
- Fix a couple places where errors were being reported incorrectly.
- Add ModuleContext methods for dealing with other modules.
- Make property value unpacking skip unexported struct fields rather than
  panicing.

Change-Id: I4775ef77ff0514fc2ce5abccbe2ce534c05272f4
2014-06-22 17:02:55 -07:00
Erik Gilling
310794f016 add ReplaceExtensions to pathtools
Change-Id: I6dc92323d4b0ef4b0f31076c868802dc568346c4
2014-06-19 21:22:52 +00:00
Jamie Gennis
e98b8a927d Add support for singletons to walk module deps.
Change-Id: I63405ee917a55ae92cf55070af94e01ddc266389
2014-06-18 12:57:56 -07:00
Jamie Gennis
48aed8cee0 Add more Build/Rule/Pool params validation.
This change adds two new kinds of checks to params validation.  First, all
BuildParams must have one or more outputs.  Second, any Pool or Rule referenced
must be visible within the Blueprint scope of the caller (e.g. if it's defined
in another Go package then an Import call must have been made).  If either of
these conditions are violated it will result in a panic.

Change-Id: Ibacb42513882d914c94eade23ef17269db5e8730
2014-06-18 12:57:56 -07:00
Jamie Gennis
71bd58a966 Improve Ninja string parse errors.
Change-Id: I8450befd19694e51bc3cb0658e8075b0d49ee614
2014-06-18 12:57:56 -07:00
Jamie Gennis
7330a23887 Clean up the bootstrap script a little.
This change makes the bootstrap script take two optional flag-based command
line arguments rather than using positional arguments.  The -i argument
replaces the old positional arguments (one of which was simply not needed), and
the -r flag now causes the script to regenerate the bootstrap Ninja file for
use when working on Blueprint itself.

Additionally this change allows all the configuration variables used in the
script to be overridden by environment variables.  This makes it possible to
create a very simple bootstrap script for a customized Blueprint-based build
system by invoking this script after setting up the proper environment
variables.

Change-Id: I60f890061ae237a68719e1e2d345d1a8e87c851c
2014-06-18 12:57:56 -07:00
Jamie Gennis
d4e1018e19 Document most of the blueprint package APIs.
This change adds docs to all the blueprint package APIs except for the Module
and Singleton types and their corresponding context types.

Change-Id: I74aa48c7743086ad79b3122d5813f5c4823c6519
2014-06-12 20:10:01 -07:00
Jamie Gennis
ec7012824a Fix a variable name
Change-Id: I0b7e14291df954de1023ab1396e6a0b8adbf5033
2014-06-12 20:10:01 -07:00
Jamie Gennis
04f106f23a Don't export the EOF constant.
Change-Id: I6f8578d0a6c62bdb1e384d5e512937d9489387b7
2014-06-12 19:41:57 -07:00
Jamie Gennis
0453c75a51 Fix some typos.
Change-Id: Ief99d9aa834eea6c6c6e3a040b62b945b32eacf8
2014-06-12 14:00:10 -07:00
Jamie Gennis
6eb4d24fad Remove the blueprint.Config type.
This change removes the definition of the Config type in the blueprint package.
The type was simply an empty interface, and it seems more clear to just have
that be explicit in the APIs.

Change-Id: Ia23a978f28e8627f890f483f62536f67264401bf
2014-06-12 12:16:09 -07:00
Jamie Gennis
7ab5f3c4ba Document the bootstrap process.
This change adds a bunch of docs describing the bootstrap process.  It also
renames a couple things in the source to better correspond with the terminology
used in the docs.  On top of that it makes the standalone build to copy minibp
from the .bootstrap/bin directory to the bin directory to make it easier to
find.

Change-Id: Ibae3e607b59e2caf7d764ec3153155fde208ec1e
2014-06-12 12:16:09 -07:00
Jamie Gennis
86179feee4 Sort modules and singletons for output.
This change causes the module and singleton content in generated Ninja files to
be sorted by name.

Change-Id: I6e1fe6d4211111c7dfa25ebe0fc721701a6d0256
2014-06-11 16:30:42 -07:00
Jamie Gennis
a22f3e5e24 Fix a logic bug in a check for matching files.
Change-Id: I04d24ecddb78c9d302ecf58320aa3eb40fe507fb
2014-06-11 16:29:26 -07:00
Jamie Gennis
b931456573 Add the blueprint/pathtools package
Change-Id: I0706d8b0c0c5cbab1425c4d0b08070fd66a5900b
2014-06-06 14:41:07 -07:00
Jamie Gennis
598fe760ca Change the bootstrap dir to .bootstrap
Change-Id: I016939015144e29f5981b754b725a6c8e48e3b0d
2014-06-06 14:41:07 -07:00
Jamie Gennis
28a63fba69 Add the blueprint.VariableConfigMethod function.
VariableConfigMethod creates a Ninja variable whose value comes directly from a
method on the config object.

Change-Id: I9baa3598678928ea3d5bc85b864b2df7d3e1b749
2014-06-06 14:41:07 -07:00
Jamie Gennis
cbc6f86e34 Fix a re-bootstrapping issue.
This change fixes an issue where the re-bootstrapping process would overwrite a
newer bootstrap manifest with one that it generates using its older minibp.  It
fixes the issue by only generating a new bootstrap manifest right after
rebuilding minibp (as part of the bootstrap process).  It then uses an
additional rebootstrap iteration to replace the old bootstrap manifest with the
new one.

Change-Id: I16bad2f30f6ad7f10da07d77105e8745adec3650
2014-06-06 14:41:07 -07:00
Jamie Gennis
1ebd3b838b Make build.ninja.in independent of the build dir.
This change makes the module definition location that's included in the build
manifest comments use paths relative to the top-level source directory.  This
should make the bootstrap build manifest not get regenerated when using a new
build directory.

Change-Id: I350562ad10aa52688c8841c96c6325502b0faa59
2014-06-04 15:33:08 -07:00
Jamie Gennis
1bc967ed43 Initial Blueprint commit.
Blueprint is a build system component that reads Blueprints files defining
modules to be built, and generates a Ninja build manifest that can be used to
perform all the build actions.  It does not dictate or implement much build
policy itself, but rather provides a framework to ease the process of defining
build logic in Go.

The "blueprint" and "blueprint/parser" Go packages contain the functionality
for reading Blueprint files and invoking build logic functions defined in other
Go packages.

The "blueprint/bootstrap" Go package contains just enough build logic to build
a binary that includes Blueprint and any pure-Go (i.e. no cgo) build logic
defined in external Go packages.  This can be used to create a minimal Ninja
file that's capable of bootstrapping a Blueprint-based build system from
source.

The "blueprint/bootstrap/minibp" Go package contains code for a minimal binary
that includes the build logic defined in the "blueprint/bootstrap" package.
This binary can then create the Ninja file for the bootstrapping process.

Change-Id: I8d8390042372a72d225785cda738525001b009f1
2014-06-04 14:23:32 -07:00
Erik Gilling
2ec08c8555 Initial empty repository 2014-05-27 21:09:47 +00:00