Commit graph

60 commits

Author SHA1 Message Date
JaeMan Park
3dba4d2c60 Disable tidy checks for generated code
Generated codes like cpp code from *.ll for *.yy files always run
clang-tidy, when generated code has warning, where is no way to fix it.

So, disable clang-tidy for generated code.

Bug: 162909698
Test: go test android/soong/cc
Change-Id: I0fee137d6170ef4bf6cf641abad572e448aceaa1
2024-01-10 16:29:51 +09: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
Trevor Radcliffe
9b81d79ef6 Implement bp2build for Sysprop Java
Bug: 297356813
Test: bp2build and inspect BUILD files
Test: Conversion Unit Tests
Change-Id: Ib70400eb91bca946df1d99d953d7a0e7e63fb7cf
2023-09-29 15:42:00 +00:00
Vinh Tran
095819530a Sandbox inputs to aidl rule in cc
Bug: 279960133
Test: go test
Test: Remove hdrs prop from IDropBoxManagerService_aidl && run  BUILD_BROKEN_DISABLE_BAZEL=true m libservices && Expect an error from aidl
Change-Id: Ifdb260d8e2da9a5767f1e212393de4134b210616
2023-05-23 15:53:10 -04:00
Vinh Tran
367d89da78 Use aidl_library in cc libraries
Introduce aidl.libs prop on cc libraries to pass in aidl_library. The goal is to eventually disallow aidl.include_dirs (a pattern for passing aidl headers dir for aidl compilation) and enforce aidl headers to be explicitly specified in Android.bp.

Bug: 278704136
Test: go test
Change-Id: Ia78bc11dfa12f47d2d1bb90dc65372ddb17f7e14
2023-05-15 17:09:22 -04:00
Trevor Radcliffe
cee4e056aa Enable bp2build for cc modules relying on sysprop
Bug: 244439349
Test: m bp2build
Test: Inspect BUILD.bazel files
Test: Unit tests
Change-Id: I85bfb9fa69cb3f96b15bdbeb797dba86b3349804
2022-09-19 23:38:33 +00:00
Trevor Radcliffe
ef9c900ec3 Generate genlex rules from bp2build for cc targets
This change will cause bp2build to generate genlex targets any
time a .l or .ll file is present in the srcs for a cc target and
add those genlex targets to the srcs attribute of the original
target.

Bug: 207408632
Test: unit tests
Change-Id: I1bce82c9d3c3d458eae1cef547ffae3d6e975134
2022-05-24 14:42:51 +00:00
Nick Desaulniers
dc24d26093 remove support for *.mc files
We've also removed the last consumer of .mc files in aosp/1867048
(external/mdnsresponder/).

Bug: 203794880
Test: lunch aosp_cf_x86_64_phone-userdebug && m
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Change-Id: I2883a04d04b099273261d76319261d0857aa0300
2021-10-26 11:38:37 -07:00
Elliott Hughes
5f314b1613 Rename gccCmd mingwCmd now that's all it's used for.
Bug: http://b/185257607
Test: treehugger
Change-Id: Ida079183828444f122ba6ea5662f63796677de7d
2021-05-18 11:56:02 -07:00
Jiyong Park
c7e592cdef cpp output of an AIDL file is together with the headers
For an AIDL file, five files are generated for the CPP backend: cpp
output, depfile, and three headers. Previously, the cpp output and the
dep file were created at <module_out>/gen/<abs_path_to_input_aidl>.cpp,
while the headers were at <module_out>/gen/aidl/<package_name>/*.h.

This not only looks inconsistent, but more critically makes it difficult
for the aidl compiler to infer the path to the headers that the build
system registered as implicit outputs. Inferring the implicit outputs
by the aidl compiler is needed because otherwise users will see the
error message from sbox just saying that some of the expected files are
not created. This can happen when the input AIDL file is put directly
into the srcs property without specifying the base directory, e.g.
some/subdir/android/foo/IFoo.aidl where the pacakge is actually
android.foo.

In order to make it easy for developers to fix such an error,
I0f23b6027ba3a4755cc2901f4a7f7fc70bffd0ef introduces a check in the aidl
compiler which is triggered earlier than the sbox error. The compiler
now enforces that the cpp output is at
<out_dir>/<package_name>/<type>.app. When the check fails, it suggests
to fix that by correctly feeding the AIDL file via filegroup and the
path property.

This change in Soong is required to satisfy aidl compiler when the base
directory is correctly set. The cpp output is now at
<module_out>/gen/aidl/<pacakge_name>/<type>.cpp.

Bug: 184586092
Test: aidl_unittests
Change-Id: I172180a40bded4f6c08679a2d862b086998be1e1
2021-04-07 21:49:34 +09:00
Paul Duffin
33056e8a9a Export aidl, proto and sysprop generated headers separately
Previously, a cc library that included .aidl, .proto and/or .sysprop
files and exported headers generated from at least one of those types
would actually export generated headers from all of them.

While headers generated from .sysprop files are always exported those
generated from .aidl or .proto should only be exported when explicitly
requested.

This change treats them separately as expected. It has the potential
to break the build as it could reduce the set of headers exported and
so a dependent module that needed those would break. The fix in that
case is to simply add one (or both) of the following to the module
that previously exported those headers:

  aidl: {
    export_aidl_headers: true,
  }

  proto: {
    export_proto_headers: true,
  }

Bug: 180712399
Test: m droid
Change-Id: I488182e27dd423d261443612f98d5c112dd3ef8f
2021-02-22 18:05:10 +00:00
Colin Cross
f1a035e6be Pass pctx and ctx to NewRuleBuilder
Enable the RuleBuilder and RuleBuilderCommand methods to access
the BuilderContext by passing it to NewRuleBuilder instead of
RuleBuilder.Build.

Test: genrule_test.go
Test: rule_builder_test.go
Test: m checkbuild
Change-Id: I63e6597e19167393876dc2259d6f521363b7dabc
2020-12-01 16:22:16 -08:00
Colin Cross
e16ce36818 Reland: Rewrite sbox to use a textproto manifest
This relands I3b918a6643cea77199fd39577ef71e34cdeacdb1 with a fix
to create the directory for the output depfile if doesn't exist.

In preparation for more complicated sandboxing that copies tools
and/or inputs into the sandbox directory, make sbox use a textproto
input that describes the commands to be run and the files to copy
in or out of the sandbox.

Bug: 124313442
Test: m checkbuild
Test: rule_builder_test.go
Test: genrule_test.go
Change-Id: I8af00c8c0b25a92f55a5032fcb525715ae8297c2
2020-11-20 15:45:04 -08:00
Colin Cross
619b9ab260 Revert "Rewrite sbox to use a textproto manifest"
This reverts commit 151b9ff0cf.

Reason for revert: broke builds

Change-Id: I69b3b8795d5a36b4fa0debb1af2d433be3c15d6c
2020-11-20 18:44:31 +00:00
Colin Cross
151b9ff0cf Rewrite sbox to use a textproto manifest
In preparation for more complicated sandboxing that copies tools
and/or inputs into the sandbox directory, make sbox use a textproto
input that describes the commands to be run and the files to copy
in or out of the sandbox.

Bug: 124313442
Test: m checkbuild
Test: rule_builder_test.go
Test: genrule_test.go
Change-Id: I3b918a6643cea77199fd39577ef71e34cdeacdb1
2020-11-18 13:02:22 -08:00
Colin Cross
3d68051218 Move genrule on top of RuleBuilder
In preparation for more complicated sandboxing support in sbox, use
a single implementation of the sbox sandboxing by moving genrule to
use RuleBuilder's sbox support instead of creating an sbox rule
directly.

Also move genrule's input list hash support into RuleBuilder.

Test: genrule_test.go
Test: rule_builder_test.go
Change-Id: I292184d02743c7e6887ebbcd232ba565db2ab0cc
2020-11-17 11:23:45 -08:00
Matthias Maennich
22fd4d1b82 soong: add support for module specific lexer flags
To support module specific lexer flags, this follows the same strategy
as the yacc flags:
 - add LexProperties to the BaseCompilerProperties
 - propagate those flags to the generator generation (i.e. genLex)
 - add a placeholder for custom flags
 - replace the placeholder with the concatenated flags

This might not support escaping very well, but I figured that this is a
very edge case. Support for escaping etc. could be added later on.

Bug: 159682555
Signed-off-by: Matthias Maennich <maennich@google.com>
Change-Id: I31a3b783bb05213fe1621191031952b41b318103
2020-08-26 21:41:33 +01:00
David Su
dd18efd95d Revert "Switch cc's use of bison and flex to prebuilt_build_tool"
Revert submission 1366377-prebuilt_build_tool_make

Reason for revert: breaks build
Reverted Changes:
I20bf062bb:Export prebuilt tools to Make
I4bb526492:Move some prebuilt build tool configs to Soong
I195b68813:Support per-module MakeVars
Ibcb257e7b:Fix dependency loop with flex
I6150f0f39:Switch cc's use of bison and flex to prebuilt_buil...
I6939451b8:Reland "Use genrules to build a consistent awk."
Idee60640f:Add prebuilt_build_tool modules for genrule use
I00893172b:Rename bison to bison_bin
I82c26be1c:Add prebuilt_build_tool to allow genrules to use p...

Change-Id: I1ca553ffe4b09250a441b9bc477c3ba98c6f6549
2020-07-24 21:25:00 +00:00
Dan Willemsen
613564eed4 Revert "Support per-module MakeVars"
This reverts commit 2019658b86.

Reason for revert: broke builds where makefiles were using M4 without depending upon it

Change-Id: I18304246e7a8a8f8c2620dd2c65ed77acd256be2
2020-07-23 21:37:35 +00:00
Dan Willemsen
2019658b86 Support per-module MakeVars
This allows setting per-module make variables earlier in the build,
particularly for prebuilt_build_tool users like LEX/M4/BISON. I moved
filegroup over because it's a simpler common interface, but it doesn't
strictly need it.

With this, the last user of the hardcoded cc.m4Cmd variable is gone.

Test: Inspect out/soong/make_vars-*.mk, out/soong/late-*.mk
Test: treehugger
Change-Id: I195b688131feac0c100c338a0749368aa5d50f4f
2020-07-17 20:07:33 -07:00
Dan Willemsen
d2e291ae5c Switch cc's use of bison and flex to prebuilt_build_tool
Test: treehugger
Change-Id: I6150f0f39151e8073d5d59fe189f614140fed57b
2020-07-17 20:07:16 -07:00
Inseob Kim
ed2641f469 Fix header deps of sysprop_library
This adds public header to deps correctly.

Bug: 148123511
Bug: 149252327
Test: VNDK_SNAPSHOT_BUILD_ARTIFACTS=true m dist vndk
Change-Id: Ib8df3dfb4a068a11fc647de8588cc52889d82fba
2020-02-19 15:30:02 +09:00
Daniel Norman
10b743509e Performs same checks as aidl_interface.go before stripping leading "I".
Test: building AIDL interface named IntEnum.aidl. Leading I is not
removed.
Change-Id: Ia40cbdf9b8936f6f58a99971eae1b2138a678c91
2019-09-24 17:41:15 -07:00
Jiyong Park
2907459e43 filegroup.path is used to specify the include path for aidl files
filegroup {
    name: "foo",
    srcs: ["srcs/aidl/com/android/**/*.aidl"],
    path: "srcs/aidl",
}

cc_library { // or java_library, etc.
    name: "bar",
    srcs: [":foo"],
}

automatically adds "-Ipath/to/foo/srcs/aidl" when compiling the aidl
files from foo for bar. This allows us to omit aidl include path
when using sources in other places via file group.

Bug: 135922046
Test: m (unit tests added)
Change-Id: I9b42f316f2858fb6da72c2f58a314f391416e809
2019-07-19 11:31:31 +09:00
Jeffrey Vander Stoep
38aaf75e44 Merge "Renderscript: rename .rs extension to .rscript" 2019-07-18 02:02:00 +00:00
Jeff Vander Stoep
d612627169 Renderscript: rename .rs extension to .rscript
Reserve .rs extension for Rust.

Bug: 137365032
Test: make checkbuild
Test: cd frameworks/compile/slang/tests
    ./slang_tests.py
    Test: atest CtsRenderscriptTestCases
    Test: CtsRsCppTestCases

Change-Id: I0458009b8bb64a012fece364835d5b78d52e15e9
Merged-In: I0458009b8bb64a012fece364835d5b78d52e15e9
2019-07-17 18:57:32 +00:00
Colin Cross
ee94d6ab14 Add RuleBuilder helper functions for built and prebuilt tools
Replace the common pattern of:
cmd.Tool(ctx.Config().HostToolPath(ctx, "tool"))
with:
cmd.BuiltTool("tool")

And similarly for PrebuiltBuildTool.

Test: m checkbuild
Change-Id: I7d63188505362c7df6a3b3e7330b4a2cca5a2409
2019-07-11 13:05:19 -07:00
Dan Willemsen
c4a6aa83e8 Use prebuilt m4 for bison too
Bison is currently looking for m4 directly in `/usr/bin/m4`, instead of
through $PATH, so it hadn't been tracked via the $PATH interposer
checks. But if you don't install m4 at all, it starts failing.

Bug: 117561006
Bug: 130111713
Test: Run on a machine without m4, build passes
Change-Id: I3fbad64127c183de79c17511e979fd5df946eb80
2019-06-25 16:12:12 -07:00
Dan Willemsen
c69d715d72 Use prebuilt m4 instead of system m4
Bug: 117561006
Test: treehugger
Change-Id: I588d867d95cc52963ce764018a9c09b26973c8c3
2019-06-19 12:50:32 -07:00
Treehugger Robot
b1856799b1 Merge "sysprop_library: Rename system scope to public" 2019-06-16 06:08:14 +00:00
Inseob Kim
5cefbd289d sysprop_library: Rename system scope to public
In the first design, public sysprops have been accessible from Java
modules linking against SDK. But SDK modules shouldn't do, because
sysprop_library isn't for the apps. This renames system to public, so
that only public(System till now) and internal scopes remain from now.

Bug: 131637873
Test: m && sysprop_test
Change-Id: I548007d4a6018922f98d3d13915cee1d66070086
2019-06-11 23:31:32 +09:00
Dan Willemsen
1945a4b47d Convert cc aidl to rule builder
This fixes an incremental build issue where we didn't clean up old aidl
header files (or necessarily notice that they were updated).

We do this by declaring the header files as outputs in the build graph,
but this means that the src file name needs to be convertible to the
aidl package name, as that's how the header file paths are created. In
many cases, filegroups can be used to strip path prefixes from the aidl
files.

Bug: 112114177
Test: treehugger
Change-Id: If534ff3dbfac329dea9a7402e30be74495754160
2019-06-06 08:23:53 -07:00
Dan Willemsen
4e0aa23dd3 Convert yacc to a single RuleBuilder rule
So that <module>/gen/yacc/... is (re)created by a single rule, previous
files are removed, and location.hh is in the build graph when it is
produced.

Test: treehugger
Change-Id: I2f6e47ea07f315e10ae1cb8ad50697e7123d0285
2019-04-15 14:52:05 -07:00
Inseob Kim
c0907f191a Create sysprop_library soong module
A newly introduced sysprop_library soong module will generate a
java_sdk_library and a cc_library from .sysprop description files.
Both Java modules and C++ modules can link against sysprop_library
module, thus giving consistency for using generated sysprop API.

As Java controls accessibility of Internal / System properties with
@hide and @SystemApi, 2 different header files will be created. And
build system will selectively expose depending on the property owner
and the place where the client libraries go into.

Bug: 80125326
Bug: 122170616
Test: 1) Create sysprop_library module.
Test: 2) Create empty txt files under prebuilts/sdk.
Test: 3) Create api directory, make update-api, and see changes.
Test: 4) Try to link against sysprop_library with various clients.
Test: 5) Soc_specific, Device_specific, Product_specific, recovery flags
work as intended.
Change-Id: I78dc5780ccfbb4b69e5c61dec26b94e92d43c333
2019-02-13 23:32:51 +00:00
Dan Willemsen
d56097dc27 Remove incorrect file comments
Test: none
Change-Id: Ia2889ee29c2c0bf18adf5d90e506cfce4b14fdcc
2018-12-27 12:26:30 -08:00
Dan Willemsen
60e62f0c44 Add nanopb-c support
Test: cd hardware/ril; mma
Change-Id: Id1481940d15a2a3f6eb29af54ee30080ff2286cb
2018-11-17 15:28:25 -08:00
Inseob Kim
21f26907cc Add support for sysprop description files to c++
From now on, a c++ shared library can be built only with adding
".sysprop" description file to srcs. Sysprop library generator will
automatically generate a .cpp and .h files, and the header file will be
exposed to any clients linking against the shared library. For the full
schema of description file, see system/tools/sysprop/sysprop.proto.

Bug: 80125326
Test: 1) write a .sysprop description file.
2) create cc_library_shared and add description file to srcs.
3) create another module, link against library of 2), include generated
header, and access generated sysprop functions
4) see compile succeeded.

Change-Id: I95005a0724aeb8f11a856b7aee92787a16a5374d
2018-10-10 00:33:01 +00:00
Steven Moreland
b468bca551 aidl: -ninja -> --ninja
Bug: 110967839
Test: AIDL's runtests.sh
Change-Id: I49c0a2526b6d4083c927104a3e66017080000847
2018-07-06 11:36:32 -07:00
Dan Willemsen
b7adae8aaf Use new flex binary
Test: treehugger
Change-Id: Ie1d41a3ee223a80b6f471b7b1cbede63cc7051f5
2018-05-24 15:45:21 -07:00
Dan Willemsen
ab9f4268c0 Add proto.canonical_path_from_root
Historically, we've always passed '-I .' as the first argument to
protoc, essentially treating all proto file package names as their full
path in the android source tree. This would make sense in a monorepo
world, but it makes less sense when we're pulling in external projects
with established package names.

So keep the same default (for now), but allow individual builds to opt
into using local paths as the default names with
'canonical_path_from_root: false'. A cleanup effort and/or large scale
change in the future could change the default to false.

As part of this, run protoc once per input proto file, since the flags
may need to change per-file. We'll also need this in order to specify
--dependency_out in the future.

Bug: 70704330
Test: aosp/master build-aosp_arm.ninja is identical
Test: aosp/master soong/build.ninja has expected changes
Test: m
Test: Build protobuf test
Change-Id: I9d6de9fd630326bbcced1c62a4a7e9546429b0ce
2018-02-22 16:48:35 -08:00
Dan Willemsen
6f46a38e56 Switch to build-tools bison
Test: m
Test: mma system/tools/hidl
Change-Id: I467c63792082ef335f2d7788d538db76e9e91d87
2018-01-08 17:34:47 -08:00
Joe Onorato
09e94ab074 When compiling with the lite protobuf option, pass the option to aprotoc to force the lite runtime.
Test: make
Merged-In: I450f89d144d496a6ddfccc6a6a5a679a05809595
Change-Id: I450f89d144d496a6ddfccc6a6a5a679a05809595
2017-12-15 08:40:27 -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
6af17aa022 Add support for .proto files in java modules
Test: m -j checkbuild
Change-Id: Ia03429948baebff85164a91a34507866c97a08ef
2017-10-03 10:25:15 -07:00
Colin Cross
38f794ee49 Refactor proto in preparation for java proto support
Test: m -j checkbuild
Change-Id: Idf00ea0bacb2777458f9af2c7eb47e1e1854eeba
2017-09-11 12:41:58 -07:00
Dan Willemsen
4f1c3d4116 Add support for Windows Message Compiler
We've only got one user of this currently, but since it needs the
location of the toolchain, and different flags based on 32 vs 64-bit,
it's easier just to add support than to get this into a genrule.

Test: Convert external/mdnsresponder to Soong, build
Change-Id: I6c19a82bc14f6ab556f6cc5f37164862ba5f9083
2017-09-09 13:06:25 -07: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
Colin Cross
2a252bef50 Support .rs and .fs files in cc_* module srcs lists
Translate .rs and .fs files to .cpp files using llvm-rs-cc.

Test: builds
Change-Id: I242cea0d09c9985730a512cec7705c3f1479f4ed
2017-05-05 18:22:30 -07:00
Dan Willemsen
e1240db6ab Support aidl cpp generation
Ideally we'd calculate the headers that are written here too, but I'll
add that in a later change that actually enforces the generated header
list.

Test: mmma -j system/tools/aidl
Change-Id: Ifd2e8e8ff444b0f67270fb5156e7bf7bceddb6be
2016-12-05 15:49:40 -08:00
Dan Willemsen
9f3c574a39 Add support for Implicit Outputs
Test: mmma -j system/tools/hidl
Test: Inspect out/soong/build.ninja before/after
Change-Id: I8e91a033342a12302d51358c5be244e32ad689d7
2016-11-03 14:35:12 -07:00