Commit graph

52 commits

Author SHA1 Message Date
Colin Cross
7f9036c89b Allow java modules to use filegroups
Using filegroups requires calling ExtractSourcesDeps from the deps
mutator.

Test: m -j checkbuild
Change-Id: I7b6c6ce0075e4a703d28085a3965f11d9bb46315
2017-08-31 13:48:52 -07:00
Colin Cross
76b5f0ca31 Rename no_standard_libraries to no_standard_libs
For consistency with libs and static_libs.  And make it a *bool
so that it can be overriden when used in java_defaults modules.

Test: java_test.go
Change-Id: If0eaf5d5571dc6e565056d273b0addd960d6b33f
2017-08-31 13:48:52 -07:00
Colin Cross
227d436943 Add core-oj to bootclasspath
Also clear the bootclasspath for device builds so javac doesn't
fall back to the default rt.jar bootclasspath.

Test: java_test.go
Change-Id: Ia21f55c7d45db560e2f44be81b2f46587d9026f2
2017-08-31 13:48:52 -07:00
Colin Cross
595a406f88 Pass --min-sdk-version to dx
Pass the sdk_version property, the platform sdk version, or 10000
to dx as --min-sdk-version.

Test: m -j checkbuild
Change-Id: I5fae03f44153dc2d6244c33f4c055e746980aefe
2017-08-31 13:48:52 -07:00
Colin Cross
5c51792926 Make binaries executable
Split InstallFileName into InstallExecutable that does chmod +x
after copying the file.  Also remove InstallFile and rename
InstallFileName to InstallFile.

Test: m -j checkbuild
Change-Id: Id41ad4eafe521f6cd5d8cc250b7747ecb3da8dfc
2017-08-31 13:48:52 -07:00
Colin Cross
c6bbef326f Add error-prone support
Add support for compiling java sources with the error-prone tool.

Test: m -j checkbuild
Change-Id: Ieb4ee0e05f8f34a52ed7bcf1c7cbacf1c9c4d0b5
2017-08-28 11:12:38 -07:00
Colin Cross
10a0349d98 Install java_binary wrappers in make
Convert java_binary modules into two make modules, one for the
underlying java_library and one for the wrapper prebuilt.

Test: m -j checkbuild
Change-Id: I5ddf74f24f1e41fc1f39b3e8d254b7e191dbd47a
2017-08-11 22:22:48 -07:00
Colin Cross
6416271a1f Bring java support closer to current version of make
Make the javac arguments match what is used by make, and export them
back to make.  A future change will switch make to use the the
exported ones.

This makes a dx.jar compiled with soong have identical class files
as one compiled with make.

Test: manual
Change-Id: Ia5196f1f42bc564e99de22e32e72fd2930e9fbae
2017-08-11 15:24:11 -07:00
Colin Cross
74d73e2bfb Rename java_prebuilt_library to java_import
And make it work like bazel's java_import, using a "jars" property
instead of "srcs", and allowing multiple jars to be listed.

Test: soong tests
Change-Id: Ida2ace6412bd77b4feb423646000a1401004e0ea
2017-08-11 15:24:11 -07:00
Colin Cross
5ea9bcc50b Fix java prebuilts
The java prebuilt tests weren't registering the prebuilts mutators,
which hid an issue where prebuilts modules weren't getting renamed
to avoid collisions with source modules of the same name, which
ended up causing the prebuilt module to try to add a dependency
on itself.

Test: java_test.go
Change-Id: I3327d27533591cb08a4b8b8b5e1668a6f72be8df
2017-07-31 23:50:01 -07:00
Colin Cross
f506d87723 Rename names in java package to not have java prefix
Prefixing names in the java package with "java" is redundant, inside
the java package it is clear that they refer to something java
related, and outside the package they will be referred to with a
java. prefix.

Test: java_test.go
Change-Id: I9eb8eecb7ac5f6fbf8e87f5c219b3f50dbd18c87
2017-07-20 05:48:03 +00:00
Colin Cross
89536d4948 Add support for java_defaults modules
Test: java_test.go
Change-Id: I6dba1671c7eb019183af94bb7b10810296740101
2017-07-20 05:47:27 +00:00
Colin Cross
e8dc34a372 Rename java module and property names for consistency
prebuilt_java_library -> java_prebuilt_library
prebuilt_sdk -> android_prebuilt_sdk
java_resource_dirs -> resource_dirs
exclude_java_resource_dirs -> exclude_resource_dirs
java_libs -> libs
java_static_libs -> static_libs

Test: java_test.go
Change-Id: Icb0eefa6663844e20ad0a8729fb2c90ec916c3eb
2017-07-19 23:19:58 +00:00
Colin Cross
be1da475d0 Use dependency tags for java modules
Test: java_test.go
Change-Id: Id265a2acd6e6c4ce7764f77c888e22b1fddc02c4
2017-07-19 23:19:51 +00:00
Colin Cross
ec7a0424c3 Use android.Prebuilt for JavaPrebuilts
Test: java_test.go
Change-Id: Iabb75edbfee731578b5b9f547594613203cf9b79
2017-07-19 23:19:31 +00:00
Colin Cross
d48633a564 Use ExistentPathForSource
Converting java to use Path objects incorrectly used PathForModuleSrc
for a path that might not exist, use ExistentPathForSource instead.

Test: java_test.go
Change-Id: I50e4e315a10ab08c4e72065094ae29844874f5e4
2017-07-14 08:24:36 -07:00
Colin Cross
36242850fd Refactor factories
Change module factories from returning a blueprint.Module and a list
of property structs to returning an android.Module, which holds the
list of property structs.

Test: build.ninja identical except for Factory: comment lines
Change-Id: Ica1d823f009db812c518f271a386fbff39c9766f
2017-06-30 21:08:36 +00:00
Colin Cross
3e3e72da90 Add java config and share it with make
Add a java/config package to hold config information, and share
it with make through makevars.

Test: builds
Change-Id: I46c088bda0fe97a1823bfdd80fa692d0bf61da1b
2017-06-23 11:24:54 -07:00
Colin Cross
540eff8e5f Split java device properties into separate struct
Prevent host modules from having fields that only make sense for
device modules.

Test: builds
Change-Id: I20278e029a38fb9a6b75ef3c2cf3c1a97cef2b87
2017-06-23 10:57:36 -07:00
Colin Cross
46c9b8bfd5 Remove non-idiomatic inheritance
Remove inheritance implemented with the bad "superclass calls
subclass through interface" pattern, and replace it with composition.

Test: builds
Change-Id: If323f89360455b3f98b40777edaaaa265bb3b5fc
2017-06-23 10:57:36 -07:00
Colin Cross
ba211130bd Update obsolete references
Test: builds
Change-Id: Ic37628b78704a03200b6326485fb4667e1c5a665
2017-06-23 10:57:36 -07:00
Paul Duffin
2b67e3b9c1 Replace core-junit with legacy-test
Bug: 30188076
Test: unused code
Change-Id: If6c27dc61078afbb04218afac678165f63f41166
2016-11-30 16:13:09 +00:00
Colin Cross
1e676bef94 Control mutator order
Register mutators inside lambdas that are called in a defined order to
correctly order mutators before and after the arch and deps mutators.

Test: build.ninja identical
Change-Id: Iefe2a3515aee8570e76a6e76925db4cda0e9e822
2016-10-12 15:33:33 -07:00
Colin Cross
798bfce9d0 Move registration into android package
Mutator registration is tightly coupled with the android package, move
all registration from the soong package to the android package.

Test: build.ninja identical
Change-Id: Ie183d0b52cc7431c9e05b231934d189208ef1efe
2016-10-12 14:30:44 -07:00
Colin Cross
635c3b0157 Rename common to android
Rename the "common" package to "android", because common is too
generic.  Also removes all android.Android naming stutter.

Ran:
gomvpkg -from 'android/soong/common' -to 'android/soong/android'
gorename -from '"android/soong/android".AndroidModuleContext' -to 'ModuleContext'
gorename -from '"android/soong/android".AndroidBaseContext' -to 'BaseContext'
gorename -from '"android/soong/android".AndroidModuleBase' -to 'ModuleBase'
gorename -from '"android/soong/android".AndroidBottomUpMutatorContext' -to 'BottomUpMutatorContext'
gorename -from '"android/soong/android".AndroidTopDownMutatorContext' -to 'TopDownMutatorContext'
gorename -from '"android/soong/android".AndroidModule' -to 'Module'

Change-Id: I3b23590b8ce7c8a1ea1139411d84a53163288da7
2016-05-18 15:37:25 -07:00
Colin Cross
c99deeb961 Use blueprint DependencyTags
Blueprint now requres DependencyTags to be passed to AddDependency
calls.  Use the tags to avoid setting member variables on modules, which
will be lost after the mutators have been called.

Change-Id: I8c1d9ed1db85a300e14394b911a516d361ba9f75
2016-04-12 15:24:02 -07:00
Dan Willemsen
782a2d116a Refactor install paths
Explicitly allow installation into the data partition instead of using
"../data" for tests. At the same time, pipe through the information
required for vendor modules.

Change-Id: I6baf9d828c285e1080e43074beef8aebdbb38875
2015-12-21 15:03:15 -08:00
Dan Willemsen
34cc69e4bf Use Path instead of string for file paths
This centralizes verification and common operations, like converting the
path to a source file to the path for a built object.

It also embeds the configuration knowledge into the path, so that we can
remove "${SrcDir}/path" from the ninja file. When SrcDir is '.', that
leads to paths like './path' instead of just 'path' like make is doing,
causing differences in compiled binaries.

Change-Id: Ib4e8910a6e867ce1b7b420d927c04f1142a7589e
2015-12-09 14:29:12 -08:00
Colin Cross
6362e27848 Remove EarlyMutators and DynamicDependencies
EarlyMutators are identical to BottomUpMutators, except they run before
DynamicDependencies.  DynamicDependencies can be replaced with a
BottomUpMutator.  Replace both EarlyMutators and DynamicDependencies
with BottomUpMutators, which allows setting the order between all
mutators through registration order.

Change-Id: Id1305d798d3d2da592061c89d7c10a71780b71a3
2015-11-03 15:46:08 -08: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
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
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
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
74d1ec0c2c Build rule updates for aosp
Various build rule changes to match AOSP:
Add libunwind_llvm and libdl as dependencies for libc++ on device
Always add libcompiler_rt-extras as a dependency
Add libm, libc, and libdl as depnendencies for libc++ static binaries
Disable some clang warnings, and add some clang filtered cflags
Add -fstack-protector to host linux builds
Add jack_flags property to java modules (currently ignored)

Change-Id: Ic0da617bdeaf25f58cb8298dd9ea91b7d6509151
2015-05-04 17:02:18 -07:00
Colin Cross
0607cf7daa java: add genrule support to java builds
Add support for source files generated by genrule or gensrcs to
java builds.

Change-Id: I39762b2ab65fa4cf92724300edc4ba995845ce92
2015-04-29 14:59:07 -07:00
Colin Cross
b7a63247ed java: modify base java rules for android app builds
Store the jar output file for the app build to use.
Allow module types built on top of javaBase to provide filelist files
containing source files.
Allow module types built on top of javaBase to insert dependencies through
JavaDynamicDependencies.
Allow any java module to depend on framework-res.apk.
Move the install rule from javaBase to JavaLibrary.

Change-Id: I46e7e80139845ef7cc89daf180bddbdf77125555
2015-04-20 13:55:27 -07:00
Colin Cross
efb9ebe14f java: add default libraries for device builds
Add implicit libraries core-libart, core-junit, ext, and framework
to device java builds.

Change-Id: I8b4e1e54bfd4bc89fbcd211ab8da6bbcf092c523
2015-04-20 13:55:27 -07:00
Colin Cross
e7a9f3f7ed java: add one-off build logic for frameworks/base
framework.jar needs to compile against R.java and Manifest.java from
framework-res.apk.  Rather than complicating the Blueprints properties
with values that will only be used once, add one-off logic to
collectDeps to extract the rJarSpec out of the framework-res module.

Change-Id: I1195b1b5e07badc583703479382ceba35300b8fd
2015-04-20 13:55:27 -07:00
Colin Cross
276284f577 Rename resource_dirs to java_resource_dirs
Java vs. Android resource directories are already confusing enough,
rename resource_dirs to java_resource_dirs to make room for
android_resource_dirs.

Change-Id: Iffd087860b98df29e81d8d2f823be87c8227e614
2015-04-20 13:52:55 -07:00
Colin Cross
f03c82b8fa Optimize javacFlags and aidlFlags in ninja files
aidlFlags gets specified for every aidl file.  Use a module scoped
ninja variable to hold the aidl flags, and while we're at it do the
same for javacFlags.

Change-Id: I980f0006c41918154ab0479d56387630a7e1d677
2015-04-13 17:31:25 -07:00
Colin Cross
aa8630ba09 Move SDK prebuilts to new prebuilt_sdk module type
SDK prebuilts need to be treated differently than other prebuilts.
They are used like a normal Java prebuilts when compiling java files,
but they are also used as aapt includes when compiling apps, and they
provide prebuilt aidl files when compiling aidl sources.  Create a
new module type so dependers can determine what kind of dependency
they are.

Change-Id: If426da63cfadcb4b14abda58c7b346554912a07a
2015-04-13 17:31:25 -07:00
Colin Cross
f05fe97df6 Add logtags source file support
Add support for converting logtags files to source files.  Each
.logtags file is converted to a .java file, but only after all
.logtags files have been combined into a merged text file by
the logtagsSingleton.

Change-Id: I375d82874029bd26a7c528e46add2a638ba123f9
2015-04-13 12:25:40 -07:00
Colin Cross
6d1e72d7c6 Fix multi-dex builds
Building with --multi-dex requires passing an output directory
instead of an output file to dx.

Change-Id: I9ffcfe8ff6b96dbdda3eec1076124cd38ae5077f
2015-04-13 12:25:40 -07:00
Colin Cross
2097830df7 Extract classes out of jarjar jar for static java libraries
jarjar modifies the .class files in a jar, when using static java
library dependencies we need to use the modified class files and
not the ones that javac produced.  If jarjar is enabled, use
the prebuilt jar extractor to get the classes out of classes-jarjar.jar
and export them through j.classJarSpecs.

Change-Id: Ia2854f1c26d630da12cab7c421007aad4f793ecd
2015-04-10 17:49:44 -07:00
Colin Cross
8cf1334116 Miscellaneous fixes for java compiling
Remove java out directory before compiling to avoid incremental compile
issues.  Move the rspfile out of the out directory so it doesn't get
deleted.  cc->javac in the javac rule.  Don't call javac if there
are no source files.

Change-Id: I0bb06c214da54a587bd9e7c9d17caaf0ed1e595e
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
6cbb127564 Fix missing bootclasspath error in java compiles
If a java library only links against the same jar as bootclasspath,
the jar was being added to classpath and not bootclasspath, leaving
bootclasspath blank and using the default bootclasspath.  Reverse
the order so that bootclasspath takes effect.

Change-Id: Ib9fbf01897314a57228013d4aef52606390b0aca
2015-04-08 15:19:36 -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
65bf4f231c Add jarjar support
If jarjar_rules is set, pass the compiled jar through jarjar to
produce a new intermediate jar.

Change-Id: Ied596433fd5c49d05f07c04245f3abe8b9aadc5e
2015-04-08 15:15:15 -07:00