Commit Graph

364 Commits

Author SHA1 Message Date
Paul Duffin e63106a08c Merge "Add model to represent generated snapshot .bp file" 2019-12-03 10:07:10 +00:00
Treehugger Robot f6739a65dd Merge "Link type will be check in android_library also" 2019-12-03 03:41:21 +00:00
Paul Duffin b645ec8e34 Add model to represent generated snapshot .bp file
Having each module type generate the contents of the snapshot's .bp
file results in lots of duplicated code. This adds an intermediate
model for use by the module types and then generates the .bp file
contents from that.

This not only removes the duplicated formatting code but it also
allows consistent handling of shared properties such as name further
reducing duplication. It also makes it possible to duplicate the
versioned and unversioned prebuilt modules from the same model.

Extracts generatedContents from generatedFile to allow the contents
to be populated without creating an output file, for testing.

Cleans up unused code.

Bug: 143678475
Test: m nothing
Change-Id: If21b84db0ef3fdfb5dc11ea0973ce6cb73603ea3
2019-12-02 12:59:38 +00:00
Treehugger Robot 4a692427f7 Merge "Add exported_plugins to java.Library." 2019-11-27 00:52:46 +00:00
Artur Satayev 9cf4669bc4 Add exported_plugins to java.Library.
The behaviour is similar to go/be#java_library.exported_plugins. Plugins added to exported_plugins of library X are not applied to the library itself, but rather to libraries that directly depend on the library X.

Test: m checkbuild
Bug: 139740873
Change-Id: I4042bd482ad9cb12d6fbaac51f039d38b1b7a428
2019-11-26 19:05:26 +00:00
Paul Duffin 50e7900744 Dedup code for generating java_import in snapshot
Removes duplicated code for generating a versioned and non-versioned
form of the java_import module in the snapshot.

Bug: 143678475
Test: m nothing and check output for dummy sdk
Change-Id: Ia8d05c3bf9ef79953a817b168dd9d59f2af2d2ce
2019-11-26 16:19:36 +00:00
Paul Duffin 0e0cf1dca5 Refactor sdk update mechanism
Creates a SnapshotBuilder and GeneratedSnapshotFile interfaces to allow
the java library snapshot work to be moved into the java package.

Test: m -j60 checkbuild
Change-Id: I857167616026149d5e85885621b53876b419ba9b
2019-11-14 17:49:02 +00:00
Jooyung Han 18020eabc4 make ApexProperties defaultable
ApexPropreties are added in InitApexModule() and they are supposed to be
defaultable. To be defaultable, InitApexModule() should be called before
InitDefaultableModule().

Bug: 144332048
Test: m (soong test added)
Change-Id: I6c90ed3b66a086292a4c0ecb37c61f83769e62bd
2019-11-13 05:52:57 +00:00
Treehugger Robot 80df439072 Merge "Enforce hidden apis usage in product(soong)" 2019-11-11 02:05:16 +00:00
Treehugger Robot c70d3c3cf6 Merge "APEX now correctly tracks jni_lib dependencies" 2019-11-09 13:53:08 +00:00
Jiyong Park 8be103b04c APEX now correctly tracks jni_lib dependencies
Bug: 144135069
Test: m (apex_test.go amended)
Change-Id: If9dde4e2e62c2642267dbcac68bab76a032682c0
2019-11-08 15:53:48 +09:00
Colin Cross c228a7046f Silence dep-ann warnings
Silence the dep-ann warnings until there is an effort to do
something about them.

Test: m framework-minus-apex doesn't print dep-ann warnings.
Change-Id: Ic172e840dded4564fecfb91e96cba0c54358e20a
2019-11-07 00:19:54 +00:00
Jeongik Cha 2cc570dc63 Enforce hidden apis usage in product(soong)
Only if PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE is set,
every app and java library in product cannot use hidden APIs anymore.

checkSdkVersion() checks if sdk_version of app and library is narrow enough,
checkLinkType() checks every library that app links agianst

Bug: 132780927
Test: m
Test: set PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE, and check whether build
error occurs.
Change-Id: Ic630503b875040f730feda4fef826ed6d71da111
2019-11-06 19:42:42 +09:00
Jeongik Cha 75b83b0a81 Link type will be check in android_library also
For now, Soong checks link-type in java_library, so it cannot block hidden api usage from android_library that app links with.
So we should add check in 'android_library'

Test: m nothing
Change-Id: Ic040270ec668bdd693b690ac8a88be1048922c3b
2019-11-01 15:29:15 +09:00
Jiyong Park 0b2387551b stem property of java modules are propagated to Make
62c7829595c0df53e96addcd347c11ac01012eee introduced the new stem
property to java modules, but it wasn't propagated to Make. Fixing the
problem.

This change also fixes a problem that (module name) == (file name) is
assumed in dexpreopt_config.go, which no longer is the case. A mutator
runs to build a map from module name to its stem. The map is then used
when filling up the file paths in the bootImageConfig struct.

Bug: 139391334
Bug: 143494499
Test: m
Test: BootImageProfileTest
Change-Id: Idbc894f877692401471130de6cbfe5e0dd129da9
2019-10-31 22:13:05 +09:00
Colin Cross 6cef481ee7 Use java language 1.9 for sdk_version: "current"
Java language was set for 1.8 for anything building against the
current SDK because the stubs were not built in Soong, so the
system modules could not be built.  The stubs have been built
in Soong since Iabd32b30954b3f4a6d9a779fde52a032b684807e, but
I5e870c34dd0ebc8ae3f888ec627da590c846a76f missed updating
this TODO.

Use 1.9 when building against the stubs, but continue using
1.8 for unbundled builds until we have prebuilt system modules.

Always use the core-current-stubs-system-modules to avoid
splitting android.* packages between the system modules and
the classpath, which would cause new classes in android.*
packages in classpath jars to be ignored.  Add a new
java9Classpath field to sdkDep that will contain the stubs jar
when targeting Java language level 1.9, and plumb it through
to javac and turbine.  Rename the modules field to bootclasspath.

Bug: 142896162
Test: m checkbuild
Change-Id: Icfd32d0a863b2303a997c7cf03cb3708aade4724
2019-10-29 13:35:39 -07:00
Colin Cross 6d8d8c6a91 Remove special case for sdk_version: "none"
The dependency handling for sdk_version: "none" (which propagated to
!sdkDep.hasStandardLibs()) was very similar to the normal useModule
case.  Combine the cases by making decodeSdkDep set useModule: true
and put the system modules in modules for the sdk_version: "none"
case.

Test: TestClasspath
Change-Id: Icc9ff4d43a38da25cc0e3628be95951d61773ad5
2019-10-29 13:35:39 -07:00
Colin Cross 1e7438524b Make javaVersion an enum
Remove the hardcoded checks against "1.9" by making javaVersion
an enum and implementing javaVersion.usesJavaModules().

Test: TestClasspath
Change-Id: I559eeb1f45880bb8177269c6d977ee4dfbadce57
2019-10-28 14:55:03 -07:00
Pete Gillin ef99a4b06e Merge "Remove support for EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9." 2019-10-28 10:28:19 +00:00
Pete Gillin a1c9e9da55 Remove support for EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9.
Prior to this change, setting that to "false" turned the default Java
language level back to 8. This change removes that option.

Bug: 115604102
Test: m java droid docs tests cts
Change-Id: I97bfd0dc8d941008b4071c6efe1c0c24950c4f1f
2019-10-25 16:55:06 +01:00
Jiyong Park 4c4c02400f add stem property to java modules
java_library, java_import and dex_import now support stem property to
set the output file name.

Bug: 139391334
Test: m
Merged-In: I11146badf558e524a973806114b9cb1344db4a6e
(cherry picked from commit 62c7829595c0df53e96addcd347c11ac01012eee)
Change-Id: I11146badf558e524a973806114b9cb1344db4a6e
2019-10-25 10:40:56 +09:00
Treehugger Robot 8141c8781a Merge "Add tradefed_java_library_host" 2019-10-19 02:45:42 +00:00
Colin Cross f0f2e2cf79 Add tradefed_java_library_host
Add a module type for tradefed libraries that causes an additional
copy to be installed at out/host/linux-x86/tradefed.

Bug: 122332235
Bug: 141877526
Test: m tradefed
Change-Id: Ib7160dd060ad83d2dfb81d6a7106cb0dac98553e
2019-10-18 15:14:15 -07:00
Treehugger Robot c5bba642f1 Merge "Prohibit dependencies outside of uses_sdks" 2019-10-18 00:30:18 +00:00
Colin Cross ad4a597c79 Merge "Add method to determine variations from a Target" 2019-10-17 18:52:20 +00:00
Jiyong Park a7bc8ad0b9 Prohibit dependencies outside of uses_sdks
When an APEX is built with uses_sdks, any depedndency from the APEX to
the outside of the APEX should be from the SDKs that the APEX is built
against.

Bug: 138182343
Test: m

Change-Id: I1c2ffe8d28ccf648d928ea59652c2d0070bf10eb
2019-10-17 11:19:53 +09:00
Colin Cross 0f7d2ef3ac Add method to determine variations from a Target
The arch variants are hardcoded in every module type.  Refactor
them out into a Target.Variations() method in preparation for
splitting the arch mutator into two, which will require using
different variations.

Test: m checkbuild
Change-Id: I28ef7cd5168095ac888fe77f04e27f9ad81978c0
2019-10-16 14:52:30 -07:00
Treehugger Robot d90d208628 Merge "AIDEGen: Remove the duplicate *.srcjar from srcs" 2019-10-15 01:51:37 +00:00
patricktu 242faad111 AIDEGen: Remove the duplicate *.srcjar from srcs
AIDEGen collects the complied sources which are generated from build
system, the sources includes not only java/kt files but also srcjar
files. Since the srcjar files are record in srcjars parameter in json
file, we should keep only java or kt files in the srcs parameter.

The size diff of module_bp_java_deps.json:
Without this patch: 15,298,369 Bytes
With this patch: 15,044,804 Bytes

The build time diff:
Without this patch: 2m31.345
With this patch: 2m32.662

Bug: 141528361
Test: 1. m clean -j
      2. aidegen tradefed
      3. Open out/soong/module_bp_java_deps.json
      4. Find the module CtsSyncManagerCommon and check the
         sync_manager_cts.srcjar files doesn't exist in srcs but exists
         in srcjars section.

Change-Id: I43fc5c05b657473054e632cae4795220907dc711
2019-10-14 10:16:17 +08:00
Paul Duffin e25c644f1e Add system_modules to droidstubs
This allows droidstubs to use the same system modules to create the
stubs that will be used to compile them. It improves consistency and
avoids droidstubs having to duplicate the libraries that make up the
system modules on its libs property.

Adds systemModules() to the sdkContext which allows consistent error
checking behavior between droidstubs and java_library.

Bug: 142534789
Test: m checkbuild
Change-Id: Ib2006906d9528a900f16851f50b62152ffb51a1b
2019-10-11 16:38:14 +01:00
Colin Cross 70dda7e3da Separate InstallPath from OutputPath
Create a new type InstallPath that is similar to OutputPath to
differentiate intermediates output paths from installed output
paths.

RelPathString is a poorly defined, undocumented function that is
primarily used to get an install path relative to out/soong to
generate an equivalent install path for Make relative to $(OUT_DIR).
Move it to InstallPath for now, and fix the one remaining user on
OutputPath.

Add a method to create an NDK install path so that ndk_sysroot.go
doesn't have to do it manually with PathForOutput.

Bug: 141877526
Test: m checkbuild
Change-Id: I83c5a0bd1fd6c3dba8d3b6d20d039f64f353ddd5
2019-10-03 10:07:53 -07:00
Colin Cross 0a2f719bca Move sharding functions for reuse
Move shardPaths and shardTests to android.ShardPaths and
android.ShardStrings for reuse in other packages.

Test: m checkbuild
Change-Id: I868802872c73616b80f56cbf11f959c01a8b793a
2019-09-29 23:26:37 -07:00
Dan Shi 6ffaaa830d Allow test to specify whether or not to auto-generate test config
Attribute `auto_gen_config` is added to test modules.
Test config will be generated if:
the attribute is not set and AndroidTest.xml doesn't exists
or
the attribute is set to true, whether or not AndroidTest.xml exists.

Test config will NOT be auto-generated if:
the attribute is not set and AndroidTest.xml exists
or
the attribute is set to false, whether or not AndroidTest.xml exists.

Bug: 141684102
Test: build test module with auto_gen_config set to true
Change-Id: I64fb003a83d8c32a967835e5f8d12fe4476043be
2019-09-26 13:29:28 -07:00
Treehugger Robot ec3e81b4be Merge "Move sysprop gen code to sysprop module" 2019-09-23 22:25:40 +00:00
Paul Duffin 2b6f04ca42 Merge "Add custom SystemModules to bootclasspath to reduce duplication" 2019-09-23 10:31:40 +00:00
Inseob Kim 988f53cf5a Move sysprop gen code to sysprop module
sysprop_library now generates srcjar itself, effectively cutting the
implicit dependency from java module to sysprop module.

Bug: 131637873
Test: m {sysprop_library}-dump-api
Test: m (with no arguments) performs API check
Change-Id: Ia11a744e74b6f733ff0e30d194fbba22505ed644
2019-09-23 15:34:06 +09:00
Treehugger Robot b1102ba828 Merge "Introduce module type 'sdk'" 2019-09-23 04:38:24 +00:00
Jiyong Park d1063c1586 Introduce module type 'sdk'
This change introduces a new module type named 'sdk'. It is a logical
group of prebuilt modules that together provide a context (e.g. APIs)
in which Mainline modules (such as APEXes) are built.

A prebuilt module (e.g. java_import) can join an sdk by adding it to the
sdk module as shown below:

sdk {
    name: "mysdk#20",
    java_libs: ["myjavalib_mysdk_20"],
}

java_import {
    name: "myjavalib_mysdk_20",
    srcs: ["myjavalib-v20.jar"],
    sdk_member_name: "myjavalib",
}

sdk {
    name: "mysdk#21",
    java_libs: ["myjavalib_mysdk_21"],
}

java_import {
    name: "myjavalib_mysdk_21",
    srcs: ["myjavalib-v21.jar"],
    sdk_member_name: "myjavalib",
}

java_library {
    name: "myjavalib",
    srcs: ["**/*/*.java"],
}

An APEX can specify the SDK(s) that it wants to build with via the new
'uses_sdks' property.

apex {
    name: "myapex",
    java_libs: ["libX", "libY"],
    uses_sdks: ["mysdk#20"],
}

With this, libX, libY, and their transitive dependencies are all built
with the version 20 of myjavalib (the first java_import module) instead
of the other one (which is for version 21) and java_library having the
same name (which is for ToT).

Bug: 138182343
Test: m (sdk_test.go added)
Change-Id: I7e14c524a7d6a0d9f575fb20822080f39818c01e
2019-09-22 08:21:27 +09:00
Paul Duffin 68289b0efd Add custom SystemModules to bootclasspath to reduce duplication
Adds a library dependency to each of the dummy system modules created
by testing.go so that any changes in the behavior were detected by
the existing tests which were then fixed.

Bug: 141359858
Test: m checkbuild
Change-Id: Id4442f4aa3931ac93049f3367b96a5b49cc075e1
2019-09-20 14:52:56 +01:00
Colin Cross e323f3cca3 Fix robolectric tests with sdk_version and prebuilt dependencies
Add deviceProperties to robolectric tests so they can set
sdk_version.  Use Dependency.BaseModuleName() instead of
ctx.OtherModuleName() to get the dependency name to pass to Make
to support prebuilts in libs, which may have a "prebuilt_" prefix
in ctx.OtherModuleName().

Test: m RunLauncherRoboTests
Change-Id: I59a889bd6107b989f336b147d0eaccabef611894
2019-09-18 16:33:27 +00:00
Colin Cross 3b706fde7f Shard kythe invocations when javac is sharded
The kythe pipeline has trouble injesting all 6000 files of
framework.jar at once.  Shared invocations of the kythe extractor
when javac is sharded to produce multiple smaller kzip files.

Bug: 140426870
Test: no change to build.ninja
Test: m out/soong/.intermediates/frameworks/base/framework/android_common/framework0.kzip
Test: TestSharding in java_test.go
Change-Id: I867db4ef5cb1e7f3ce8359a46aac2c00ed8a8912
2019-09-05 16:49:11 -07:00
Treehugger Robot 7153b767a5 Merge changes from topic "drop_circular_dep"
* changes:
  Remove srcs_lib and srcs_lib_whitelist_pkgs
  Remove the automatic dependency to framework-res.apk for R/Manifest
  Prepare to be able to put framework-res in srcs
2019-08-30 13:47:31 +00:00
Pete Gillin 4e8b48a055 Normalize and validate the java_version property.
There are two parts to this change.

Normalization: If a module specifies 'java_version: "9"', this is now
normalized into 'java_version: "1.9"'. Users might reasonably assume
that "9" should be valid, since javac treats them as synonyms (and, in
fact, the javac documentation lists "9" as a valid value but doesn't
mention "1.9"). However, the soong code that triggers JPMS support
(i.e. setting -system rather than --boot-class-path) looks for the
string "1.9", so prior to this change modules specifying "9" would
fail with a confusing error ('javac: option --boot-class-path not
allowed with target 1.9'). Normalizing "9" to "1.9" fixes this. (The
change normalizes the other supported values, too, for consistency.)

Validation: This change also makes the build fail-fast with a clear
error message for invalid values. In particular, modules specifying
"10" or "11" fail with an explicit message that this is not supported,
in anticipation of the switch to OpenJDK 11. Prior to this change,
modules setting those values would get the confusing
'--boot-class-path not allowed' error described about since JPMS
support would not be triggered. (That could be fixed by changing the
JPMS logic to trigger on "10" and "11", but that would be dangerous
since support in the rest of the system for v54 and v55 class files is
unproven: it is better to fail explicitly.) (This change also makes it
fail-fast for any unrecognized values.)

Test: make java
Test: make targets with java_version set to "1.8", "8", "1.9", and "9", all succeed ("9" fails without this change)
Test: make targets with java_version set to "10" and "11", fail with the explicit "not supported" message
Test: make target with java_version set to "xxx", fails fast with the "unrecognized" message
Bug: 131683177
Change-Id: I2f5eb496c29d7736c68c01401c3f0967aeae99fc
2019-08-29 16:10:04 +01:00
Jiyong Park b5ddfa9219 Remove srcs_lib and srcs_lib_whitelist_pkgs
They are no longer used. Sources are provided via filegroup.

Also removing the SrcDependency interface as it is no longer used.

Bug: 135922046
Test: m
Merged-In: I81f9614d20fbdd2f7d18340d6dbdb592e7acde06
(cherry picked from commit fa21cba64a)
Change-Id: I81f9614d20fbdd2f7d18340d6dbdb592e7acde06
2019-08-29 13:58:40 +09:00
Jiyong Park 289206594c Remove the automatic dependency to framework-res.apk for R/Manifest
framework-minus-apex and framework-annotation-proc had automatic
dependency to framework-res.apk to get the generated R.java and
Manifest.java as their inputs.

That is no longer needed as the sources are fed from framework-srcs
filegroup.

Bug: 70046217
Test: m

Merged-In: Ibb03db01c177d6e908cbbdf91f18be8744f02c03
(cherry picked from commit 8cc55bdffe)
Change-Id: Ibb03db01c177d6e908cbbdf91f18be8744f02c03
2019-08-29 13:58:18 +09:00
Inseob Kim 4288274f14 Implement sysprop_library API stability check
sysprop_library now checks the API stability itself, cutting dependency
on java_sdk_library. Under the directory {module_dir}/api,
{module_name}-current.txt and {module_name}-latest.txt hold API
signatures.

When sysprop_library is built, or a user run "m {module_name}-check-api"
command, API check is performed. First, current.txt must have exactly
same signature with built sysprop_library module. Second, current.txt
must be compatible with latest.txt.

Build system emits a handy error message to generate/update those API
files, in case of missing or mismatching. Also, a script file for
freezing API files is introduced.

Bug: 131637873
Test: 1) m && boot blueline
Test: 2) m {sysprop_library} performs API check
Test: 3) manual test for check-api, freezing api
Change-Id: I9d25f5dc64299e666527ca8e23d7233966901c4e
Merged-In: I9d25f5dc64299e666527ca8e23d7233966901c4e
Merged-In: Ib7ad4f17e82c90da5ef3f80e2ab88c0b53112c60
(cherry picked from commit 093f0eb133)
2019-08-23 06:28:34 +00:00
Jeongik Cha 356dac4a17 Elaborate comment on paltform_apis
Bug: 132780927
Test: None
Change-Id: If0a4f97ea8f0af0c962fd963daad01adb3e5412f
2019-08-19 14:12:02 +09:00
Colin Cross 2d975b197e Add an output file tag for proguard dictionaries
Allow modules to depend on the proguard dictionary of another module
using module{.proguard_map}.

Bug: 122332855
Test: m checkbuild
Change-Id: I918b487872c1a8ef8a51c0b994277efb0512d157
2019-08-06 09:45:04 -07:00
Jeongik Cha 8a64f8c907 Merge "Add a rule about platform_apis" 2019-07-31 01:09:35 +00:00
Treehugger Robot 247de68b89 Merge "Support source code cross-referencing for C++ and Java" 2019-07-30 00:13:12 +00:00