Commit graph

217 commits

Author SHA1 Message Date
Treehugger Robot
f7e7776079 Merge "Disable "__builtin_func" when converting mk to bp" into main 2024-03-26 02:30:35 +00:00
Herbert Xue
3fe7b7f66e Disable "__builtin_func" when converting mk to bp
The "__builtin_func" doesn't work in soong. The converting tool
androidmk should disable this feature.

Bug: 329770862
Test: 1. cd build/soong/androidmk/androidmk
      2. go test -run TestEndToEnd
Change-Id: I1de04e4e1a34fb7335e0013f59b33f7f2673722a
2024-03-21 10:47:32 +08:00
Min Yun
53ca8b2512 Handles if a space is encountered while parsing the rule
kati and GNU make may have blank lines in the middle of commands declared in rules.
Add compatibility for this.

Change-Id: Iae03053c0cb901074c26420c0c6ac1c0e00d99de
2024-02-24 08:08:08 +09:00
Treehugger Robot
3b21c9cadd Merge "The androidmk supports converting "LOCAL_PROTOC_FLAGS"" into main 2024-01-18 02:34:58 +00:00
Treehugger Robot
936a57d3e9 Merge "Fix the error of androidmk unittest" into main 2024-01-18 02:22:17 +00:00
Herbert Xue
d63054e214 Fix the error of androidmk unittest
The unittest checking Android.mk path which is the relative path with
"ANDROID_BUILD_TOP". This can be fix with clean it.

Bug: 319563069
Test: 1. cd build/soong/androidmk/androidmk
      2. go test
Change-Id: Iaf6c331abeadfec3416387f416aaebc0ecfa8a21
2024-01-17 15:09:29 +08:00
Herbert Xue
65e0963e4a The androidmk supports converting "LOCAL_PROTOC_FLAGS"
LOCAL_PROTOC_FLAGS can be converted as "proto.local_include_dirs" with
value "--proto_path".

Bug: 314862115
Test: 1. m androidmk
      2. go test
Change-Id: Id4e589623ffef50c2549720b1ef828cd38a940a0
2024-01-17 11:30:38 +08:00
Herbert Xue
5418340dc7 Support converting LOCAL_PROTO_JAVA_OUTPUT_PARAMS
LOCAL_PROTO_JAVA_OUTPUT_PARAMS can be converted as "proto.output_params"
in androidmk. The "," will be filtered out.

Bug: 314862115
Test: m androidmk
Change-Id: If784e7fd38e2b729272414afab186be027d3b225
2024-01-11 15:20:54 +08:00
Jim Tang
b9db38631e Ignore LOCAL_XTS_TEST_PACKAGE translation
This commit enables `androidmk` to skip checking the obsolete attribute
`LOCAL_XTS_TEST_PACKAGE` without generating warning message.

Bug: 318619340
Test: m androidmk && androidmk <somewhere>/Android.mk
Change-Id: I42dbbd4aa1c61b9e344bfb219b372a0c48d77645
2024-01-09 12:51:56 +08:00
Herbert Xue
caadada423 Add support for parsing 'LOCAL_TARGET_SDK_VERSION' in androidmk
Update androidmk to enable parsing of 'LOCAL_TARGET_SDK_VERSION' from
an Android.mk and translating it to target_sdk_version in an Android.bp.

Bug: 313336240
Test: m androidmk
Test: androidmk vendor/xts/gts-tests/tests/assist/Android.mk
Change-Id: I465aba3ea7d22a9978fc370a6718a2cfc43dce36
2023-11-28 17:01:00 +08:00
Colin Cross
d079e0b270 Reformat build/soong for go 1.19
Test: none
Change-Id: I132368f0fcbdb5ea088b5b84dbe4ccfdd9e94cad
2022-08-17 10:43:13 -07:00
Cole Faust
1323877b7e Support complicated variable references
Bug: 226974242
Test: go test
Change-Id: Iaec16f5c498e7c75c9ee5d53d3499efadfba16bc
2022-05-10 05:26:35 +00:00
Cole Faust
35b994e1e7 Fix crash in MakeString.EndsWith()
Bug: 226974242
Test: go test
Change-Id: I21ff26d00ed7be145ae2c1175f1438b6e7d60834
2022-04-28 16:08:02 -07:00
Yuntao Xu
b8e80350d2 rewrite android_app to android_test in mk2bp
1. When a converted android_app module has the `test_suites` property,
rewrite the module type to an android_test one;
2. Refactor the existing codes for rewriting cc_binary to cc_test.

Bug: 217650002
Test: add unit and end-to-end tests
Test: TreeHugger
Change-Id: I90d744a2ae93561f63ed8606f37ea4aa26fa6137
2022-04-05 18:40:19 -07:00
Cole Faust
e309a91ca8 Parse variable references with #s
Inside a variable reference, a # does not start
a comment.

Fixes: 218742602
Test: go test
Change-Id: I16cf04c74a8aa30482fd9293175f893e4efb60f1
2022-03-17 17:15:12 -07:00
Trevor Radcliffe
ecdb9f701a Add support for privileged apps to androidmk
Fixes: 221894523
Test: Added unit tests
Test: Manual test
Change-Id: I2285e4e24d94d519ee68dde74edc2d4fb2120146
2022-03-03 15:22:08 +00:00
Yuntao Xu
4cba817e24 mk2bp LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG
Added the support to convert the Make boolean variable
LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG as auto_gen_config
and reverse its value in the androidmk tool.

Bug: 216194235
Test: m androidmk
Test: TreeHugger
Change-Id: Ieb51d52df78b9f8d78b36e864fa1e3489faa8c45
2022-02-08 17:35:28 -08:00
Yuntao Xu
680478266b Add LOCAL_GENERATED_SOURCES to androidmk
Added the LOCAL_GENERATED_SOURCES support to the androidmk tool.

Bug: 216527541
Test: TreeHugger
Change-Id: I05b7aa4be6b50e405ec8ec15765d375a4626cc48
2022-01-31 11:54:43 -08:00
Trevor Radcliffe
82cf9a7d4b Remove res and assets in androidmk if default
Test: new tests in androidmk_test and bpfix_test. Ran against file.
Fixes: 209019903
Change-Id: I5fc9005302c006b3205b4cbd04cef7c2aca40bc8
2022-01-25 23:10:21 +00:00
Liz Kammer
e9ecddc972 Add support for a prebuilt_root_host type.
Test: art-tests
Change-Id: If013e46d2bbd9cc937a11fe7cf3b67eb8b262b55
2022-01-06 12:14:59 -05:00
Yuntao Xu
45513fe80a Support LOCAL_CHECK_ELF_FILES in androidmk tool
Added the support of LOCAL_CHECK_ELF_FILES in the androidmk tool.

Bug: 206162779
Test: m androidmk
Test: TreeHugger
Change-Id: I0864f54259044de2d53686a47094635d4125c071
2021-12-15 20:20:49 -08:00
Yuntao Xu
21be0e26b9 Add tests for converting license in androidmk
1. Added unit tests for license conversions in the androidmk tool, by
using a mocked filesystem;
2. Added integration tests in a shell script with a mocked filesystem.

Bug: 205615944
Test: m androidmk
Test: bash androidmk_test.sh
Test: TreeHugger
Change-Id: Id3d1f914190b52b82aadda7ea019192787b839d6
2021-12-07 11:26:16 -08:00
Yuntao Xu
214cdaf1d4 Handle license conversions in androidmk
1. Support license conversions in the androidmk tool. More details can be
found at go/license-androidmk;
2. As usage examples, locally this functionality has been applied to
aosp/1881088 and aosp/1869664;

Bug: 202964622
Test: m androidmk
Test: manually ran androidmk <typical Android.mk files>
Test: TreeHugger
Change-Id: I7d5013d25ad8961e997109d0378f20f5085e0ecf
2021-11-16 11:41:31 -08:00
Trevor Radcliffe
93295f27e4 Ignore obsolete lines when converting makefiles
Specifically this skips cases where LOCAL_MODULE_PATH
is TARGET_OUT_OPTIONAL_EXECUTABLES or TARGET_OUT_DATA_APPS.

Test: Added tests
Test: Treehugger
Change-Id: Ib64f22fc3936703c665d07dbb25d8ebf3b9f56c5
2021-10-13 17:16:18 +00:00
Trevor Radcliffe
31b48a72d0 Add support for USES_LIBRARIES to androidmk
And OPTIONAL_USES_LIBRARIES. Also includes lint fix.

Fixes: 202163928
Test: Ran tool against development/apps/Development/Android.mk
Test: Added integration test cases
Change-Id: I9c8130b19f05df938f01957852384c0532e73433
2021-10-06 20:28:01 +00:00
Justin Yun
0f922ea335 Convert LOCAL_PRODUCT_SERVICES_MODULE to product_specific
LOCAL_PRODUCT_SERVICES_MODULE is interpreted as LOCAL_PRODUCT_MODULE.
When converting Android.mk to Android.bp, it must be converted to
product_specific.

Bug: 135957588
Test: na
Change-Id: I9298991aef10cc7cb82d40cd667c142e64ee50c6
2021-09-08 10:11:57 +09:00
Sasha Smundak
b051c4ede3 Product config makefiles to Starlark converter
Test: treehugger; internal tests in mk2rbc_test.go
Bug: 172923994
Change-Id: I43120b9c181ef2b8d9453e743233811b0fec268b
2021-07-14 09:51:10 -07:00
Yuntao Xu
f1b75a2377 convert BUILD_CTS_SUPPORT_PACKAGE in mk files
1. Modified the logic of the androidmk tool, to convert the BUILD_CTS_SUPPORT_PACKAGE
field to the android_test_helper_app module type rather than android_test;
2. Updated the unit tests as well.

Bug: 191907322
Test: m androidmk
Test: TreeHugger
Change-Id: Iabff299f6d043521481ef1af457c708353559823
2021-06-24 16:02:31 -07:00
Yuntao Xu
8d87cb0bee Support LOCAL_CERTIFICATE_LINEAGE for androidmk
Added the support of `LOCAL_CERTIFICATE_LINEAGE` for the mk2bp
conversion tool `androidmk`.

Bug: 185169879
Test: rum 'm androidmk'
Test: TreeHugger
Change-Id: I7e89e60be4be26833cac13c911a9b38284a47301
2021-06-08 20:00:47 -07:00
Yuntao Xu
c97761e781 Support LOCAL_ENFORCE_USES_LIBRARIES in androidmk
1. add LOCAL_ENFORCE_USES_LIBRARIES support in the androidmk tool;
2. add one test case.

Bug: 187838385
Test: run 'm androidmk'
Test: TreeHugger
Change-Id: Ibdde2a5a58ef45655a3083b592fa21f7fe63d032
2021-05-11 12:39:54 -07:00
Jaewoong Jung
3ef77e89f0 Make runtime_resource_overlay product specific.
When mk2bp'ing a runtime_resource_overlay module, make it product
specific by default so that it reflects how the current make
configuration works.

Bug: 155783598
Test: bpfix_test.go
Change-Id: Icafa8228fe65ecc5b33ad80ad721e7997fbff383
2021-02-25 18:58:16 -08: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
Jaewoong Jung
18aefc1977 Remove unnecessary snake case variables.
Test: m nothing + TreeHugger
Change-Id: I99f7162944daa6c57c6ae4763261e108bb5cb6b1
2020-12-22 12:38:35 -08:00
Sasha Smundak
d63f7f0846 Add missing export/unexport directives
Test: treehugger
Bug: 172923994
Change-Id: I70494a02d37d149042a4d5772f1cf14b8bbcc06e
2020-12-07 14:15:07 -08:00
Sasha Smundak
cbc17ee62d Fix empty item handling in Split function, rewrite Words function
Test: treehugger
Bug: 172923994
Change-Id: Ic7ee7b1af6e1438df5cf06754b9bec7038b624f2
2020-12-04 17:24:03 -08:00
Sasha Smundak
7890211d58 Fix comments with continuation
Backgound: aog/919954 tried to handle
```
   second line
```

but did it incorrectly. The parser works correctly (so this change
reverts aog/919954), it returns multiline comment, but the serializer
converting the internal representation to Blueprint was not emitting
'//' on the lines after the first.

Test: treehugger
Bug: 127521510
Change-Id: I0257a8b3cc4ffcaa6bea44113ceba66bb99d7e43
2020-11-19 11:52:20 -08:00
Sasha Smundak
9c35d8bfde Parse else ifxxx statement
More recent versions of make provide "else ifdef/ifndef/ifeq/ifneq" directive:
ifdef FOO
...
else ifdef BAR
...
endif
Fix the parser to handle it. It returns the same Directive as the respective ifxxx
counterpart, only that the Name is set to "elifdef/elifndef/elifeq/elifneq".

Test: treehugger
Change-Id: I74c6a2c7224bce1dd3465012fa84880fae21349b
2020-11-17 23:18:14 -08:00
Dan Shi
d79572f73e Add unit_test test option in test configs
This change allows a test (native, java, rust or python) to be included
in host-unit-tests suite when test option `unit_test` is set to true.

Bug: 172006742
Test: m host-unit-tests
Change-Id: I69d3eb5b51198c549e2e6914ceac3a4fc33c3cf2
2020-11-16 11:05:00 -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
Dan Shi
ee0b81a4fe Revert "Implement vts_config module"
This reverts commit ff36da04e8.

Reason for revert: remove vts10 harness and build configs
Bug: 169581727
Bug: 166662663
Test: build

Change-Id: I090b41c99c2279d24f08e4343289cbdcc7934f5d
2020-10-08 10:38:08 -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
Liz Kammer
0449a6337e Add relative_install_path property to prebuilt_etc
This supports a more consistent property across modules for specifying a
subdirectory to install a file into for prebuilt_etc modules.

Updates bpfix to rewrite `sub_dir` to `relative_install_path`.

Test: gotest prebuilt_etc_test
Test: gotest bpfix_test
Bug: 156568187
Change-Id: Idd05cd2178c46e290764a3b708faa8275818ca1e
2020-06-29 10:54:03 -07:00
Liz Kammer
5e4070cb6b Add androidmk error for multiple assignments
Identify variables that are cleared or reassigned, add an error and
prevent reassignment which caused a parser error.

Test: go test androidmk_test
Bug: 112653593
Change-Id: I0db3372b60812ff4cdaebb38a56ed0af0dbdb27e
2020-06-24 10:33:59 -07:00
Liz Kammer
9946f0308f Rename variables with "-" in androidmk
Make variables containg a "-" would succeed the translation to
blueprint, only to fail during the blueprint format step. Rename those
variables with a "-" and update references to them.

Test: androidmk_test.go
Bug: 112653593
Change-Id: Ifcbe1c6749a1e7f1e0b78cd6f01a8f1f52a334d0
2020-06-17 17:20:53 -07:00
Chris Parsons
26cdf135ff When bpfix fails in androidmk, output the tree anyway
This can help with debugging cases where the resulting blueprint file is
invalid.

Test: Manual run of androidmk
Change-Id: I39605afa851aa6cdd8b49cc56386a8fc7347115c
2020-06-09 16:01:51 -04:00
Liz Kammer
6e85e4c2bc Support preprocessed prebuilt tests in androidmk
Adds support to translate app prebuilt tests to android_test_import and
LOCAL_REPLACE_PREBUILT_APK_INSTALLED to preprocessed property.

Test: androidmk_test.go, bpfix_test.go
Bug: 155412211
Change-Id: I77c07c684125adf228ba91911998823a68b3a65d
2020-05-26 09:12:42 -07:00
Liz Kammer
74151f2c8c Add androidmk support for runtime_resource_overlay
Test: androidmk_test.go
Bug: 148673525
Change-Id: I25c277c52b91e9308e15d92364b5504a8f556c9f
2020-05-07 14:40:57 -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
Sasha Smundak
6a9f5cfa1e Emit error if expression cannot be evaluated to boolean during androidmk conversion
Fixes: 127517965
Test: run androidmk /sdx/asmundak/repos/iandr/vendor/google_paintbox/amber/camera/tests/Android.mk
Change-Id: If7b6bcb88bb8f25d3f421a847750a82b1e50833e
2020-02-28 09:18:08 -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