Commit graph

52 commits

Author SHA1 Message Date
Colin Cross
a6bc19e415 Check that a product variable is set
Store product variables in pointers so that we can only apply the
properties if the product variable was set to a value.  Also only apply
bool properties if they are true, adn rearrange the code to do the
cheapest checks first.

Remove device_uses_logd, it doesn't exist any more.

Change-Id: Icf42408f57bd611746f8d985bfceb50c7f95ea59
2015-09-16 14:19:55 -07:00
Dan Willemsen
8a12ccd282 Merge "Freeze environment reading after saving deps" 2015-09-15 23:57:07 +00:00
Dan Willemsen
e7680babe2 Freeze environment reading after saving deps
Any reads after the deps are saved won't show up as dependencies later.
So panic if new environment variables are read after saving deps.

Change-Id: Ia51deaf750804d3b99e69c001939a104c2d8c9f2
2015-09-15 20:30:03 +00:00
Dan Willemsen
00faa6d9da Add cortex-a53 cpu variant
Used in bionic

Change-Id: I5936f8468937fc259ef75d8278a592b8a7b07077
2015-09-15 13:25:38 -07:00
Colin Cross
485e572aeb Read product variables from soong.variables
Refactor the soong.config loading code to support reading in
product variables from soong.variables.

Change-Id: I389e6bb5c501b53167267d5f5d0d25557811cf72
2015-09-14 16:09:36 -07:00
Colin Cross
7f64b6de31 Support product variables
Allow modules to vary their properties based on product variables.
For now, DEVICE_USES_LOGD, DEVICE_USES_JEMALLOC, and DEVICE_USES_DLMALLOC,
and BOARD_MALLOC_ALIGNMENT are supported.

Product variables can provide a value (only bool and int supported for
now), and if any of the product variable properties contains a "%d"
then Sprintf will be called with the property value as the format
and the product variable value convert to an int as the only argument.

For example:

    product_variables: {
        dlmalloc_alignment: {
            cflags: ["-DMALLOC_ALIGNMENT=%d"],
        },
    },

will cause -DMALLOC_ALIGNMENT=16 to be added to any top level
properties called "cflags".

Change-Id: I74882a6ab4914d3e222f8d06cfac371b7b829ae5
2015-08-24 16:20:08 -07:00
Colin Cross
6e18ca49f8 Fix java resource glob file list location
The source path was being appended to the module out directory
to create the file list file, which was resulting in .. in the
source path moving the file list file up the directory tree.
Use SrcDirRelPath to convert the globbed resource directories
to be relatiave to $srcDir before appending them.

Also do the same fix to generated aidl, logtags, yacc, and lex
files.

Change-Id: I2e636bd30abf03bc1d80a897951a9812cc3e09ef
2015-08-24 16:19:43 -07:00
Dan Willemsen
24f2f8df87 Update to new blueprint api for bootstrap.BinDir
And regenerate build.ninja.in

Change-Id: I35e8b0362799f94b33309d3944b411de5dbcf40a
2015-08-24 15:40:44 -07:00
Colin Cross
a819f08275 Fix glob filename overlap
If resources and java files were compiled from the same directory,
ctx.Glob could try to create a glob file that had the same name
as the directory containing another glob file.  Namespace each
call to ctx.Glob so they never conflict.

Change-Id: I4db73af568a2ff2e708e9db64798073b1ed2ff61
2015-07-23 17:52:17 -07:00
Colin Cross
01432f6b11 Add support for x86_sse3 and x86_sse4 arch sections
Change-Id: I26b642808c66bc4562b3079edbe482febf9b2435
2015-07-09 18:01:05 -07:00
Colin Cross
463a90e587 use init functions to register module types, etc.
Instead of putting all the blueprint registrations in soong_build,
put them all in init() functions.  This puts the registration next
to the implementation.

Change-Id: Ide1a749518f5e9d1367a18ab3bb1d91da3310c76
2015-07-09 17:57:18 -07:00
Dan Willemsen
ffce3fcf33 Enable host multilib
Change-Id: I17405452a141d9ce15e4093f6610e8a9eceb98a9
2015-07-08 13:02:19 -07:00
Colin Cross
ec19363c23 Add cpu-variant properties
Add nested properties that can vary based on the specific cpu type,
for example cortex-a9 or cortex-a15.

Change-Id: I107d6e30527c11d0bdd9bf17fb29513ffb07f9cc
2015-07-07 14:38:24 -07:00
Dan Willemsen
2ef08f4458 Add exclude_* and remove arch_subtract / "-file"
To align with the current make build system, add exclude_srcs and
exclude_java_resource_dirs. These replace the functionality of
arch_subtract and glob exclusions that use "-file" to exclude a file.

Change-Id: I91c23d5e3c9409f2d9f7921f950153a03a68ad61
2015-07-01 20:59:39 +00:00
Colin Cross
b3245e9cf6 androidbp: simplify translation by evaluating all expressions in Blueprint
Translation is getting complicated because the expressions supported
by Blueprint are difficult to support in Make.  Modify androidbp
to use context aware parsing so it can evaluate all expressions at
parse time, so it only needs to deal with constant values.

Change-Id: I57047645fb48475baecd0361f78a93ec0a26011e
2015-06-30 17:51:25 -07:00
Colin Cross
00a36d3f21 Remove unnecessary glob depFile phony rule
The glob depFile is not a listed output file of a rule, so it will
never be deleted by the cleanup phase.  Remove the unnecessary phony
rule to avoid a warning when running soong -d explain:
ninja explain: output .intermediates/androidmk/glob/build/soong/Androidmk.d of phony edge with no inputs doesn't exist

Change-Id: I40ed5a28fb29b8455981f6debf1de2ea21c911ea
2015-06-29 13:09:30 -07:00
Colin Cross
7d5136f033 Improve property comments for docs
Improve the comments associated with properties to work better with
Blueprint's auto-documenting feature.

Make all properties structs into named types so that thet types can be
found using reflection and cross-referenced to the source code to
auto-extract docs.

Remove the leading <property>: text from properties, the documentation
will include the lowercased name of the property.

Add filter tags to the nested arch properties.

Change-Id: I4ef5db86358886fe61456c24eb2dbe6f7b876115
2015-06-29 10:36:02 -07:00
Dan Willemsen
cdd1a99096 Add dependency to existing Android.mk files
So that we generate the Android.mk file if it is removed. Adding
Android.mk files is already handled by the implicit dependencies in
common.Glob

Change-Id: I568e24b7bc44ecadbbe01c1f7c6a97afd819c7db
2015-06-19 21:25:19 +00:00
Dan Willemsen
bf9207aceb Create 'androidmk' rule to automatically run androidbp
This finds any Android.bp files with Android modules defined, and if
there isn't an Android.mk file in the same directory, it will run
androidbp to generate one in $OUT

Change-Id: Ie8aef492e8cd28f6c314ce1254730975a1b8991f
2015-06-18 12:56:43 -07:00
Colin Cross
8f101b45fc Allow common.Glob to be called by singletons
Make common.Glob take an interface that is the intersection of
blueprint.ModuleContext and blueprint.SingletonContext used by
Glob and GlobRule, allowing it to be called on either.  Also
move ExpandSources and Glob into AndroidModuleContext.

Change-Id: I8d1a3160c5dd201033afdb37210e82d8065b137d
2015-06-17 15:36:48 -07:00
Colin Cross
1f8c52be73 Add per-directory build targets
Build a map of blueprint directory to modules built from that
directory, and then add phony rules to build.ninja that emulate
the behavior of mma in the current build system.

Also fixes checkbuild to depend on checkbuild files and installable
files, but not installed files.

Change-Id: I8bad6e93387940df7439dbd4554f6d79f924c65f
2015-06-17 10:18:35 -07:00
Colin Cross
6a745c6ad0 Fix gofmt
Change-Id: I031ecd7f28a0fb29d8c5d322e4910cc4947b2fb8
2015-06-16 16:44:05 -07:00
Colin Cross
3ab7d8835f Use proptools.CloneEmptyProperties
CloneEmptyProperties is much faster than CloneProperties followed
by ZeroProperties.  Cuts >100ms off soong_build runtime, which will
become more important when we start calling soong_build a second
time to automatically generate documentation.

Change-Id: I45d948b36d9937a21b13dab068c3ce9a60b5a59b
2015-05-19 13:03:01 -07:00
Colin Cross
f22982707d Check that local, top level, and exported include paths exist
Require directories listed in the include_dirs, local_include_dirs, and
exported_include_dirs properties to exist.

Change-Id: I5b079bd2c607839bb28dae43801cd7345bde2299
2015-05-12 11:36:53 -07:00
Colin Cross
d3ba039f74 Separate HostOrDevice out of Arch
Take HostOrDevice out of Arch, and put it into AndroidModuleBase
instead.  Also separate out the host vs. device mutator from
ArchMutator.  This will make it possible for genrules to depend
on a host tool, regardless of which host arches it is compiled
for.

Change-Id: I22bbfd28b65c3eebdfa101a712f90dd615148dc8
2015-05-09 00:10:19 +00:00
Colin Cross
0af4b8468b Add support for building on Darwin hosts
Add toolchain and build rules for building on Darwin.

Change-Id: I78e21f4051b2941182121b28c9ddfa24396ada41
2015-05-07 14:09:48 -07:00
Colin Cross
b05bff2f26 Add per target archtecture properties
At least libcutils and boringssl need to set source files that
apply to x86 or x86_64, but only on the host or on the device.
Add new properties that can contain arch variant properties:
target.android_arm
target.android_arm64
target.android_mips
target.android_mips64
target.android_x86
target.android_x86_64
target.linux_x86
target.linux_x86_64
target.darwin_x86
target.darwin_x86_64

Change-Id: I5a7076653a7367a63daa7f7e34a6a28f5cbdfbe7
2015-04-30 16:35:06 -07:00
Colin Cross
6a114caa17 Fix globbing bugs
Fix two bugs in globbing: check for excludes before globs so that
excludes that contain globs are not treated as includes, and
remove the Generator attribute from globRule so that the rule
reruns if the command line changes, for example if the glob or
excludes list changes.

Change-Id: I216c0c925eeb00a3814300548c005bcdf64a1f30
2015-04-29 14:59:23 -07:00
Colin Cross
30e076af2e Add support for building android apps
Add support for running aapt to generate R.java and Manifest.java,
compiling java into jar, adding resources to the jar to convert it
into an apk, signing the apk, and zipaligning the apk.

Change-Id: I7a73fef590d07f35b3d0b56a8571780c09bb10ae
2015-04-20 14:12:30 -07:00
Colin Cross
c1e86a3896 Fix race condition in config.Getenv
The envDeps map may be accessed concurrently by multiple modules
in GenerateBuildActions, wrap the accesses in a mutex.

Change-Id: I18abf2687997c045a99b987908623f7d8c2ea344
2015-04-15 12:41:44 -07:00
Colin Cross
9b6826f7cf Quote glob exclude options
Put quotes around the glob exclude options to avoid accidentally
expanding globs during execution.

Change-Id: Ia6fc7fa7dbe1d75e97d6039642e1c89be027689a
2015-04-10 16:12:49 -07:00
Colin Cross
c3c0a49622 Remove Config interface
Replace the Config interface with a struct that wraps the real
*config object.  This keeps the existing pointer behavior without
having to list all of the available config functions in the interface.

Change-Id: If55a622b5a112ca5dc7193ebd59f2931b3a8e6cd
2015-04-10 15:50:37 -07:00
Colin Cross
c0b06f191f Add aidl file support to java builds
Add support for aidl files listed in srcs for java builds, and
an aidl_preprocess module type for framework and sdk aidls.

Change-Id: I3aa537f4483822e5b534c74d0b35f13a938f8947
2015-04-08 16:37:31 -07:00
Colin Cross
fce532760f Support subtracting sources from globs
Support -file or -path/glob in file lists that contain globs to
subtract files from the resulting glob.  Also move source file
prefixing and handling into a common function.

Change-Id: Ib6d74ce22f53cae7348c4ba35b779976d90359a6
2015-04-08 15:19:30 -07:00
Colin Cross
1332b0035c Move config into common and provide helper
Using ctx.Config().(Config) everywhere is a mouthful, and it is
inefficient to do the type assertion.  Put the Config interface into
the context, and provide an AConfig() to return the Config already
converted to the right type.

Change-Id: I301a1fd7d2a005580aabca7866a37c5d42ad8c69
2015-04-08 15:19:24 -07:00
Colin Cross
581c189988 Add yacc and lex support
Add support for yacc (.y or .yy) and lex (.l or .ll) files.  Also
tweak locations of .o files for normal and generated sources to
makes sure they don't collide.

Change-Id: I03172cddbdc022525bf392a81d72050406b8cdb3
2015-04-08 15:17:45 -07:00
Colin Cross
2fe6687847 Support java libraries, binaries, and prebuilts
Add support for compiling java libraries (.jar files with
or without .dex), java binaries (.jar files with a wrapper
script to run them), and java prebuilts (for the SDK .jars)

Change-Id: Id624da64c92cf20c6d9577c6bb06e5b212af0d1b
2015-04-03 16:24:44 -07:00
Colin Cross
35cec12a11 Clean up installing
Use the config to get paths to install to, allow installing
a file to a different file name than the intermediate file,
and allow dependencies between installed files.

Change-Id: I37ac32d2fa1458150b6d54f6ec9cdac70a0259e8
2015-04-03 15:55:08 -07:00
Colin Cross
3e8ec07787 Support excludes in globs
Java resource support requires globbing directories while ignoring
specific filenames.  Add support for multiple -e options to
soong_glob to specify filenames to exclude, and split out Glob
into GlobRule to insert a rule to generate a glob file list.

Change-Id: Ia911dd68bd1638452881d18378572d015fd4e31a
2015-04-03 15:55:08 -07:00
Colin Cross
c77f9d1404 Add global tags properties, remove resourceDirs
Add tags to the global properties, but ignore it for now.  Remove
resourceDirs, we don't use it.

Change-Id: I1862573d3ac02e539492c8ff95bacbab3588bfc4
2015-04-02 14:49:33 -07:00
Colin Cross
28d76590f1 Use ContainsProperty to support default values
Instead of setting a string property to magic default value and then
checking for it later, call ctx.ContainsProperty to determine if it
was set.  Use the same method on the clang bool property, which
couldn't be set to a magic value.

blueprint's ModuleContext.ContainsProperty only works on a single
property, not on all arch variant properties -
ModuleContext.ContainsProperty("clang") will return false if
clang was not set but arch.arm.clang was set - so track which
properties were extended inside extendProperties, and override
ModuleContext.ContainsProperty in AndroidModuleContext to also
check the extended properties.

Change-Id: I03cbe71dc69344972e23d6c794da9be05e720c45
2015-03-27 17:54:50 -07:00
Colin Cross
c940435029 Fix checkbuild files on last variant
The context checkbuild files were not copied to the module checkbuild
files before calling generateModuleTarget, which would cause them
to not be considered, and in the case of a module with a single
variant, cause a build failure when the checkbuild target was skipped.

Change-Id: I77faafdc1a8a866e3c2c1157f987015b553acf01
2015-03-27 15:58:25 -07:00
Colin Cross
f8209413f1 Support target: { android64: {...}} for linker
The linker and a few other executables and libraries need to know
if they are a 32-bit process running on a 64-bit host.  Add
android64 and android32 target types to set custom cflags.

Change-Id: I142378e2d5be17a87ff761257dacc1734b093048
2015-03-27 15:58:24 -07:00
Dan Albert
be96168ee3 Add support for building NDK modules.
Change-Id: I2c5ede530e40a635e26ae45950580ef450e7dcc6
2015-03-26 21:58:12 -07:00
Colin Cross
68f55102da Support dependencies on environment variables
Ninja can't depend on environment variables, so modifying build
behavior based on environment variables requires coordinating
between the soong script that invokes ninja and the soong_build
manifest generator.

Allow any module to call Config.Getenv to get the contents of an
environment variable while registering a dependency on it.
After all modules have been processed write out the state of
all used environment variables to a JSON file called
.soong.environment.  During the next build the soong script
will use the soong_env tool to compare the contents of
.soong.environment to the current environment, and force a
build manifest regeneration by deleting the .soong.environment
file if any variables have changed.

Change-Id: Id0d81933a857bc2fc1cd7a393a3c6cec73dc4824
2015-03-26 14:13:49 -07:00
Colin Cross
f6566ed2ba Add new AndroidModuleContext helper functions
Add Host(), Device(), and Debug() to AndroidModuleContext to allow
build rule generators to easily determine build options.

Change-Id: Ib93a462cb45189399063f641b3a8df175db0592e
2015-03-25 11:33:08 -07:00
Colin Cross
70b4059e3f Update import paths for changes to blueprint
Blueprint has been modified to include a canonical import path,
update soong to match.

Change-Id: If29d31afbf3bf2e6364961a66456fa5f8f738455
2015-03-23 12:57:34 -07:00
Colin Cross
5049f02e60 Add gensrcs module type
gensrcs allows sources to be generated by a specified command.

Change-Id: I725086fcdcd72bfe6c07fb8903e7b520678a247f
2015-03-19 10:51:41 -07:00
Colin Cross
c472d57f57 Refactor cc compiling to shared ccBase and ccDynamic initialization
Refactor common code out of NewCC* to initialize the ccBase,
ccDynamic, and ccLibrary structures.  Also adds an enum for the
default multilib values.

Change-Id: Iaeffe86bf2568b6054be4ddcee725818af45e14f
2015-03-17 15:11:14 -07:00
Colin Cross
e2e6fc2b37 Enable checkbuild by default
Temporarily enable checkbuild by default while we are adding lots
of modules to the build.

Change-Id: I26671d90b13fc2dcbb7a458a86e9be9cd070a918
2015-03-17 13:26:49 -07:00