Commit graph

87 commits

Author SHA1 Message Date
Colin Cross
94e347e6a5 Don't create SDK variants for native bridge modules
Native bridge modules never need to build against NDK stubs, so
don't create SDK variants.  Also clear the sdk_version property
for modules that don't have SDK variants so that later code doesn't
use it to trigger SDK behaviors.

Test: m checkbuild
Change-Id: I1920fa82e9fab06235f01a62624382efa16cc6e3
2021-01-19 15:00:45 -08:00
Colin Cross
95f1ca07ce Store ndkKnownLibs in the config
Storing ndkKnownLibs prevents multiple tests from running in parallel
as one may be writing to the list while another is reading from it.
Store it in the config so each test has its own copy.

Test: go test -race ./apex
Change-Id: Iba57c9494012c9e0ae9e5ffaa63b9b2bd2c77492
2020-11-17 10:50:19 -08:00
Colin Cross
31076b3185 Move stubs related methods out of LinkableInterface
The stubs methods are very specific to cc for now, move them out
of LinkableInterface so they are not shared with rust.  Instead,
create a cc.Module.library field that contains the libraryInterface
to simplify calling libraryInterface methods on cc modules.

Test: all Soong tests
Test: no change to Soong outputs
Change-Id: I0289d866ce1f7a765631fe3101a62b1b4988ba1c
2020-10-29 14:17:54 -07:00
Colin Cross
0477b42276 Add llndk_stubs property
Prepare for making the relationship between an llndk_library stubs
module and the cc_library implementation module explicit by
adding an llndk_stubs property.  Each cc_library will be updated
to point to its llndk_library, and the llndk_library name will
be changed to make the .llndk suffix explicit.  Then the implicit
connection and suffix can be removed.

Bug: 170784825
Test: m checkbuild
Change-Id: I6b0482a3f286ec29b2e928551aa4317749f2b499
2020-10-21 10:55:33 -07:00
Colin Cross
3572cf74f9 Move LLNDK and NDK versionSelectorMutator special cases into versionedInterface
Implement stubsVersions on *llndkStubDecorator and *stubDecorator to
handle the special cases in versionSelectorMutator.

Test: m checkbuild
Change-Id: Idc985c52f91450df42c0275b2b2acef3f2ed8868
2020-10-12 16:55:49 -07:00
Colin Cross
bbc941b0d0 use version mutator for CRT
Move the CRT objects into the version mutator and retire the
ndk_api mutator.

Test: no change to build.ninja or Android-${TARGET_PRODUCT}.mk
Change-Id: Ibbbde323e3e0e8e4702dda4f3828a49786280118
2020-10-12 16:55:49 -07:00
Colin Cross
5ec407b594 Use version mutator for NDK
The ndk_api mutator is similar to the version mutator.  Move the
ndk_library ndk_api variations into the version mutator instead,
which will help later when consolidating the stubs handling
between NDK, LLDNK and Apex libraries.

Test: No change to build.ninja or Android-${TARGET_PRODUCT}.mk
Change-Id: I51417cf669265762c15f7289e1dc186d017ef4a9
2020-10-12 16:55:49 -07:00
Dan Albert
0b176c8038 Replace FutureApiLevel with an ApiLevel.
Keeping the int constant around for now as FutureApiLevelInt because
it's still useful in places that haven't adopted ApiLevel yet for
testing if their non-ApiLevel API level is current or not.

Test: treehugger
Bug: http://b/154667674
Change-Id: I47a7012703f41fdeb56f91edf9c83afa93042deb
2020-09-22 15:04:48 -07:00
Dan Albert
1a2462717e Replace stringly-typed API levels.
Handling of API levels within Soong is currently fairly difficult
since it isn't always clear based on context what kind of API level a
given string represents, how much canonicalizing and error checking
the code receiving the string are expected to do, or how those errors
should be treated.

The API level struct does not export its raw data, so as to keep its
"constructor" private to the android package, and to prevent misuse of
the `number` field, which is only an implementation detail for preview
API levels. API levels can be parsed with either
`android.ApiLevelFromUser`, which returns any errors to the caller, or
`android.ApiLevelOrPanic`, which is used in the case where the input
is trusted and any errors in parsing should panic. Even within the
`android` package, these APIs should be preferred over direct
construction.

For cases where there are context specific parsing requirements, such
as handling the "minimum" alias in the cc module,
`nativeApiLevelFromUser` and `nativeApiLevelOrPanic` should be used
instead.

Test: treehugger
Bug: http://b/154667674
Change-Id: Id52921fda32cb437fb1775ac2183299dedc0cf20
2020-09-18 12:41:28 -07:00
Thiébaud Weksteen
d458745f15 cc: export Stripper struct
The cc stripping logic can be reused for Rust. Export the Stripper
structure for that purpose. Extract the strip-related flags from
builderFlags into StripFlags. Add the method flagsToStripFlags
(similarly to flagsToBuilderFlags).

Add the helper method disableStripping on libraryDecorator.

Test: m
Bug: 153430439
Change-Id: I11aef1abb8d498a4c1672500a7398279edf7f548
2020-08-27 10:13:42 +02:00
Dan Albert
92fe740677 Stop using prebuilt NDK CRT objects.
We don't need the prebuilt versions. The NDK CRT objects are (now)
built from the platform sources and the only difference is that the
NDK CRT objects also include an ELF note that identifies the NDK
version, which isn't helpful for anything built by the platform.

Add a `crt` property to cc_object that allows CRT objects to identify
themselves. CRT objects, unlike other modules, will have a variant
built per-API level they support, rather than just an SDK variant and
a platform variant. This is needed because new CRT objects will rely
on APIs not available in old libcs and old CRT objects will not
support all the features of a modern one.

Test: treehugger
Bug: http://b/159925977
Change-Id: I6595485fa1bfe0ad4945193d344b863f64eec654
2020-08-11 15:06:55 -07:00
Treehugger Robot
c92a48ffa7 Merge "Update language to comply with Android's inclusive language guidance" 2020-07-29 01:12:36 +00:00
Dan Albert
f740ed01ff Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Bug: 161896447
Test: None
Change-Id: I05f296357c7993088190ef45e49fb8e3a02559d6
2020-07-27 13:21:10 -07:00
Dan Albert
06f58afd81 Get NDK python script tests running.
Imports weren't working in tests because the package had been created.
The Python "binaries" built by Soong don't seem to take their own
pkg_path into account, so I split the separate pieces of code here out
into their own packages.

Note that the ndk_api_coverage_parser tests do not actually pass
before or after this change (seems like it might be a
non-deterministic ordering issue in the attributes of the generated
output?), but they can at least be run now.

Test: pytest ndkstubgen
Test: pytest symbolfile
Test: pytest ndk_api_coverage_parser
Test: out/host/linux-x86/nativetest64/test_ndkstubgen/test_ndkstubgen
Test: out/host/linux-x86/nativetest64/test_symbolfile/test_symbolfile
Test: out/host/linux-x86/nativetest64/test_ndk_api_coverage_parser/test_ndk_api_coverage_parser
Bug: None
Change-Id: I2ac22f7ced7566e4808070f2f72fd04355846e0b
2020-07-16 13:23:29 -07:00
Dan Albert
de5aade0e8 Generate the known NDK libraries list.
This doesn't need to be manually maintained. It briefly did need to be
during the transition from the old prebuilts, but that's long gone.

Test: treehugger
Bug: http://b/113547923
Change-Id: If05633f3cf622ab39e560a3dfcc88f3eb50406bf
2020-06-30 12:32:51 -07:00
sophiez
148b317ab8 Fix build breakage b/158783867
Add missing dependency for file 'api_levels.json' in rule
'parseNdkApiRule'
Forest test build link: http://shortn/_iCbktdkPsT

Test: m ndk

Change-Id: I9bcd3f8d261e40b6033ec82c4a50971ccb8b45b1
2020-06-12 20:19:50 +00:00
sophiez
58cabb7af6 NDK Api Coverage
Enable ndk_library processing for api code coverage. All parsed generated xml files will be dist and later upload to artifacts.

Test: m ndk

Change-Id: I76ac52f60d5bbb106308658cf7417b845af9a49e
2020-06-11 18:18:40 +00:00
sophiez
b858c6d497 Add ndk api parser for ndk api coverage.
Test: m test_ndk_api_coverage_parser

Change-Id: I7be4f505757b1ca915de5e378952f8b104e1d362
2020-06-09 14:33:20 -07:00
Jooyung Han
aed150d6ed Apex: support codenames for min_sdk_version
Apex can use codenames like "Q", "R" for its min_sdk_version property.
Also, cc_library can use codenames for its stubs.versions.

Bug: 152655956
Test: m
Merged-In: I077ad7b2ac5d90b4c8708921e43846206f05ba70
Change-Id: I077ad7b2ac5d90b4c8708921e43846206f05ba70
(cherry picked from commit 29e91d2121)
2020-04-09 16:04:17 +09:00
Colin Cross
c511bc50dc Revert^2 "Add sdk mutator for native modules"
f8e80229fe

Change-Id: Ic30ab6b844684bfc3e8ece5a1913980d5fbf8de2
2020-04-07 16:50:32 +00:00
Colin Cross
f8e80229fe Revert "Add sdk mutator for native modules"
Revert submission 1242911-sdk_version_variant

Reason for revert: b/153394225
Reverted Changes:
Ife99745fb:Use libnativewindow for platform variant of libagq...
I1bae84c43:Use libnativewindow for platform variant of androi...
I6e6021ed3:Use stl to depend on libc++
Ife99745fb:Use libnativewindow for platform variant of libRSS...
I2c9f439b9:Fix static dependency on libprotobuf-cpp-lite-ndk
Iff2aff9cf:Set sdk_version for cc_genrules used by modules wi...
I7d72934aa:Add sdk mutator for native modules
Ief378a007:Use sdk variant of Soong modules when LOCAL_SDK_VE...

Bug: 149591340
Change-Id: I798fa902c779469c6382b6699351e5d12bf14785
Fixes: 153394225
2020-04-07 04:21:21 +00:00
Colin Cross
82e192c3ae Add sdk mutator for native modules
Compiling native modules against the NDK disables platform features
like ASAN.  For anything shipped on the system image there is no
reason to compile against the NDK.  Add a new mutator to Soong that
creates a platform and an SDK variant for modules that set
sdk_version, and ignore sdk_version for the platform variant.  The
SDK variant will be used for embedding in APKs that may be installed
on older platforms.  Apexes use their own variants that enforce
backwards compatibility.

Test: sdk_test.go
Test: TestJNIPackaging
Bug: 149591340
Change-Id: I7d72934aaee2e1326cc0ba5f29f51f14feec4521
2020-04-01 16:09:05 -07:00
Elliott Hughes
da3a071eaa Remove unused mips workarounds.
This was never really finished, and hasn't been supported for years.

Test: treehugger
Change-Id: I21d4c3112aa8cf0c56e59f0cc19ff8725ef714b9
2020-03-06 18:15:44 -08:00
Nick Desaulniers
eb20744361 Revert "Revert "soong: upgrade Android platform to clang-r370808""
This reverts commit 862eb4648a.

Re-upgrades the compiler to clang-r370808, after first dealing with
regressions in ndk_translate and execute only pages.

Bug: 139945549
Bug: 145807809
Bug: 145827049
Bug: 145825270
Test: atest \
  CtsSelinuxTargetSdk27TestCases:android.security.SELinuxTargetSdkTest#testNoExecuteOnly
Test: m ndk_translation_host_unit_tests && \
  ./out/host/linux-x86/nativetest/ndk_translation_host_unit_tests/ndk_translation_host_unit_tests
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Change-Id: I714b582faffa8c92384818a7b12338d621968548
2019-12-13 13:13:06 -08:00
Treehugger Robot
cf96a82fbd Merge "Expose some factories for aidl_test.go" 2019-12-13 05:51:38 +00:00
Nick Desaulniers
862eb4648a Revert "soong: upgrade Android platform to clang-r370808"
This reverts commit 4f49e35902.

Causes test failures in ndk_translate.
Bug: 145807809
Bug: 145827049
Test: N/A
Change-Id: I8f42a15fec44475b74b1926c70bc98e03fe66f52
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-12-09 19:16:08 +00:00
Jooyung Han
b90e491e2b Expose some factories for aidl_test.go
Because aidl_interface depends on some ndk modules, their factories are
exposed so that aidl_test.go can use them.

Bug: n/a
Test: m
Change-Id: I98d282cc77310d5896a7abaf3936456a14d56ccf
2019-12-09 18:21:48 +09:00
Nick Desaulniers
4f49e35902 soong: upgrade Android platform to clang-r370808
-Wc99-designators warns for the use of nested and array initializers in
C++20 code. Many internal projects have pushed back against this
warning.

Disables:
- -Wimplicit-int-float-conversion
- -Wpointer-compare
- -Wxor-used-as-pow
- -Wfinal-dtor-non-final-class
- -Wreorder-init-list

For projects under external/, vendor/, etc, but only if they use
Android.bp (not Android.mk) and -Wreorder-init-list may be re-enabled by
-Wall if set locally.

-Wno-incomplete-setjmp-declaration is needed for NDK stubs that get
generated (functions without full definitions of their parameters).

Sets
- -Wno-error=implicit-int-float-conversion
- -Wno-error=reorder-init-list
for all projects in order to unblock landing the compiler upgrade due to
internal projects not being able to disable or fix these before the
upgrade.

Bug: 139945549
Test: build (aosp_crosshatch, crosshatch, aosp_x86_64-eng,
  walleye), boot internal devices, bionic + RS atests, kernel builds.
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Change-Id: I18e3c0eb657fd59824526f36c6dd57bdcf0526ba
2019-11-26 10:09:15 -08:00
Jiyong Park
48d75efa6f symbols in stub library isn't affected by -fvisibility=hidden
Fixing the bug that -fvisibility=hidden in a cc_library is used even
when compiling stub.c file where the symbols shouldn't be hidden.

Bug: 144781653
Test: add folowing to libEGL and build
+    stubs: {
+        symbol_file: "libEGL.map.txt",
+        versions: ["29"],
+    },

Change-Id: Iab70f36a4fb98737fc35827dbc9e1ca1a99d4354
2019-11-21 15:11:49 +09:00
Colin Cross
4af21ed26f Split local and global cflags
Native compiler flags are currently applied in approximately:
global cflags
local cflags
local include dirs
global include dirs
global conlyflags
local conlyflags
global cppflags
local cppflags

This means that a flag that is enabled in the global cppflags
cannot be disabled in the local cflags, and an Android.bp author
must know to disable it in the local cppflags.  A better order
would be:
global cflags
global conlyflags
global cppflags
local cflags
local conlyflags
local cppflags
local include dirs
global include dirs

We are mixing both the global and local cflags into a single
variable, and similar for conlyflags and cppflags, which
prevents reordering them.  This CL prepares to reorder them
by splitting the global and local cflags into separate variables.

Bug: 143713277
Test: m native
Change-Id: Ic55a8c3516c331dc5f2af9d00e59ceca9d3e6c15
2019-11-07 15:27:58 -08:00
Slava Shklyaev
aef0d6e7ff Add neuralnetworks to ndkPrebuiltSharedLibs
Bug: 138207382
Test: make
Change-Id: Id0b334011446546963a2f1258d8a3b6999e4f96f
2019-07-26 08:57:54 +00:00
Dan Willemsen
939408aa22 Add dependency to version script when linking stub libraries
This isn't an effective issue with local builds currently, since the
version script is generated from the same rule as the sources used to
compile the objects that are also used in the link command. But if we
ever separated those paths or adopted restat, we could miss this
dependency.

This is also required for my RBE build to actually expose this file to
the link step.

Test: treehugger
Change-Id: I32bbb18cf7edddc88759d4f445d081868f3e9b44
2019-06-10 18:02:25 -07:00
Colin Cross
0ea8ba82fc Consolidate baseContext, BaseContext, and BaseModuleContext
blueprint.BaseModuleContext is the set of methods available to all
module-specific calls (GenerateBuildActions or mutators).  The
android package split the same functionality across baseContext (nee
androidBaseContext), BaseModuleContext, and BaseContext.
Consolidate all of them into android.BaseModuleContext.

Test: m checkbuild
Change-Id: I2d7f5c56fd4424032cb93edff6dc730ff33e4f1e
2019-06-06 20:01:31 -07:00
Treehugger Robot
95aabdad9c Merge "Add aaudio, amidi, camera2ndk and nativewindow NDK libraries." 2019-05-13 18:30:33 +00:00
dimitry
03dc3f63f6 Enable native bridge support by default for certain ndk modules
The ndk_library, ndk_prebuilt_object and ndk_prebuilt_static_stl
modules are natural targets to have native bridge support enabled,
since they build user facing object which have to be supported for
translated architectures.

Bug: http://b/77159578
Test: make
Change-Id: Ic556f4c1c41e5b3dc92f9c290b4482dee8faed33
2019-05-09 16:37:16 +02:00
Sasha Smundak
b500ce53e2 Add aaudio, amidi, camera2ndk and nativewindow NDK libraries.
Various CTS tests refer to them.
Test: treehugger
Change-Id: I455063b02ec872c430edb1c619d38323d7ffd488
2019-05-07 19:29:53 -07:00
Patrice Arruda
6ea42118f2 Soong: Add synopsis to ndk_* modules.
Added synopsis to the following modules under cc package:
    * ndk_headers
    * ndk_library
    * versioned_ndk_headers
    * preprocessed_ndk_headers

Bug: b/128337482
Test: Generated the documentation and verified that the synopsis was
added to each of the module.

Change-Id: I2146919528cf039ed9327b3358de5b1bdb28275a
2019-04-09 18:50:44 -07:00
Pirama Arumuga Nainar
65c95ff1fb Include libprofile-extras to all coverage variants
Bug: http://b/128524141

Include libprofile-extras (defined in system/extras/toolchain-extras) to
all modules that need a coverage variant.  Also add
'-uinit_profile_extras' when linking with coverage.  This causes the
setup code in libprofile-extras to be linked into binaries/libraries
with coverage enabled.

We add the static library to the non-coverage variants as well but is a
no-op for them (since the '-u...' flag is not added for them).

Adding this dependency creates several circular dependencies since
coverage variants were being created for other module types that never
had any compilation or linking done during the build.  This change stops
creating coverage variants for toolchain_library, cc_prebuilt_library_*,
cc_library_headers module types (by adding a function to the linker
interface to specify whether native coverage is enabled).

Test: m NATIVE_COVERAGE=true COVERAGE_PATHS=*
Test: blueline_coverage target in internal branch (using forrest)
Change-Id: I5db876eb953639a55ba007248dd24e497f987730
2019-03-29 08:56:42 -07:00
Dan Willemsen
62b9cf952c Update NDK library list
Apparently this isn't autogenerated based on the list of ndk_library
modules?

Fixes: 124019854
Test: try to use libsync from a cc_library with sdk_version: "current"
Change-Id: I5016e1b7d77ed9255bf4b185c168efe8d0b73d12
2019-02-06 18:41:27 -08:00
Jiyong Park
3fd0baf651 When a stub is built for APEX, it is generated with --apex
Now, symbols that are only to be visible to across APEXes can be tagged
as # vndk. Then when generating the stubs library, the tagged symbol
is included. The symbol is NOT included in other cases; build NDK stubs,
etc.

Bug: 120638081
Test: m (apex_test updated.)
Change-Id: Idb2b552badddfc26af113cc8d4b984788f478813
2018-12-16 02:13:14 +09:00
Dan Albert
23d37e09e9 Allow NDK APIs to be marked as drafts.
Draft APIs are available to the platform and to CTS to allow
developers to iterate on an API, but hidden from the NDK artifacts to
avoid releasing the API until it is ready.

Test: Mark binder_ndk headers and library as drafts, make checkbuild,
      build-ndk-prebuilts.sh, verify missing from NDK artifact.
Bug: http://b/120091134
Change-Id: I8685e92bdaaea581e17fe98e7a2bfb9388f9f132
2018-11-28 09:52:12 -08:00
Colin Cross
e40b4eaeb0 Export cc module types and mutators needed for JNI testing
JNI testing will need to create basic native shared library
modules, export the minimum mutators and module types for
the required dependencies of a native shared library.

Bug: 80095087
Test: cc_test.go
Change-Id: Ibe7bc88b69cb0851291cb09a4c0c6cdb421b8651
2018-10-08 15:20:56 -07:00
Steven Moreland
fa287846ea Add libbinder_ndk to the NDK.
Bug: 111445392
Test: atest android.binder.cts.NdkBinderTest
Change-Id: If7e25f6e856524c531c41dacf3e7f798f42cc7a5
2018-08-29 21:45:51 -07:00
Ryan Prichard
37ebbdee6c Revert part of "Stop versioning NDK stubs pre-M."
This reverts commit e67144e302.

Keep the getApiLevelsMap function and keep using it in
shouldUseVersionScript. It seems useful. (Also, keeping it probably avoids
an AOSP->internal merge conflict...)

Bug: https://github.com/android-ndk/ndk/issues/750
Test: m out/soong/ndk.timestamp, examine dynsym in stubs
Change-Id: Icbb26fc46a9a1dc99f22af195468f08713c4f216
2018-07-24 12:46:35 -07:00
Dan Albert
e67144e302 Stop versioning NDK stubs pre-M.
Test: make ndk # readelf various stubs to check version info
Bug: https://github.com/android-ndk/ndk/issues/622
Merged-In: Ic2930cfe5ee8377bb89bfb1bc051b6975f6e57d3
Change-Id: Ic2930cfe5ee8377bb89bfb1bc051b6975f6e57d3
2018-07-17 23:26:00 +00:00
Pirama Arumuga Nainar
70ba5a38d1 Add compile-time pathDeps as implicit dependencies
Bug: http://b/70820751
Bug: http://b/70857959

Clang does not output file dependencies from the -fprofile-use= flag
during -MD/-MM.  Add this and other path dependencies as implicit Ninja
dependencies.  Generated header dependencies are retained as OrderOnly
dependencies.

Test: Perturb profdata files for hwui/skia in internal branch and verify
that the sources get rebuilt.

Change-Id: I3247d995ee27a4882172eb15ff36acf56536b6f7
2017-12-19 15:44:38 -08:00
Colin Cross
6510f91a1c Replace ModuleContext.AConfig() with Config()
AConfig() now duplicates Config().  Replace the uses of AConfig()
with Config().  Leave AConfig() for now until code in other
projects is cleaned up.

Test: m checkbuild
Change-Id: Ic88be643049d21dba45dbd1a65588ed94bf43bdc
2017-11-30 00:44:18 +00:00
Colin Cross
0875c52de7 Wrap PackageContext and SingletonContext
Wrap blueprint.PackageContext so that the *Func methods can provide
an android.Config instead of an interface{}.  The modified signatures
means that every method in ModuleContext and SingletonContext
that takes a blueprint.PackageContext now needs to be wrapped to
take an android.PackageContext.

SingletonContext wasn't previously wrapped at all, but as long
as it is, wrap everything like ModuleContext does.  This requires
updating every Singleton to use the android-specific methods.

Test: builds, all Soong tests pass
Change-Id: I4f22085ebca7def6c5cde49e8210b59d994ba625
2017-11-29 05:04:30 +00:00
Chih-Hung Hsieh
64a38dcb18 Add default -Wall -Werror or -Wall.
* When -Wno-error and -Werror are not used:
  add -Wall to the front of cflags
  if the project is in the WarningAllowedProjects,
  otherwise add -Wall -Werror.
* Add -Wall -Werror to ndk_library build targets.
* Collect names of modules with -Wno-error or without -Werror,
  and pass them to makefile variables:
      SOONG_MODULES_USING_WNO_ERROR
      SOONG_MODULES_ADDED_WERROR
      SOONG_MODULES_ADDED_WALL
* Generate ANDROID_WARNING_ALLOWED_PROJECTS for old makefiles.

Bug: 66996870
Test: normal build
Change-Id: I31385e12b80ca946c7395a5a184ef259b029aac6
2017-11-20 18:28:26 -08:00
Colin Cross
f18e11074d Fix using aidl files from filegroups
Compute sources including from filegroup and genrule dependencies
before determining if any sources will cause flags to be added.

Test: gen_test.go
Change-Id: I0434b003bbda07a58bb2ce1a0a72997918c8fae2
2017-11-17 11:22:08 -08:00