Commit graph

32 commits

Author SHA1 Message Date
Cole Faust
1da0b20575 Allow soong config value variables to set nested properties
Previously, it would error out if it saw anything that wasn't a string
or slice of strings. Now it will also recurse in sub-structs.

Fixes: 326255534
Test: go test
Change-Id: Icbca8e4a2cf54b5610599a10805550fed05eb396
2024-02-21 11:38:09 -08:00
Cole Faust
a03ac3a75a Allow value variables to set pointer properties
Non-null pointers were always leading to an "unsupported property type"
error due to not updating the kind field.

Bug: 319897584
Test: Presubmits
Change-Id: I058ab8d153d9507f9037d699acf6e1fe4f08f538
2024-01-12 14:28:53 -08:00
Colin Cross
3cc3154d33 Remove more bp2build
Bug: 315353489
Test: m blueprint_tests
Change-Id: Ib854fe1a448c258fe086691a6e5ed2d98537f5e4
2024-01-05 09:54:09 -08:00
Liz Kammer
8103dc428e Migrate overlapping config var defs in all bp file
Unlike most module types, config variable handling is always namespaced
to the Android.bp file, which limits reuse of the variable definitions.
Additionally multiple of these module types can define a string variable
in the same config namespace, but specify different valid values for the
string.

Previously, we cached the first instance we see of variable + namespace;
however, this caused non-determinism in which defintion would be used
and not migrating all values. Instead, we now only cache within a single
Android.bp file where the variable definitions are re-used.

Test: go tests
Bug: 271481817
Change-Id: Ic327657c508e47a705bacd24712a1916e105c7cd
2023-03-06 09:15:36 -05:00
Cole Faust
18994c73f1 Replace SortedStringKeys with SortedKeys
Now that we have generics.

Bug: 193460475
Test: presubmits
Change-Id: I1594fd8feb505175d5c09c03ef397e5ffd5b09cb
2023-02-28 16:51:32 -08:00
Paul Duffin
e8b4768134 Avoid separate call to module factory to create conditional properties
Previously, the soong_config_module_type (and related module types)
would make a special call to the module factory of the module type
being customized to get the properties from which it created the
conditional properties. That caused problems when trying to customize
a singleton module. See the bug for more details.

This change avoids that special call by deferring the creation of the
conditional properties struct until just after the
soong_config_module_type's factory function calls the customized module
factory to create the module and properties. The properties are then
used to create the conditional properties struct avoiding the extra
factory call.

The conditional properties struct is only created once per module type
that soong_config_module_type (and related module types) creates.

Bug: 264876909
Test: m nothing
Change-Id: I55dc71d2553cb59d921a96c6458d0bc877512bbb
2023-01-09 16:49:00 +00:00
Cole Faust
acf417b085 Merge "Revert^4 "Prevent unspecified values in soong_config_string_variables"" 2022-11-02 16:56:45 +00:00
Cole Faust
b0a91330bb Revert^4 "Prevent unspecified values in soong_config_string_variables"
This reverts commit b7b2e12475.

Reason for revert: Issues on -plus-aosp branches have been fixed

Change-Id: Ie2f7ce45502b999280e099d9c0f9d0f7d6b7ba08
2022-11-01 17:10:23 +00:00
Victor Liu
2ea00270a3 Merge "Revert "Revert ^2 "Prevent unspecified values in soong_config_st..."" 2022-10-27 19:11:31 +00:00
Brad Hinegardner
b7b2e12475 Revert "Revert ^2 "Prevent unspecified values in soong_config_st..."
Revert submission 2262062-colefaust_soong_config_string_variable_2nd_try

Reason for revert: breaks builds, b/255996492 among others
Reverted Changes:
I3e2f59e5f:Fix typo
Id3bcd9a46:Revert ^2 "Prevent unspecified values in soong_con...

Change-Id: Ifa8ebb3993bf2c716c3ec3c9fdbe72ba019e77ad
2022-10-27 19:01:10 +00:00
Cole Faust
3bd8f0a6e6 Merge "Revert ^2 "Prevent unspecified values in soong_config_string_variable""" 2022-10-27 16:41:29 +00:00
Cole Faust
135d987d7c Revert ^2 "Prevent unspecified values in soong_config_string_variable""
This reverts commit 38944c70c4.

Reason for revert: I believe we're ready for this now, but run build_test 1-4 on internal master for at least master and tm-dev-plus-aosp on go/abtd before submitting

Change-Id: Id3bcd9a46f3087cf2d34dece5294828ea9436788
2022-10-20 00:34:00 +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
Cole Faust
3aa9dacdde Revert^3 "Prevent unspecified values in soong_config_string_variable"
This reverts commit bd86457796.

Reason for revert: More breakages

Change-Id: I9252b62444870d3d16a84254190cefb64e0a4bf3
2022-04-08 00:42:33 +00:00
Cole Faust
bd86457796 Revert^2 "Prevent unspecified values in soong_config_string_variable""
This reverts commit 38944c70c4.

Reason for revert: Reintroduce this change now that fixes have been made in the affected products.

Change-Id: I6a4cb37a75fb108145b9cf10a9c9aaa35fb5ea0b
2022-04-05 21:42:57 +00:00
Andrei-Valentin Onea
38944c70c4 Revert "Prevent unspecified values in soong_config_string_variable"
This reverts commit 542905a280.

Reason for revert: This check is breaking multiple builds, creating fixes to minimize re-land work.

Change-Id: I6431bd0864f49781910dad787e1ba9375b9931b3
2022-03-24 13:52:58 +00:00
Cole Faust
542905a280 Prevent unspecified values in soong_config_string_variable
Currently, setting a soong config string variable to a value
that's not listed just does nothing. Change it so it's an
error instead.

Bug: 220375749
Test: Presubmits
Change-Id: I14c1c76ac556ccb0cbd167c95eb3fd7625a6a52c
2022-03-17 17:01:26 -07:00
Liz Kammer
72beb34609 Add package for printing starlark formatted data
Bug: 216168792
Test: build/bazel/ci/bp2build.sh
Change-Id: I3a06b19396f7ffe1c638042cda7e731dd840f1d6
2022-02-08 17:32:28 -05:00
Jingwen Chen
4ad40d99b0 Add a mutex for soong config var map writes.
Fixes: 207572723
Test: CI
Change-Id: Ide4ca9961b8615186c3ab703c461b6ef53ef656e
2021-11-24 03:42:35 +00:00
Jingwen Chen
01812020c1 Add support for writing all Soong config variables into @soong_injection.
Also remove the need to use bp2build_available on
soong_config_module_types as we want to convert every single of them
into the tree for a complete soong_injection soong_config_variables.bzl
file.

The variables are split into their bool, value and string types
respectively, as they all need to be handled differently on the Bazel
product_platform side, as well as for generating constraint values and
settings. For example, value variables need to integrate with
TemplateVariableInfo, and string variables need to include the string
value itself into the select key/constraint value.

Sample soong_config_variables.bzl file: https://gist.github.com/jin/cef700bfb20c8656a931306dd71d47e1

Test: CI
Bug: 198556411
Change-Id: I8665dd1269a507edb37de62407ed3641564bea5c
2021-11-23 08:37:30 +00:00
Jingwen Chen
a47f28d28e bp2build: add support for soong_config_module_type.
Test: CI, go unit test
Bug: 198556411
Change-Id: Idf862904d51d822f92af0c072341c31b7a02fc64
2021-11-08 13:38:28 +00:00
Colin Cross
997f27aa03 Fix nested properties in soong config structs
Fix recursing into nested properties when creating the structs for
affectable properties in soong config modules.

Fixes: 181156850
Test: Test_createAffectablePropertiesType
Change-Id: I4fb645d7e334977d0bbf192c3b43a7bba8289f49
2021-03-05 17:26:37 -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
Liz Kammer
432bd598ae Add conditions_default for soong config variables.
Each variable can specify a conditions_default for properties to be used
when the variable is not set, not set to a true value (for bools), or is
set to a value that is not present in the module (for strings).

Test: m nothing
Test: go test soong tests
Change-Id: I76ec026da2369b407f0f530f77760f530e7958fc
2021-01-21 14:25:20 -05:00
Liz Kammer
40ddfaae7a Check whether value_variables are set
If value variable had not been set by a user, previously we would error
out. Now, we just skip it.

Test: go test soong tests
Test: m nothing
Change-Id: Ibab67e00b28055b5feee2f4fd79bf4dfb2fc6704
2020-12-17 12:18:37 -08:00
Liz Kammer
fe8853d2e6 Add test & documentation for PropertiesToApply
Document PropertiesToApply expectations about props, and suggest it
should generally be generated via CreateProperties.

Test: go soong tests
Test: m nothing
Change-Id: I7cc2590db96865382ad6e0da333d4a4e2c697f45
2020-12-17 18:59:41 +00: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
Jaewoong Jung
4b79e98a6e Soong package structure refactoring
Give prebuilt_etc and sh_binary their own packages and split the
gigantic main Android.bp up to small, per-package ones.

Test: m nothing, TreeHugger
Bug: 156980228
Change-Id: I7b00cd344b9f16861f1ff39edf0029f016b853d0
2020-06-01 13:44:48 -07:00
Dan Willemsen
b0935db8c3 soong config: add value_variable substitution
There are some cases that aren't handled with the existing variable
types for booleans or known lists of strings. Similarly to our
product_variables that uses %s / %d for things like
PLATFORM_SDK_VERSION, allow vendors to define their own config variables
to be substituted into properties.

For example, some of the makefiles that I've attempted to convert had
the option to pass in version numbers from the board, or the default
display size:

  -DDISPLAY_VERSION=550
  -DDISP_H=1080

These examples happen to be integers, but since our configuration
language (make) doesn't support numbers, %s works just as well.

This change will allow the above to be represented using:

  soong_config_module_type {
      name: "acme_cc_defaults",
      module_type: "cc_defaults",
      config_namespace: "acme",
      value_variables: [
          "DISPLAY_VERSION",
	  "DISP_H",
      ],
      properties: ["cflags"],
  }

  acme_cc_defaults {
      name: "my_defaults",
      soong_config_variables: {
          DISPLAY_VERSION: {
	      cflags: ["-DDISPLAY_VERSION=%s"],
	  },
	  DISP_H: {
	      cflags: ["-DDISP_H=%s"],
	  }
      },
  }

Test: built-in tests
Change-Id: I18f35746b5cc39c304a136980249e886d38c6df6
2020-03-24 07:15:16 -07:00
Dan Willemsen
2b8b89cfa2 soong_config: bool_variables shortcut
Using a lot of boolean variables can become very verbose without adding
really any new information:

      variables: ["a", "b", "c"],
  }

  soong_config_bool_variable {
      name: "a",
  }

  soong_config_bool_variable {
      name: "b",
  }

  soong_config_bool_variable {
      name: "c",
  }

Now turns into:

      bool_variables: ["a", "b", "c"],
  }

Test: built-in tests
Change-Id: If5455a38433431c7ecbce1e5b32cfbb47f42602a
2020-03-23 22:42:32 -07:00
Colin Cross
9d34f35815 Simplify vendor conditionals
Support vendor conditionals with no Go code.

Test: TestSoongConfigModule
Change-Id: I42546e7f17324921ada80f4d8e1cd399830f8dfc
2020-01-24 16:43:40 -08:00