Commit Graph

218 Commits

Author SHA1 Message Date
shinwang 9e4c07a92f In java/java.go, enhance the checking logic for Dependency interface implementation
Add nil checking for Dependency interface implementation

Bug: 121985695

Test: 1. m aidegen
      2. $ANDROID_HOST_OUT/bin/aidegen framework
      3. check import static android.Manifest.permission.BIND_VOICE_INTERACTION;
	 denpendency should be resolved in frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java

Change-Id: Ibac280ce3de2537f453c4ca7e8f79f55667f1fa0
2018-12-25 03:36:37 +00:00
Colin Cross 1f367bfe8b Add a flag to allow unbundled builds to build SDKs from source
Mainline modules are tightly coupled to the platform, and should
build against the current SDK from source and not prebuilts. Add
a flag UNBUNDLED_BUILD_SDKS_FROM_SOURCE to specify that a
TARGET_BUILD_APPS build should build the current SDK instead of
using the prebuilts.

Bug: 121194841
Bug: 121231426
Test: no change to out/build-aosp_sailfish.ninja
Test: forrest unbundled build
Test: forrest master apps build
Test: forrest mainline modules build
Change-Id: I45a40a335483dae2fe192721df9b31bdbab97ee5
2018-12-18 22:46:24 -08:00
Colin Cross 43f08db29e Dexpreopt soong modules inside soong
Port the dexpreopt logic from Make to the dexpreopt package in Soong,
and use it to dexpreopt Soong modules.  The same package is also
compiled into the dexpreopt_gen binary to generate dexpreopt scripts
for Make modules.

This relands Ib67e2febf9ed921f06e8a86b9ec945c80dff35eb and
I462182638bd57b1367b5bfb0718e975c11ae66f7, along with multiple fixes
to depsfile generation in dexpreopt_gen that caused .odex files for
modules in defined make to be missing dependencies on boot.art, and
a fix to not dexpreopt and strip tests.

Bug: 119412419
Bug: 120273280
Test: no differences to dexpreopt outputs on aosp_sailfish system/,
      only expected changes to dexpreopt outputs on system_other
      (.vdex files for privileged Soong modules no longer incorrectly
      contain .dex contents).
Test: OUT_DIR=$PWD/out m
Test: NINJA_ARGS="-t deps out/target/product/sailfish/obj/APPS/Contacts_intermediates/dexpreopt.zip" m
Change-Id: I6bb2c971cee65d2338839753aa0d84939f335b1b
2018-12-15 19:07:54 -08:00
Colin Cross 4ff85ebeb7 Revert "Dexpreopt soong modules inside soong"
This reverts commit 29ff88741e.

Test: none
Bug: 119412419
2018-12-14 11:49:58 -08:00
Colin Cross 29ff88741e Dexpreopt soong modules inside soong
Port the dexpreopt logic from Make to the dexpreopt package in Soong,
and use it to dexpreopt Soong modules.  The same package is also
compiled into the dexpreopt_gen binary to generate dexpreopt scripts
for Make modules.

Bug: 119412419
Bug: 120273280
Test: no differences to dexpreopt outputs on aosp_sailfish system/,
      only expected changes to dexpreopt outputs on system_other
      (.vdex files for privileged Soong modules no longer incorrectly
      contain .dex contents).
Change-Id: Ib67e2febf9ed921f06e8a86b9ec945c80dff35eb
2018-12-13 15:53:54 +00:00
Zoran Jovanovic 8736ce29e8 Enable kotlinc flags in blueprint files
Add support for adding kotlinc files in the module.

Some flags are unnecessary as they are added by
default (-no-jdk and -no-stdlib), or are not needed
on an Android build (-include-runtime), or may
conflict with the build (-kotlin-home and
-Xintellij-plugin-root), so the error stops the
build if they are added.

Test: part of java/java_test.go
Change-Id: If3b2777062daaa490a20c014e9b1bb4b1cb0a8df
Signed-off-by: Zoran Jovanovic <zoran.jovanovic@sony.com>
2018-11-14 15:02:46 +00:00
Jiyong Park 8fd6192480 APEX can be flattened
When TARGET_FLATTEN_APEX is set to true, APEXes are flattened, which
means files in an APEX is not packaged into the mini file system image,
but instead directly copied to the system partition.

This option is for devices where kernel does not support loopback
devices or the maximum number of loopback devices is too small (though
the threshold is TBD as of now).

This CL also fixes a bug that jars having bytecode are installed instead
of those having dex.

Bug: 118485880
Test: TARGET_FLATTEN_APEX=true m apex.test; tree
out/target/product/.../system/apex/apex.test shows list of files in it.

Test; m apex.test, then a file out/target/product/.../system/apex/apex
.test.apex exists.

Change-Id: I5a3d62d392d05f2779c4925388afe4f6e460059b
2018-11-14 13:41:54 +09:00
Dan Willemsen 419290aba9 Support setting target_sdk_version separately from sdk_version
Before this change, if targetSdkVersion wasn't set in the
AndroidManifest.xml, we'd set it to the sdk_version from the Android.bp.

But there are cases where you want to compile against a later SDK, but
target an earlier one (especially if you depend on libraries that need
to be compiled against more recent SDKs, like androidx).

Test: build APK with different target_sdk_version.
Change-Id: Iaed36b522955a374a049ef331158cc8fc5798ad2
2018-10-31 21:37:34 -07:00
Neil Fuller 401eeba29f Remove sdk_version: "core_platform_current"
This (effectively) reverts commit 3c979c3348.

core_platform_current is the new default when no_framework_libs: true
so doesn't need to be specified anywhere.

Bug: 113148576
Test: build
Change-Id: I6bb6c1a0ea24437c8253dc5d8fabd37edabc9d3e
2018-10-26 09:11:22 +00:00
Colin Cross 5a0dcd5acf Store dex files uncompressed and unstripped in privileged APKs
Privileged APKs need to store their dex files uncompressed so they
can be verified and mapped directly out of the APK.

Also track whether the module will be dexpreopted or not in order
to determine if the dex file should be stripped before signing.

Test: SystemUI.apk contains an uncompressed dex file
Change-Id: I4dca86c7f8778595882405b34adcf2a7bae03c67
2018-10-25 17:47:12 +00:00
Jiyong Park 46f78fb4c6 Don't check the link type from stubs libs.
getLinkType also tells whether the module in question is a stubs lib or
not. If it is a stubs lib, link type from it isn't checked beause
dependency from the stubs lib doesn't matter; the stubs lib is
build-time only artifact.

In addition, core-lambda-stubs is added to the list of stubs libs.

Bug: 117964170
Test: m with https://android-review.googlesource.com/c/platform/libcore/+/793518/4
Change-Id: Ibd63484a1cc48dfd0afed6e6de098b7a38db5e61
2018-10-22 09:29:32 +09:00
Colin Cross 4b964c00a6 Fix instrumentation_for to match LOCAL_INSTRUMENTATION_FOR
The value from instrumentation_for should not go to
aapt2 link --rename-instrumentation-target-package, that should
be the equivalent of LOCAL_MANIFEST_INSTRUMENTATION_FOR.  That
property is never used in Make, so it is left unimplemented in
Soong.

Add the module listed in instrumentation_for as a shared library
for javac, but don't import its resources.

Bug: 117804211
Test: m checkbuild
Change-Id: I7f035dc0ecb964a3ca391ae1ca2b87cb0f6a7cec
2018-10-18 23:54:38 +00:00
Colin Cross 094054ab07 Support main_class property in java_binary modules
Add a main_class property that will be used to generate a manifest
containing a Main-Class entry.

Test: m checkbuild
Change-Id: I0a59bb2b93cad915afd82fba708fa0f7eda2fe7a
2018-10-18 14:55:07 -07:00
patricktu bb640e0240 aidegen: Fix bug of generating module dependency information
Bug: 117588037
Test: cd $android_root;make aidegen;aidegen -m tradefed
Change-Id: I05712ef3243771605034e4e9a746b8e1081c3516
2018-10-11 18:33:16 +08:00
Colin Cross bd01e2abee Add support for android_app_certificate modules
Some android_app modules need certificates located outside their
directory.  Instead of requiring paths from the root of the tree,
add an android_app_certificate module that exports the certificate
files.

Test: m checkbuild
Change-Id: Icbf3898894f3eb857e2d907e3e58dd072c6fabe9
2018-10-08 15:25:54 -07:00
Colin Cross a4f08813a3 Add support for JNI libraries to android_app modules
Make android_app modules a MultiTargets module, which means the
common variant will have a list of Targets that it needs to handle.
Collect JNI libraries for each Target, and package them into or
alongside the APK.

Bug: 80095087
Test: app_test.go
Change-Id: Iabd3921e1d4c4b4cfcc7e131a0b0d9ab83b0ebbb
2018-10-08 15:20:56 -07:00
Colin Cross 48de9a4ef5 Make more java modules defaultable
Make java_import, android_library and android_library_import modules
defaultable, and add some missing property structs to java_defaults.
Also use InitJavaModule everywhere.

Test: m checkbuild
Change-Id: I981875bbec5d1f87bae73f36a385e0b77c56c368
2018-10-03 14:31:10 -07:00
Jiyong Park 4584a8ac8e sdk_version <= 28 implies Java 1.8
When sdk_version is equal to or less than 28, java_version is implied to
1.8 unless it is explicitly specified. It was 26 originally, and is now
updated to 28 which is the most recent API version.

Bug: 117069453
Test: EXPERIMENTAL_USE_OPENJDK9=true make apex_aidl_interface
Change-Id: I18ebe3ec51ada54103f6d203b9bfae8ec6ea5d90
2018-10-03 18:05:04 +09:00
Colin Cross 05518bc13b soong_zip: Add tests
Add test that cover basic command line usage of soong_zip.  -D
is not covered yet as the implementation will be replaced with
one that is also more easily testable in the next patch.

Bug: 116751500
Test: zip_test.go
Change-Id: I5a1bcee74ebc9cb3cf332c36f89bc12c0e807ad2
2018-09-28 13:56:06 -07:00
Jack He 3333889da5 TradeFed: Add "test_config_template" flag in Android.bp
* Allow module owner to specify a test_config_template in Android.bp
* The rule goes:
  1. When "test_config" is set, Soong uses specified test config
  2. If 1 is not true, check if "AndroidTest.xml" exist in the
     directory, if so, use "AndroidTest.xml
  3. If 1 and 2 are not true, check if "test_config_template" is set.
     If so, use module specific template to generate test config
  4. Otherwise, use Soong default template for test config for autogen

Bug: 113359343
Test: make
Change-Id: I9fb4b2b266be9e0c7cf23da4a51e1c8ae67cd857
2018-09-26 18:02:55 -07:00
Tobias Thierer dda713d6fc Allow patch_module attribute in target: { android: { ... } } block.
patch_module is currently only used for non-host targets, although
there's a slim chance that there might be use cases on host in
future.

Currently, the only use case is patch_module: "java.base" in
device targets. To avoid erroneously carrying the patch_module
attribute over into the host version of the target, this CL
lets them place it into the target: { android: { ... } } block.

Test: Treehugger
Test: EXPERIMENTAL_USE_OPENJDK9=true make android-icu4j-tests
Bug: 115604102

Change-Id: If025d503d9c5681748a502a1d7433e8dbec3cac1
2018-09-19 16:31:30 +01:00
Brandon Lee 5d45c6f6f8 Collect modules' info to create IDE project file.
- Register a singleton and implement GenerateBuildActions func in java/jdeps.go.
- Declare a interface and a struct to collect info in android/module.go.
- Implement IDEInfo for Library & Import module in java/jdeps.go.
- Implement IDEInfo for Genrule module in genrule/genrule.go.
- Implement IDEInfo for fileGroup module in android/filegroup.go.
- Test codes for jdeps.go in java/jdeps_test.go.

Bug: 111044346

Test: export SOONG_COLLECT_JAVA_DEPS=1;mmm packages/apps/Settings
      out/soong/module_bp_java_deps.json will be generated

Change-Id: If61da77b4d7614c2c5da438b6af4c725ceccc5c3
2018-09-18 17:44:10 +00:00
Colin Cross cedd4768f5 Allow exclude_java_resources to affect java_resource_dirs
Allow excluding files from directory globbed by java_resource_dirs.

Test: java_test.go
Change-Id: I9922842248be1a386ab111a5187608438638ffb1
2018-09-13 18:28:03 +00:00
Neil Fuller 3c979c3348 Add a new sdk_version "core_platform_current"
Add a new sdk_version "core_platform_current"
value to java_library.

This adds the ability to compile system code against the
core platform API stubs. These stubs will contain the public SDK
API _and_ a selection of extra methods just intended
for use by system code (e.g. framework .jar) and
which must be preserved if "core" is modularized to
retain source and binary compatibility. Methods
outside of the core platform API must not be relied upon.

Future changes will adding methods to the core platform API and
switch targets over to use the stubs.

As soon as feasible, (hopefully) the default for when
unspecified will be changed to be the same as specifying
core_platform_current and build rules will have to explicitly
specify when they want to compile against the core library
implementation directly.

Bug: 113148576
Test: mmm libcore/mmodules/core_platform_api_client_demo
Change-Id: I72a03f28a4c38b4232e513a088c2d4e962c98868
2018-09-12 07:29:26 +00:00
Tobias Thierer 06dd04f20e Enable Java 9 language support through java_version: "1.9" alone.
Some logic in java.go was conditional on TargetOpenJDK9(), which in
turn relies on a global build flag (EXPERIMENTAL_USE_OPENJDK9=true).
This CL changes the logic in collectBuilderFlags() to check for
javaVersion greater or equal "1.9" instead, which is true when either
EXPERIMENTAL_USE_OPENJDK9=true (global) or javaVersion "1.9" (a
per-build target attribute).

Because the value of flags.javaVersion isn't available there,
TargetOpenJDK9()-dependent logic in Module.deps() was changed to
be unconditional; as far as I understand, this means that system
modules deps will be built regardless of whether they're needed
later in the build. This will probably slow down the build
unnecessarily until the first user of these system modules appears
(expected soon), but probably not by much.

There is some TargetOpenJDK9() related logic remaining in droiddoc.go,
but this doesn't seem to break the build of Java 9 language sources
and is probably no longer needed now that metalava is used for
generating the stubs (thanks to Nan!), and those do not contain any
Java 9 language features.

Bug: 112443425
Test: Checked that Java 9 language support works on AOSP after
      this CL without a need for EXPERIMENTAL_USE_OPENJDK9=true,
      ie. after also patching CL http://r.android.com/646840 ,
      "make docs droid cts" completes, the device boots and
      Java9LanguageFeaturesTest passes.

Change-Id: I393b97a7b3bb4c1c3d06580c639e94ff6cf916ff
2018-09-11 19:54:28 +01:00
Mathew Inwood ebe29ce4c6 Adapt special case framework support.
I'm adding a annotation processor to the framework target that does not
run as part of the main build, but only for a parallel build target
framework-annotation-proc, which is identical to framework except that it
also runs an annotation processor. Update build rules to be aware of this
target so that it builds successfully.

Test: m framework-annotation-proc
Bug: 113853502

Change-Id: I8b20758dc8bd0e8cb2542414d7a45a2cd7d2e158
2018-09-04 14:57:44 +01:00
Colin Cross 42d48b7b8b Enforce dependencies have right architecture
ctx.AddDependency will succeed if the named dependency only has a
single variant, even if that variant is the wrong architecture.
Use ctx.AddVariationDependency(nil, ...) instead, which requires
that all variations of the calling module match the dependency.

Bug: 112707915
Test: no change to out/soong/build.ninja
Test: using a device dependency in a host java module is an error
Change-Id: I70b661a57d4412eb63b8c9841febfb756e9e025d
2018-08-30 16:31:02 +00:00
Nan Zhang 4c819fb590 Add jetifier support in Soong.
This is a blocker for droiddoc targets migration under vendor/.

Test: N/A
Bug: b/72552006
Change-Id: If85a0917c1ac0d88b9d5b488216a638b4dabd39f
2018-08-29 11:37:32 -07:00
Colin Cross 9b38aef182 Revert "Add support for renamed kotlin stdlib."
This reverts commit 66c0c4067f.

Bug: 112674805
Test: m checkbuild
Change-Id: I687888136b570f080b57af352af0130355acd216
2018-08-29 05:41:25 +00:00
Colin Cross 55f63eadbd Put kotlin classes in header jar
If a module has kotlin sources the compiled kotlin clsases must be put
in the header jar for anything that depends on the module to use.

Bug: 113153312
Test: m checkbuild
Change-Id: Ibc44e9a97655937315b03b05e51e09c2954d7008
2018-08-27 13:19:49 -07:00
Nan Zhang 863f05b797 Removed Metalava related checks
Test: m -j checkbuild
Bug: b/70351683 b/78245848
Change-Id: Ie26e95081d8d90b626cfb43d017cb2ae500b7b25
Merged-In: Ie26e95081d8d90b626cfb43d017cb2ae500b7b25
2018-08-17 09:17:49 -07:00
Colin Cross 331a1213b0 Don't pass resources to r8
R8 complains when it gets dex files in the input jar, but some tests
use dex files or dex jars as resources.  Keep resources separate
from classes until after r8 has been run.

Test: java_test.go
Test: m checkbuild
Change-Id: I1d9164d60d6b054ebb138648da07d80ee769177f
2018-08-16 17:03:56 -07:00
Colin Cross 8144008360 Support patch_module in java modules
A few tests that have classes in the java.base module need to pass
--patch-module=java.base=<classpath> to javac.

Test: m checkbuild
Change-Id: I246bad92dcde976969b064aace5e2856e2bac971
2018-08-16 16:14:09 -07:00
Colin Cross 3063b78ea5 Make :module provide the output file for java modules
Make :module on a java_library provide the output file, which is
normally the implementation jar.  For java_library modules with
installable: true or compile_dex: true this will be the dexjar
instead.  For android_app modules this will be the apk.

Bug: 80144045
Test: no change to out/soong/build.ninja
Change-Id: I739674aee60a38bfccb859369e4414b46f293d82
2018-08-16 16:13:58 -07:00
Colin Cross b628ea5327 Don't link java tests against junit by default
There is more variety of java tests than I expected, don't
default to including junit, that's just going to lead to
unexpected junit classes for module authors that don't know
to set junit: false.  All existing uses of java_test are
already not using junit or setting static_libs: ["junit"],
and all test in Make are already specifying junit.

Bug: 70770641
Test: m checkbuild
Change-Id: I4393b70d87dd2b6e3bb719fdb758915053bee0c7
2018-08-15 11:08:59 -07:00
Colin Cross d96ca35779 Support data properties in java_test and android_test
Files in the data property will be passed to
LOCAL_COMPATIBILITY_SUPPORT_FILES in Make.

Test: m checkbuild
Change-Id: Ifc074317f957aba8f55daa30abc5b9737d1eceac
2018-08-14 15:44:39 -07:00
Colin Cross 303e21f695 Move autogenerated test config into Soong
Move autogenerating the test config for Soong modules into Soong
for java_test and android_test modules.

Bug: 70770641
Test: m checkbuild
Test: atest CtsUiRenderingTestCases
Change-Id: I02593add0407ef694b91c14cf27411a4f3cc4745
2018-08-14 15:44:08 -07:00
Nan Zhang 4973ecff89 Enable prebuilt jar installation in framework
Test: m -j dokka
Bug: 72394196
Change-Id: Ide09dc2fe64ea5db0d771e16d4b9293638b5d65c
2018-08-10 13:42:12 -07:00
Julien Desprez e146e39fa6 Support 'test_config' into soong modules
Test: make general-tests
Bug: 110982517
Change-Id: Ib2eab2653fdfce6f699b85c9fbc64558b6d40363
2018-08-07 15:51:21 -07:00
Steven Moreland 667f688f36 Build Java aidl w/ '-b'.
As it turns out, AIDL originally passed and returned success
when it was asked to compile an unstructured parcelable even
though no output files were created.

The build system currently can't handle this because it is
expecting outputs here, so I am adding this argument here
which will cause the compiler to exit and error earlier as
expected.

Notice also that the make implementation of the AIDL build
system also passes in this argument.

Test: m framework (which invokes this many times)
Bug: N/A
Change-Id: Ia9b5280dc3593756784035a523399545c9947d80
2018-07-26 12:55:08 -07:00
Nan Zhang ec93cd9f2a Add private-stub-annotations.jar as core-java lib
Since currently android.jar compile against to it.

Test: m -j metalava_android_stubs_current
Bug: b/78245848
Change-Id: Id5812f69125085821182295e577849b5f2c4bead
2018-07-24 11:16:56 -07:00
Dan Willemsen 59339a29e1 Fix `go vet` issues
Test: go vet ./...
Change-Id: Ifb936ccc5e2b5a2c3fcbbbcb54f680e2973ea1b3
2018-07-22 21:18:45 -07:00
Sundong Ahn 241cd3747c Change classpath for droiddoc
When the module type is SdkLibraryDependency, the classpath has been
gotten from headerJar
Becuase droiddoc uses src files when it builds, we should change to use
ImplementationJars instead of headerJar.

Bug: 77577799
Test: make -j

Change-Id: I1a072be69d7edff5636ea80af700be7796c3b0fc
2018-07-17 23:52:49 +00:00
Olivier Gaillard 0a4cfbc21a Add a Generate_get_transaction_name flag.
Add a flag to be able to generate the Binder#getTransactionName method

Test: manual
Bug: 111200705

Change-Id: I3e8106261df5c63cdc005d07c9d8efcc6732db70
2018-07-17 09:00:45 +00:00
Colin Cross 29788aad61 Fix .kotlin_builtins glob
The files in kotlin jars seem to be called .kotlin_builtins, not
.kotlin_builtin.

Test: m checkbuild
Change-Id: I541aea758bbef6bb23632836cceb8339b82ffdff
2018-07-16 15:24:43 -07:00
Colin Cross 4c03f68763 Make merge_zips -stripFile use blueprint style globs
merge_zips -stripFile was only considering the name of the file and
ignoring the path.  Make it more useful by supporting blueprint style
globs.  The previous behavior can be recreated by prefixing with **/.

Bug: 111389216
Test: m checkbuild
Change-Id: I25760fe3f1f77704dd9da9d107d9a38a415d681f
2018-07-16 15:24:43 -07:00
Colin Cross 37f6d79c7e Add exclude_files and exclude_dirs properties to java_import
Prebuilt jars sometime contain files that we don't want.  In Make
we would delete everything in META-INF when importing jars, but
that caused problems when there were necessary files in there,
so we added LOCAL_DONT_DELETE_JAR_META_INF.

Soong does the opposite, keeping everything by default.  Add
properties to allow explicitly stripping unwanted files instead.

Bug: 111389216
Test: m checkbuild
Change-Id: I6d07f519ebc7d0e1bf0af93416bb569e3c2b1500
2018-07-12 16:59:59 -07:00
Colin Cross 9ae1b927d4 Don't install java libraries by default
Very few java libraries need to be installed, most are statically
included in other modules.  Device modules that are not installed
also don't need to be dexed, saving checkbuild time.  Change the
default for java_library to not be installed, and allow libraries
that should be installed to specify installed: true.  This makes
java_libary and java_library_static identical.  It also simplifies
some corner cases when converting from Make to Soong if a module
is built for the host (which doesn't differentiate between static
and non-static/installable) and statically for the device, which
couldn't be represented in a single java_library in soong.

Bug: 110885583
Test: m checkbuild, compare presubmit target files
Change-Id: Idc0841c39a17cebd7bac3559c9408596d167a393
2018-07-11 05:35:59 +00:00
Colin Cross 83bb3167f6 Add support for min_sdk_version
Add min_sdk_version properties and use it for aapt2
--min-sdk-version and --target-sdk-version flags.  Add an sdkContext
interface that any function that needs an sdk version can take in
order to get the values for the current module.

Bug: 110848854
Test: m checkbuild
Change-Id: Ic69f1f935d8b865ec77689350407df08bfac5925
2018-07-09 12:42:01 -07:00
David Brazdil 17ef5635fa Add option to compile dex for a Java library
Currently Soong will only compile a Java library into dex if the
library has device support and is installable. For our use case of
inspecting the dex at build time this is not sufficient. Add a new
"compile_dex" device property which forces the creation of a dex
rule. In this case, the class jar remains the output file of the
module.

Bug: 79409988
Test: on related CL
Change-Id: Ia908a47148a03a0bdb0da4315cce6efc86c51865
2018-07-09 16:04:41 +00:00