Commit graph

53 commits

Author SHA1 Message Date
mrziwang
e6c8581fbe Use OutputFilesProvider on bpf
This changes makes bpf module type uses OutputFilesProvider,
instead of current OutputFileProducer for inter-module-
communication.

Test: CI
Bug: 339477385
Bug: 342406930
Change-Id: I85d1141e9f6583cc5427756107da99f56b0c7ea1
2024-06-04 22:09:13 -07:00
Jiyong Park
06c4cdcf87 bpf modules can be included in filesystem modules
Bug: 322246536
Test: go test ./...
Change-Id: I5f29258e45475b30cdb26014c2db147182ec52fa
2024-02-16 15:35:03 +09:00
LaMont Jones
b509938e4f Propagate AconfigFiles in ModuleBase.
Aconfig file dependencies are module-independent, and properly part of
ModuleBase.

Bug: b/308625757
Test: manual

Change-Id: I38c5907d1671cc69bb198345201316ae781fdc9f
2024-01-24 23:45:12 +00:00
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
Aditya Choudhary
26df39fe44 Add source file provider for genrule/srcs, python libraries and rust libraries.
Change-Id: I2d7d4684a10c15aeecc27b8db800ab27a807d2e2
2023-12-05 19:56:26 +00:00
Colin Cross
a16bd6b714 Don't write license data to Android-${TARGET_PRODUCT}.mk
All the necessary license data is already propagated through the license
metadata file, and the entries in Android-${TARGET_PRODUCT}.mk are not
used.  Remove them, which should both reduce the size and parsing cost
of the Android-${TARGET_PRODUCT}.mk file and also removes a variable
that changes when dependencies are added or removed, which will
eventually allow running kati less often.

Bug: 309006256
Test: No change to out/Android-aosp_cf_x86_64_phone.ninja
Change-Id: Idfeb6fd10d77497ca274f8e74fe8e994ce1cafe6
2023-11-21 15:27:44 -08:00
Motomu Utsumi
9c5b51e4f6 Merge "Remove unused file path" into main 2023-09-22 02:06:54 +00:00
Motomu Utsumi
fca0ccc744 Remove unused file path
frameworks/libs/net was moved to the packages/modules/Connectivity

Bug: 296014682
Test: TH
Change-Id: I1c17eb0cb4a2d6d2526b26fd800f206e93d4e009
2023-09-21 11:38:14 +00: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
Motomu Utsumi
44591557f4 Add package/modules/Connectivity bpf_headers path
Following CLs will move frameworks/libs/net to packages/modules/Connectivity.
This CL is a preparation for that.

Bug: 296014682
Test: m
Change-Id: Ie6483d1e5dfbf6c4745c10d3bb031344368c8c8f
2023-08-22 19:24:24 +09:00
Sasha Smundak
dcb6129269 Streamline AndroidMk generation
Add AndroidMkEmitAssignList to emit a line to assign the items from
the given list of string arrays.

Test: treehugger
Change-Id: Id5acbef38ea4e91349bd2461f226db352d4b8123
2022-12-12 18:06:49 -08:00
Sasha Smundak
5c4729df93 Show module type in a module section of the Android-TARGET.mk
The first line of each section will be
```
include $(CLEAR_VARS)  # <module type>
...
```

Bug: 257037252
Test: treehugger
Change-Id: Iba586155b682fe4e1e5817d8397eda8f9d9c8789
2022-12-01 21:12:11 -08:00
Connor O'Brien
6a288bc799 bpf: use PwdPrefix() helper
relPwd is only set if runtime.GOOS != "darwin" but is used
unconditionally. Instead, unconditionally set relPwd using the
cc.PwdPrefix() helper.

Bug: 238165437
Test: m timeInState.o
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: I5294bb6ea95dad60fbf64e9d958e1f1b32a02a48
2022-11-10 16:35:12 -08:00
Connor O'Brien
b573f5ffd2 Merge "bpf: use relative source file path in debug info" 2022-11-10 20:23:28 +00:00
Connor O'Brien
3e739cf426 bpf: use relative source file path in debug info
Enabling BTF leads clang to generate debug line info that includes the
absolute path to the source file. For C++ modules the
-fdebug-prefix-map flag is used to convert these to relative paths. Do
the same for BPF programs when BTF is enabled.

Test: build timeInState.c; strings shows only relative path to source
file
Bug: 238165437
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: Ie4ebc8f9a7d115baeddde5c7ac3ae710335ddf13
2022-11-10 20:22:48 +00:00
Zi Wang
aa981edcf0 Incorporate bpf into mixed builds
Bug: 240163393
Test: TestBpfWithBazel in bpf_test.go
Change-Id: I1d24a9c0d1d6911987c730bf1b5b7e02d6e73a5e
2022-10-07 18:30:45 +00:00
Zi Wang
b3cb38c3c8 Add bp2build converter for bpf
Bug: 240163393
Test: m bp2build
Test: bp2build/bpf_conversion_test.go
Change-Id: Ie3bbc64511146b099a766d7e8b56e93cef58ef68
2022-09-28 14:18:45 -07:00
Zi Wang
4877c72b47 Add comments to bpf properties
Bug: 240141438
Test: m soong_docs
Change-Id: I86388391da9b6f30f0f3745490641e918d68c046
2022-08-12 18:17:07 +00:00
Ken Chen
5372a24375 Disallow '_' in bpf source name
Current design:
1. The bpf compiled object name is derived from the source name
   (e.g. foo.c -> foo.o).
2. Full bpf program/map name are concatenated by object name + '_' +
   program/map name in run-time. (e.g. obj name: x.o; program name: y_z;
   full bpf program name will be x_y_z)

Issue:
x.o with map y_z and x_y.o with map z can cause naming collision in
run-time, since both result in x_y_z. This commit prevents it from
happening with a build-time check.

Bug: 236706995
Test: m
Change-Id: Ic03bfcf07a5748ed63246b71d5ae8de0405e658a
2022-07-07 20:02:28 +08:00
Steven Moreland
606c5e9e99 bpf: support installing to vendor
Bug: 140330870
Test: use bpf{} to install bpf program to vendor and have it
  successfully loaded and installed by Android's bpfloader.

Change-Id: If0aac3098e39498f0238516ec839b6ac910cc61e
2022-02-09 00:45:02 +00:00
Connor O'Brien
2573965c5e Add option to generate BTF debug info for bpf programs
Add "btf" option that generates BTF debug info to support easier map
inspection. This is accomplished by passing the "-g" flag to clang
when compiling the BPF program.

The "-g" option also generates a number of DWARF debug sections which
are not necessary for loading BTF information, so strip these to avoid
increasing file size unnecessarily. bpfloader currently only supports
BTF info for maps, not programs, so we also strip the .BTF.ext section
containing program BTF info.

Bug: 203823368
Test: libbpf_load_test
Test: verify time_in_state.o includes .BTF section iff "btf: true" is
set
Test: verify time_in_state.o still loads if BTF is enabled
Change-Id: Ica25b253bace59d04130b0210350188399889bbe
Signed-off-by: Connor O'Brien <connoro@google.com>
2022-01-27 12:00:45 -08:00
Treehugger Robot
a9a5d36884 Merge "[NETD-BPF#34] Add a tag for bpf to specify the install folder" 2022-01-19 09:41:57 +00:00
Ken Chen
fad7f9d8b7 [NETD-BPF#34] Add a tag for bpf to specify the install folder
Currently, the bpf module netd.o (source system/netd/bpf_progs/netd.c)
will be built to /system/etc/bpf/netd.o. In Android T, it will be moved
to mainline module com.android.tethering.

The expected behavior is:
- In T device, it uses the netd.o in mainline module.
- In pre-T devices, it uses the original netd, built from platform.

However, netd.o will be double loaded if the tethering module is
installed in Pre-T devices. Because:
1. bpf in apex is packed into /apex/MAINLINE_MODULE/etc/bpf/
2. bpf in platform is packed into /system/etc/bpf/
3. bpfloader in pre-T loads ANY bpf modules under
/apex/com.android.tethering/etc/bpf/ and /system/etc/bpf/.

We can't change the behavior of bpfloader in pre-T devices. We can't
delete the /system/etc/bpf/netd.o from pre-T devices. Both of them are
not mainline modules. So the mainlined netd.o needs to be packed into a
folder other than /apex/com.android.tethering/etc/bpf/ or
/system/etc/bpf/.

This commit adds a tag 'sub_dir' for bpf module. The installation path
of bpf modules will be:
- /system/etc/bpf/SUB_DIR/     (for platform code)
- /apex/MAINLINE_MODULE/etc/bpf/SUB_DIR/     (for mainline module)

Bug: 202086915
Test: add test in apex_test.go and build
Change-Id: Icc6619768ab006de9f86620a7df1bb2853eaba13
2022-01-19 04:02:29 +00:00
Ken Chen
78df0f1a4e Remove global bpf include path system/bpf/progs/include
Delete it because there is only one user left
(system/bpfprogs/time_in_state.c). It can be specified locally.

Bug: 202086915
Test: build and boot
Change-Id: I1cb0ceb7b8e3fb63af34e11e5fece11fa038b24e
2021-12-23 10:45:55 +08:00
Ken Chen
fd26444abd [NETD-BPF#21] Move a few headers to frameworks/libs/net
BPF headers used by both platform and mainline modules should be in
frameworks/libs/net.

Bug: 202086915
Test: build and boot
Test: cd packages/modules/Connectivity/netd; atest
Change-Id: I5a86ccd44a673a18138201f186b104f5214fd449
2021-12-23 10:00:58 +08:00
Paul Duffin
89648f98fa Remove usages of FixtureFactory from misc packages
These packages have already been migrated to use per test build
directory so have no need for a FixtureFactory.

Bug: 183235980
Test: m nothing
Change-Id: I667d1d992caaf0f615de91f89efdae11c44986c2
2021-03-22 18:31:53 +00:00
Paul Duffin
854d661572 Migrate bpf package to a per test build directory
Bug: 182885307
Test: m nothing
Change-Id: I0ee9575af056057ca37831a3afebba2be1e54d27
2021-03-17 16:10:55 +00:00
Paul Duffin
12c7eb8cb1 Support test fixtures in bpf package
Restructures the bpf package test setup code to create FixturePreparer
instances for setting up a test fixture and converts the test to use
it.

Bug: 181070625
Test: m nothing
Change-Id: I7c76ed6dc292ca92d76ef95c4167f7ca2d68e1af
2021-03-09 23:07:17 +00:00
Bob Badour
02040de891 Add LOCAL_LICENSE_KINDS to build/soong
Added SPDX-license-identifier-Apache-2.0 to:
  Android.bp
  android/Android.bp
  android/soongconfig/Android.bp
  androidmk/Android.bp
  apex/Android.bp
  bazel/Android.bp
  bp2build/Android.bp
  bpf/Android.bp
  bpfix/Android.bp
  cc/Android.bp
  cc/config/Android.bp
  cc/libbuildversion/Android.bp
  cc/libbuildversion/tests/Android.bp
  cc/ndk_api_coverage_parser/Android.bp
  cc/ndkstubgen/Android.bp
  cc/symbolfile/Android.bp
  cmd/dep_fixer/Android.bp
  cmd/diff_target_files/Android.bp
  cmd/extract_apks/Android.bp
  cmd/extract_jar_packages/Android.bp
  cmd/extract_linker/Android.bp
  cmd/fileslist/Android.bp
  cmd/host_bionic_inject/Android.bp
  cmd/javac_wrapper/Android.bp
  cmd/merge_zips/Android.bp
  cmd/multiproduct_kati/Android.bp
  cmd/path_interposer/Android.bp
  cmd/pom2bp/Android.bp
  cmd/pom2mk/Android.bp
  cmd/sbox/Android.bp
  cmd/soong_build/Android.bp
  cmd/soong_env/Android.bp
  cmd/soong_ui/Android.bp
  cmd/zip2zip/Android.bp
  cmd/zipsync/Android.bp
  cuj/Android.bp
  dexpreopt/Android.bp
  dexpreopt/dexpreopt_gen/Android.bp
  env/Android.bp
  etc/Android.bp
  filesystem/Android.bp
  finder/Android.bp
  finder/cmd/Android.bp
  genrule/Android.bp
  jar/Android.bp
  java/Android.bp
  java/config/Android.bp
  kernel/Android.bp
  linkerconfig/Android.bp
  linkerconfig/proto/Android.bp
  makedeps/Android.bp
  partner/Android.bp
  phony/Android.bp
  python/Android.bp
  python/tests/Android.bp
  remoteexec/Android.bp
  rust/Android.bp
  rust/config/Android.bp
  scripts/Android.bp
  sdk/Android.bp
  sh/Android.bp
  shared/Android.bp
  symbol_inject/Android.bp
  symbol_inject/cmd/Android.bp
  sysprop/Android.bp
  tradefed/Android.bp
  ui/build/Android.bp
  ui/logger/Android.bp
  ui/metrics/Android.bp
  ui/metrics/proc/Android.bp
  ui/status/Android.bp
  ui/terminal/Android.bp
  ui/tracer/Android.bp
  xml/Android.bp
  zip/Android.bp
  zip/cmd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  finder/fs/Android.bp
  third_party/zip/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work

Change-Id: Ia47ca14f16b8c9f84f9d533a07e5b00e2c04e8d4
2021-02-06 04:23:21 +00:00
Bob Badour
b499922acc Revert^2 "Export soong license data to make."
61a55a0344

Change-Id: I5fb017c683df18bad42a8e27fb2d7c7c510514e5
2021-01-06 20:49:11 -08:00
Jerome Gaillard
61a55a0344 Revert "Export soong license data to make."
Revert submission 1377717-metalics

Reason for revert: This has broken renderscript_mac target for aosp-master, see b/176909442

Reverted Changes:
I26ac54ca9:Define the standard license_kind rules.
I656486070:Export soong license data to make.
If9d661dfc:Export soong license data to make.
I97943de53:Add ability to declare licenses in soong.
Icaff40171:Rough-in license metadata support to make.
Ib8e538bd0:Add variables for notice deps, license kinds etc.

Change-Id: I51799c94a274eadab414abd80a07b5cda4584be9
2021-01-06 19:00:05 +00:00
Bob Badour
74fab31712 Export soong license data to make.
See: http://go/android-license-checking-in-soong-v2-design

Bug: 151953481
Bug: 151177513
Bug: 67772237

Change-Id: If9d661dfcaa732c459d38d8ad7ec4a0e540846b8
2021-01-05 08:42:48 -08:00
Colin Cross
ae8600b507 Pass Config to NewTestContext instead of ctx.Register
Prepare for using Config when adding singletons by passing
Config to NewTestContext and NewContext instead of to ctx.Register.
This will enable a followup change to store SingletonMakeVarsProviders
registered on the Context in the Config, which is necessary to run
multiple tests in parallel without data races.

Test: all soong tests
Change-Id: Id229629a4e42ff4487d317241673837726c075fc
2020-11-12 10:07:49 -08:00
Colin Cross
405af07859 Revert "Make lots of tests run in parallel"
This reverts commit 323dc60712.

Reason for revert: Possible cause of test instability
Bug: 170513220
Test: soong tests

Change-Id: Iee168e9fbb4210569e6cffcc23e60d111403abb8
2020-10-09 18:34:24 -07:00
Colin Cross
323dc60712 Make lots of tests run in parallel
Putting t.Parallel() in each test makes them run in parallel.
Additional t.Parallel() could be added to each subtest, although
that requires making a local copy of the loop variable for
table driven tests.

Test: m checkbuild
Change-Id: I5d9869ead441093f4d7c5757f2447385333a95a4
2020-10-06 15:12:22 -07:00
markchien
2f59ec98d1 Include bpf program in APEXes
bpf program is put to an APEX via 'bpfs' property. It is
placed under etc/bpf directory in it.

Fix: 167530625
Test: m
Change-Id: Ia36b486f0cffb619ecc4f7a318cde881abc5baf4
2020-09-02 22:18:25 +08:00
Kousik Kumar
fb0e251f30 Add no-canonical-prefixes to make sure paths in .d file are relative paths
Test: Ran "m out/soong/.intermediates/system/netd/bpf_progs/clatd.o/android_common/obj/system/netd/bpf_progs/clatd.o"
and verified that the output .d file did NOT contain absolute paths.

Change-Id: I2d187638eb7a6db8de057b83312cba3116985ac8
2020-03-25 16:44:13 -07:00
Maciej Żenczykowski
79f6f75332 bpf progs depend on system/core/libcutils/include
Test: build, atest
Bug: 149434314
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I070bc147abe43556d66082e19c16214ae6a9f94b
2020-02-18 23:51:52 +00:00
Ramy Medhat
8ea054a81e Add support for experimentally enabling RBE support on specific rules.
This CL adds RBE support to javac, r8, and d8 rules which is only
enabled if respective environment variables are set.

Test: an aosp_crosshatch build with and without the new variables.
Change-Id: Ic82f3627944f6a5ee7b9f3228170c2709b1bfcb8
2020-01-28 12:42:47 -05:00
Colin Cross
98be1bb00f Move filesystem into Config
The filesystem object was available through ModuleContext.Fs(), but
gives too much access to the filesystem without enforicing correct
dependencies.  In order to support sandboxing the soong_build
process move the filesystem into the Config.  The next change will
make it private.

Bug: 146437378
Test: all Soong tests
Change-Id: I5d3ae9108f120fd335b21efd612aefa078378813
2019-12-18 08:19:10 -08:00
Colin Cross
4b49b768a2 Make TestContext.RegisterModuleType take an android.ModuleFactory
Avoid having to pass ModuleFactoryAdaptor to every call to
RegisterModuleType in a test by wrapping RegisterModuleType.

Test: all soong tests
Change-Id: If8847d16487de0479cc3020b728256922b3cadba
2019-11-25 10:59:44 -08:00
Ramy Medhat
dd0418a4d4 Run non-RBE supported actions in the local pool when USE_RBE is set.
Bug: 143938974
Test: ran CTS build at -j500 successfully.
Change-Id: I55074bd67308cd716972e24fb56a20bc393d5d9d
2019-11-05 22:57:35 +00:00
Colin Cross
41955e8895 Support tagged module references
There are cases where a module needs to refer to an intermediate
output of another module instead of its final output.  For example,
a module may want to use the .jar containing .class files from
another module whose final output is a .jar containing classes.dex
files.  Support a new ":module{.tag}" format in any property that
is annotated with `android:"path"`, which will query the target
module for its ".tag" output(s).

Test: path_properties_test.go, paths_test.go
Test: no unexpected changes in build.ninja
Change-Id: Icd3c9b0d83ff125771767c04046fcffb9fc3f65a
2019-06-04 10:22:51 -07:00
Colin Cross
815daf95b2 Add bpf_test.go to build and fix tests
bpf_test.go was not listed in testSrcs, which meant it was not run
during the build, but ran and failed with go test android/soong/...

Don't redeclare the cc module types and mutators, use exported
functions from cc/testing.go instead, which contain a new
dependency needed by cc modules.

This reapplies I4542640e8ff08e71565ed50617dbe67d86b29b69 after
fixes for mac tests.

Test: m
Test: go test android/soong/...
Change-Id: I3dc3fdedbd7063df4a2e0cadf2a4e0711b1823ad
2019-05-17 08:43:36 -07:00
Colin Cross
d3d3ad1686 Revert "Add bpf_test.go to build and fix the tests"
This reverts commit 192e3aa6a8.

Reason for revert: broke mac tests

Change-Id: I3f4c679e11d9361dbc2daaf6c89282259b225d61
2019-05-14 22:46:24 +00:00
Colin Cross
192e3aa6a8 Add bpf_test.go to build and fix the tests
bpf_test.go was not listed in testSrcs, which meant it was not run
during the build, but ran and failed with go test android/soong/...

Test: m
Test: go test android/soong/...
Change-Id: I4542640e8ff08e71565ed50617dbe67d86b29b69
2019-05-14 18:40:19 +00:00
Colin Cross
0adfee5a20 Fix relative path of bpf modules
Using bpf as test data installs the module into a strange
subdirectory, clear the Rel() value before exporting it as
a SourceFileProducer.

Bug: 130206035
Test: m vts_test_binary_bpf_module
Change-Id: Ifdae90d11b15d65c097562d7d6985a8a1dca2bfd
2019-04-10 18:32:00 +00: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
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