Commit graph

41 commits

Author SHA1 Message Date
Colin Cross
402130276c Convert SetProvider to generic providers API
Convert all of the callers of SetProvider to use the type-safe
android.SetProvider API.

Bug: 316410648
Test: builds
Change-Id: If58f4b5355264ddab2045bc3591a4eac19cd58fc
2023-12-14 16:12:20 -08:00
Colin Cross
8ff105860d Remove ConvertWithBp2build implementations
Remove the ConvertWithBp2build implementations from all the module
types, along with the related code.

Bug: 315353489
Test: m blueprint_tests
Change-Id: I212672286686a318893bc7348ddd5a5ec51e77a7
2023-12-08 13:51:05 -08:00
Chris Parsons
637458d326 Have ConvertWBp2build use Bp2buildMutatorContext
This no-op refactoring facilitates some upcoming functional changes for
"bp2build allowlist v2". The work requires that the bp2build conversion
mutator be changed from a TopDown mutator to a BottomUp mutator.
Refactoring all bp2build-related methods so that they use Bp2buildMutatorContext
makes it easier to make this functional change without touching tens of
files and multiple projects.

Bug: 285631638
Test: m bp2build
Change-Id: I3d1ef3064146e959c6f0dc315350fc9764bf2bd2
2023-09-20 14:49:35 +00:00
Spandan Das
e12d252e22 Create a bp2build converter for ndk_prebuilt_*_stl
This module type will be converted to a cc_prebuilt_* bazel target. It
will provide
1. a prebuilt (.a/.so) file
2. headers (as -isystem)

Test: added a bp2build unit test
Bug: 298088835
Change-Id: Ib58cc7f6fde8f4ca34516f6f18a4c048a02a049a
2023-09-13 18:08:55 +00:00
Spandan Das
6e332d2266 Make ndk_prebuilt_*_stl's libDir relative to module
Currently, we have ~4 of these modules which are all defined in
prebuilts/ndk. However, using ctx.ModuleDir() instead has the following
advantages
- makes bp2build simpler since we do not need to relativize this path
- prevents soong modules from reaching into another directory (as the
  test setups were doing).

Test: m nothing
Change-Id: I780e2564cb37ebf4b800f0cd184789f3fc6f2fc8
2023-09-13 18:05:13 +00:00
Colin Cross
c85750bfe3 Use generics for DepSets
Use Go's generics for DepSets so they don't require a type-specific
wrapper and reflection.

Test: depsets_test.go
Change-Id: I22ba0b7d680d37d2cd05230b0f560d166c4dd20b
2023-06-22 08:18:33 -07:00
Dan Albert
e75af185a8 Remove dead code.
NDK CRT objects haven't been prebuilts for ages.

Bug: None
Test: treehugger
Change-Id: I923381da629b78487587e997018fa63dd818617f
2023-03-28 23:13:16 +00:00
Liz Kammer
ef6dfea679 Only store what's used in SharedLibraryInfo
There was a reference to the static library provider, but only the
transitive static deps were used, so only store that part. Other members
were stored but unused anywhere.

Test: go test soong tests
Test: m nothing
Change-Id: I12a6b94806c052c3f0df3cab0a10f17042af1c38
2021-06-08 16:44:23 -04:00
Colin Cross
2df8177575 Add Target to cc.SharedLibraryInfo
Dependencies from common arch modules like java libraires to cc modules
may need to retrieve the Target of the library, add it to
SharedLibraryInfo.

Bug: 176593487
Test: cc_test.go
Change-Id: I93ab9da5fab2ccc42c6b483a6d83c071b541d1e6
2021-01-26 11:02:53 -08:00
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
0de8a1e17b Start using Providers instead of direct module access
Export information about static libraries, shared libraries and
exported flags through Providers instead of accessing the module
directly.  Much more is left to be converted, but this significantly
simplifies the dependencies on libraries with stubs by making it easy
for a module to masquerade as another by simply exporting the
providers from the other module.  Instead of depending on all the
versions of a library and then picking which one to use later, it
can depend only on the implementation variant and then select the
right SharedLibraryInfo from the variant.

Test: m checkbuild
Test: only expected changes to build.ninja
Change-Id: I1fd9eb4d251cf96ed8398d586efc3e0817663c76
2020-10-12 16:55:47 -07:00
Jooyung Han
749dc69af1 apex/apk: enforce min_sdk_version of all deps
Enforce min_sdk_version for every payload dependency of updatable
APEX/APKs.

android.CheckMinSdkVersion() calls ApexModule.ShouldSupportSdkVersion
for every transitive dependency from APEX/APK modules to see if it
meets the min_sdk_version requirements.

The common implementation for apex/android_app is provided in
android/apex.go.

Bug: 145796956
Bug: 152655956
Bug: 153333044
Test: m nothing
Change-Id: I4a947dc94026df7cebd552b6e8ccdb4cc1f67170
2020-06-24 02:00:33 +09:00
Colin Cross
ff550f3e13 Merge "Revert^2 "Add sdk mutator for native modules"" 2020-04-08 18:29:30 +00: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
d66b121000 Merge "Revert "Add sdk mutator for native modules"" 2020-04-07 04:25:34 +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
f5d6756a35 Merge "Add sdk mutator for native modules" 2020-04-07 01:52:11 +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
Jiyong Park
e01e228270 Make ndk_prebuilt_* be available to any apex
The NDK prebuilts are implicitly used when building with sdk_version set.
Make the module types be available to any apex so that we don't need to
manually add apex_available property to the module definitions manually.

Bug: 150999716
Test: m

Change-Id: I0870afa4c74b4a06ab1273dff84615778561ecc9
2020-03-20 17:02:14 +09: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
Inseob Kim
6937844c29 Separate exported includes out of flags
Exported includes have been maintained along with other C/C++ flags.
This makes dependencies unclear, and users have had to parse flags to
get exported directories. This separates exported includes and
exported flags, thus making data more structured and explicit.

Bug: 132818174
Test: m
Change-Id: I5c25ac2224988c4a67e4db6fd6e4d39090b74041
2019-06-11 10:37:56 +09:00
Jaewoong Jung
710756a6ff android_app stl property bug fix
When it is set to c++_shared, the added dependency should be
libc++_shared, not libc++.

Fixes: 130891985
Test: app_test.go, atest 'CtsNdkBinderTestCases' w/ conversion CL
Change-Id: I0e50e0d5bf511aa6e52d16cd715a185721011255
2019-06-04 12:36:00 -07: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
Patrice Arruda
8c8563746c Soong: Add synopsis to ndk_prebuilt_* modules.
Added synopsis to the following modules under cc package:
   * ndk_prebuilt_object
   * ndk_prebuilt_static_stl
   * ndk_prebuilt_shared_stl

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

Change-Id: Icca7418268a0328b622014da8a077b26800075fd
2019-04-26 18:36:57 -07:00
Colin Cross
06080f4137 Fix double space in include argument
The double space is confusing compdb.go.  compdb.go should be fixed,
but the double space is unnecessary so remove it.

Also make -isystem consistently followed by a space.

Bug: 117124308
Test: m checkbuild
Change-Id: I5ce7530d2ef66be8d8285e252d60a39299984a06
2018-10-02 11:16:56 -07:00
Dan Albert
61f32128aa Dedup version-script handling code.
This is common to binaries and libraries, so move it from library.link
and binary.link to baseLinker.linkerFlags and baseLinker.linkerDeps.

Test: make checkbuild
Bug: None
Change-Id: I5fb24118e601673ae0713a6adc773a1565749be8
2018-08-08 14:36:34 -07:00
Ryan Prichard
b1703659a8 Use Soong modules for the NDK's extra STL libraries
* The extra STL libs are:

       libc++abi.a [needed for ndk_libc++_static]
       libandroid_support.a [always needed in NDK r16]
       libunwind.a [needed for ARM32]

 * The existing STL-dependency logic in linkShared only applies to shared
   libraries. By moving it to STL deps, the extra STL libs are linked into
   both shared libraries and executables.

 * Remove the ndk_prebuilt_library/ndkPrebuiltLibraryFactory module type,
   which is unused now.

 * Reuse the ndk_prebuilt_static_stl module type to describe the extra
   static libraries that are linked with both the static and shared libc++
   STLs.

Bug: b/73133405
Test: manual
Change-Id: I3f73e4f882d39e6efa470073bb4fc8c42dff8253
2018-03-29 21:26:06 +00:00
Dan Albert
749fc7885f Remove support for stlport.
Test: make checkbuild
Bug: None
Change-Id: I066574dd623ddd617f7cdbabbb16e01ece0b4cdc
2018-01-05 10:59:33 -08:00
Dan Albert
c9460bbff8 Remove support for gnustl.
Test: make checkbuild
Bug: None
Change-Id: Ifa457e9907e20bafa2885fbd6935d43b7f22aaaf
2018-01-05 10:59:33 -08:00
Dan Albert
8ba131b3e2 Expose the NDK STLs to make.
Without this any module exposed to make that uses an NDK STL will
have unsatisfied dependencies.

Test: make native
Bug: None
Change-Id: Ia456cdc230d5ebf5e1256ab131ab78248b790bc8
2017-12-15 14:51:30 -08: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
03cc1b6d97 Use -isystem to export ndk stl includes
Hides:
In file included from frameworks/rs/cpu_ref/rsCpuExecutable.cpp:4:
In file included from prebuilts/ndk/current/sources/cxx-stl/llvm-libc++/include/fstream:169:
In file included from prebuilts/ndk/current/sources/cxx-stl/llvm-libc++/include/ostream:138:
In file included from prebuilts/ndk/current/sources/cxx-stl/llvm-libc++/include/ios:216:
In file included from prebuilts/ndk/current/sources/cxx-stl/llvm-libc++/include/__locale:21:
prebuilts/ndk/current/sources/android/support/include/locale.h:97:9: error: 'LC_GLOBAL_LOCALE' macro redefined [-Werror,-Wmacro-redefined]
       ^
out-soong/ndk/sysroot/usr/include/locale.h:115:9: note: previous definition is here
       ^

Test: builds
Change-Id: I766e8645db33e6e71f44a131aa0b1649d83e8c51
2017-05-05 18:22:30 -07:00
Colin Cross
a48ab5b207 Build a static library for header-only libraries
library.static() was being used to determine if a library was static,
shared, or header only, which resulted in header only libraries
behaving like shared libraries, when they should be treated as static
libraries with no sources.  Explicitly use library.static(),
library.shared(), and library.header() instead.

Bug: 35228396
Test: builds, manually examine changes to build.ninja and Android.mk
Change-Id: I51729992cc6338deda1396b86f12bc9f73e674d8
2017-02-14 17:52:10 -08:00
Colin Cross
37047f1c7e Pass DepsContext to dependency methods
Pass a DepsContext that embeds android.BottomUpMutatorContext
instead of android.BaseContext so that dependency methods can
directly add dependencies.

Test: m -j
Change-Id: Id4c157975d3d6f03efd99785d217bef486a76139
2016-12-13 17:32:29 -08:00
Colin Cross
ab3b7323c4 Remove boolean arguments from NewLibrary()
NewLibrary is going to be used for header only libraries.  Instead
of adding more boolean arguments, replace the existing ones with
BuildOnlyStatic and BuildOnlyShared calls on the libraryDecorator
returned by NewLibrary.

Test: m -j, compare build.ninja
Change-Id: Id390b66cbf2a5f0932b32f40a5e18eb9e3852ee7
2016-12-13 14:50:51 -08:00
Dan Willemsen
5cb580f407 Start using "struct Objects" to store object Paths
So that we can represent other files that get generated along with the
objects, like the gcno coverage information, and per-file clang-tidy
runs.

Test: Soong's build.ninja identical before/after
Change-Id: I5c553a153c436d5403549f62c73fe79c5f101779
2016-10-31 16:18:49 -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
b916a38233 Refactor cc modules to use decorators instead of inheritance
For example , instead of trying to have libraryLinker inherit from
baseLinker and libraryCompiler inherit from baseCompiler, create a
single decorator object that wraps both baseLinker and baseCompiler.

Test: Builds, no unexpected changes to build.ninja
Change-Id: I2468adaea8466c203a240259ba5694b8b1df7a52
2016-08-05 10:25:09 -07:00
Colin Cross
42742b8bb0 Rename compiler, linker and installer methods to be unique
compiler, linker, and installer interfaces may be implemented by a
single decorator object, rename their methods to be unique to avoid the
same method being called multiple times.

Test: out/soong/build.ninja unchanged
Change-Id: I1608c41cd68f614ba99c11bb9fcc7936f618d9aa
2016-08-01 13:47:15 -07:00
Colin Cross
b98c8b0595 Move toolchain and global variables into separate package
Move all of the configuration into a cc/config package

Change-Id: If56fc7242062ed1ce3cb297f78a1e0ef7537373c
2016-08-01 13:37:01 -07:00
Colin Cross
4d9c2d17c3 Separate cc.go
Split cc.go into files per module type, plus files for the compiler,
linker, and installer stages.

Change-Id: Id44c03f42fcd180950ccd008d4de0c144ea3597b
2016-07-29 15:17:58 -07:00