Commit graph

43 commits

Author SHA1 Message Date
Spandan Das
319711b0bc Create a bp2build converter for ndk_headers
And add this module type to alwaysConvertList

Test: go test ./bp2build
Bug: 300504837
Change-Id: Ic09738ab47e7c497287b73de0f952d52aa78dd17
2023-09-20 23:04:02 +00:00
Aleksei Vetrov
262ed1a347 NDK library: collect NDK headers for ABI monitoring
Collect all NDK exported headers paths into a file that is used to
detect public types that should be ABI monitored.

Assume that we have the following code in exported header:

typedef struct Context Context;
typedef struct Output {
    ...
} Output;
void DoSomething(Context* ctx, Output* output);

If none of public headers exported to end-users contain definition of
"struct Context", then "struct Context" layout and members shouldn't be
monitored. However we use DWARF information from a real library, which
may have access to the definition of "string Context" from
implementation headers, and it will leak to ABI.

STG tool doesn't access source and header files, only DWARF information
from compiled library. And the DWARF contains file name where a type is
defined. So we need a rule to build a list of paths to public headers,
so STG can distinguish private types from public and do not monitor
private types that are not accessible to library users.

Bug: 156513478
Test: development/tools/ndk/update_ndk_abi.sh with enabled canDumpAbi
Change-Id: I9fa41e73450a41379638debb3dc56f421e0fb870
Signed-off-by: Aleksei Vetrov <vvvvvv@google.com>
2023-09-13 15:39:58 +00:00
Spandan Das
230c312f83 Deprecate api bp2build of ndk_library and ndk_headers
To support export of NDK APIs in multi-tree, we added functionality to
generate Bazel targets of ndk related Soong module types. Since this use
case does not exist anymore, deprecate this to prevent bitrot

The removed code includes
- `ConvertWithApi2Build` implementation of these libraries, which
  generates the Bazel targets in the synthetic `api_bp2build` workspace
- (api) bp2build unit tests for these module types

Test: go build ./cc
Bug: 284029211
Change-Id: Id3278fa119e0ab87f31f39a3783197a81b655e43
2023-05-31 03:44:51 +00:00
Spandan Das
8b4a5f352e Move API providing modules from bp2build to api_bp2build workspace
The module types in scope are
1. ndk_library
2. ndk_headers, versioned_ndk_headers
3. api_domain

These modules will no longer generate Bazel targets in bp2build
workspace. A new soong mode `api_bp2build` will be used to generate API
specific targets in a separate Bazel workspace at out/soong/api_bp2build

Test: go test ./bp2build

Change-Id: I01d06b6d8b8364c0d56d6d3f07f8f8bf21db31d7
2022-10-04 17:33:32 +00:00
Spandan Das
81593891ee Create api_domain module type and its bp2build converter
This module does not have any build actions in Soong yet. It will be
converted to a Bazel target using bp2build, and API export will be run
on the generated Bazel target

Test: go test ./bp2build
Test: TH
Change-Id: I76df32bd9f23b60e746b2700af07668a2ed74844
2022-09-21 19:49:46 +00:00
Spandan Das
0773a60302 bp2build for ndk_headers
Create bp2build converters for the following module types
- ndk_headers
- versioned_ndk_headers

Details
- Partial bp2build conversion. Only `cc_api_headers` targets will be
  generted within the scope of this CL
- Glob expansion. Aligned with other bp2build converters, this impl will
  expand globs in Android.bp so that all .h files are explicitly listed
  in the generated BUILD files. As an extreme example, the size of
  out/soong/workspace/bionic/libc/BUILD will increase from ~170KB to
  ~230KB (33% increase). This makes the BUILD files less readable, and
  `cc_api_headers` section of the BUILD file should probably not be
  checked into the tree in this format

Test: b cquery //bionic/libc:libc_uapi --output=starlark
--starlark:expr="providers(target).get('//build/bazel/rules/apis:cc_api_contribution.bzl%CcApiHeaderInfo')"
Test: go test ./bp2build
Test: go test ./cc

Change-Id: I810d5380f72dc90f4cdf4aa508570f3a80d8d932
2022-08-31 19:40:22 +00:00
Colin Cross
d079e0b270 Reformat build/soong for go 1.19
Test: none
Change-Id: I132368f0fcbdb5ea088b5b84dbe4ccfdd9e94cad
2022-08-17 10:43:13 -07:00
Dan Albert
d05ba00415 Remove draft API support.
This is unused and doesn't work with our current API review process
anyway (un-drafting an API won't be flagged for API council review).

Test: treehugger
Bug: None
Change-Id: I6d8fcc9885b82dac5ada7772d9e3fb9101524ece
2021-04-13 15:55:47 -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
Colin Cross
988414c2cf Sandbox soong_build by changing to root directory
This relands I12a0f907753fefd1997ab8b4ea2ac331234093cf along with
a fix to blueprint for absolute paths.

Store the current working directory and then change to the root
directory so that all file accesses must go through helpers in
the android package that properly track dependencies.

Change-Id: I24ac485677aa102eec1a2521d16820da6ee1ae77
Fixes: 146437378
Test: m checkbuild
Test: m OUT_DIR=/tmp/out nothing
2020-01-11 01:11:46 +00:00
Colin Cross
47e4f9e1e8 Revert "Sandbox soong_build by changing to root directory"
This reverts commit 05c25ccb4a.

Reason for revert: broke absolute OUT_DIR
Bug: 146437378

Change-Id: I523ed79d40e1c1ef040212ba794a7a084abea75d
2020-01-10 18:51:04 +00:00
Colin Cross
05c25ccb4a Sandbox soong_build by changing to root directory
Store the current working directory and then change to the root
directory so that all file accesses must go through helpers in
the android package that properly track dependencies.

Fixes: 146437378
Test: m checkbuild
Change-Id: I12a0f907753fefd1997ab8b4ea2ac331234093cf
2020-01-09 14:19:46 -08: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
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
Colin Cross
8a49795df1 Replace ctx.ExpandSources with android.PathsForModuleSrc
Move the logic from ctx.ExpandSources into android.PathsForModuleSrc
and ctx.ExpandSource into android.PathForModuleSrc, and deprecate
them.  When combined with the pathDepsMutator this will let all
properties that take source paths also take filegroups or genrule
outputs, as long as they are tagged with `android:"path"`.

Test: All soong tests
Change-Id: I01625e76b5da19240e9649bf26a014eeeafcab8f
2019-03-20 19:36:13 +00:00
Colin Cross
07e51619a2 Remove ModuleSrcPath
ModuleSrcPath was designed as a type that ensured that modules only
referenced sources inside the directory that contained the Android.bp
file.  In practice they don't work very well, because allowing
filegroups and genrules as inputs to any module that takes a source
path means that the path might end up being to a file in another
source directory or to a generated file in the output directory.

Remove ModuleSrcPath, replacing it with SourcePath in the places
that need to explicitly refer to a path in the source tree, or
Path where it may be a source path or a generated path.

Make PathForModuleSrc return a Path instead of a SourcePath in
preparation for consolidation with ctx.ExpandSources, which will
make it possibly return paths to generated files.

Test: All soong tests
Change-Id: I973a78470ed14307eea5f6d0cc93942775a65715
2019-03-20 19:36:03 +00:00
Colin Cross
27b922f53e Annotate paths and deprecate ExtractSource(s)Deps
Add `android:"path"` to all properties that take paths to source
files, and remove the calls to ExtractSource(s)Deps, the
pathsDepsMutator will add the necessary SourceDepTag dependency.

Test: All soong tests
Change-Id: I488ba1a5d680aaa50b04fc38acf693e23c6d4d6d
2019-03-07 18:36:35 +00:00
Colin Cross
5f692ec219 Remove empty DepsMutator methods
Add an empty DepsMutator to ModuleBase so it doesn't have to be
implemented on every module that doesn't need it.

Test: all soong tests
Change-Id: I545a832a0dbf27386d3080377a75ea482cd9ce59
2019-02-01 17:17:58 -08: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
Logan Chien
2f066354d4 Use prebuilt bionic versioner
This commit replaces versioner host binary (built just-in-time) with
a prebuilt binary under `prebuilts/clang-tools/${OS}/bin/versioner`.
This is a part of the effort to switch to clang-r339409b.

See also.
https://android-review.googlesource.com/c/platform/bionic/+/799321

Bug: 113263746
Test: make checkbuild
Change-Id: Ia845e1c01d8b8084d00bdc4af706e867e1599863
2018-10-30 10:11:45 +08:00
Colin Cross
395f2cfa89 Move Ndk_abis from soong.config to soong.variables
soong.config is not cleared between builds, which can cause
problems when switching between an ndk build and a platform build.

Bug: 118398924
Test: OUT_DIR=out_ndk DIST_DIR=dist build/soong/scripts/build-ndk-prebuilts.sh
Change-Id: Ifc03a0c25f46625375cdda5723e4a09d7d8050d5
2018-10-24 23:20:10 +00:00
Dan Willemsen
4f644da0ad Don't use arch-specific modules when we want a single module
This breaks when two host OSes are enabled for example.

Bug: 31559095
Test: enable host bionic as a second Host OS, attempt a build
Test: treehugger
Change-Id: If52f77d7d3b0755d768028cbddda320303a69e65
2018-10-22 15:46:03 -07:00
Dan Albert
cb1b4b2d53 Add a preprocessed_ndk_headers module type.
Unlike the old version of this (which has been renamed to
verioned_ndk_headers), this module includes a property to specify the
preprocessor to be used.

This is going to be used for preprocessing ICU4C's unicode/uconfig.h
to alter a config value that needs to differ between the platform and
the NDK.

Test: make checkbuild
Bug: https://github.com/android-ndk/ndk/issues/548
Change-Id: If5c6f54f90cf5a4187693a941748d72f39b0d797
2018-06-01 11:02:38 -07:00
Dan Albert
97f9c963ad Rename preprocessed_ndk_headers to versioned_ndk_headers.
The current rule runs a specific preprocessor over the source files,
and I'm adding support for generic preprocessed headers in a follow
up patch.

Test: make checkbuild
Bug: None
Change-Id: I1f3193cd595f151309e6321e1b41d8d16085379d
2018-05-24 15:12:51 -07:00
Dan Albert
19ff8b4662 Add exclude_srcs property to ndk_headers modules.
Test: make checkbuild
Bug: None
Change-Id: I2778c1140ab50abc0f7dee66da35ebacef77ea72
2018-05-24 15:12:26 -07:00
Dan Albert
7122205a5a Fix typo. Properies -> Properties.
Test: make checkbuild
Bug: None
Change-Id: I0b5e3dd44f507207f2de90e922dd7016cffce118
2018-05-24 15:12:20 -07:00
Dan Willemsen
540a78c1ce Turn GlobFiles into a Glob for files, use it
GlobFiles had allowed results to be anywhere in the source tree,
restrict it to results within the current module directory.

Then use it for ExpandSources and other places where we only want files.
This fixes using '*' in cc_test's `data` property, which can only
support files.

The only thing this changes today is that java_resource_dirs and
java_resources no longer pass directories to soong_zip's -f argument.
core-libart previously added some icu directories, now it only passes
files.

Bug: 71906438
Test: only expected changes in out/soong/build.ninja
Test: add data: ["**/*"] to a cc_test, build successfully
Change-Id: Iff1bd8c005a48e431c740706d7e23f4f957d8b1d
2018-03-01 14:05:20 -08: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
Lazar Trsic
cdb710fed5 Skip MIPS headers when generating NDK prebuilts
When generating NDK prebuilts, skip installing MIPS headers, but keep
them when doing regular platform build. Ndk_abis property is only set
to true with build/soong/scripts/build-ndk-prebuilts.sh

Revert this once MIPS is supported in NDK again.

This effectively skips installing the following header modules when
creating NDK prebuilts:
- libc_asm_mips
- libc_asm_mips64

This fixes the issue introduced by commit:
050f046 Remove mips/mips64 headers from the NDK sysroot.

Test: build/soong/scripts/build-ndk-prebuilts.sh
Test: build aosp_mips[64]-eng

Change-Id: I3af73649bc8ac304bca0e21ec81f156abe546c90
Signed-off-by: Lazar Trsic <Lazar.Trsic@mips.com>
2017-11-28 15:07:16 +01:00
Nan Zhang
a5e7cb4eab Change remaining properties to *string, *bool in Soong.
Test: m -j checkbuild
Bug: b/68853585
Change-Id: I0fd10ff31e90c1941e80cfbf25e40e9988f1e202
2017-11-09 22:42:32 -08:00
Nan Zhang
0007d810e2 Change bool, and string properties to *bool, and *string for cc
there's no use case for prepending/appending to bool, and string
properties within module struct. Declearing "*bool" and "*string" almost
cover everything user need.

I did see one case that user specify relative_install_path as
path prefix in cc_defaults, and concatenate with the one in real module
to get the final relative install path in Android.bp <bionic/tests/libs>.

Test: m -j checkbuild
Bug: b/68853585
Change-Id: If3a7a2689c3fc307aae136af6bc9c57f27a1e1a0
2017-11-07 15:57:16 -08:00
Colin Cross
ae88703df5 Move ModuleContext.ModuleBuild to ModuleContext.Build
Now that android.ModuleContext does not include blueprint.ModuleContext
we can rename android.ModuleContext.ModuleBuild to
android.ModuleContext.Build without colliding with
blueprint.ModuleContext.Build.  Leave ModuleBuild as a wrapper around
Build for now to avoid having to update all the users outside
build/soong simultaneously.

Test: m checkbuild
Change-Id: I18eb8cc04faf002049a11d9aac97e9732ff5d638
2017-10-24 10:59:00 -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
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
67a5c132c5 Prettify soong ninja build descriptions
Descriptions currently look like:
[  0% 4/29328] cc out-soong/.intermediates/external/clang/lib/Sema/libclangSema/android_arm_armv7-a-neon_denver_static_core/obj/external/clang/lib/Sema/SemaCodeComplete.o

This is not very helpful - most of the characters are used to show the
output path, which contains useful information like target architecture,
but also contains most of the path to the source files twice, and less
useful information like the exact variant name used by soong.
Make the descriptions look like:
[  0% 3/29329] //external/clang/lib/Sema:libclangSema clang++ SemaTemplateInstantiate.cpp

This is //path/to/module:modulename tool relative/path/to/source/file

Test: builds, looks pretty
Change-Id: I3087aa7d4eb1860ef6239d77407b8b35445616d7
2017-05-10 11:04:16 -07:00
Dan Willemsen
b916b80bf3 Add LLNDK support for the VNDK
Instead of using the NDK headers and libraries, add LL-NDK specific
headers and library stubs for VNDK users. This allows us to provide an
expanded liblog interface.

Test: aosp_arm; m -j
Test: Enable BOARD_VNDK_VERSION on aosp_arm; m -j
Test: Inspect out/soong/build.ninja before/after (w/o vndk)
Change-Id: Ic85f07fa10c695b5baab10c41f5e0ad38700bf3d
2017-04-07 10:18:56 -07:00
Dan Albert
d2130a9359 Use a timestamp file for preprocessed_ndk_headers.
Having a directory as an output causes superfluous rebuilds, but we
can't have *only* implicit outputs.

Test: make ndk && make ndk
Bug: None
Change-Id: I8c2cd1df2ebf6e0cdb3a0441365d486708554010
2017-03-29 18:33:28 -07:00
Dan Albert
e6a4d7c5e8 Move versioner's -o before positional arguments.
Mac's getopt can't handle this.

Test: make ndk # on mac
Bug: None
Change-Id: I5a4911632f3da77a5489571520526f90f5d80abf
2017-03-29 11:58:40 -07:00
Dan Willemsen
0e2d97b4b1 Stop making the ndk headers host-specific
This breaks when I enable a second host configuration for host bionic.

Make non-arch modules !Device and !Host by adding "Generic" as the zero
value. Make the SkipDeviceInstall config only apply to Device modules.

Test: out/soong/build.ninja is identical expect for comments
Change-Id: I6e2bd3814a9968554d3901a508d822d5c79d08a0
2017-03-15 20:20:22 +00:00
Dan Albert
269fab82eb Add preprocessed_ndk_headers.
Prototypes in the bionic headers are annotated with `__INTRODUCED_IN`
tags that are processed by bionic/tools/versioner into their usable
form (tags replaced with `#if __ANDROID_API__ >= foo` guards). We've
previously done this as a periodic manual step with the results
checked in to prebuilts/ndk, but that's been a huge hassle for me.
Make the tool a part of the build instead.

Test: make checkbuild
Bug: http://b/35673791
Change-Id: I2f5c1aeae239ac4ab6616eb5c71360e3055f86d5
2017-02-22 14:52:52 -08:00
Dan Albert
c6345fb7ec Add a "license" property to ndk_headers.
This field points to the license file for the headers being shipped.

Test: make ndk && less $SOONG_OUT/ndk/NOTICE
Bug: None
Change-Id: I386f4e6f6d9776f422ffc09b8dab69e1911b08a4
2016-10-20 13:30:07 -07: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
Dan Albert
914449fca8 Generate NDK sysroots from the platform build.
The list of migrated libraries is currently empty. Libraries will be
migrated as follow up patches.

Test: Migrated libc to this system and everything still builds.
      build.ninja shows libraries being built and used and headers are
      collected for the sysroot.
Bug: http://b/27533932
Change-Id: Iaba00543c1390f432befe0eed768ed3fbb8a9b96
2016-07-28 00:42:05 -07:00