Merge "Revert "Consider non-shipping lunch targets to be future."" into main
diff --git a/CleanSpec.mk b/CleanSpec.mk
index f8c96ff..f562279 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -787,6 +787,10 @@
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/)
$(call add-clean-step, find $(OUT_DIR) -type f -name "*.jar" -print0 | xargs -0 rm -f)
+# Remove obsolete dexpreopt_config artifacts
+$(call add-clean-step, rm -f $(PRODUCT_OUT)/dexpreopt_config/dexpreopt.config)
+$(call add-clean-step, rm -f $(PRODUCT_OUT)/dexpreopt_config/dexpreopt_soong.config)
+
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
diff --git a/ci/Android.bp b/ci/Android.bp
index 066b83f..104f517 100644
--- a/ci/Android.bp
+++ b/ci/Android.bp
@@ -14,6 +14,7 @@
package {
default_applicable_licenses: ["Android-Apache-2.0"],
+ default_team: "trendy_team_adte",
}
python_test_host {
@@ -74,6 +75,7 @@
name: "build_test_suites",
srcs: [
"build_test_suites.py",
+ "optimized_targets.py",
],
}
diff --git a/ci/build_test_suites.py b/ci/build_test_suites.py
index 29ed50e..6e1f88c 100644
--- a/ci/build_test_suites.py
+++ b/ci/build_test_suites.py
@@ -15,11 +15,19 @@
"""Build script for the CI `test_suites` target."""
import argparse
+from dataclasses import dataclass
+import json
import logging
import os
import pathlib
import subprocess
import sys
+from typing import Callable
+import optimized_targets
+
+
+REQUIRED_ENV_VARS = frozenset(['TARGET_PRODUCT', 'TARGET_RELEASE', 'TOP'])
+SOONG_UI_EXE_REL_PATH = 'build/soong/soong_ui.bash'
class Error(Exception):
@@ -35,16 +43,54 @@
self.return_code = return_code
-REQUIRED_ENV_VARS = frozenset(['TARGET_PRODUCT', 'TARGET_RELEASE', 'TOP'])
-SOONG_UI_EXE_REL_PATH = 'build/soong/soong_ui.bash'
+class BuildPlanner:
+ """Class in charge of determining how to optimize build targets.
+
+ Given the build context and targets to build it will determine a final list of
+ targets to build along with getting a set of packaging functions to package up
+ any output zip files needed by the build.
+ """
+
+ def __init__(
+ self,
+ build_context: dict[str, any],
+ args: argparse.Namespace,
+ target_optimizations: dict[str, optimized_targets.OptimizedBuildTarget],
+ ):
+ self.build_context = build_context
+ self.args = args
+ self.target_optimizations = target_optimizations
+
+ def create_build_plan(self):
+
+ if 'optimized_build' not in self.build_context['enabled_build_features']:
+ return BuildPlan(set(self.args.extra_targets), set())
+
+ build_targets = set()
+ packaging_functions = set()
+ for target in self.args.extra_targets:
+ target_optimizer_getter = self.target_optimizations.get(target, None)
+ if not target_optimizer_getter:
+ build_targets.add(target)
+ continue
+
+ target_optimizer = target_optimizer_getter(
+ target, self.build_context, self.args
+ )
+ build_targets.update(target_optimizer.get_build_targets())
+ packaging_functions.add(target_optimizer.package_outputs)
+
+ return BuildPlan(build_targets, packaging_functions)
-def get_top() -> pathlib.Path:
- return pathlib.Path(os.environ['TOP'])
+@dataclass(frozen=True)
+class BuildPlan:
+ build_targets: set[str]
+ packaging_functions: set[Callable[..., None]]
def build_test_suites(argv: list[str]) -> int:
- """Builds the general-tests and any other test suites passed in.
+ """Builds all test suites passed in, optimizing based on the build_context content.
Args:
argv: The command line arguments passed in.
@@ -54,9 +100,14 @@
"""
args = parse_args(argv)
check_required_env()
+ build_context = load_build_context()
+ build_planner = BuildPlanner(
+ build_context, args, optimized_targets.OPTIMIZED_BUILD_TARGETS
+ )
+ build_plan = build_planner.create_build_plan()
try:
- build_everything(args)
+ execute_build_plan(build_plan)
except BuildFailureError as e:
logging.error('Build command failed! Check build_log for details.')
return e.return_code
@@ -64,6 +115,16 @@
return 0
+def parse_args(argv: list[str]) -> argparse.Namespace:
+ argparser = argparse.ArgumentParser()
+
+ argparser.add_argument(
+ 'extra_targets', nargs='*', help='Extra test suites to build.'
+ )
+
+ return argparser.parse_args(argv)
+
+
def check_required_env():
"""Check for required env vars.
@@ -79,43 +140,40 @@
raise Error(f'Missing required environment variables: {t}')
-def parse_args(argv):
- argparser = argparse.ArgumentParser()
+def load_build_context():
+ build_context_path = pathlib.Path(os.environ.get('BUILD_CONTEXT', ''))
+ if build_context_path.is_file():
+ try:
+ with open(build_context_path, 'r') as f:
+ return json.load(f)
+ except json.decoder.JSONDecodeError as e:
+ raise Error(f'Failed to load JSON file: {build_context_path}')
- argparser.add_argument(
- 'extra_targets', nargs='*', help='Extra test suites to build.'
- )
-
- return argparser.parse_args(argv)
+ logging.info('No BUILD_CONTEXT found, skipping optimizations.')
+ return empty_build_context()
-def build_everything(args: argparse.Namespace):
- """Builds all tests (regardless of whether they are needed).
+def empty_build_context():
+ return {'enabled_build_features': []}
- Args:
- args: The parsed arguments.
- Raises:
- BuildFailure: If the build command fails.
- """
- build_command = base_build_command(args, args.extra_targets)
+def execute_build_plan(build_plan: BuildPlan):
+ build_command = []
+ build_command.append(get_top().joinpath(SOONG_UI_EXE_REL_PATH))
+ build_command.append('--make-mode')
+ build_command.extend(build_plan.build_targets)
try:
run_command(build_command)
except subprocess.CalledProcessError as e:
raise BuildFailureError(e.returncode) from e
+ for packaging_function in build_plan.packaging_functions:
+ packaging_function()
-def base_build_command(
- args: argparse.Namespace, extra_targets: set[str]
-) -> list[str]:
- build_command = []
- build_command.append(get_top().joinpath(SOONG_UI_EXE_REL_PATH))
- build_command.append('--make-mode')
- build_command.extend(extra_targets)
-
- return build_command
+def get_top() -> pathlib.Path:
+ return pathlib.Path(os.environ['TOP'])
def run_command(args: list[str], stdout=None):
diff --git a/ci/build_test_suites_test.py b/ci/build_test_suites_test.py
index 08a79a3..a9ff3fb 100644
--- a/ci/build_test_suites_test.py
+++ b/ci/build_test_suites_test.py
@@ -14,7 +14,9 @@
"""Tests for build_test_suites.py"""
+import argparse
from importlib import resources
+import json
import multiprocessing
import os
import pathlib
@@ -27,9 +29,11 @@
import textwrap
import time
from typing import Callable
+import unittest
from unittest import mock
import build_test_suites
import ci_test_lib
+import optimized_targets
from pyfakefs import fake_filesystem_unittest
@@ -80,12 +84,20 @@
with self.assertRaisesRegex(SystemExit, '42'):
build_test_suites.main([])
+ def test_incorrectly_formatted_build_context_raises(self):
+ build_context = self.fake_top.joinpath('build_context')
+ build_context.touch()
+ os.environ['BUILD_CONTEXT'] = str(build_context)
+
+ with self.assert_raises_word(build_test_suites.Error, 'JSON'):
+ build_test_suites.main([])
+
def test_build_success_returns(self):
with self.assertRaisesRegex(SystemExit, '0'):
build_test_suites.main([])
def assert_raises_word(self, cls, word):
- return self.assertRaisesRegex(build_test_suites.Error, rf'\b{word}\b')
+ return self.assertRaisesRegex(cls, rf'\b{word}\b')
def _setup_working_build_env(self):
self.fake_top = pathlib.Path('/fake/top')
@@ -222,6 +234,171 @@
os.kill(p.pid, signal.SIGINT)
+class BuildPlannerTest(unittest.TestCase):
+
+ class TestOptimizedBuildTarget(optimized_targets.OptimizedBuildTarget):
+
+ def __init__(self, output_targets):
+ self.output_targets = output_targets
+
+ def get_build_targets(self):
+ return self.output_targets
+
+ def package_outputs(self):
+ return f'packaging {" ".join(self.output_targets)}'
+
+ def test_build_optimization_off_builds_everything(self):
+ build_targets = {'target_1', 'target_2'}
+ build_planner = self.create_build_planner(
+ build_context=self.create_build_context(optimized_build_enabled=False),
+ build_targets=build_targets,
+ )
+
+ build_plan = build_planner.create_build_plan()
+
+ self.assertSetEqual(build_targets, build_plan.build_targets)
+
+ def test_build_optimization_off_doesnt_package(self):
+ build_targets = {'target_1', 'target_2'}
+ build_planner = self.create_build_planner(
+ build_context=self.create_build_context(optimized_build_enabled=False),
+ build_targets=build_targets,
+ )
+
+ build_plan = build_planner.create_build_plan()
+
+ self.assertEqual(len(build_plan.packaging_functions), 0)
+
+ def test_build_optimization_on_optimizes_target(self):
+ build_targets = {'target_1', 'target_2'}
+ build_planner = self.create_build_planner(
+ build_targets=build_targets,
+ build_context=self.create_build_context(
+ enabled_build_features={self.get_target_flag('target_1')}
+ ),
+ )
+
+ build_plan = build_planner.create_build_plan()
+
+ expected_targets = {self.get_optimized_target_name('target_1'), 'target_2'}
+ self.assertSetEqual(expected_targets, build_plan.build_targets)
+
+ def test_build_optimization_on_packages_target(self):
+ build_targets = {'target_1', 'target_2'}
+ build_planner = self.create_build_planner(
+ build_targets=build_targets,
+ build_context=self.create_build_context(
+ enabled_build_features={self.get_target_flag('target_1')}
+ ),
+ )
+
+ build_plan = build_planner.create_build_plan()
+
+ optimized_target_name = self.get_optimized_target_name('target_1')
+ self.assertIn(
+ f'packaging {optimized_target_name}',
+ self.run_packaging_functions(build_plan),
+ )
+
+ def test_individual_build_optimization_off_doesnt_optimize(self):
+ build_targets = {'target_1', 'target_2'}
+ build_planner = self.create_build_planner(
+ build_targets=build_targets,
+ )
+
+ build_plan = build_planner.create_build_plan()
+
+ self.assertSetEqual(build_targets, build_plan.build_targets)
+
+ def test_individual_build_optimization_off_doesnt_package(self):
+ build_targets = {'target_1', 'target_2'}
+ build_planner = self.create_build_planner(
+ build_targets=build_targets,
+ )
+
+ build_plan = build_planner.create_build_plan()
+
+ expected_packaging_function_outputs = {None, None}
+ self.assertSetEqual(
+ expected_packaging_function_outputs,
+ self.run_packaging_functions(build_plan),
+ )
+
+ def create_build_planner(
+ self,
+ build_targets: set[str],
+ build_context: dict[str, any] = None,
+ args: argparse.Namespace = None,
+ target_optimizations: dict[
+ str, optimized_targets.OptimizedBuildTarget
+ ] = None,
+ ) -> build_test_suites.BuildPlanner:
+ if not build_context:
+ build_context = self.create_build_context()
+ if not args:
+ args = self.create_args(extra_build_targets=build_targets)
+ if not target_optimizations:
+ target_optimizations = self.create_target_optimizations(
+ build_context, build_targets
+ )
+ return build_test_suites.BuildPlanner(
+ build_context, args, target_optimizations
+ )
+
+ def create_build_context(
+ self,
+ optimized_build_enabled: bool = True,
+ enabled_build_features: set[str] = set(),
+ test_context: dict[str, any] = {},
+ ) -> dict[str, any]:
+ build_context = {}
+ build_context['enabled_build_features'] = enabled_build_features
+ if optimized_build_enabled:
+ build_context['enabled_build_features'].add('optimized_build')
+ build_context['test_context'] = test_context
+ return build_context
+
+ def create_args(
+ self, extra_build_targets: set[str] = set()
+ ) -> argparse.Namespace:
+ parser = argparse.ArgumentParser()
+ parser.add_argument('extra_targets', nargs='*')
+ return parser.parse_args(extra_build_targets)
+
+ def create_target_optimizations(
+ self, build_context: dict[str, any], build_targets: set[str]
+ ):
+ target_optimizations = dict()
+ for target in build_targets:
+ target_optimizations[target] = (
+ lambda target, build_context, args: optimized_targets.get_target_optimizer(
+ target,
+ self.get_target_flag(target),
+ build_context,
+ self.TestOptimizedBuildTarget(
+ {self.get_optimized_target_name(target)}
+ ),
+ )
+ )
+
+ return target_optimizations
+
+ def get_target_flag(self, target: str):
+ return f'{target}_enabled'
+
+ def get_optimized_target_name(self, target: str):
+ return f'{target}_optimized'
+
+ def run_packaging_functions(
+ self, build_plan: build_test_suites.BuildPlan
+ ) -> set[str]:
+ output = set()
+ for packaging_function in build_plan.packaging_functions:
+ output.add(packaging_function())
+
+ return output
+
+
def wait_until(
condition_function: Callable[[], bool],
timeout_secs: float = 3.0,
diff --git a/ci/optimized_targets.py b/ci/optimized_targets.py
new file mode 100644
index 0000000..224c8c0
--- /dev/null
+++ b/ci/optimized_targets.py
@@ -0,0 +1,69 @@
+#
+# Copyright 2024, The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from abc import ABC
+
+
+class OptimizedBuildTarget(ABC):
+ """A representation of an optimized build target.
+
+ This class will determine what targets to build given a given build_cotext and
+ will have a packaging function to generate any necessary output zips for the
+ build.
+ """
+
+ def __init__(self, build_context, args):
+ self.build_context = build_context
+ self.args = args
+
+ def get_build_targets(self):
+ pass
+
+ def package_outputs(self):
+ pass
+
+
+class NullOptimizer(OptimizedBuildTarget):
+ """No-op target optimizer.
+
+ This will simply build the same target it was given and do nothing for the
+ packaging step.
+ """
+
+ def __init__(self, target):
+ self.target = target
+
+ def get_build_targets(self):
+ return {self.target}
+
+ def package_outputs(self):
+ pass
+
+
+def get_target_optimizer(target, enabled_flag, build_context, optimizer):
+ if enabled_flag in build_context['enabled_build_features']:
+ return optimizer
+
+ return NullOptimizer(target)
+
+
+# To be written as:
+# 'target': lambda target, build_context, args: get_target_optimizer(
+# target,
+# 'target_enabled_flag',
+# build_context,
+# TargetOptimizer(build_context, args),
+# )
+OPTIMIZED_BUILD_TARGETS = dict()
diff --git a/core/Makefile b/core/Makefile
index 02deadd..823d32e 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1375,30 +1375,7 @@
@echo "make $@: ignoring dependencies"
$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
-else ifeq (true,$(PRODUCT_SUPPORTS_VBOOT)) # BOARD_AVB_ENABLE != true
-
-# $1: boot image target
-define build_boot_supports_vboot
- $(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned
- $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1)
- $(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),boot))
-endef
-
-$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) $(FUTILITY)
- $(call pretty,"Target boot image: $@")
- $(call build_boot_supports_vboot,$@)
-
-$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",boot)
-$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
-
-UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
-
-.PHONY: bootimage-nodeps
-bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) $(FUTILITY)
- @echo "make $@: ignoring dependencies"
- $(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_supports_vboot,$(b)))
-
-else # PRODUCT_SUPPORTS_VBOOT != true
+else # BOARD_AVB_ENABLE != true
# $1: boot image target
define build_boot_novboot
@@ -2233,11 +2210,6 @@
$(if $(PRODUCT_VENDOR_DLKM_VERITY_PARTITION),$(hide) echo "vendor_dlkm_verity_block_device=$(PRODUCT_VENDOR_DLKM_VERITY_PARTITION)" >> $(1))
$(if $(PRODUCT_ODM_DLKM_VERITY_PARTITION),$(hide) echo "odm_dlkm_verity_block_device=$(PRODUCT_ODM_DLKM_VERITY_PARTITION)" >> $(1))
$(if $(PRODUCT_SYSTEM_DLKM_VERITY_PARTITION),$(hide) echo "system_dlkm_verity_block_device=$(PRODUCT_SYSTEM_DLKM_VERITY_PARTITION)" >> $(1))
-$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCT_SUPPORTS_VBOOT)" >> $(1))
-$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCT_VBOOT_SIGNING_KEY)" >> $(1))
-$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1))
-$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(notdir $(FUTILITY))" >> $(1))
-$(if $(PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1))
$(if $(BOARD_AVB_ENABLE), \
$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1)$(newline) \
$(if $(filter $(2),system), \
@@ -2747,15 +2719,9 @@
# $(1): output file
# $(2): optional kernel file
define build-recoveryimage-target
- $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
- $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
- $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_RECOVERY_MKBOOTIMG_ARGS) \
- --output $(1).unsigned, \
- $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
- $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
- $(BOARD_RECOVERY_MKBOOTIMG_ARGS) --output $(1))
- $(if $(filter true,$(PRODUCT_SUPPORTS_VBOOT)), \
- $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1))
+ $(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
+ $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
+ $(BOARD_RECOVERY_MKBOOTIMG_ARGS) --output $(1)
$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(call get-bootimage-partition-size,$(1),boot))), \
$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
@@ -2766,9 +2732,6 @@
endef
recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
-ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
- recoveryimage-deps += $(VBOOT_SIGNER)
-endif
ifeq (true,$(BOARD_AVB_ENABLE))
recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
endif
@@ -4369,7 +4332,7 @@
INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET := $(PRODUCT_OUT)/pvmfw_embedded.avbpubkey
INSTALLED_PVMFW_BINARY_TARGET := $(call module-target-built-files,pvmfw_bin)
INTERNAL_PVMFWIMAGE_FILES := $(call module-target-built-files,pvmfw_img)
-INTERNAL_PVMFW_EMBEDDED_AVBKEY := $(call module-target-built-files,pvmfw_embedded_key)
+INTERNAL_PVMFW_EMBEDDED_AVBKEY := $(call module-target-built-files,pvmfw_embedded_key_pub_bin)
INTERNAL_PVMFW_SYMBOL := $(TARGET_OUT_EXECUTABLES_UNSTRIPPED)/pvmfw
$(call declare-1p-container,$(INSTALLED_PVMFWIMAGE_TARGET),)
@@ -4919,7 +4882,7 @@
$(if $(BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST),\
$(hide) $(foreach partition,$(BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST), \
$(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
- --output $(1)/$(partition).avbpubkey;)) \
+ --output $(1)/$(partition).avbpubkey;))
$(if $(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),\
$(hide) $(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS), \
$(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_$(call to-upper,$(partition))_KEY_PATH) \
@@ -5651,12 +5614,6 @@
resize2fs \
soong_zip \
-ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
-INTERNAL_OTATOOLS_MODULES += \
- futility-host \
- vboot_signer
-endif
-
INTERNAL_OTATOOLS_FILES := \
$(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
@@ -5692,10 +5649,6 @@
$(sort $(shell find external/avb/test/data -type f -name "testkey_*.pem" -o \
-name "atx_metadata.bin"))
endif
-ifeq (true,$(PRODUCT_SUPPORTS_VBOOT))
-INTERNAL_OTATOOLS_PACKAGE_FILES += \
- $(sort $(shell find external/vboot_reference/tests/devkeys -type f))
-endif
INTERNAL_OTATOOLS_RELEASETOOLS := \
$(shell find build/make/tools/releasetools -name "*.pyc" -prune -o \
@@ -7055,18 +7008,19 @@
endif
-$(DEXPREOPT_CONFIG_ZIP): $(SOONG_ZIP)
- $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/dexpreopt_config
-
+$(DEXPREOPT_CONFIG_ZIP): PRIVATE_DEXPREOPT_CONFIG_ZIP_PARAMS :=
ifeq (,$(TARGET_BUILD_UNBUNDLED))
ifneq (,$(DEX_PREOPT_CONFIG_FOR_MAKE))
- $(hide) cp $(DEX_PREOPT_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
+$(DEXPREOPT_CONFIG_ZIP): PRIVATE_DEXPREOPT_CONFIG_ZIP_PARAMS += -e $(notdir $(DEX_PREOPT_CONFIG_FOR_MAKE)) -f $(DEX_PREOPT_CONFIG_FOR_MAKE)
endif
ifneq (,$(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE))
- $(hide) cp $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) $(PRODUCT_OUT)/dexpreopt_config
+$(DEXPREOPT_CONFIG_ZIP): PRIVATE_DEXPREOPT_CONFIG_ZIP_PARAMS += -e $(notdir $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE)) -f $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE)
endif
endif #!TARGET_BUILD_UNBUNDLED
- $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/dexpreopt_config -D $(PRODUCT_OUT)/dexpreopt_config
+
+$(DEXPREOPT_CONFIG_ZIP): $(SOONG_ZIP)
+ $(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/dexpreopt_config
+ $(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/dexpreopt_config -D $(PRODUCT_OUT)/dexpreopt_config $(PRIVATE_DEXPREOPT_CONFIG_ZIP_PARAMS)
.PHONY: dexpreopt_config_zip
dexpreopt_config_zip: $(DEXPREOPT_CONFIG_ZIP)
@@ -7561,6 +7515,10 @@
droidcore-unbundled: $(QEMU_VERIFIED_BOOT_PARAMS)
endif
+
+# Preprocess files for emulator and sdk.
+-include development/build/tools/sdk-preprocess-files.mk
+
# -----------------------------------------------------------------
# The emulator package
ifeq ($(BUILD_EMULATOR),true)
diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk
index c43081e..13a5bc0 100644
--- a/core/android_soong_config_vars.mk
+++ b/core/android_soong_config_vars.mk
@@ -29,6 +29,7 @@
$(call add_soong_config_var,ANDROID,BOARD_USES_ODMIMAGE)
$(call add_soong_config_var,ANDROID,BOARD_USES_RECOVERY_AS_BOOT)
$(call add_soong_config_var,ANDROID,CHECK_DEV_TYPE_VIOLATIONS)
+$(call add_soong_config_var,ANDROID,PLATFORM_SEPOLICY_VERSION)
$(call add_soong_config_var,ANDROID,PLATFORM_SEPOLICY_COMPAT_VERSIONS)
$(call add_soong_config_var,ANDROID,PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT)
$(call add_soong_config_var,ANDROID,TARGET_DYNAMIC_64_32_DRMSERVER)
@@ -60,23 +61,20 @@
# Set this soong config variable to true for now, and cleanup `prefer` as part of b/308187800
$(call add_soong_config_var_value,ANDROID,module_build_from_source,true)
-# Messaging app vars
-ifeq (eng,$(TARGET_BUILD_VARIANT))
-$(call soong_config_set,messaging,build_variant_eng,true)
-endif
-
# Enable SystemUI optimizations by default unless explicitly set.
SYSTEMUI_OPTIMIZE_JAVA ?= true
$(call add_soong_config_var,ANDROID,SYSTEMUI_OPTIMIZE_JAVA)
-# Enable Compose in SystemUI by default.
-SYSTEMUI_USE_COMPOSE ?= true
-$(call add_soong_config_var,ANDROID,SYSTEMUI_USE_COMPOSE)
-
ifdef PRODUCT_AVF_ENABLED
$(call add_soong_config_var_value,ANDROID,avf_enabled,$(PRODUCT_AVF_ENABLED))
endif
+# Enable AVF remote attestation according to the flag value if PRODUCT_AVF_REMOTE_ATTESTATION_DISABLED is not
+# set to true explicitly.
+ifneq (true,$(PRODUCT_AVF_REMOTE_ATTESTATION_DISABLED))
+ $(call add_soong_config_var_value,ANDROID,avf_remote_attestation_enabled,$(RELEASE_AVF_ENABLE_REMOTE_ATTESTATION))
+endif
+
ifdef PRODUCT_AVF_MICRODROID_GUEST_GKI_VERSION
$(call add_soong_config_var_value,ANDROID,avf_microdroid_guest_gki_version,$(PRODUCT_AVF_MICRODROID_GUEST_GKI_VERSION))
endif
@@ -95,6 +93,8 @@
$(call add_soong_config_var_value,ANDROID,release_avf_enable_llpvm_changes,$(RELEASE_AVF_ENABLE_LLPVM_CHANGES))
$(call add_soong_config_var_value,ANDROID,release_avf_enable_multi_tenant_microdroid_vm,$(RELEASE_AVF_ENABLE_MULTI_TENANT_MICRODROID_VM))
$(call add_soong_config_var_value,ANDROID,release_avf_enable_network,$(RELEASE_AVF_ENABLE_NETWORK))
+# TODO(b/341292601): This flag is needed until the V release. We with clean it up after V together
+# with most of the release_avf_ flags here.
$(call add_soong_config_var_value,ANDROID,release_avf_enable_remote_attestation,$(RELEASE_AVF_ENABLE_REMOTE_ATTESTATION))
$(call add_soong_config_var_value,ANDROID,release_avf_enable_vendor_modules,$(RELEASE_AVF_ENABLE_VENDOR_MODULES))
$(call add_soong_config_var_value,ANDROID,release_avf_enable_virt_cpufreq,$(RELEASE_AVF_ENABLE_VIRT_CPUFREQ))
@@ -103,11 +103,15 @@
$(call add_soong_config_var_value,ANDROID,release_binder_death_recipient_weak_from_jni,$(RELEASE_BINDER_DEATH_RECIPIENT_WEAK_FROM_JNI))
+$(call add_soong_config_var_value,ANDROID,release_libpower_no_lock_binder_txn,$(RELEASE_LIBPOWER_NO_LOCK_BINDER_TXN))
+
$(call add_soong_config_var_value,ANDROID,release_package_libandroid_runtime_punch_holes,$(RELEASE_PACKAGE_LIBANDROID_RUNTIME_PUNCH_HOLES))
$(call add_soong_config_var_value,ANDROID,release_selinux_data_data_ignore,$(RELEASE_SELINUX_DATA_DATA_IGNORE))
-
-$(call add_soong_config_var_value,ANDROID,release_write_appcompat_override_system_properties,$(RELEASE_WRITE_APPCOMPAT_OVERRIDE_SYSTEM_PROPERTIES))
+ifneq (,$(filter eng userdebug,$(TARGET_BUILD_VARIANT)))
+ # write appcompat system properties on userdebug and eng builds
+ $(call add_soong_config_var_value,ANDROID,release_write_appcompat_override_system_properties,true)
+endif
# Enable system_server optimizations by default unless explicitly set or if
# there may be dependent runtime jars.
@@ -144,6 +148,7 @@
# Add crashrecovery build flag to soong
$(call soong_config_set,ANDROID,release_crashrecovery_module,$(RELEASE_CRASHRECOVERY_MODULE))
+# Add crashrecovery file move flags to soong, for both platform and module
ifeq (true,$(RELEASE_CRASHRECOVERY_FILE_MOVE))
$(call soong_config_set,ANDROID,crashrecovery_files_in_module,true)
$(call soong_config_set,ANDROID,crashrecovery_files_in_platform,false)
@@ -151,5 +156,9 @@
$(call soong_config_set,ANDROID,crashrecovery_files_in_module,false)
$(call soong_config_set,ANDROID,crashrecovery_files_in_platform,true)
endif
-# Weirdly required because platform_bootclasspath is using AUTO namespace
-$(call soong_config_set,AUTO,release_crashrecovery_module,$(RELEASE_CRASHRECOVERY_MODULE))
+# Required as platform_bootclasspath is using this namespace
+$(call soong_config_set,bootclasspath,release_crashrecovery_module,$(RELEASE_CRASHRECOVERY_MODULE))
+
+# Enable Profiling module. Also used by platform_bootclasspath.
+$(call soong_config_set,ANDROID,release_package_profiling_module,$(RELEASE_PACKAGE_PROFILING_MODULE))
+$(call soong_config_set,bootclasspath,release_package_profiling_module,$(RELEASE_PACKAGE_PROFILING_MODULE))
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 9c7e906..0d72903 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -768,6 +768,10 @@
$(LOCAL_BUILT_MODULE):$(dir)/$(my_installed_module_stem)))) \
$(eval my_compat_dist_config_$(suite) := ))
+ifneq (,$(LOCAL_SOONG_CLASSES_JAR))
+ $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
+ $(eval my_compat_api_map_$(suite) += $(LOCAL_SOONG_CLASSES_JAR)))
+endif
# Auto-generate build config.
ifeq (,$(test_config))
@@ -821,6 +825,12 @@
$(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
$(s):$(dir)/$(n)))))
+ $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
+ $(eval my_compat_api_map_$(suite) += $(foreach f, $(LOCAL_COMPATIBILITY_SUPPORT_FILES), \
+ $(eval p := $(subst :,$(space),$(f))) \
+ $(eval s := $(word 1,$(p))) \
+ $(if $(filter %.apk,$(s)) $(filter %.jar,$(s)),$(s),))))
+
ifneq (,$(test_config))
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
$(eval my_compat_dist_config_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
@@ -863,7 +873,9 @@
$(call filter-copy-pair,$(src_path),$(call append-path,$(dir),$(file)),$(my_installed_test_data)))) \
$(eval my_compat_dist_test_data_$(suite) += \
$(foreach dir, $(call compatibility_suite_dirs,$(suite),$(arch_dir)), \
- $(filter $(my_installed_test_data),$(call append-path,$(dir),$(file)))))))
+ $(filter $(my_installed_test_data),$(call append-path,$(dir),$(file))))) \
+ $(eval my_compat_api_map_$(suite) += \
+ $(if $(filter %.apk,$(src_path)) $(filter %.jar,$(src_path)),$(src_path),))))
endif
else
ifneq ($(my_test_data_file_pairs),)
@@ -873,7 +885,9 @@
$(eval file := $(word 2,$(parts))) \
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
$(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite),$(arch_dir)), \
- $(src_path):$(call append-path,$(dir),$(file))))))
+ $(src_path):$(call append-path,$(dir),$(file)))) \
+ $(eval my_compat_api_map_$(suite) += \
+ $(if $(filter %.apk,$(src_path)) $(filter %.jar,$(src_path)),$(src_path),))))
endif
endif
@@ -885,7 +899,8 @@
$(call create-suite-dependencies)
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
$(eval my_compat_dist_config_$(suite) := ) \
- $(eval my_compat_dist_test_data_$(suite) := ))
+ $(eval my_compat_dist_test_data_$(suite) := ) \
+ $(eval my_compat_api_map_$(suite) := ))
endif # LOCAL_UNINSTALLABLE_MODULE
@@ -950,6 +965,8 @@
$(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE)
ALL_MODULES.$(my_register_name).SOONG_MODULE_TYPE := \
$(ALL_MODULES.$(my_register_name).SOONG_MODULE_TYPE) $(LOCAL_SOONG_MODULE_TYPE)
+ALL_MODULES.$(my_register_name).IS_SOONG_MODULE := \
+ $(if $(filter $(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)),true)
ifndef LOCAL_IS_HOST_MODULE
ALL_MODULES.$(my_register_name).TARGET_BUILT := \
$(ALL_MODULES.$(my_register_name).TARGET_BUILT) $(LOCAL_BUILT_MODULE)
@@ -1108,6 +1125,7 @@
$(LOCAL_JNI_SHARED_LIBRARIES)
endif
+ALL_MODULES.$(my_register_name).TEST_MODULE_CONFIG_BASE := $(LOCAL_TEST_MODULE_CONFIG_BASE)
##########################################################################
## When compiling against API imported module, use API import stub
@@ -1250,6 +1268,8 @@
endif
endif
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=base_rules))
+
###########################################################
# Ensure privileged applications always have LOCAL_PRIVILEGED_MODULE
###########################################################
diff --git a/core/binary.mk b/core/binary.mk
index f86b5a4..77ae6ef 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -1352,6 +1352,8 @@
my_allowed_types := $(my_allowed_ndk_types) native:platform native:platform_vndk
endif
+ALL_MODULES.$(my_register_name).WHOLE_STATIC_LIBS := $(my_whole_static_libraries)
+
my_link_deps := $(addprefix STATIC_LIBRARIES:,$(my_whole_static_libraries) $(my_static_libraries))
ifneq ($(filter-out STATIC_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
my_link_deps += $(addprefix SHARED_LIBRARIES:,$(my_shared_libraries))
diff --git a/core/check_elf_file.mk b/core/check_elf_file.mk
index b5be81f..ec3c4b0 100644
--- a/core/check_elf_file.mk
+++ b/core/check_elf_file.mk
@@ -7,9 +7,12 @@
#
# Inputs:
# - LOCAL_ALLOW_UNDEFINED_SYMBOLS
+# - LOCAL_IGNORE_MAX_PAGE_SIZE
# - LOCAL_BUILT_MODULE
# - LOCAL_IS_HOST_MODULE
# - LOCAL_MODULE_CLASS
+# - TARGET_CHECK_PREBUILT_MAX_PAGE_SIZE
+# - TARGET_MAX_PAGE_SIZE_SUPPORTED
# - intermediates
# - my_installed_module_stem
# - my_prebuilt_src_file
@@ -26,6 +29,21 @@
# In addition to $(my_check_elf_file_shared_lib_files), some file paths are
# added by `resolve-shared-libs-for-elf-file-check` from `core/main.mk`.
$(check_elf_files_stamp): PRIVATE_SHARED_LIBRARY_FILES := $(my_check_elf_file_shared_lib_files)
+
+# For different page sizes to work, we must support a larger max page size
+# as well as properly reflect page size at runtime. Limit this check, since many
+# devices set the max page size (for future proof) than actually use the
+# larger page size.
+ifeq ($(strip $(TARGET_CHECK_PREBUILT_MAX_PAGE_SIZE)),true)
+ifeq ($(strip $(LOCAL_IGNORE_MAX_PAGE_SIZE)),true)
+$(check_elf_files_stamp): PRIVATE_MAX_PAGE_SIZE :=
+else
+$(check_elf_files_stamp): PRIVATE_MAX_PAGE_SIZE := $(TARGET_MAX_PAGE_SIZE_SUPPORTED)
+endif
+else
+$(check_elf_files_stamp): PRIVATE_MAX_PAGE_SIZE :=
+endif
+
$(check_elf_files_stamp): $(my_prebuilt_src_file) $(my_check_elf_file_shared_lib_files) $(CHECK_ELF_FILE) $(LLVM_READOBJ)
@echo Check prebuilt ELF binary: $<
$(hide) mkdir -p $(dir $@)
@@ -33,6 +51,7 @@
$(hide) $(CHECK_ELF_FILE) \
--skip-bad-elf-magic \
--skip-unknown-elf-machine \
+ $(if $(PRIVATE_MAX_PAGE_SIZE),--max-page-size=$(PRIVATE_MAX_PAGE_SIZE)) \
$(if $(PRIVATE_SONAME),--soname $(PRIVATE_SONAME)) \
$(foreach l,$(PRIVATE_SHARED_LIBRARY_FILES),--shared-lib $(l)) \
$(foreach l,$(PRIVATE_SYSTEM_SHARED_LIBRARIES),--system-shared-lib $(l)) \
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index fb42878..6192690 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -106,6 +106,7 @@
LOCAL_HEADER_LIBRARIES:=
LOCAL_HOST_PREFIX:=
LOCAL_HOST_REQUIRED_MODULES:=
+LOCAL_IGNORE_MAX_PAGE_SIZE:=
LOCAL_INIT_RC:=
LOCAL_INJECT_BSSL_HASH:=
LOCAL_INSTALLED_MODULE:=
@@ -259,6 +260,7 @@
LOCAL_SOONG_HEADER_JAR :=
LOCAL_SOONG_INSTALL_PAIRS :=
LOCAL_SOONG_INSTALL_SYMLINKS :=
+LOCAL_SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES:=
LOCAL_SOONG_INSTALLED_MODULE :=
LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=
LOCAL_SOONG_LICENSE_METADATA :=
@@ -297,6 +299,7 @@
LOCAL_TEST_DATA_BINS:=
LOCAL_TEST_MAINLINE_MODULES:=
LOCAL_TEST_MODULE_TO_PROGUARD_WITH:=
+LOCAL_TEST_MODULE_CONFIG_BASE:=
LOCAL_TIDY:=
LOCAL_TIDY_CHECKS:=
LOCAL_TIDY_FLAGS:=
diff --git a/core/config.mk b/core/config.mk
index ce11b1d..9f134d3 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -419,6 +419,13 @@
endif
.KATI_READONLY := TARGET_MAX_PAGE_SIZE_SUPPORTED
+ifdef PRODUCT_CHECK_PREBUILT_MAX_PAGE_SIZE
+ TARGET_CHECK_PREBUILT_MAX_PAGE_SIZE := $(PRODUCT_CHECK_PREBUILT_MAX_PAGE_SIZE)
+else
+ TARGET_CHECK_PREBUILT_MAX_PAGE_SIZE := false
+endif
+.KATI_READONLY := TARGET_CHECK_PREBUILT_MAX_PAGE_SIZE
+
# Boolean variable determining if AOSP relies on bionic's PAGE_SIZE macro.
ifdef PRODUCT_NO_BIONIC_PAGE_SIZE_MACRO
TARGET_NO_BIONIC_PAGE_SIZE_MACRO := $(PRODUCT_NO_BIONIC_PAGE_SIZE_MACRO)
@@ -711,8 +718,6 @@
VERITY_SIGNER := $(HOST_OUT_EXECUTABLES)/verity_signer
BUILD_VERITY_METADATA := $(HOST_OUT_EXECUTABLES)/build_verity_metadata
BUILD_VERITY_TREE := $(HOST_OUT_EXECUTABLES)/build_verity_tree
-FUTILITY := $(HOST_OUT_EXECUTABLES)/futility-host
-VBOOT_SIGNER := $(HOST_OUT_EXECUTABLES)/vboot_signer
DEXDUMP := $(HOST_OUT_EXECUTABLES)/dexdump$(BUILD_EXECUTABLE_SUFFIX)
PROFMAN := $(HOST_OUT_EXECUTABLES)/profman
@@ -1237,25 +1242,29 @@
# consistency with those defined in BoardConfig.mk files.
include $(BUILD_SYSTEM)/android_soong_config_vars.mk
+SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.$(TARGET_PRODUCT).variables
+SOONG_EXTRA_VARIABLES := $(SOONG_OUT_DIR)/soong.$(TARGET_PRODUCT).extra.variables
+
ifeq ($(CALLED_FROM_SETUP),true)
include $(BUILD_SYSTEM)/ninja_config.mk
include $(BUILD_SYSTEM)/soong_config.mk
endif
+SOONG_VARIABLES :=
+SOONG_EXTRA_VARIABLES :=
+
-include external/ltp/android/ltp_package_list.mk
DEFAULT_DATA_OUT_MODULES := ltp $(ltp_packages)
.KATI_READONLY := DEFAULT_DATA_OUT_MODULES
include $(BUILD_SYSTEM)/dumpvar.mk
-ifneq ($(KEEP_VNDK),true)
ifdef BOARD_VNDK_VERSION
BOARD_VNDK_VERSION=
endif
ifdef PLATFORM_VNDK_VERSION
PLATFORM_VNDK_VERSION=
endif
-endif
ifeq (true,$(FULL_SYSTEM_OPTIMIZE_JAVA))
ifeq (false,$(SYSTEM_OPTIMIZE_JAVA))
diff --git a/core/copy_headers.mk b/core/copy_headers.mk
index 397ea62..2e82db7 100644
--- a/core/copy_headers.mk
+++ b/core/copy_headers.mk
@@ -50,4 +50,5 @@
_chFrom :=
_chTo :=
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=COPY_HEADERS))
endif # LOCAL_COPY_HEADERS
diff --git a/core/definitions.mk b/core/definitions.mk
index 40b7980..51def29 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2925,19 +2925,15 @@
echo "Install path: $(patsubst $(PRODUCT_OUT)/%,%,$(PRIVATE_INSTALLED_MODULE))" >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \
echo >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log
endef
-ART_VERIDEX_APPCOMPAT_SCRIPT:=$(HOST_OUT)/bin/appcompat.sh
+ART_VERIDEX_APPCOMPAT:=$(HOST_OUT)/bin/appcompat
define run-appcompat
$(hide) \
- echo "appcompat.sh output:" >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \
- PACKAGING=$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING ANDROID_LOG_TAGS="*:e" $(ART_VERIDEX_APPCOMPAT_SCRIPT) --dex-file=$@ --api-flags=$(INTERNAL_PLATFORM_HIDDENAPI_FLAGS) 2>&1 >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log
+ echo "appcompat output:" >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log && \
+ ANDROID_LOG_TAGS="*:e" $(ART_VERIDEX_APPCOMPAT) --dex-file=$@ 2>&1 >> $(PRODUCT_OUT)/appcompat/$(PRIVATE_MODULE).log
endef
appcompat-files = \
$(AAPT2) \
- $(ART_VERIDEX_APPCOMPAT_SCRIPT) \
- $(INTERNAL_PLATFORM_HIDDENAPI_FLAGS) \
- $(HOST_OUT_EXECUTABLES)/veridex \
- $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/core_dex_intermediates/classes.dex \
- $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/oahl_dex_intermediates/classes.dex
+ $(ART_VERIDEX_APPCOMPAT) \
else
appcompat-header =
run-appcompat =
@@ -3589,11 +3585,14 @@
$(if $(filter $(suite),$(ALL_COMPATIBILITY_SUITES)),,\
$(eval ALL_COMPATIBILITY_SUITES += $(suite)) \
$(eval COMPATIBILITY.$(suite).FILES :=) \
- $(eval COMPATIBILITY.$(suite).MODULES :=)) \
+ $(eval COMPATIBILITY.$(suite).MODULES :=) \
+ $(eval COMPATIBILITY.$(suite).API_MAP_FILES :=)) \
$(eval COMPATIBILITY.$(suite).FILES += \
$$(foreach f,$$(my_compat_dist_$(suite)),$$(call word-colon,2,$$(f))) \
$$(foreach f,$$(my_compat_dist_config_$(suite)),$$(call word-colon,2,$$(f))) \
$$(my_compat_dist_test_data_$(suite))) \
+ $(eval COMPATIBILITY.$(suite).API_MAP_FILES += $$(my_compat_api_map_$(suite))) \
+ $(eval COMPATIBILITY.$(suite).SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES += $(LOCAL_SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES)) \
$(eval ALL_COMPATIBILITY_DIST_FILES += $$(my_compat_dist_$(suite))) \
$(eval COMPATIBILITY.$(suite).MODULES += $$(my_register_name))) \
$(eval $(my_all_targets) : \
diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk
index 151591e..08e2da3 100644
--- a/core/dex_preopt_odex_install.mk
+++ b/core/dex_preopt_odex_install.mk
@@ -202,6 +202,12 @@
endif
ifneq (,$(LOCAL_COMPATIBILITY_SUITE))
LOCAL_ENFORCE_USES_LIBRARIES := false
+
+ # Enable the check for WTS
+ ifneq ($(filter wts,$(LOCAL_COMPATIBILITY_SUITE)),)
+ LOCAL_ENFORCE_USES_LIBRARIES := true
+ endif
+
endif
# Disable the check if the app contains no java code.
diff --git a/core/envsetup.mk b/core/envsetup.mk
index 3271079..c063f60 100644
--- a/core/envsetup.mk
+++ b/core/envsetup.mk
@@ -50,13 +50,6 @@
# Release config
include $(BUILD_SYSTEM)/release_config.mk
-# Set default value of KEEP_VNDK.
-ifeq ($(RELEASE_DEPRECATE_VNDK),true)
- KEEP_VNDK ?= false
-else
- KEEP_VNDK ?= true
-endif
-
# ---------------------------------------------------------------
# Set up version information
include $(BUILD_SYSTEM)/version_util.mk
@@ -82,7 +75,7 @@
# ---------------------------------------------------------------
# The product defaults to generic on hardware
ifeq ($(TARGET_PRODUCT),)
-TARGET_PRODUCT := aosp_arm
+TARGET_PRODUCT := aosp_arm64
endif
diff --git a/core/executable_internal.mk b/core/executable_internal.mk
index fecf4f6..2a76c9d 100644
--- a/core/executable_internal.mk
+++ b/core/executable_internal.mk
@@ -110,4 +110,6 @@
$(LOCAL_BUILT_MODULE): $(my_coverage_path)/$(GCNO_ARCHIVE)
endif
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=EXECUTABLE))
+
endif # skip_build_from_source
diff --git a/core/fuzz_test.mk b/core/fuzz_test.mk
index 8a4b8c3..1181c66 100644
--- a/core/fuzz_test.mk
+++ b/core/fuzz_test.mk
@@ -43,3 +43,5 @@
endif
include $(BUILD_EXECUTABLE)
+
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=FUZZ_TEST))
\ No newline at end of file
diff --git a/core/header_library_internal.mk b/core/header_library_internal.mk
index 35ee1bc..a21c853 100644
--- a/core/header_library_internal.mk
+++ b/core/header_library_internal.mk
@@ -19,3 +19,5 @@
$(LOCAL_BUILT_MODULE):
$(hide) touch $@
+
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=HEADER_LIBRARY))
\ No newline at end of file
diff --git a/core/host_executable_internal.mk b/core/host_executable_internal.mk
index 2ff9ff2..7c79a1e 100644
--- a/core/host_executable_internal.mk
+++ b/core/host_executable_internal.mk
@@ -57,4 +57,6 @@
$(LOCAL_BUILT_MODULE): $(all_objects) $(all_libraries) $(CLANG_CXX)
$(transform-host-o-to-executable)
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=HOST_EXECUTABLE))
+
endif # skip_build_from_source
diff --git a/core/host_java_library.mk b/core/host_java_library.mk
index d45da48..652eb0e 100644
--- a/core/host_java_library.mk
+++ b/core/host_java_library.mk
@@ -124,3 +124,5 @@
ifeq ($(TURBINE_ENABLED),false)
$(eval $(call copy-one-file,$(LOCAL_FULL_CLASSES_JACOCO_JAR),$(full_classes_header_jar)))
endif
+
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=HOST_JAVA_LIBRARY))
\ No newline at end of file
diff --git a/core/host_prebuilt.mk b/core/host_prebuilt.mk
index 79f3ffa..7dc6704 100644
--- a/core/host_prebuilt.mk
+++ b/core/host_prebuilt.mk
@@ -17,3 +17,5 @@
$(call record-module-type,HOST_PREBUILT)
LOCAL_IS_HOST_MODULE := true
include $(BUILD_MULTI_PREBUILT)
+
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=HOST_PREBUILT))
\ No newline at end of file
diff --git a/core/host_shared_library_internal.mk b/core/host_shared_library_internal.mk
index ae8b798..22a02d4 100644
--- a/core/host_shared_library_internal.mk
+++ b/core/host_shared_library_internal.mk
@@ -53,4 +53,6 @@
$(LOCAL_ADDITIONAL_DEPENDENCIES)
$(transform-host-o-to-shared-lib)
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=HOST_SHARED_LIBRARY))
+
endif # skip_build_from_source
diff --git a/core/host_static_library_internal.mk b/core/host_static_library_internal.mk
index 3946aa7..079c45e 100644
--- a/core/host_static_library_internal.mk
+++ b/core/host_static_library_internal.mk
@@ -23,3 +23,5 @@
$(LOCAL_BUILT_MODULE): $(built_whole_libraries)
$(LOCAL_BUILT_MODULE): $(all_objects)
$(transform-host-o-to-static-lib)
+
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=HOST_STATIC_LIBRARY))
\ No newline at end of file
diff --git a/core/java_common.mk b/core/java_common.mk
index 65feb15..a21f062 100644
--- a/core/java_common.mk
+++ b/core/java_common.mk
@@ -32,6 +32,8 @@
else ifneq (,$(LOCAL_SDK_VERSION)$(TARGET_BUILD_USE_PREBUILT_SDKS))
# TODO(ccross): allow 1.9 for current and unbundled once we have SDK system modules
LOCAL_JAVA_LANGUAGE_VERSION := 1.8
+ else ifeq ($(EXPERIMENTAL_TARGET_JAVA_VERSION_21),true)
+ LOCAL_JAVA_LANGUAGE_VERSION := 21
else
LOCAL_JAVA_LANGUAGE_VERSION := 17
endif
diff --git a/core/java_library.mk b/core/java_library.mk
index 3ac03dc..97ce92c 100644
--- a/core/java_library.mk
+++ b/core/java_library.mk
@@ -88,3 +88,5 @@
$(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE)))
endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
+
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=JAVA_LIBRARY))
\ No newline at end of file
diff --git a/core/multi_prebuilt.mk b/core/multi_prebuilt.mk
index c97d481..415401b 100644
--- a/core/multi_prebuilt.mk
+++ b/core/multi_prebuilt.mk
@@ -132,3 +132,5 @@
prebuilt_static_java_libraries :=
prebuilt_is_host :=
prebuilt_module_tags :=
+
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=MULTI_PREBUILT))
\ No newline at end of file
diff --git a/core/native_test.mk b/core/native_test.mk
index 8b49fbd..c12b211 100644
--- a/core/native_test.mk
+++ b/core/native_test.mk
@@ -21,3 +21,5 @@
endif
include $(BUILD_EXECUTABLE)
+
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=NATIVE_TEST))
\ No newline at end of file
diff --git a/core/node_fns.mk b/core/node_fns.mk
index 144eb8b..d2cee9e 100644
--- a/core/node_fns.mk
+++ b/core/node_fns.mk
@@ -203,7 +203,7 @@
$(call _expand-inherited-values,$(1),$(2),$(3),$(4))
$(eval $(1).$(2).inherited :=)
- $(eval _include_stack := $(wordlist 2,9999,$$(_include_stack)))
+ $(eval _include_stack := $(wordlist 2,9999,$(_include_stack)))
endef
#
diff --git a/core/package_internal.mk b/core/package_internal.mk
index a03a62b..a7eb572 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -731,3 +731,5 @@
)
endif
endif
+
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=PACKAGE))
\ No newline at end of file
diff --git a/core/packaging/flags.mk b/core/packaging/flags.mk
index e715fd1..a96ea8f 100644
--- a/core/packaging/flags.mk
+++ b/core/packaging/flags.mk
@@ -22,50 +22,6 @@
# -----------------------------------------------------------------
-# Release Config Flags
-
-# Create a summary file of build flags for each partition
-# $(1): built build flags json file
-# $(2): installed build flags json file
-# $(3): flag names
-define generate-partition-build-flag-file
-$(eval $(strip $(1)): PRIVATE_OUT := $(strip $(1)))
-$(eval $(strip $(1)): PRIVATE_FLAG_NAMES := $(strip $(3)))
-$(strip $(1)):
- mkdir -p $$(dir $$(PRIVATE_OUT))
- echo '{' > $$(PRIVATE_OUT)
- echo '"flags": [' >> $$(PRIVATE_OUT)
- $$(foreach flag, $$(PRIVATE_FLAG_NAMES), \
- ( \
- printf ' { "name": "%s", "value": "%s", ' \
- '$$(flag)' \
- '$$(_ALL_RELEASE_FLAGS.$$(flag).VALUE)' \
- ; \
- printf '"set": "%s", "default": "%s", "declared": "%s" }' \
- '$$(_ALL_RELEASE_FLAGS.$$(flag).SET_IN)' \
- '$$(_ALL_RELEASE_FLAGS.$$(flag).DEFAULT)' \
- '$$(_ALL_RELEASE_FLAGS.$$(flag).DECLARED_IN)' \
- ; \
- printf '$$(if $$(filter $$(lastword $$(PRIVATE_FLAG_NAMES)),$$(flag)),,$$(comma))\n' ; \
- ) >> $$(PRIVATE_OUT) ; \
- )
- echo "]" >> $$(PRIVATE_OUT)
- echo "}" >> $$(PRIVATE_OUT)
-$(call copy-one-file, $(1), $(2))
-endef
-
-$(foreach partition, $(_FLAG_PARTITIONS), \
- $(eval build_flag_summaries.$(partition) := $(PRODUCT_OUT)/$(partition)/etc/build_flags.json) \
- $(eval $(call generate-partition-build-flag-file, \
- $(TARGET_OUT_FLAGS)/$(partition)/build_flags.json, \
- $(build_flag_summaries.$(partition)), \
- $(_ALL_RELEASE_FLAGS.PARTITIONS.$(partition)) \
- ) \
- ) \
-)
-
-
-# -----------------------------------------------------------------
# Aconfig Flags
# Create a summary file of build flags for each partition
diff --git a/core/phony_package.mk b/core/phony_package.mk
index 578d629..c978793 100644
--- a/core/phony_package.mk
+++ b/core/phony_package.mk
@@ -12,3 +12,5 @@
$(hide) echo "Fake: $@"
$(hide) mkdir -p $(dir $@)
$(hide) touch $@
+
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=PHONY_PACKAGE))
\ No newline at end of file
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index 9462640..d5261f4 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -63,3 +63,5 @@
$(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES)
my_prebuilt_src_file :=
+
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=PREBUILT))
\ No newline at end of file
diff --git a/core/product.mk b/core/product.mk
index 15faf7d..5ceccbf 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -32,6 +32,7 @@
# PRODUCT_MAX_PAGE_SIZE_SUPPORTED=65536, the possible values for PAGE_SIZE could be
# 4096, 16384 and 65536.
_product_single_value_vars += PRODUCT_MAX_PAGE_SIZE_SUPPORTED
+_product_single_value_vars += PRODUCT_CHECK_PREBUILT_MAX_PAGE_SIZE
# Boolean variable determining if AOSP relies on bionic's PAGE_SIZE macro.
_product_single_value_vars += PRODUCT_NO_BIONIC_PAGE_SIZE_MACRO
@@ -159,7 +160,6 @@
# List of jars to be included in the ART boot image for testing.
_product_list_vars += PRODUCT_TEST_ONLY_ART_BOOT_IMAGE_JARS
-_product_single_value_vars += PRODUCT_SUPPORTS_VBOOT
_product_list_vars += PRODUCT_SYSTEM_SERVER_APPS
# List of system_server classpath jars on the platform.
_product_list_vars += PRODUCT_SYSTEM_SERVER_JARS
@@ -303,9 +303,6 @@
# This flag implies PRODUCT_USE_DYNAMIC_PARTITIONS.
_product_single_value_vars += PRODUCT_RETROFIT_DYNAMIC_PARTITIONS
-# List of tags that will be used to gate blueprint modules from the build graph
-_product_list_vars += PRODUCT_INCLUDE_TAGS
-
# List of directories that will be used to gate blueprint modules from the build graph
_product_list_vars += PRODUCT_SOURCE_ROOT_DIRS
@@ -426,6 +423,9 @@
# If true, installs a full version of com.android.virt APEX.
_product_single_value_vars += PRODUCT_AVF_ENABLED
+# If false, disable the AVF remote attestaton feature.
+_product_single_value_vars += PRODUCT_AVF_REMOTE_ATTESTATION_DISABLED
+
# If true, kernel with modules will be used for Microdroid VMs.
_product_single_value_vars += PRODUCT_AVF_KERNEL_MODULES_ENABLED
@@ -487,6 +487,11 @@
# Enables 16KB developer option for device if set.
_product_single_value_vars += PRODUCT_16K_DEVELOPER_OPTION
+# If set, adb root will be disabled (really ro.debuggable=0) in userdebug
+# builds. It's already off disabled in user builds. Eng builds are unaffected
+# by this flag.
+_product_single_value_vars += PRODUCT_NOT_DEBUGGABLE_IN_USERDEBUG
+
.KATI_READONLY := _product_single_value_vars _product_list_vars
_product_var_list :=$= $(_product_single_value_vars) $(_product_list_vars)
diff --git a/core/product_config.mk b/core/product_config.mk
index f21c1c4..f939690 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -280,27 +280,6 @@
current_product_makefile :=
-#############################################################################
-# Check product include tag allowlist
-BLUEPRINT_INCLUDE_TAGS_ALLOWLIST := \
- com.android.mainline_go \
- com.android.mainline \
- mainline_module_prebuilt_nightly \
- mainline_module_prebuilt_monthly_release
-.KATI_READONLY := BLUEPRINT_INCLUDE_TAGS_ALLOWLIST
-$(foreach include_tag,$(PRODUCT_INCLUDE_TAGS), \
- $(if $(filter $(include_tag),$(BLUEPRINT_INCLUDE_TAGS_ALLOWLIST)),,\
- $(call pretty-error, $(include_tag) is not in BLUEPRINT_INCLUDE_TAGS_ALLOWLIST: $(BLUEPRINT_INCLUDE_TAGS_ALLOWLIST))))
-# Create default PRODUCT_INCLUDE_TAGS
-ifeq (, $(PRODUCT_INCLUDE_TAGS))
-# Soong analysis is global: even though a module might not be relevant to a specific product (e.g. build_tools for aosp_arm),
-# we still analyse it.
-# This means that in setups where we two have two prebuilts of module_sdk, we need a "default" to use in analysis
-# This should be a no-op in aosp and internal since no Android.bp file contains blueprint_package_includes
-# Use the big android one and main-based prebuilts by default
-PRODUCT_INCLUDE_TAGS += com.android.mainline mainline_module_prebuilt_nightly
-endif
-
# AOSP and Google products currently share the same `apex_contributions` in next.
# This causes issues when building <aosp_product>-next-userdebug in main.
# Create a temporary allowlist to ignore the google apexes listed in `contents` of apex_contributions of `next`
diff --git a/core/release_config.mk b/core/release_config.mk
index e3ec3a0..2898868 100644
--- a/core/release_config.mk
+++ b/core/release_config.mk
@@ -49,9 +49,6 @@
# If this is a google source tree, restrict it to only the one file
# which has OWNERS control. If it isn't let others define their own.
-# TODO: Remove wildcard for build/release one when all branch manifests
-# have updated.
-_must_protobuf :=
config_map_files := $(wildcard build/release/release_config_map.mk) \
$(wildcard vendor/google_shared/build/release/release_config_map.mk) \
$(if $(wildcard vendor/google/release/release_config_map.mk), \
@@ -64,7 +61,7 @@
) \
)
-protobuf_map_files := $(wildcard build/release/release_config_map.textproto) \
+protobuf_map_files := build/release/release_config_map.textproto \
$(wildcard vendor/google_shared/build/release/release_config_map.textproto) \
$(if $(wildcard vendor/google/release/release_config_map.textproto), \
vendor/google/release/release_config_map.textproto, \
@@ -76,6 +73,9 @@
) \
)
+# Remove support for the legacy approach.
+_must_protobuf := true
+
# PRODUCT_RELEASE_CONFIG_MAPS is set by Soong using an initial run of product
# config to capture only the list of config maps needed by the build.
# Keep them in the order provided, but remove duplicates.
@@ -130,7 +130,9 @@
# Disable the build flag in release-config.
_args += --guard=false
endif
- _flags_file:=$(OUT_DIR)/soong/release-config/release_config-$(TARGET_PRODUCT)-$(TARGET_RELEASE).vars
+ _args += --allow-missing=true
+ _flags_dir:=$(OUT_DIR)/soong/release-config
+ _flags_file:=$(_flags_dir)/release_config-$(TARGET_PRODUCT)-$(TARGET_RELEASE).vars
# release-config generates $(_flags_varmk)
_flags_varmk:=$(_flags_file:.vars=.varmk)
$(shell $(OUT_DIR)/release-config $(_args) >$(OUT_DIR)/release-config.out && touch -t 200001010000 $(_flags_varmk))
@@ -138,7 +140,7 @@
ifneq (,$(_final_product_config_pass))
# Save the final version of the config.
$(shell if ! cmp --quiet $(_flags_varmk) $(_flags_file); then cp $(_flags_varmk) $(_flags_file); fi)
- # This will also set _all_release_configs and _used_files for us.
+ # This will also set ALL_RELEASE_CONFIGS_FOR_PRODUCT and _used_files for us.
$(eval include $(_flags_file))
$(KATI_extra_file_deps $(OUT_DIR)/release-config $(protobuf_map_files) $(_flags_file))
else
@@ -148,7 +150,24 @@
_used_files :=
ifeq (,$(_must_protobuf)$(RELEASE_BUILD_FLAGS_IN_PROTOBUF))
_use_protobuf :=
+ else
+ _base_all_release := all_release_configs-$(TARGET_PRODUCT)
+ $(call dist-for-goals,droid,\
+ $(_flags_dir)/$(_base_all_release).pb:build_flags/all_release_configs.pb \
+ $(_flags_dir)/$(_base_all_release).textproto:build_flags/all_release_configs.textproto \
+ $(_flags_dir)/$(_base_all_release).json:build_flags/all_release_configs.json \
+ $(_flags_dir)/inheritance_graph-$(TARGET_PRODUCT).dot:build_flags/inheritance_graph-$(TARGET_PRODUCT).dot \
+ )
+# These are always created, add an empty rule for them to keep ninja happy.
+$(_flags_dir)/inheritance_graph-$(TARGET_PRODUCT).dot:
+ : created by $(OUT_DIR)/release-config
+$(_flags_dir)/$(_base_all_release).pb $(_flags_dir)/$(_base_all_release).textproto $(_flags_dir)/$(_base_all_release).json:
+ : created by $(OUT_DIR)/release-config
+ _base_all_release :=
endif
+ _flags_dir:=
+ _flags_file:=
+ _flags_varmk:=
endif
ifeq (,$(_use_protobuf))
# The .mk files are the canonical source of truth.
@@ -199,9 +218,9 @@
$(error declare-release-config: config $(strip $(1)) must have release config files, override another release config, or both) \
)
$(if $(strip $(4)),$(eval _all_release_configs.$(strip $(1)).ALIAS := true))
- $(eval _all_release_configs := $(sort $(_all_release_configs) $(strip $(1))))
+ $(eval ALL_RELEASE_CONFIGS_FOR_PRODUCT := $(sort $(ALL_RELEASE_CONFIGS_FOR_PRODUCT) $(strip $(1))))
$(if $(strip $(3)), \
- $(if $(filter $(_all_release_configs), $(strip $(3))),
+ $(if $(filter $(ALL_RELEASE_CONFIGS_FOR_PRODUCT), $(strip $(3))),
$(if $(filter $(_all_release_configs.$(strip $(1)).OVERRIDES),$(strip $(3))),,
$(eval _all_release_configs.$(strip $(1)).OVERRIDES := $(_all_release_configs.$(strip $(1)).OVERRIDES) $(strip $(3)))), \
$(error No release config $(strip $(3))) \
@@ -227,13 +246,13 @@
FLAG_DECLARATION_FILES :=
# Verify that all inherited/overridden release configs are declared.
-$(foreach config,$(_all_release_configs),\
+$(foreach config,$(ALL_RELEASE_CONFIGS_FOR_PRODUCT),\
$(foreach r,$(all_release_configs.$(r).OVERRIDES),\
$(if $(strip $(_all_release_configs.$(r).FILES)$(_all_release_configs.$(r).OVERRIDES)),,\
$(error Release config $(config) [declared in: $(_all_release_configs.$(r).DECLARED_IN)] inherits from non-existent $(r).)\
)))
# Verify that alias configs do not have config files.
-$(foreach r,$(_all_release_configs),\
+$(foreach r,$(ALL_RELEASE_CONFIGS_FOR_PRODUCT),\
$(if $(_all_release_configs.$(r).ALIAS),$(if $(_all_release_configs.$(r).FILES),\
$(error Alias release config "$(r)" may not specify release config files $(_all_release_configs.$(r).FILES))\
)))
@@ -248,7 +267,7 @@
# if the variable was completely unset.
TARGET_RELEASE ?= was_unset
ifeq ($(TARGET_RELEASE),was_unset)
- $(error No release config set for target; please set TARGET_RELEASE, or if building on the command line use 'lunch <target>-<release>-<build_type>', where release is one of: $(_all_release_configs))
+ $(error No release config set for target; please set TARGET_RELEASE, or if building on the command line use 'lunch <target>-<release>-<build_type>', where release is one of: $(ALL_RELEASE_CONFIGS_FOR_PRODUCT))
endif
# Instead of leaving this string empty, we want to default to a valid
# setting. Full builds coming through this path is a bug, but in case
@@ -259,8 +278,8 @@
# During pass 1 of product config, using a non-existent release config is not an error.
# We can safely assume that we are doing pass 1 if DUMP_MANY_VARS=="PRODUCT_RELEASE_CONFIG_MAPS".
ifneq (,$(_final_product_config_pass))
- ifeq ($(filter $(_all_release_configs), $(TARGET_RELEASE)),)
- $(error No release config found for TARGET_RELEASE: $(TARGET_RELEASE). Available releases are: $(_all_release_configs))
+ ifeq ($(filter $(ALL_RELEASE_CONFIGS_FOR_PRODUCT), $(TARGET_RELEASE)),)
+ $(error No release config found for TARGET_RELEASE: $(TARGET_RELEASE). Available releases are: $(ALL_RELEASE_CONFIGS_FOR_PRODUCT))
endif
endif
@@ -309,14 +328,13 @@
.KATI_READONLY := TARGET_RELEASE
ifeq (,$(_use_protobuf))
-$(foreach config, $(_all_release_configs), \
+$(foreach config, $(ALL_RELEASE_CONFIGS_FOR_PRODUCT), \
$(eval _all_release_configs.$(config).DECLARED_IN:= ) \
$(eval _all_release_configs.$(config).FILES:= ) \
)
applied_releases:=
# use makefiles
endif
-_all_release_configs:=
config_map_files:=
protobuf_map_files:=
@@ -363,3 +381,4 @@
_can_protobuf :=
_must_protobuf :=
_use_protobuf :=
+
diff --git a/core/shared_library_internal.mk b/core/shared_library_internal.mk
index 2f510d9..ae34cb8 100644
--- a/core/shared_library_internal.mk
+++ b/core/shared_library_internal.mk
@@ -101,4 +101,6 @@
$(LOCAL_BUILT_MODULE): $(my_coverage_path)/$(GCNO_ARCHIVE)
endif
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=SHARED_LIBRARY))
+
endif # skip_build_from_source
diff --git a/core/soong_config.mk b/core/soong_config.mk
index 7300e8c..8948046 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -1,5 +1,4 @@
SOONG_MAKEVARS_MK := $(SOONG_OUT_DIR)/make_vars-$(TARGET_PRODUCT).mk
-SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.$(TARGET_PRODUCT).variables
SOONG_ANDROID_MK := $(SOONG_OUT_DIR)/Android-$(TARGET_PRODUCT).mk
include $(BUILD_SYSTEM)/art_config.mk
@@ -30,6 +29,7 @@
$(call add_json_str, Make_suffix, -$(TARGET_PRODUCT))
$(call add_json_str, BuildId, $(BUILD_ID))
+$(call add_json_str, BuildFingerprintFile, build_fingerprint.txt)
$(call add_json_str, BuildNumberFile, build_number.txt)
$(call add_json_str, BuildHostnameFile, build_hostname.txt)
$(call add_json_str, BuildThumbprintFile, build_thumbprint.txt)
@@ -144,8 +144,6 @@
$(call add_json_list, NativeCoveragePaths, $(NATIVE_COVERAGE_PATHS))
$(call add_json_list, NativeCoverageExcludePaths, $(NATIVE_COVERAGE_EXCLUDE_PATHS))
-$(call add_json_bool, SamplingPGO, $(filter true,$(SAMPLING_PGO)))
-
$(call add_json_bool, ArtUseReadBarrier, $(call invert_bool,$(filter false,$(PRODUCT_ART_USE_READ_BARRIER))))
$(call add_json_str, BtConfigIncludeDir, $(BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR))
$(call add_json_list, DeviceKernelHeaders, $(TARGET_DEVICE_KERNEL_HEADERS) $(TARGET_BOARD_KERNEL_HEADERS) $(TARGET_PRODUCT_KERNEL_HEADERS))
@@ -167,7 +165,6 @@
$(call add_json_list, BootJars, $(PRODUCT_BOOT_JARS))
$(call add_json_list, ApexBootJars, $(filter-out $(APEX_BOOT_JARS_EXCLUDED), $(PRODUCT_APEX_BOOT_JARS)))
-$(call add_json_bool, VndkUseCoreVariant, $(TARGET_VNDK_USE_CORE_VARIANT))
$(call add_json_bool, VndkSnapshotBuildArtifacts, $(VNDK_SNAPSHOT_BUILD_ARTIFACTS))
$(call add_json_map, BuildFlags)
@@ -205,9 +202,6 @@
$(call add_json_bool, Uml, $(filter true,$(TARGET_USER_MODE_LINUX)))
$(call add_json_str, VendorPath, $(TARGET_COPY_OUT_VENDOR))
$(call add_json_str, OdmPath, $(TARGET_COPY_OUT_ODM))
-$(call add_json_str, VendorDlkmPath, $(TARGET_COPY_OUT_VENDOR_DLKM))
-$(call add_json_str, OdmDlkmPath, $(TARGET_COPY_OUT_ODM_DLKM))
-$(call add_json_str, SystemDlkmPath, $(TARGET_COPY_OUT_SYSTEM_DLKM))
$(call add_json_str, ProductPath, $(TARGET_COPY_OUT_PRODUCT))
$(call add_json_str, SystemExtPath, $(TARGET_COPY_OUT_SYSTEM_EXT))
$(call add_json_bool, MinimizeJavaDebugInfo, $(filter true,$(PRODUCT_MINIMIZE_JAVA_DEBUG_INFO)))
@@ -288,7 +282,7 @@
$(call add_json_bool, BoardMoveRecoveryResourcesToVendorBoot, $(filter true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
$(call add_json_str, PrebuiltHiddenApiDir, $(BOARD_PREBUILT_HIDDENAPI_DIR))
-$(call add_json_str, ShippingApiLevel, $(PRODUCT_SHIPPING_API_LEVEL))
+$(call add_json_str, Shipping_api_level, $(PRODUCT_SHIPPING_API_LEVEL))
$(call add_json_list, BuildBrokenPluginValidation, $(BUILD_BROKEN_PLUGIN_VALIDATION))
$(call add_json_bool, BuildBrokenClangProperty, $(filter true,$(BUILD_BROKEN_CLANG_PROPERTY)))
@@ -303,6 +297,7 @@
$(call add_json_bool, BuildBrokenIncorrectPartitionImages, $(filter true,$(BUILD_BROKEN_INCORRECT_PARTITION_IMAGES)))
$(call add_json_list, BuildBrokenInputDirModules, $(BUILD_BROKEN_INPUT_DIR_MODULES))
$(call add_json_bool, BuildBrokenDontCheckSystemSdk, $(filter true,$(BUILD_BROKEN_DONT_CHECK_SYSTEMSDK)))
+$(call add_json_bool, BuildBrokenDupSysprop, $(filter true,$(BUILD_BROKEN_DUP_SYSPROP)))
$(call add_json_list, BuildWarningBadOptionalUsesLibsAllowlist, $(BUILD_WARNING_BAD_OPTIONAL_USES_LIBS_ALLOWLIST))
@@ -319,7 +314,6 @@
$(call add_json_bool, IgnorePrefer32OnDevice, $(filter true,$(IGNORE_PREFER32_ON_DEVICE)))
-$(call add_json_list, IncludeTags, $(PRODUCT_INCLUDE_TAGS))
$(call add_json_list, SourceRootDirs, $(PRODUCT_SOURCE_ROOT_DIRS))
$(call add_json_list, AfdoProfiles, $(ALL_AFDO_PROFILES))
@@ -333,73 +327,10 @@
$(call add_json_bool, ReleaseDefaultModuleBuildFromSource, $(RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE))
-$(call add_json_bool, KeepVndk, $(filter true,$(KEEP_VNDK)))
-
$(call add_json_bool, CheckVendorSeappViolations, $(filter true,$(CHECK_VENDOR_SEAPP_VIOLATIONS)))
$(call add_json_bool, BuildIgnoreApexContributionContents, $(PRODUCT_BUILD_IGNORE_APEX_CONTRIBUTION_CONTENTS))
-$(call add_json_map, PartitionVarsForBazelMigrationOnlyDoNotUse)
- $(call add_json_str, ProductDirectory, $(dir $(INTERNAL_PRODUCT)))
-
- $(call add_json_map,PartitionQualifiedVariables)
- $(foreach image_type,SYSTEM VENDOR CACHE USERDATA PRODUCT SYSTEM_EXT OEM ODM VENDOR_DLKM ODM_DLKM SYSTEM_DLKM, \
- $(call add_json_map,$(call to-lower,$(image_type))) \
- $(call add_json_bool, BuildingImage, $(filter true,$(BUILDING_$(image_type)_IMAGE))) \
- $(call add_json_str, BoardErofsCompressor, $(BOARD_$(image_type)IMAGE_EROFS_COMPRESSOR)) \
- $(call add_json_str, BoardErofsCompressHints, $(BOARD_$(image_type)IMAGE_EROFS_COMPRESS_HINTS)) \
- $(call add_json_str, BoardErofsPclusterSize, $(BOARD_$(image_type)IMAGE_EROFS_PCLUSTER_SIZE)) \
- $(call add_json_str, BoardExtfsInodeCount, $(BOARD_$(image_type)IMAGE_EXTFS_INODE_COUNT)) \
- $(call add_json_str, BoardExtfsRsvPct, $(BOARD_$(image_type)IMAGE_EXTFS_RSV_PCT)) \
- $(call add_json_str, BoardF2fsSloadCompressFlags, $(BOARD_$(image_type)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS)) \
- $(call add_json_str, BoardFileSystemCompress, $(BOARD_$(image_type)IMAGE_FILE_SYSTEM_COMPRESS)) \
- $(call add_json_str, BoardFileSystemType, $(BOARD_$(image_type)IMAGE_FILE_SYSTEM_TYPE)) \
- $(call add_json_str, BoardJournalSize, $(BOARD_$(image_type)IMAGE_JOURNAL_SIZE)) \
- $(call add_json_str, BoardPartitionReservedSize, $(BOARD_$(image_type)IMAGE_PARTITION_RESERVED_SIZE)) \
- $(call add_json_str, BoardPartitionSize, $(BOARD_$(image_type)IMAGE_PARTITION_SIZE)) \
- $(call add_json_str, BoardSquashfsBlockSize, $(BOARD_$(image_type)IMAGE_SQUASHFS_BLOCK_SIZE)) \
- $(call add_json_str, BoardSquashfsCompressor, $(BOARD_$(image_type)IMAGE_SQUASHFS_COMPRESSOR)) \
- $(call add_json_str, BoardSquashfsCompressorOpt, $(BOARD_$(image_type)IMAGE_SQUASHFS_COMPRESSOR_OPT)) \
- $(call add_json_str, BoardSquashfsDisable4kAlign, $(BOARD_$(image_type)IMAGE_SQUASHFS_DISABLE_4K_ALIGN)) \
- $(call add_json_str, ProductBaseFsPath, $(PRODUCT_$(image_type)_BASE_FS_PATH)) \
- $(call add_json_str, ProductHeadroom, $(PRODUCT_$(image_type)_HEADROOM)) \
- $(call add_json_str, ProductVerityPartition, $(PRODUCT_$(image_type)_VERITY_PARTITION)) \
- $(call add_json_str, BoardAvbAddHashtreeFooterArgs, $(BOARD_AVB_$(image_type)_ADD_HASHTREE_FOOTER_ARGS)) \
- $(call add_json_str, BoardAvbKeyPath, $(BOARD_AVB_$(image_type)_KEY_PATH)) \
- $(call add_json_str, BoardAvbAlgorithm, $(BOARD_AVB_$(image_type)_ALGORITHM)) \
- $(call add_json_str, BoardAvbRollbackIndex, $(BOARD_AVB_$(image_type)_ROLLBACK_INDEX)) \
- $(call add_json_str, BoardAvbRollbackIndexLocation, $(BOARD_AVB_$(image_type)_ROLLBACK_INDEX_LOCATION)) \
- $(call end_json_map) \
- )
- $(call end_json_map)
-
- $(call add_json_bool, TargetUserimagesUseExt2, $(filter true,$(TARGET_USERIMAGES_USE_EXT2)))
- $(call add_json_bool, TargetUserimagesUseExt3, $(filter true,$(TARGET_USERIMAGES_USE_EXT3)))
- $(call add_json_bool, TargetUserimagesUseExt4, $(filter true,$(TARGET_USERIMAGES_USE_EXT4)))
-
- $(call add_json_bool, TargetUserimagesSparseExtDisabled, $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)))
- $(call add_json_bool, TargetUserimagesSparseErofsDisabled, $(filter true,$(TARGET_USERIMAGES_SPARSE_EROFS_DISABLED)))
- $(call add_json_bool, TargetUserimagesSparseSquashfsDisabled, $(filter true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED)))
- $(call add_json_bool, TargetUserimagesSparseF2fsDisabled, $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)))
-
- $(call add_json_str, BoardErofsCompressor, $(BOARD_EROFS_COMPRESSOR))
- $(call add_json_str, BoardErofsCompressorHints, $(BOARD_EROFS_COMPRESS_HINTS))
- $(call add_json_str, BoardErofsPclusterSize, $(BOARD_EROFS_PCLUSTER_SIZE))
- $(call add_json_str, BoardErofsShareDupBlocks, $(BOARD_EROFS_SHARE_DUP_BLOCKS))
- $(call add_json_str, BoardErofsUseLegacyCompression, $(BOARD_EROFS_USE_LEGACY_COMPRESSION))
- $(call add_json_str, BoardExt4ShareDupBlocks, $(BOARD_EXT4_SHARE_DUP_BLOCKS))
- $(call add_json_str, BoardFlashLogicalBlockSize, $(BOARD_FLASH_LOGICAL_BLOCK_SIZE))
- $(call add_json_str, BoardFlashEraseBlockSize, $(BOARD_FLASH_ERASE_BLOCK_SIZE))
-
- $(call add_json_bool, BoardUsesRecoveryAsBoot, $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
- $(call add_json_bool, ProductUseDynamicPartitionSize, $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)))
- $(call add_json_bool, CopyImagesForTargetFilesZip, $(filter true,$(COPY_IMAGES_FOR_TARGET_FILES_ZIP)))
-
- $(call add_json_bool, BoardAvbEnable, $(filter true,$(BOARD_AVB_ENABLE)))
-
- $(call add_json_list, ProductPackages, $(sort $(PRODUCT_PACKAGES)))
-$(call end_json_map)
-
$(call add_json_bool, BuildFromSourceStub, $(findstring true,$(PRODUCT_BUILD_FROM_SOURCE_STUB) $(BUILD_FROM_SOURCE_STUB)))
$(call add_json_bool, HiddenapiExportableStubs, $(filter true,$(PRODUCT_HIDDEN_API_EXPORTABLE_STUBS)))
@@ -426,4 +357,6 @@
rm $(SOONG_VARIABLES).tmp; \
fi)
+include $(BUILD_SYSTEM)/soong_extra_config.mk
+
endif # CONFIGURE_SOONG
diff --git a/core/soong_extra_config.mk b/core/soong_extra_config.mk
new file mode 100644
index 0000000..c2b4775
--- /dev/null
+++ b/core/soong_extra_config.mk
@@ -0,0 +1,103 @@
+$(call json_start)
+
+$(call add_json_str, DeviceCpuVariantRuntime, $(TARGET_CPU_VARIANT_RUNTIME))
+$(call add_json_str, DeviceAbiList, $(TARGET_CPU_ABI_LIST))
+$(call add_json_str, DeviceAbiList32, $(TARGET_CPU_ABI_LIST_32_BIT))
+$(call add_json_str, DeviceAbiList64, $(TARGET_CPU_ABI_LIST_64_BIT))
+$(call add_json_str, DeviceSecondaryCpuVariantRuntime, $(TARGET_2ND_CPU_VARIANT_RUNTIME))
+
+$(call add_json_str, Dex2oatTargetCpuVariantRuntime, $(DEX2OAT_TARGET_CPU_VARIANT_RUNTIME))
+$(call add_json_str, Dex2oatTargetInstructionSetFeatures, $(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES))
+$(call add_json_str, SecondaryDex2oatCpuVariantRuntime, $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT_RUNTIME))
+$(call add_json_str, SecondaryDex2oatInstructionSetFeatures, $($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES))
+
+$(call add_json_str, BoardPlatform, $(TARGET_BOARD_PLATFORM))
+$(call add_json_str, BoardShippingApiLevel, $(BOARD_SHIPPING_API_LEVEL))
+$(call add_json_str, ShippingApiLevel, $(PRODUCT_SHIPPING_API_LEVEL))
+$(call add_json_str, ShippingVendorApiLevel, $(PRODUCT_SHIPPING_VENDOR_API_LEVEL))
+
+$(call add_json_str, ProductModel, $(PRODUCT_MODEL))
+$(call add_json_str, ProductModelForAttestation, $(PRODUCT_MODEL_FOR_ATTESTATION))
+$(call add_json_str, ProductBrandForAttestation, $(PRODUCT_BRAND_FOR_ATTESTATION))
+$(call add_json_str, ProductNameForAttestation, $(PRODUCT_NAME_FOR_ATTESTATION))
+$(call add_json_str, ProductDeviceForAttestation, $(PRODUCT_DEVICE_FOR_ATTESTATION))
+$(call add_json_str, ProductManufacturerForAttestation, $(PRODUCT_MANUFACTURER_FOR_ATTESTATION))
+
+$(call add_json_str, SystemBrand, $(PRODUCT_SYSTEM_BRAND))
+$(call add_json_str, SystemDevice, $(PRODUCT_SYSTEM_DEVICE))
+$(call add_json_str, SystemManufacturer, $(PRODUCT_SYSTEM_MANUFACTURER))
+$(call add_json_str, SystemModel, $(PRODUCT_SYSTEM_MODEL))
+$(call add_json_str, SystemName, $(PRODUCT_SYSTEM_NAME))
+
+# Collapses ?= and = operators for system property variables. Also removes double quotes to prevent
+# malformed JSON. This change aligns with the existing behavior of sysprop.mk, which passes property
+# variables to the echo command, effectively discarding surrounding double quotes.
+define collapse-prop-pairs
+$(subst ",,$(call collapse-pairs,$(call collapse-pairs,$$($(1)),?=),=))
+endef
+
+$(call add_json_list, PRODUCT_SYSTEM_PROPERTIES, $(call collapse-prop-pairs,PRODUCT_SYSTEM_PROPERTIES))
+$(call add_json_list, PRODUCT_SYSTEM_DEFAULT_PROPERTIES, $(call collapse-prop-pairs,PRODUCT_SYSTEM_DEFAULT_PROPERTIES))
+$(call add_json_list, PRODUCT_SYSTEM_EXT_PROPERTIES, $(call collapse-prop-pairs,PRODUCT_SYSTEM_EXT_PROPERTIES))
+$(call add_json_list, PRODUCT_VENDOR_PROPERTIES, $(call collapse-prop-pairs,PRODUCT_VENDOR_PROPERTIES))
+$(call add_json_list, PRODUCT_PRODUCT_PROPERTIES, $(call collapse-prop-pairs,PRODUCT_PRODUCT_PROPERTIES))
+$(call add_json_list, PRODUCT_ODM_PROPERTIES, $(call collapse-prop-pairs,PRODUCT_ODM_PROPERTIES))
+$(call add_json_list, PRODUCT_PROPERTY_OVERRIDES, $(call collapse-prop-pairs,PRODUCT_PROPERTY_OVERRIDES))
+
+$(call add_json_str, BootloaderBoardName, $(TARGET_BOOTLOADER_BOARD_NAME))
+
+$(call add_json_bool, SdkBuild, $(filter sdk sdk_addon,$(MAKECMDGOALS)))
+
+_config_enable_uffd_gc := \
+ $(firstword $(OVERRIDE_ENABLE_UFFD_GC) $(PRODUCT_ENABLE_UFFD_GC) default)
+$(call add_json_str, EnableUffdGc, $(_config_enable_uffd_gc))
+_config_enable_uffd_gc :=
+
+$(call add_json_str, SystemServerCompilerFilter, $(PRODUCT_SYSTEM_SERVER_COMPILER_FILTER))
+
+$(call add_json_bool, Product16KDeveloperOption, $(filter true,$(PRODUCT_16K_DEVELOPER_OPTION)))
+
+$(call add_json_str, RecoveryDefaultRotation, $(TARGET_RECOVERY_DEFAULT_ROTATION))
+$(call add_json_str, RecoveryOverscanPercent, $(TARGET_RECOVERY_OVERSCAN_PERCENT))
+$(call add_json_str, RecoveryPixelFormat, $(TARGET_RECOVERY_PIXEL_FORMAT))
+
+ifdef AB_OTA_UPDATER
+$(call add_json_bool, AbOtaUpdater, $(filter true,$(AB_OTA_UPDATER)))
+$(call add_json_str, AbOtaPartitions, $(subst $(space),$(comma),$(sort $(AB_OTA_PARTITIONS))))
+endif
+
+ifdef PRODUCT_USE_DYNAMIC_PARTITIONS
+$(call add_json_bool, UseDynamicPartitions, $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)))
+endif
+
+ifdef PRODUCT_RETROFIT_DYNAMIC_PARTITIONS
+$(call add_json_bool, RetrofitDynamicPartitions, $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)))
+endif
+
+$(call add_json_bool, DontUseVabcOta, $(filter true,$(BOARD_DONT_USE_VABC_OTA)))
+
+$(call add_json_bool, FullTreble, $(filter true,$(PRODUCT_FULL_TREBLE)))
+
+$(call add_json_bool, NoBionicPageSizeMacro, $(filter true,$(PRODUCT_NO_BIONIC_PAGE_SIZE_MACRO)))
+
+$(call add_json_bool, PropertySplitEnabled, $(filter true,$(BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED)))
+
+$(call add_json_str, ScreenDensity, $(TARGET_SCREEN_DENSITY))
+
+$(call add_json_bool, UsesVulkan, $(filter true,$(TARGET_USES_VULKAN)))
+
+$(call add_json_bool, ZygoteForce64, $(filter true,$(ZYGOTE_FORCE_64)))
+
+$(call add_json_str, VendorSecurityPatch, $(VENDOR_SECURITY_PATCH))
+$(call add_json_str, VendorImageFileSystemType, $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE))
+
+$(call json_end)
+
+$(shell mkdir -p $(dir $(SOONG_EXTRA_VARIABLES)))
+$(file >$(SOONG_EXTRA_VARIABLES).tmp,$(json_contents))
+
+$(shell if ! cmp -s $(SOONG_EXTRA_VARIABLES).tmp $(SOONG_EXTRA_VARIABLES); then \
+ mv $(SOONG_EXTRA_VARIABLES).tmp $(SOONG_EXTRA_VARIABLES); \
+ else \
+ rm $(SOONG_EXTRA_VARIABLES).tmp; \
+ fi)
diff --git a/core/static_java_library.mk b/core/static_java_library.mk
index 4a72a1f..dd1d8b5 100644
--- a/core/static_java_library.mk
+++ b/core/static_java_library.mk
@@ -229,3 +229,5 @@
aar_classes_jar :=
all_res_assets :=
LOCAL_IS_STATIC_JAVA_LIBRARY :=
+
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=STATIC_JAVA_LIBRARY))
\ No newline at end of file
diff --git a/core/static_library_internal.mk b/core/static_library_internal.mk
index 0392460..844360e 100644
--- a/core/static_library_internal.mk
+++ b/core/static_library_internal.mk
@@ -41,3 +41,5 @@
$(intermediates)/$(GCNO_ARCHIVE) : $(LOCAL_GCNO_FILES) $(built_whole_gcno_libraries)
$(package-coverage-files)
endif
+
+$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=STATIC_LIBRARY))
\ No newline at end of file
diff --git a/core/sysprop_config.mk b/core/sysprop_config.mk
index e8428c8..6e3da72 100644
--- a/core/sysprop_config.mk
+++ b/core/sysprop_config.mk
@@ -195,6 +195,7 @@
user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT))
enable_target_debugging := true
+enable_dalvik_lock_contention_logging := true
ifneq (,$(user_variant))
# Target is secure in user builds.
ADDITIONAL_SYSTEM_PROPERTIES += ro.secure=1
@@ -207,6 +208,13 @@
ifneq ($(user_variant),userdebug)
# Disable debugging in plain user builds.
enable_target_debugging :=
+ enable_dalvik_lock_contention_logging :=
+ else
+ # Disable debugging in userdebug builds if PRODUCT_NOT_DEBUGGABLE_IN_USERDEBUG
+ # is set.
+ ifneq (,$(strip $(PRODUCT_NOT_DEBUGGABLE_IN_USERDEBUG)))
+ enable_target_debugging :=
+ endif
endif
# Disallow mock locations by default for user builds
@@ -221,16 +229,22 @@
ADDITIONAL_SYSTEM_PROPERTIES += ro.allow.mock.location=1
endif # !user_variant
+ifeq (true,$(strip $(enable_dalvik_lock_contention_logging)))
+ # Enable Dalvik lock contention logging.
+ ADDITIONAL_SYSTEM_PROPERTIES += dalvik.vm.lockprof.threshold=500
+endif # !enable_dalvik_lock_contention_logging
+
ifeq (true,$(strip $(enable_target_debugging)))
# Target is more debuggable and adbd is on by default
ADDITIONAL_SYSTEM_PROPERTIES += ro.debuggable=1
- # Enable Dalvik lock contention logging.
- ADDITIONAL_SYSTEM_PROPERTIES += dalvik.vm.lockprof.threshold=500
else # !enable_target_debugging
# Target is less debuggable and adbd is off by default
ADDITIONAL_SYSTEM_PROPERTIES += ro.debuggable=0
endif # !enable_target_debugging
+enable_target_debugging:=
+enable_dalvik_lock_contention_logging:=
+
ifneq ($(filter sdk sdk_addon,$(MAKECMDGOALS)),)
_is_sdk_build := true
endif
diff --git a/core/tasks/art.mk b/core/tasks/art.mk
new file mode 100644
index 0000000..ded6125
--- /dev/null
+++ b/core/tasks/art.mk
@@ -0,0 +1,26 @@
+# Copyright (C) 2024 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+########################################################################
+# clean-oat rules
+#
+
+.PHONY: clean-oat
+clean-oat: clean-oat-host clean-oat-target
+
+.PHONY: clean-oat-host
+clean-oat-host:
+ find $(OUT_DIR) '(' -name '*.oat' -o -name '*.odex' -o -name '*.art' -o -name '*.vdex' ')' -a -type f | xargs rm -f
+ rm -rf $(TMPDIR)/*/test-*/dalvik-cache/*
+ rm -rf $(TMPDIR)/android-data/dalvik-cache/*
diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk
index b9f0988..2e2ea79 100644
--- a/core/tasks/cts.mk
+++ b/core/tasks/cts.mk
@@ -16,6 +16,8 @@
test_suite_tradefed := cts-tradefed
test_suite_dynamic_config := cts/tools/cts-tradefed/DynamicConfig.xml
test_suite_readme := cts/tools/cts-tradefed/README
+test_suite_tools := $(HOST_OUT_JAVA_LIBRARIES)/ats_console_deploy.jar \
+ $(HOST_OUT_JAVA_LIBRARIES)/ats_olc_server_local_mode_deploy.jar
$(call declare-1p-target,$(test_suite_dynamic_config),cts)
$(call declare-1p-target,$(test_suite_readme),cts)
diff --git a/core/tasks/device-tests.mk b/core/tasks/device-tests.mk
index 4167a7e..5850c4e 100644
--- a/core/tasks/device-tests.mk
+++ b/core/tasks/device-tests.mk
@@ -27,9 +27,9 @@
$(device-tests-zip) : PRIVATE_device_tests_list := $(PRODUCT_OUT)/device-tests_list
$(device-tests-zip) : PRIVATE_HOST_SHARED_LIBS := $(my_host_shared_lib_for_device_tests)
$(device-tests-zip) : PRIVATE_device_host_shared_libs_zip := $(device_tests_host_shared_libs_zip)
-$(device-tests-zip) : $(COMPATIBILITY.device-tests.FILES) $(my_host_shared_lib_for_device_tests) $(SOONG_ZIP)
+$(device-tests-zip) : $(COMPATIBILITY.device-tests.FILES) $(COMPATIBILITY.device-tests.SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES) $(my_host_shared_lib_for_device_tests) $(SOONG_ZIP)
rm -f $@-shared-libs.list
- echo $(sort $(COMPATIBILITY.device-tests.FILES)) | tr " " "\n" > $@.list
+ echo $(sort $(COMPATIBILITY.device-tests.FILES) $(COMPATIBILITY.device-tests.SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES)) | tr " " "\n" > $@.list
grep $(HOST_OUT_TESTCASES) $@.list > $@-host.list || true
grep -e .*\\.config$$ $@-host.list > $@-host-test-configs.list || true
$(hide) for shared_lib in $(PRIVATE_HOST_SHARED_LIBS); do \
diff --git a/core/tasks/general-tests.mk b/core/tasks/general-tests.mk
index cae71e4..d6fc072 100644
--- a/core/tasks/general-tests.mk
+++ b/core/tasks/general-tests.mk
@@ -47,11 +47,11 @@
$(general_tests_zip) : PRIVATE_TOOLS := $(general_tests_tools)
$(general_tests_zip) : PRIVATE_INTERMEDIATES_DIR := $(intermediates_dir)
$(general_tests_zip) : PRIVATE_general_tests_configs_zip := $(general_tests_configs_zip)
-$(general_tests_zip) : $(COMPATIBILITY.general-tests.FILES) $(general_tests_tools) $(SOONG_ZIP)
+$(general_tests_zip) : $(COMPATIBILITY.general-tests.FILES) $(COMPATIBILITY.general-tests.SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES) $(general_tests_tools) $(SOONG_ZIP)
rm -rf $(PRIVATE_INTERMEDIATES_DIR)
rm -f $@ $(PRIVATE_general_tests_list_zip)
mkdir -p $(PRIVATE_INTERMEDIATES_DIR) $(PRIVATE_INTERMEDIATES_DIR)/tools
- echo $(sort $(COMPATIBILITY.general-tests.FILES)) | tr " " "\n" > $(PRIVATE_INTERMEDIATES_DIR)/list
+ echo $(sort $(COMPATIBILITY.general-tests.FILES) $(COMPATIBILITY.general-tests.SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES)) | tr " " "\n" > $(PRIVATE_INTERMEDIATES_DIR)/list
find $(PRIVATE_KERNEL_LTP_HOST_OUT) >> $(PRIVATE_INTERMEDIATES_DIR)/list
grep $(HOST_OUT_TESTCASES) $(PRIVATE_INTERMEDIATES_DIR)/list > $(PRIVATE_INTERMEDIATES_DIR)/host.list || true
grep $(TARGET_OUT_TESTCASES) $(PRIVATE_INTERMEDIATES_DIR)/list > $(PRIVATE_INTERMEDIATES_DIR)/target.list || true
diff --git a/core/tasks/mcts.mk b/core/tasks/mcts.mk
new file mode 100644
index 0000000..09a4191
--- /dev/null
+++ b/core/tasks/mcts.mk
@@ -0,0 +1,32 @@
+# Copyright (C) 2023 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ifneq ($(wildcard test/mts/README.md),)
+
+mcts_test_suites :=
+mcts_test_suites += mcts
+
+$(foreach module, $(mts_modules), $(eval mcts_test_suites += mcts-$(module)))
+
+$(foreach suite, $(mcts_test_suites), \
+ $(eval test_suite_name := $(suite)) \
+ $(eval test_suite_tradefed := mts-tradefed) \
+ $(eval test_suite_readme := test/mts/README.md) \
+ $(eval include $(BUILD_SYSTEM)/tasks/tools/compatibility.mk) \
+ $(eval .PHONY: $(suite)) \
+ $(eval $(suite): $(compatibility_zip)) \
+ $(eval $(call dist-for-goals, $(suite), $(compatibility_zip))) \
+)
+
+endif
diff --git a/core/tasks/meta-lic.mk b/core/tasks/meta-lic.mk
index c41de63..3520a32 100644
--- a/core/tasks/meta-lic.mk
+++ b/core/tasks/meta-lic.mk
@@ -30,6 +30,23 @@
$(eval $(call declare-1p-copy-files,device/google/atv,atv-component-overrides.xml))
$(eval $(call declare-1p-copy-files,device/google/atv,tv_core_hardware.xml))
+# Moved here from device/google/bramble/Android.mk
+$(eval $(call declare-copy-files-license-metadata,device/google/bramble,default-permissions.xml,SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,))
+$(eval $(call declare-copy-files-license-metadata,device/google/bramble,libnfc-nci.conf,SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,))
+$(eval $(call declare-copy-files-license-metadata,device/google/bramble,fstab.postinstall,SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,))
+$(eval $(call declare-copy-files-license-metadata,device/google/bramble,ueventd.rc,SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,))
+$(eval $(call declare-copy-files-license-metadata,device/google/bramble,wpa_supplicant.conf,SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,))
+$(eval $(call declare-copy-files-license-metadata,device/google/bramble,hals.conf,SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,))
+$(eval $(call declare-copy-files-license-metadata,device/google/bramble,media_profiles_V1_0.xml,SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,))
+$(eval $(call declare-copy-files-license-metadata,device/google/bramble,media_codecs_performance.xml,SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,))
+$(eval $(call declare-copy-files-license-metadata,device/google/bramble,device_state_configuration.xml,SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,))
+$(eval $(call declare-copy-files-license-metadata,device/google/bramble,task_profiles.json,SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,))
+$(eval $(call declare-copy-files-license-metadata,device/google/bramble,p2p_supplicant.conf,SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,))
+$(eval $(call declare-copy-files-license-metadata,device/google/bramble,wpa_supplicant.conf,SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,))
+$(eval $(call declare-copy-files-license-metadata,device/google/bramble,wpa_supplicant_overlay.conf,SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,))
+
+$(eval $(call declare-1p-copy-files,device/google/bramble,audio_policy_configuration.xml))
+
# Moved here from device/google/barbet/Android.mk
$(eval $(call declare-copy-files-license-metadata,device/google/barbet,default-permissions.xml,SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,))
$(eval $(call declare-copy-files-license-metadata,device/google/barbet,libnfc-nci.conf,SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,))
@@ -147,3 +164,27 @@
# Moved here from hardware/interfaces/tv/Android.mk
$(eval $(call declare-1p-copy-files,hardware/interfaces/tv,tuner_vts_config_1_0.xml))
$(eval $(call declare-1p-copy-files,hardware/interfaces/tv,tuner_vts_config_1_1.xml))
+
+# Moved here from device/generic/goldfish/Android.mk
+$(eval $(call declare-1p-copy-files,device/generic/goldfish/data,))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish/input,))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish/wifi,))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish/camera,))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish,hals.conf))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish,init.qemu-adb-keys.sh))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish,init.system_ext.rc))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish,.json))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish,ueventd.rc))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish,wpa_supplicant.conf))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish,media_profiles_V1_0.xml))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish,init.ranchu.rc))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish,fstab.ranchu))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish,display_settings.xml))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish,display_settings_freeform.xml))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish,device_state_configuration.xml))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish,init.ranchu-core.sh))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish,init.ranchu-net.sh))
+$(eval $(call declare-1p-copy-files,device/generic/goldfish,audio_policy_configuration.xml))
+
+# Moved here from packages/services/Car/Android.mk
+$(eval $(call declare-1p-copy-files,packages/services/Car,))
diff --git a/core/tasks/module-info.mk b/core/tasks/module-info.mk
index daa7089..7593668 100644
--- a/core/tasks/module-info.mk
+++ b/core/tasks/module-info.mk
@@ -49,6 +49,7 @@
$(call write-optional-json-list, "supported_variants", $(sort $(ALL_MODULES.$(m).SUPPORTED_VARIANTS))) \
$(call write-optional-json-list, "host_dependencies", $(sort $(ALL_MODULES.$(m).HOST_REQUIRED_FROM_TARGET))) \
$(call write-optional-json-list, "target_dependencies", $(sort $(ALL_MODULES.$(m).TARGET_REQUIRED_FROM_HOST))) \
+ $(call write-optional-json-bool, "test_module_config_base", $(ALL_MODULES.$(m).TEST_MODULE_CONFIG_BASE)) \
'}')'\n}\n' >> $@.tmp
$(PRIVATE_MERGE_JSON_OBJECTS) -o $@ $(PRIVATE_SOONG_MODULE_INFO) $@.tmp
rm $@.tmp
diff --git a/core/tasks/tools/compatibility.mk b/core/tasks/tools/compatibility.mk
index 4e78d89..86c23f8 100644
--- a/core/tasks/tools/compatibility.mk
+++ b/core/tasks/tools/compatibility.mk
@@ -26,7 +26,15 @@
# Output variables:
# compatibility_zip: the path to the output zip file.
-test_suite_subdir := android-$(test_suite_name)
+special_mts_test_suites :=
+special_mts_test_suites += mcts
+special_mts_test_suites += $(mts_modules)
+ifneq ($(filter $(special_mts_test_suites),$(subst -, ,$(test_suite_name))),)
+ test_suite_subdir := android-mts
+else
+ test_suite_subdir := android-$(test_suite_name)
+endif
+
out_dir := $(HOST_OUT)/$(test_suite_name)/$(test_suite_subdir)
test_artifacts := $(COMPATIBILITY.$(test_suite_name).FILES)
test_tools := $(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar \
@@ -107,9 +115,9 @@
compatibility_zip_deps += $(test_suite_notice_txt)
compatibility_zip_resources += $(test_suite_notice_txt)
-compatibility_tests_list_zip := $(out_dir)-tests_list.zip
+compatibility_tests_list_zip := $(HOST_OUT)/$(test_suite_name)/android-$(test_suite_name)-tests_list.zip
-compatibility_zip := $(out_dir).zip
+compatibility_zip := $(HOST_OUT)/$(test_suite_name)/android-$(test_suite_name).zip
$(compatibility_zip) : .KATI_IMPLICIT_OUTPUTS := $(compatibility_tests_list_zip)
$(compatibility_zip): PRIVATE_OUT_DIR := $(out_dir)
$(compatibility_zip): PRIVATE_TOOLS := $(test_tools) $(test_suite_prebuilt_tools)
diff --git a/envsetup.sh b/envsetup.sh
index 640ed14..06dadd3 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -48,80 +48,13 @@
fi
IMPORTING_ENVSETUP=true source $T/build/make/shell_utils.sh
-
-# Help
-function hmm() {
-cat <<EOF
-
-Run "m help" for help with the build system itself.
-
-Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
-- lunch: lunch <product_name>-<release_type>-<build_variant>
- Selects <product_name> as the product to build, and <build_variant> as the variant to
- build, and stores those selections in the environment to be read by subsequent
- invocations of 'm' etc.
-- tapas: tapas [<App1> <App2> ...] [arm|x86|arm64|x86_64] [eng|userdebug|user]
- Sets up the build environment for building unbundled apps (APKs).
-- banchan: banchan <module1> [<module2> ...] \\
- [arm|x86|arm64|riscv64|x86_64|arm64_only|x86_64only] [eng|userdebug|user]
- Sets up the build environment for building unbundled modules (APEXes).
-- croot: Changes directory to the top of the tree, or a subdirectory thereof.
-- m: Makes from the top of the tree.
-- mm: Builds and installs all of the modules in the current directory, and their
- dependencies.
-- mmm: Builds and installs all of the modules in the supplied directories, and their
- dependencies.
- To limit the modules being built use the syntax: mmm dir/:target1,target2.
-- mma: Same as 'mm'
-- mmma: Same as 'mmm'
-- provision: Flash device with all required partitions. Options will be passed on to fastboot.
-- cgrep: Greps on all local C/C++ files.
-- ggrep: Greps on all local Gradle files.
-- gogrep: Greps on all local Go files.
-- jgrep: Greps on all local Java files.
-- jsongrep: Greps on all local Json files.
-- ktgrep: Greps on all local Kotlin files.
-- resgrep: Greps on all local res/*.xml files.
-- mangrep: Greps on all local AndroidManifest.xml files.
-- mgrep: Greps on all local Makefiles and *.bp files.
-- owngrep: Greps on all local OWNERS files.
-- rsgrep: Greps on all local Rust files.
-- sepgrep: Greps on all local sepolicy files.
-- sgrep: Greps on all local source files.
-- tomlgrep: Greps on all local Toml files.
-- pygrep: Greps on all local Python files.
-- godir: Go to the directory containing a file.
-- allmod: List all modules.
-- gomod: Go to the directory containing a module.
-- pathmod: Get the directory containing a module.
-- outmod: Gets the location of a module's installed outputs with a certain extension.
-- dirmods: Gets the modules defined in a given directory.
-- installmod: Adb installs a module's built APK.
-- refreshmod: Refresh list of modules for allmod/gomod/pathmod/outmod/installmod.
-- syswrite: Remount partitions (e.g. system.img) as writable, rebooting if necessary.
-
-Environment options:
-- SANITIZE_HOST: Set to 'address' to use ASAN for all host modules.
-- ANDROID_QUIET_BUILD: set to 'true' to display only the essential messages.
-
-Look at the source to view more functions. The complete list is:
-EOF
- local T=$(gettop)
- local A=""
- local i
- for i in `cat $T/build/envsetup.sh | sed -n "/^[[:blank:]]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do
- A="$A $i"
- done
- echo $A
-}
-
# Get all the build variables needed by this script in a single call to the build system.
function build_build_var_cache()
{
local T=$(gettop)
# Grep out the variable names from the script.
- cached_vars=(`cat $T/build/envsetup.sh | tr '()' ' ' | awk '{for(i=1;i<=NF;i++) if($i~/get_build_var/) print $(i+1)}' | sort -u | tr '\n' ' '`)
- cached_abs_vars=(`cat $T/build/envsetup.sh | tr '()' ' ' | awk '{for(i=1;i<=NF;i++) if($i~/get_abs_build_var/) print $(i+1)}' | sort -u | tr '\n' ' '`)
+ cached_vars=(`cat $T/build/envsetup.sh | tr '()' ' ' | awk '{for(i=1;i<=NF;i++) if($i~/_get_build_var_cached/) print $(i+1)}' | sort -u | tr '\n' ' '`)
+ cached_abs_vars=(`cat $T/build/envsetup.sh | tr '()' ' ' | awk '{for(i=1;i<=NF;i++) if($i~/_get_abs_build_var_cached/) print $(i+1)}' | sort -u | tr '\n' ' '`)
# Call the build system to dump the "<val>=<value>" pairs as a shell script.
build_dicts_script=`\builtin cd $T; build/soong/soong_ui.bash --dumpvars-mode \
--vars="${cached_vars[*]}" \
@@ -162,7 +95,7 @@
}
# Get the value of a build variable as an absolute path.
-function get_abs_build_var()
+function _get_abs_build_var_cached()
{
if [ "$BUILD_VAR_CACHE_READY" = "true" ]
then
@@ -179,7 +112,7 @@
}
# Get the exact value of a build variable.
-function get_build_var()
+function _get_build_var_cached()
{
if [ "$BUILD_VAR_CACHE_READY" = "true" ]
then
@@ -251,25 +184,25 @@
fi
# And in with the new...
- ANDROID_LUNCH_BUILD_PATHS=$(get_abs_build_var SOONG_HOST_OUT_EXECUTABLES)
- ANDROID_LUNCH_BUILD_PATHS+=:$(get_abs_build_var HOST_OUT_EXECUTABLES)
+ ANDROID_LUNCH_BUILD_PATHS=$(_get_abs_build_var_cached SOONG_HOST_OUT_EXECUTABLES)
+ ANDROID_LUNCH_BUILD_PATHS+=:$(_get_abs_build_var_cached HOST_OUT_EXECUTABLES)
# Append llvm binutils prebuilts path to ANDROID_LUNCH_BUILD_PATHS.
- local ANDROID_LLVM_BINUTILS=$(get_abs_build_var ANDROID_CLANG_PREBUILTS)/llvm-binutils-stable
+ local ANDROID_LLVM_BINUTILS=$(_get_abs_build_var_cached ANDROID_CLANG_PREBUILTS)/llvm-binutils-stable
ANDROID_LUNCH_BUILD_PATHS+=:$ANDROID_LLVM_BINUTILS
# Set up ASAN_SYMBOLIZER_PATH for SANITIZE_HOST=address builds.
export ASAN_SYMBOLIZER_PATH=$ANDROID_LLVM_BINUTILS/llvm-symbolizer
# Append asuite prebuilts path to ANDROID_LUNCH_BUILD_PATHS.
- local os_arch=$(get_build_var HOST_PREBUILT_TAG)
+ local os_arch=$(_get_build_var_cached HOST_PREBUILT_TAG)
ANDROID_LUNCH_BUILD_PATHS+=:$T/prebuilts/asuite/acloud/$os_arch
ANDROID_LUNCH_BUILD_PATHS+=:$T/prebuilts/asuite/aidegen/$os_arch
ANDROID_LUNCH_BUILD_PATHS+=:$T/prebuilts/asuite/atest/$os_arch
- export ANDROID_JAVA_HOME=$(get_abs_build_var ANDROID_JAVA_HOME)
+ export ANDROID_JAVA_HOME=$(_get_abs_build_var_cached ANDROID_JAVA_HOME)
export JAVA_HOME=$ANDROID_JAVA_HOME
- export ANDROID_JAVA_TOOLCHAIN=$(get_abs_build_var ANDROID_JAVA_TOOLCHAIN)
+ export ANDROID_JAVA_TOOLCHAIN=$(_get_abs_build_var_cached ANDROID_JAVA_TOOLCHAIN)
ANDROID_LUNCH_BUILD_PATHS+=:$ANDROID_JAVA_TOOLCHAIN
# Fix up PYTHONPATH
@@ -298,20 +231,20 @@
export PYTHONPATH=$ANDROID_PYTHONPATH$PYTHONPATH
unset ANDROID_PRODUCT_OUT
- export ANDROID_PRODUCT_OUT=$(get_abs_build_var PRODUCT_OUT)
+ export ANDROID_PRODUCT_OUT=$(_get_abs_build_var_cached PRODUCT_OUT)
export OUT=$ANDROID_PRODUCT_OUT
unset ANDROID_HOST_OUT
- export ANDROID_HOST_OUT=$(get_abs_build_var HOST_OUT)
+ export ANDROID_HOST_OUT=$(_get_abs_build_var_cached HOST_OUT)
unset ANDROID_SOONG_HOST_OUT
- export ANDROID_SOONG_HOST_OUT=$(get_abs_build_var SOONG_HOST_OUT)
+ export ANDROID_SOONG_HOST_OUT=$(_get_abs_build_var_cached SOONG_HOST_OUT)
unset ANDROID_HOST_OUT_TESTCASES
- export ANDROID_HOST_OUT_TESTCASES=$(get_abs_build_var HOST_OUT_TESTCASES)
+ export ANDROID_HOST_OUT_TESTCASES=$(_get_abs_build_var_cached HOST_OUT_TESTCASES)
unset ANDROID_TARGET_OUT_TESTCASES
- export ANDROID_TARGET_OUT_TESTCASES=$(get_abs_build_var TARGET_OUT_TESTCASES)
+ export ANDROID_TARGET_OUT_TESTCASES=$(_get_abs_build_var_cached TARGET_OUT_TESTCASES)
# Finally, set PATH
export PATH=$ANDROID_LUNCH_BUILD_PATHS:$PATH
@@ -384,7 +317,7 @@
echo "Couldn't locate the top of the tree. Try setting TOP." >&2
return
fi
- get_build_var report_config
+ _get_build_var_cached report_config
}
function set_stuff_for_environment()
@@ -452,6 +385,7 @@
complete -F _bazel__complete -o nospace b
fi
complete -F _lunch lunch
+ complete -F _lunch_completion lunch2
complete -F _complete_android_module_names pathmod
complete -F _complete_android_module_names gomod
@@ -474,7 +408,7 @@
{
local uname=$(uname)
local choices
- choices=$(TARGET_BUILD_APPS= TARGET_PRODUCT= TARGET_RELEASE= TARGET_BUILD_VARIANT= get_build_var COMMON_LUNCH_CHOICES 2>/dev/null)
+ choices=$(TARGET_BUILD_APPS= TARGET_PRODUCT= TARGET_RELEASE= TARGET_BUILD_VARIANT= _get_build_var_cached COMMON_LUNCH_CHOICES 2>/dev/null)
local ret=$?
echo
@@ -533,7 +467,7 @@
selection=aosp_cf_x86_64_phone-trunk_staging-eng
elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
then
- local choices=($(TARGET_BUILD_APPS= TARGET_PRODUCT= TARGET_RELEASE= TARGET_BUILD_VARIANT= get_build_var COMMON_LUNCH_CHOICES 2>/dev/null))
+ local choices=($(TARGET_BUILD_APPS= TARGET_PRODUCT= TARGET_RELEASE= TARGET_BUILD_VARIANT= _get_build_var_cached COMMON_LUNCH_CHOICES 2>/dev/null))
if [ $answer -le ${#choices[@]} ]
then
# array in zsh starts from 1 instead of 0.
@@ -563,9 +497,18 @@
return 1
fi
+ _lunch_meat $product $release $variant
+}
+
+function _lunch_meat()
+{
+ local product=$1
+ local release=$2
+ local variant=$3
+
TARGET_PRODUCT=$product \
- TARGET_BUILD_VARIANT=$variant \
TARGET_RELEASE=$release \
+ TARGET_BUILD_VARIANT=$variant \
build_build_var_cache
if [ $? -ne 0 ]
then
@@ -575,8 +518,8 @@
fi
return 1
fi
- export TARGET_PRODUCT=$(get_build_var TARGET_PRODUCT)
- export TARGET_BUILD_VARIANT=$(get_build_var TARGET_BUILD_VARIANT)
+ export TARGET_PRODUCT=$(_get_build_var_cached TARGET_PRODUCT)
+ export TARGET_BUILD_VARIANT=$(_get_build_var_cached TARGET_BUILD_VARIANT)
export TARGET_RELEASE=$release
# Note this is the string "release", not the value of the variable.
export TARGET_BUILD_TYPE=release
@@ -586,14 +529,11 @@
set_stuff_for_environment
[[ -n "${ANDROID_QUIET_BUILD:-}" ]] || printconfig
- if [ "${TARGET_BUILD_VARIANT}" = "userdebug" ] && [[ -z "${ANDROID_QUIET_BUILD}" ]]; then
- echo
- echo "Want FASTER LOCAL BUILDS? Use -eng instead of -userdebug (however for" \
- "performance benchmarking continue to use userdebug)"
- fi
- if [ $used_lunch_menu -eq 1 ]; then
- echo
- echo "Hint: next time you can simply run 'lunch $selection'"
+ if [[ -z "${ANDROID_QUIET_BUILD}" ]]; then
+ local spam_for_lunch=$(gettop)/build/make/tools/envsetup/spam_for_lunch
+ if [[ -x $spam_for_lunch ]]; then
+ $spam_for_lunch
+ fi
fi
destroy_build_var_cache
@@ -613,13 +553,119 @@
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ -z "$COMMON_LUNCH_CHOICES_CACHE" ]; then
- COMMON_LUNCH_CHOICES_CACHE=$(TARGET_BUILD_APPS= get_build_var COMMON_LUNCH_CHOICES)
+ COMMON_LUNCH_CHOICES_CACHE=$(TARGET_BUILD_APPS= _get_build_var_cached COMMON_LUNCH_CHOICES)
fi
COMPREPLY=( $(compgen -W "${COMMON_LUNCH_CHOICES_CACHE}" -- ${cur}) )
return 0
}
+function _lunch_usage()
+{
+ (
+ echo "The lunch command selects the configuration to use for subsequent"
+ echo "Android builds."
+ echo
+ echo "Usage: lunch TARGET_PRODUCT [TARGET_RELEASE [TARGET_BUILD_VARIANT]]"
+ echo
+ echo " Choose the product, release and variant to use. If not"
+ echo " supplied, TARGET_RELEASE will be 'trunk_staging' and"
+ echo " TARGET_BUILD_VARIANT will be 'eng'"
+ echo
+ echo
+ echo "Usage: lunch TARGET_PRODUCT-TARGET_RELEASE-TARGET_BUILD_VARIANT"
+ echo
+ echo " Chose the product, release and variant to use. This"
+ echo " legacy format is maintained for compatibility."
+ echo
+ echo
+ echo "Note that the previous interactive menu and list of hard-coded"
+ echo "list of curated targets has been removed. If you would like the"
+ echo "list of products, release configs for a particular product, or"
+ echo "variants, run list_products, list_release_configs, list_variants"
+ echo "respectively."
+ echo
+ ) 1>&2
+}
+
+function lunch2()
+{
+ if [[ $# -eq 1 && $1 = "--help" ]]; then
+ _lunch_usage
+ return 0
+ fi
+ if [[ $# -eq 0 ]]; then
+ echo "No target specified. See lunch --help" 1>&2
+ return 1
+ fi
+ if [[ $# -gt 3 ]]; then
+ echo "Too many parameters given. See lunch --help" 1>&2
+ return 1
+ fi
+
+ local product release variant
+
+ # Handle the legacy format
+ local legacy=$(echo $1 | grep "-")
+ if [[ $# -eq 1 && -n $legacy ]]; then
+ IFS="-" read -r product release variant <<< "$1"
+ if [[ -z "$product" ]] || [[ -z "$release" ]] || [[ -z "$variant" ]]; then
+ echo "Invalid lunch combo: $1" 1>&2
+ echo "Valid combos must be of the form <product>-<release>-<variant> when using" 1>&2
+ echo "the legacy format. Run 'lunch --help' for usage." 1>&2
+ return 1
+ fi
+ fi
+
+ # Handle the new format.
+ if [[ -z $legacy ]]; then
+ product=$1
+ release=$2
+ if [[ -z $release ]]; then
+ release=trunk_staging
+ fi
+ variant=$3
+ if [[ -z $variant ]]; then
+ variant=eng
+ fi
+ fi
+
+ # Validate the selection and set all the environment stuff
+ _lunch_meat $product $release $variant
+}
+
+unset ANDROID_LUNCH_COMPLETION_PRODUCT_CACHE
+unset ANDROID_LUNCH_COMPLETION_CHOSEN_PRODUCT
+unset ANDROID_LUNCH_COMPLETION_RELEASE_CACHE
+# Tab completion for lunch.
+function _lunch_completion()
+{
+ # Available products
+ if [[ $COMP_CWORD -eq 1 ]] ; then
+ if [[ -z $ANDROID_LUNCH_COMPLETION_PRODUCT_CACHE ]]; then
+ ANDROID_LUNCH_COMPLETION_PRODUCT_CACHE=$(list_products)
+ fi
+ COMPREPLY=( $(compgen -W "${ANDROID_LUNCH_COMPLETION_PRODUCT_CACHE}" -- "${COMP_WORDS[COMP_CWORD]}") )
+ fi
+
+ # Available release configs
+ if [[ $COMP_CWORD -eq 2 ]] ; then
+ if [[ -z $ANDROID_LUNCH_COMPLETION_RELEASE_CACHE || $ANDROID_LUNCH_COMPLETION_CHOSEN_PRODUCT != ${COMP_WORDS[1]} ]] ; then
+ ANDROID_LUNCH_COMPLETION_RELEASE_CACHE=$(list_releases ${COMP_WORDS[1]})
+ ANDROID_LUNCH_COMPLETION_CHOSEN_PRODUCT=${COMP_WORDS[1]}
+ fi
+ COMPREPLY=( $(compgen -W "${ANDROID_LUNCH_COMPLETION_RELEASE_CACHE}" -- "${COMP_WORDS[COMP_CWORD]}") )
+ fi
+
+ # Available variants
+ if [[ $COMP_CWORD -eq 3 ]] ; then
+ COMPREPLY=(user userdebug eng)
+ fi
+
+ return 0
+}
+
+
# Configures the build to build unbundled apps.
# Run tapas with one or more app names (from LOCAL_PACKAGE_NAME)
function tapas()
@@ -819,183 +865,14 @@
run_tool_with_logging "ADB" $ADB "${@}"
}
-function run_tool_with_logging() {
- # Run commands in a subshell for us to handle forced terminations with a trap
- # handler.
- (
- local tool_tag="$1"
- shift
- local tool_binary="$1"
- shift
-
- # If the logger is not configured, run the original command and return.
- if [[ -z "${ANDROID_TOOL_LOGGER}" ]]; then
- "${tool_binary}" "${@}"
- return $?
- fi
-
- # Otherwise, run the original command and call the logger when done.
- local start_time
- start_time=$(date +%s.%N)
- local logger=${ANDROID_TOOL_LOGGER}
-
- # Install a trap to call the logger even when the process terminates abnormally.
- # The logger is run in the background and its output suppressed to avoid
- # interference with the user flow.
- trap '
- exit_code=$?;
- # Remove the trap to prevent duplicate log.
- trap - EXIT;
- "${logger}" \
- --tool_tag="${tool_tag}" \
- --start_timestamp="${start_time}" \
- --end_timestamp="$(date +%s.%N)" \
- --tool_args="$*" \
- --exit_code="${exit_code}" \
- ${ANDROID_TOOL_LOGGER_EXTRA_ARGS} \
- > /dev/null 2>&1 &
- exit ${exit_code}
- ' SIGINT SIGTERM SIGQUIT EXIT
-
- # Run the original command.
- "${tool_binary}" "${@}"
- )
-}
-
-# simplified version of ps; output in the form
-# <pid> <procname>
-function qpid() {
- local prepend=''
- local append=''
- if [ "$1" = "--exact" ]; then
- prepend=' '
- append='$'
- shift
- elif [ "$1" = "--help" -o "$1" = "-h" ]; then
- echo "usage: qpid [[--exact] <process name|pid>"
- return 255
+function fastboot() {
+ local FASTBOOT=$(command which fastboot)
+ if [ -z "$FASTBOOT" ]; then
+ echo "Command fastboot not found; try lunch (and building) first?"
+ return 1
fi
-
- local EXE="$1"
- if [ "$EXE" ] ; then
- qpid | \grep "$prepend$EXE$append"
- else
- adb shell ps \
- | tr -d '\r' \
- | sed -e 1d -e 's/^[^ ]* *\([0-9]*\).* \([^ ]*\)$/\1 \2/'
- fi
-}
-
-# coredump_setup - enable core dumps globally for any process
-# that has the core-file-size limit set correctly
-#
-# NOTE: You must call also coredump_enable for a specific process
-# if its core-file-size limit is not set already.
-# NOTE: Core dumps are written to ramdisk; they will not survive a reboot!
-
-function coredump_setup()
-{
- echo "Getting root...";
- adb root;
- adb wait-for-device;
-
- echo "Remounting root partition read-write...";
- adb shell mount -w -o remount -t rootfs rootfs;
- sleep 1;
- adb wait-for-device;
- adb shell mkdir -p /cores;
- adb shell mount -t tmpfs tmpfs /cores;
- adb shell chmod 0777 /cores;
-
- echo "Granting SELinux permission to dump in /cores...";
- adb shell restorecon -R /cores;
-
- echo "Set core pattern.";
- adb shell 'echo /cores/core.%p > /proc/sys/kernel/core_pattern';
-
- echo "Done."
-}
-
-# coredump_enable - enable core dumps for the specified process
-# $1 = PID of process (e.g., $(pid mediaserver))
-#
-# NOTE: coredump_setup must have been called as well for a core
-# dump to actually be generated.
-
-function coredump_enable()
-{
- local PID=$1;
- if [ -z "$PID" ]; then
- printf "Expecting a PID!\n";
- return;
- fi;
- echo "Setting core limit for $PID to infinite...";
- adb shell /system/bin/ulimit -P $PID -c unlimited
-}
-
-# core - send SIGV and pull the core for process
-# $1 = PID of process (e.g., $(pid mediaserver))
-#
-# NOTE: coredump_setup must be called once per boot for core dumps to be
-# enabled globally.
-
-function core()
-{
- local PID=$1;
-
- if [ -z "$PID" ]; then
- printf "Expecting a PID!\n";
- return;
- fi;
-
- local CORENAME=core.$PID;
- local COREPATH=/cores/$CORENAME;
- local SIG=SEGV;
-
- coredump_enable $1;
-
- local done=0;
- while [ $(adb shell "[ -d /proc/$PID ] && echo -n yes") ]; do
- printf "\tSending SIG%s to %d...\n" $SIG $PID;
- adb shell kill -$SIG $PID;
- sleep 1;
- done;
-
- adb shell "while [ ! -f $COREPATH ] ; do echo waiting for $COREPATH to be generated; sleep 1; done"
- echo "Done: core is under $COREPATH on device.";
-}
-
-# systemstack - dump the current stack trace of all threads in the system process
-# to the usual ANR traces file
-function systemstack()
-{
- stacks system_server
-}
-
-# Read the ELF header from /proc/$PID/exe to determine if the process is
-# 64-bit.
-function is64bit()
-{
- local PID="$1"
- if [ "$PID" ] ; then
- if [[ "$(adb shell cat /proc/$PID/exe | xxd -l 1 -s 4 -p)" -eq "02" ]] ; then
- echo "64"
- else
- echo ""
- fi
- else
- echo ""
- fi
-}
-
-function gettargetarch
-{
- get_build_var TARGET_ARCH
-}
-
-function getprebuilt
-{
- get_abs_build_var ANDROID_PREBUILTS
+ # Support tool event logging for fastboot command.
+ run_tool_with_logging "FASTBOOT" $FASTBOOT "${@}"
}
# communicate with a running device or emulator, set up necessary state,
@@ -1050,100 +927,6 @@
hat -JXmx512m $localFile
}
-function getbugreports()
-{
- local reports=(`adb shell ls /sdcard/bugreports | tr -d '\r'`)
-
- if [ ! "$reports" ]; then
- echo "Could not locate any bugreports."
- return
- fi
-
- local report
- for report in ${reports[@]}
- do
- echo "/sdcard/bugreports/${report}"
- adb pull /sdcard/bugreports/${report} ${report}
- gunzip ${report}
- done
-}
-
-function getsdcardpath()
-{
- adb ${adbOptions} shell echo -n \$\{EXTERNAL_STORAGE\}
-}
-
-function getscreenshotpath()
-{
- echo "$(getsdcardpath)/Pictures/Screenshots"
-}
-
-function getlastscreenshot()
-{
- local screenshot_path=$(getscreenshotpath)
- local screenshot=`adb ${adbOptions} ls ${screenshot_path} | grep Screenshot_[0-9-]*.*\.png | sort -rk 3 | cut -d " " -f 4 | head -n 1`
- if [ "$screenshot" = "" ]; then
- echo "No screenshots found."
- return
- fi
- echo "${screenshot}"
- adb ${adbOptions} pull ${screenshot_path}/${screenshot}
-}
-
-function startviewserver()
-{
- local port=4939
- if [ $# -gt 0 ]; then
- port=$1
- fi
- adb shell service call window 1 i32 $port
-}
-
-function stopviewserver()
-{
- adb shell service call window 2
-}
-
-function isviewserverstarted()
-{
- adb shell service call window 3
-}
-
-function key_home()
-{
- adb shell input keyevent 3
-}
-
-function key_back()
-{
- adb shell input keyevent 4
-}
-
-function key_menu()
-{
- adb shell input keyevent 82
-}
-
-function smoketest()
-{
- if [ ! "$ANDROID_PRODUCT_OUT" ]; then
- echo "Couldn't locate output files. Try running 'lunch' first." >&2
- return
- fi
- local T=$(gettop)
- if [ ! "$T" ]; then
- echo "Couldn't locate the top of the tree. Try setting TOP." >&2
- return
- fi
-
- (\cd "$T" && mmm tests/SmokeTest) &&
- adb uninstall com.android.smoketest > /dev/null &&
- adb uninstall com.android.smoketest.tests > /dev/null &&
- adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTestApp.apk &&
- adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTest.apk &&
- adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner
-}
-
function godir () {
if [[ -z "$1" ]]; then
echo "Usage: godir <regex>"
@@ -1195,87 +978,10 @@
\cd $T/$pathname
}
-# Verifies that module-info.txt exists, returning nonzero if it doesn't.
-function verifymodinfo() {
- if [ ! "$ANDROID_PRODUCT_OUT" ]; then
- if [ "$QUIET_VERIFYMODINFO" != "true" ] ; then
- echo "No ANDROID_PRODUCT_OUT. Try running 'lunch' first." >&2
- fi
- return 1
- fi
-
- if [ ! -f "$ANDROID_PRODUCT_OUT/module-info.json" ]; then
- if [ "$QUIET_VERIFYMODINFO" != "true" ] ; then
- echo "Could not find module-info.json. Please run 'refreshmod' first." >&2
- fi
- return 1
- fi
-}
-
-# List all modules for the current device, as cached in all_modules.txt. If any build change is
-# made and it should be reflected in the output, you should run `m nothing` first.
-function allmod() {
- cat $ANDROID_PRODUCT_OUT/all_modules.txt 2>/dev/null
-}
-
-# Get the path of a specific module in the android tree, as cached in module-info.json.
-# If any build change is made, and it should be reflected in the output, you should run
-# 'refreshmod' first. Note: This is the inverse of dirmods.
-function pathmod() {
- if [[ $# -ne 1 ]]; then
- echo "usage: pathmod <module>" >&2
- return 1
- fi
-
- verifymodinfo || return 1
-
- local relpath=$(python3 -c "import json, os
-module = '$1'
-module_info = json.load(open('$ANDROID_PRODUCT_OUT/module-info.json'))
-if module not in module_info:
- exit(1)
-print(module_info[module]['path'][0])" 2>/dev/null)
-
- if [ -z "$relpath" ]; then
- echo "Could not find module '$1' (try 'refreshmod' if there have been build changes?)." >&2
- return 1
- else
- echo "$ANDROID_BUILD_TOP/$relpath"
- fi
-}
-
-# Get the path of a specific module in the android tree, as cached in module-info.json.
-# If any build change is made, and it should be reflected in the output, you should run
-# 'refreshmod' first. Note: This is the inverse of pathmod.
-function dirmods() {
- if [[ $# -ne 1 ]]; then
- echo "usage: dirmods <path>" >&2
- return 1
- fi
-
- verifymodinfo || return 1
-
- python3 -c "import json, os
-dir = '$1'
-while dir.endswith('/'):
- dir = dir[:-1]
-prefix = dir + '/'
-module_info = json.load(open('$ANDROID_PRODUCT_OUT/module-info.json'))
-results = set()
-for m in module_info.values():
- for path in m.get(u'path', []):
- if path == dir or path.startswith(prefix):
- name = m.get(u'module_name')
- if name:
- results.add(name)
-for name in sorted(results):
- print(name)
-"
-}
-
-
# Go to a specific module in the android tree, as cached in module-info.json. If any build change
# is made, and it should be reflected in the output, you should run 'refreshmod' first.
+# Note: This function is in envsetup because changing the directory needs to happen in the current
+# shell. All other functions that use module-info.json should be in build/soong/bin.
function gomod() {
if [[ $# -ne 1 ]]; then
echo "usage: gomod <module>" >&2
@@ -1289,90 +995,11 @@
cd $path
}
-# Gets the list of a module's installed outputs, as cached in module-info.json.
-# If any build change is made, and it should be reflected in the output, you should run 'refreshmod' first.
-function outmod() {
- if [[ $# -ne 1 ]]; then
- echo "usage: outmod <module>" >&2
- return 1
- fi
-
- verifymodinfo || return 1
-
- local relpath
- relpath=$(python3 -c "import json, os
-module = '$1'
-module_info = json.load(open('$ANDROID_PRODUCT_OUT/module-info.json'))
-if module not in module_info:
- exit(1)
-for output in module_info[module]['installed']:
- print(os.path.join('$ANDROID_BUILD_TOP', output))" 2>/dev/null)
-
- if [ $? -ne 0 ]; then
- echo "Could not find module '$1' (try 'refreshmod' if there have been build changes?)" >&2
- return 1
- elif [ ! -z "$relpath" ]; then
- echo "$relpath"
- fi
-}
-
-# adb install a module's apk, as cached in module-info.json. If any build change
-# is made, and it should be reflected in the output, you should run 'refreshmod' first.
-# Usage: installmod [adb install arguments] <module>
-# For example: installmod -r Dialer -> adb install -r /path/to/Dialer.apk
-function installmod() {
- if [[ $# -eq 0 ]]; then
- echo "usage: installmod [adb install arguments] <module>" >&2
- echo "" >&2
- echo "Only flags to be passed after the \"install\" in adb install are supported," >&2
- echo "with the exception of -s. If -s is passed it will be placed before the \"install\"." >&2
- echo "-s must be the first flag passed if it exists." >&2
- return 1
- fi
-
- local _path
- _path=$(outmod ${@:$#:1})
- if [ $? -ne 0 ]; then
- return 1
- fi
-
- _path=$(echo "$_path" | grep -E \\.apk$ | head -n 1)
- if [ -z "$_path" ]; then
- echo "Module '$1' does not produce a file ending with .apk (try 'refreshmod' if there have been build changes?)" >&2
- return 1
- fi
- local serial_device=""
- if [[ "$1" == "-s" ]]; then
- if [[ $# -le 2 ]]; then
- echo "-s requires an argument" >&2
- return 1
- fi
- serial_device="-s $2"
- shift 2
- fi
- local length=$(( $# - 1 ))
- echo adb $serial_device install ${@:1:$length} $_path
- adb $serial_device install ${@:1:$length} $_path
-}
-
function _complete_android_module_names() {
local word=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(allmod | grep -E "^$word") )
}
-# Print colored exit condition
-function pez {
- "$@"
- local retval=$?
- if [ $retval -ne 0 ]
- then
- echo $'\E'"[0;31mFAILURE\e[00m"
- else
- echo $'\E'"[0;32mSUCCESS\e[00m"
- fi
- return $retval
-}
-
function get_make_command()
{
# If we're in the top of an Android tree, use soong_ui.bash instead of make
@@ -1390,57 +1017,11 @@
fi
}
-function _trigger_build()
-(
- local -r bc="$1"; shift
- local T=$(gettop)
- if [ -n "$T" ]; then
- _wrap_build "$T/build/soong/soong_ui.bash" --build-mode --${bc} --dir="$(pwd)" "$@"
- else
- >&2 echo "Couldn't locate the top of the tree. Try setting TOP."
- return 1
- fi
- local ret=$?
- if [[ ret -eq 0 && -z "${ANDROID_QUIET_BUILD:-}" && -n "${ANDROID_BUILD_BANNER}" ]]; then
- echo "${ANDROID_BUILD_BANNER}"
- fi
- return $ret
-)
-
function make()
{
_wrap_build $(get_make_command "$@") "$@"
}
-function provision()
-{
- if [ ! "$ANDROID_PRODUCT_OUT" ]; then
- echo "Couldn't locate output files. Try running 'lunch' first." >&2
- return 1
- fi
- if [ ! -e "$ANDROID_PRODUCT_OUT/provision-device" ]; then
- echo "There is no provisioning script for the device." >&2
- return 1
- fi
-
- # Check if user really wants to do this.
- if [ "$1" = "--no-confirmation" ]; then
- shift 1
- else
- echo "This action will reflash your device."
- echo ""
- echo "ALL DATA ON THE DEVICE WILL BE IRREVOCABLY ERASED."
- echo ""
- echo -n "Are you sure you want to do this (yes/no)? "
- read
- if [[ "${REPLY}" != "yes" ]] ; then
- echo "Not taking any action. Exiting." >&2
- return 1
- fi
- fi
- "$ANDROID_PRODUCT_OUT/provision-device" "$@"
-}
-
# Zsh needs bashcompinit called to support bash-style completion.
function enable_zsh_completion() {
# Don't override user's options if bash-style completion is already enabled.
@@ -1522,7 +1103,7 @@
return
;;
esac
- OUT_DIR="$(get_abs_build_var OUT_DIR)"
+ OUT_DIR="$(_get_abs_build_var_cached OUT_DIR)"
if [[ "$1" == "--regenerate" ]]; then
shift 1
NINJA_ARGS="-t commands $@" m
@@ -1537,32 +1118,59 @@
# in build/soong/bin. Unset these for the time being so the real
# script is picked up.
# TODO: Remove this some time after a suitable delay (maybe 2025?)
+unset allmod
unset aninja
-unset overrideflags
-unset m
-unset mm
-unset mmm
-unset mma
-unset mmma
unset cgrep
+unset core
+unset coredump_enable
+unset coredump_setup
+unset dirmods
+unset get_build_var
+unset get_abs_build_var
+unset getlastscreenshot
+unset getprebuilt
+unset getscreenshotpath
+unset getsdcardpath
+unset gettargetarch
unset ggrep
unset gogrep
+unset hmm
+unset installmod
+unset is64bit
+unset isviewserverstarted
unset jgrep
unset jsongrep
+unset key_back
+unset key_home
+unset key_menu
unset ktgrep
+unset m
unset mangrep
unset mgrep
+unset mm
+unset mma
+unset mmm
+unset mmma
+unset outmod
+unset overrideflags
unset owngrep
+unset pathmod
+unset pez
unset pygrep
+unset qpid
unset rcgrep
+unset refreshmod
unset resgrep
unset rsgrep
+unset run_tool_with_logging
unset sepgrep
unset sgrep
+unset startviewserver
+unset stopviewserver
+unset systemstack
+unset syswrite
unset tomlgrep
unset treegrep
-unset syswrite
-unset refreshmod
validate_current_shell
@@ -1571,4 +1179,3 @@
addcompletions
-
diff --git a/shell_utils.sh b/shell_utils.sh
index 450bb83..86f3f49 100644
--- a/shell_utils.sh
+++ b/shell_utils.sh
@@ -126,4 +126,27 @@
}
+function log_tool_invocation()
+{
+ if [[ -z $ANDROID_TOOL_LOGGER ]]; then
+ return
+ fi
+
+ LOG_TOOL_TAG=$1
+ LOG_START_TIME=$(date +%s.%N)
+ trap '
+ exit_code=$?;
+ # Remove the trap to prevent duplicate log.
+ trap - EXIT;
+ $ANDROID_TOOL_LOGGER \
+ --tool_tag="${LOG_TOOL_TAG}" \
+ --start_timestamp="${LOG_START_TIME}" \
+ --end_timestamp="$(date +%s.%N)" \
+ --tool_args="$*" \
+ --exit_code="${exit_code}" \
+ ${ANDROID_TOOL_LOGGER_EXTRA_ARGS} \
+ > /dev/null 2>&1 &
+ exit ${exit_code}
+ ' SIGINT SIGTERM SIGQUIT EXIT
+}
diff --git a/target/product/aosp_arm64.mk b/target/product/aosp_arm64.mk
index 364fed4..783ed3b 100644
--- a/target/product/aosp_arm64.mk
+++ b/target/product/aosp_arm64.mk
@@ -44,7 +44,7 @@
$(call inherit-product, $(SRC_TARGET_DIR)/product/telephony_system_ext.mk)
# pKVM
-$(call inherit-product, packages/modules/Virtualization/apex/product_packages.mk)
+$(call inherit-product-if-exists, packages/modules/Virtualization/apex/product_packages.mk)
#
# All components inherited here go to product image
@@ -58,6 +58,9 @@
AB_OTA_UPDATER := true
AB_OTA_PARTITIONS ?= system
+# Set widevine apex signed with dev key
+$(call soong_config_set,widevine,use_devkey,true)
+
#
# Special settings for GSI releasing
#
diff --git a/target/product/aosp_x86_64.mk b/target/product/aosp_x86_64.mk
index 595940d..e9ca482 100644
--- a/target/product/aosp_x86_64.mk
+++ b/target/product/aosp_x86_64.mk
@@ -60,6 +60,9 @@
AB_OTA_UPDATER := true
AB_OTA_PARTITIONS ?= system
+# Set widevine apex signed with dev key
+$(call soong_config_set,widevine,use_devkey,true)
+
#
# Special settings for GSI releasing
#
diff --git a/target/product/base_product.mk b/target/product/base_product.mk
index 5446064..0ac220b 100644
--- a/target/product/base_product.mk
+++ b/target/product/base_product.mk
@@ -16,6 +16,7 @@
# Base modules and settings for the product partition.
PRODUCT_PACKAGES += \
+ build_flag_product \
fs_config_dirs_product \
fs_config_files_product \
group_product \
diff --git a/target/product/base_system.mk b/target/product/base_system.mk
index 634bf66..146479c 100644
--- a/target/product/base_system.mk
+++ b/target/product/base_system.mk
@@ -45,6 +45,7 @@
bu \
bugreport \
bugreportz \
+ build_flag_system \
cgroups.json \
charger \
cmd \
@@ -82,6 +83,7 @@
CtsShimPrivPrebuilt \
debuggerd\
device_config \
+ DeviceDiagnostics \
dmctl \
dnsmasq \
dmesgd \
@@ -90,7 +92,9 @@
dump.erofs \
dumpstate \
dumpsys \
+ E2eeContactKeysProvider \
e2fsck \
+ enhanced-confirmation.xml \
ExtShared \
flags_health_check \
framework-graphics \
@@ -234,6 +238,7 @@
org.apache.http.legacy \
otacerts \
PackageInstaller \
+ package-shareduid-allowlist.xml \
passwd_system \
perfetto \
perfetto-extras \
@@ -286,6 +291,7 @@
uiautomator \
uinput \
uncrypt \
+ uprobestats \
usbd \
vdc \
vintf \
@@ -327,6 +333,12 @@
com.android.nfcservices
endif
+# Check if the build supports Profiling module
+ifeq ($(RELEASE_PACKAGE_PROFILING_MODULE),true)
+ PRODUCT_PACKAGES += \
+ com.android.profiling
+endif
+
ifeq ($(RELEASE_USE_WEBVIEW_BOOTSTRAP_MODULE),true)
PRODUCT_PACKAGES += \
com.android.webview.bootstrap
@@ -498,3 +510,6 @@
# Use "image" APEXes always.
$(call inherit-product,$(SRC_TARGET_DIR)/product/updatable_apex.mk)
+
+$(call soong_config_set, bionic, large_system_property_node, $(RELEASE_LARGE_SYSTEM_PROPERTY_NODE))
+$(call soong_config_set, Aconfig, read_from_new_storage, $(RELEASE_READ_FROM_NEW_STORAGE))
diff --git a/target/product/base_system_ext.mk b/target/product/base_system_ext.mk
index 76f008f..92ca227 100644
--- a/target/product/base_system_ext.mk
+++ b/target/product/base_system_ext.mk
@@ -16,6 +16,7 @@
# Base modules and settings for the system_ext partition.
PRODUCT_PACKAGES += \
+ build_flag_system_ext \
fs_config_dirs_system_ext \
fs_config_files_system_ext \
group_system_ext \
diff --git a/target/product/base_vendor.mk b/target/product/base_vendor.mk
index ec3de75..1854f97 100644
--- a/target/product/base_vendor.mk
+++ b/target/product/base_vendor.mk
@@ -18,6 +18,7 @@
PRODUCT_PACKAGES += \
adbd.recovery \
android.hardware.health@2.0-impl-default.recovery \
+ build_flag_vendor \
cgroups.recovery.json \
charger.recovery \
init_second_stage.recovery \
diff --git a/target/product/default_art_config.mk b/target/product/default_art_config.mk
index 4a968d7..1a3f2cf 100644
--- a/target/product/default_art_config.mk
+++ b/target/product/default_art_config.mk
@@ -101,8 +101,16 @@
PRODUCT_BOOT_JARS += \
framework-nfc
else
- PRODUCT_APEX_BOOT_JARS := \
+ PRODUCT_APEX_BOOT_JARS += \
com.android.nfcservices:framework-nfc
+ $(call soong_config_set,bootclasspath,nfc_apex_bootclasspath_fragment,true)
+endif
+
+# Check if build supports Profiling module.
+ifeq ($(RELEASE_PACKAGE_PROFILING_MODULE),true)
+ PRODUCT_APEX_BOOT_JARS += \
+ com.android.profiling:framework-profiling \
+
endif
# List of system_server classpath jars delivered via apex.
@@ -153,6 +161,13 @@
com.android.uwb:service-uwb \
com.android.wifi:service-wifi \
+# Check if build supports Profiling module.
+ifeq ($(RELEASE_PACKAGE_PROFILING_MODULE),true)
+ PRODUCT_APEX_STANDALONE_SYSTEM_SERVER_JARS += \
+ com.android.profiling:service-profiling \
+
+endif
+
# Overrides the (apex, jar) pairs above when determining the on-device location. The format is:
# <old_apex>:<old_jar>:<new_apex>:<new_jar>
PRODUCT_CONFIGURED_JAR_LOCATION_OVERRIDES := \
diff --git a/target/product/generic_system.mk b/target/product/generic_system.mk
index 9748c7c..4793657 100644
--- a/target/product/generic_system.mk
+++ b/target/product/generic_system.mk
@@ -146,3 +146,6 @@
$(TARGET_COPY_OUT_SYSTEM)/ \
$(call require-artifacts-in-path, $(_my_paths), $(_my_allowed_list))
+
+# Product config map to toggle between sources and prebuilts of required mainline modules
+PRODUCT_RELEASE_CONFIG_MAPS += $(wildcard vendor/google_shared/build/release/gms_mainline/required/release_config_map.textproto)
diff --git a/target/product/go_defaults.mk b/target/product/go_defaults.mk
index a10cfa8..7fbc09d 100644
--- a/target/product/go_defaults.mk
+++ b/target/product/go_defaults.mk
@@ -17,6 +17,9 @@
# Inherit common Android Go defaults.
$(call inherit-product, build/make/target/product/go_defaults_common.mk)
+PRODUCT_RELEASE_CONFIG_MAPS += $(wildcard vendor/google_shared/build/release/go_devices/release_config_map.mk)
+
+# TODO (b/342265627): Remove v/g/r once all the flags have been moved to v/g_s/b/r
PRODUCT_RELEASE_CONFIG_MAPS += $(wildcard vendor/google/release/go_devices/release_config_map.mk)
# Add the system properties.
diff --git a/target/product/gsi_release.mk b/target/product/gsi_release.mk
index 5044a39..da1284e 100644
--- a/target/product/gsi_release.mk
+++ b/target/product/gsi_release.mk
@@ -58,9 +58,6 @@
device/generic/common/overlays/overlay-config.xml:$(TARGET_COPY_OUT_SYSTEM_EXT)/overlay/config/config.xml
endif
-# b/308878144 no more VNDK on 24Q1 and beyond
-KEEP_VNDK ?= false
-
# Support additional VNDK snapshots
PRODUCT_EXTRA_VNDK_VERSIONS := \
30 \
diff --git a/target/product/handheld_system.mk b/target/product/handheld_system.mk
index 3c401f3..fb55f56 100644
--- a/target/product/handheld_system.mk
+++ b/target/product/handheld_system.mk
@@ -75,6 +75,10 @@
vr \
PRODUCT_PACKAGES += $(RELEASE_PACKAGE_VIRTUAL_CAMERA)
+# Set virtual_camera_service_enabled soong config variable based on the
+# RELEASE_PACKAGE_VIRTUAL_CAMERA build. virtual_camera_service_enabled soong config
+# variable is used to prevent accessing the service when it's not present in the build.
+$(call soong_config_set,vdm,virtual_camera_service_enabled,$(if $(RELEASE_PACKAGE_VIRTUAL_CAMERA),true,false))
PRODUCT_SYSTEM_SERVER_APPS += \
FusedLocation \
diff --git a/target/product/runtime_libart.mk b/target/product/runtime_libart.mk
index d9c3c9a..dc78368 100644
--- a/target/product/runtime_libart.mk
+++ b/target/product/runtime_libart.mk
@@ -176,4 +176,5 @@
dalvik.vm.usap_pool_refill_delay_ms?=3000
PRODUCT_SYSTEM_PROPERTIES += \
- dalvik.vm.useartservice=true
+ dalvik.vm.useartservice=true \
+ dalvik.vm.enable_pr_dexopt=true
diff --git a/target/product/security/README b/target/product/security/README
index 2b161bb..1e015f0 100644
--- a/target/product/security/README
+++ b/target/product/security/README
@@ -37,3 +37,31 @@
This is called by build/make/core/Makefile to incorporate the OTA signing keys
into the recovery image.
+
+converting to java keystore for Android Studio
+----------------------------------------------
+
+Suppose we want to convert shared.pk8 and shared.x509.pem to shared.keystore.
+
+ $ openssl pkcs8 -inform DER -nocrypt \
+ -in build/make/target/product/security/shared.pk8 \
+ -out shared.pem
+ $ openssl pkcs12 -export \
+ -in build/make/target/product/security/shared.x509.pem \
+ -inkey shared.pem -out shared.p12 \
+ -password pass:android -name AndroidDebugKey
+ $ keytool -importkeystore -deststorepass android \
+ -destkeystore shared.keystore -srckeystore shared.p12 \
+ -srcstoretype PKCS12 -srcstorepass android
+
+The keystore can be used in build.gradle as follows.
+
+signingConfigs {
+ shared {
+ storeFile file("shared.keystore")
+ storePassword "android"
+ keyPassword "android"
+ keyAlias "AndroidDebugKey"
+ }
+}
+
diff --git a/target/product/vboot.mk b/target/product/vboot.mk
deleted file mode 100644
index 48a4883..0000000
--- a/target/product/vboot.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Copyright (C) 2015 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Provides dependencies necessary for verified boot
-
-PRODUCT_SUPPORTS_VBOOT := true
-
-# The dev key is used to sign boot and recovery images.
-# We expect this file to exist with the suffixes ".vbprivk" and ".vbpupk".
-# TODO: find a proper location for this
-PRODUCT_VBOOT_SIGNING_KEY := external/vboot_reference/tests/devkeys/kernel_data_key
-PRODUCT_VBOOT_SIGNING_SUBKEY := external/vboot_reference/tests/devkeys/kernel_subkey
diff --git a/teams/Android.bp b/teams/Android.bp
index b3a5752..fbf1344 100644
--- a/teams/Android.bp
+++ b/teams/Android.bp
@@ -4391,3 +4391,24 @@
// go/trendy/manage/engineers/5955405559201792
trendy_team_id: "5955405559201792",
}
+
+team {
+ name: "trendy_team_android_media_better_together",
+
+ // go/trendy/manage/engineers/5617300451721216
+ trendy_team_id: "5617300451721216",
+}
+
+team {
+ name: "trendy_team_attack_tools",
+
+ // go/trendy/manage/engineers/4705629185081344
+ trendy_team_id: "4705629185081344",
+}
+
+team {
+ name: "trendy_team_android_media_solutions_editing",
+
+ // go/trendy/manage/engineers/5350750192762880
+ trendy_team_id: "5350750192762880",
+}
diff --git a/tests/Android.bp b/tests/Android.bp
deleted file mode 100644
index 39debf5..0000000
--- a/tests/Android.bp
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright 2024 Google Inc. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package {
- default_applicable_licenses: ["Android-Apache-2.0"],
- default_team: "trendy_team_build",
-}
-
-python_test_host {
- name: "run_tool_with_logging_test",
- main: "run_tool_with_logging_test.py",
- pkg_path: "testdata",
- srcs: [
- "run_tool_with_logging_test.py",
- ],
- test_options: {
- unit_test: true,
- },
- data: [
- ":envsetup_minimum.zip",
- ":tool_event_logger",
- ],
- test_suites: [
- "general-tests",
- ],
- version: {
- py3: {
- embedded_launcher: true,
- },
- },
-}
diff --git a/tests/run_tool_with_logging_test.py b/tests/run_tool_with_logging_test.py
deleted file mode 100644
index 6f9b59c..0000000
--- a/tests/run_tool_with_logging_test.py
+++ /dev/null
@@ -1,345 +0,0 @@
-# Copyright 2024 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import dataclasses
-import glob
-from importlib import resources
-import logging
-import os
-from pathlib import Path
-import re
-import shutil
-import signal
-import stat
-import subprocess
-import sys
-import tempfile
-import textwrap
-import time
-import unittest
-import zipfile
-
-EXII_RETURN_CODE = 0
-INTERRUPTED_RETURN_CODE = 130
-
-
-class RunToolWithLoggingTest(unittest.TestCase):
-
- @classmethod
- def setUpClass(cls):
- super().setUpClass()
- # Configure to print logging to stdout.
- logging.basicConfig(filename=None, level=logging.DEBUG)
- console = logging.StreamHandler(sys.stdout)
- logging.getLogger("").addHandler(console)
-
- def setUp(self):
- super().setUp()
- self.working_dir = tempfile.TemporaryDirectory()
- # Run all the tests from working_dir which is our temp Android build top.
- os.chdir(self.working_dir.name)
- # Extract envsetup.zip which contains the envsetup.sh and other dependent
- # scripts required to set up the build environments.
- with resources.files("testdata").joinpath("envsetup.zip").open("rb") as p:
- with zipfile.ZipFile(p, "r") as zip_f:
- zip_f.extractall()
-
- def tearDown(self):
- self.working_dir.cleanup()
- super().tearDown()
-
- def test_does_not_log_when_logger_var_empty(self):
- test_tool = TestScript.create(self.working_dir)
-
- self._run_script_and_wait(f"""
- ANDROID_TOOL_LOGGER=""
- run_tool_with_logging "FAKE_TOOL" {test_tool.executable} arg1 arg2
- """)
-
- test_tool.assert_called_once_with_args("arg1 arg2")
-
- def test_does_not_log_with_logger_unset(self):
- test_tool = TestScript.create(self.working_dir)
-
- self._run_script_and_wait(f"""
- unset ANDROID_TOOL_LOGGER
- run_tool_with_logging "FAKE_TOOL" {test_tool.executable} arg1 arg2
- """)
-
- test_tool.assert_called_once_with_args("arg1 arg2")
-
- def test_log_success_with_logger_enabled(self):
- test_tool = TestScript.create(self.working_dir)
- test_logger = TestScript.create(self.working_dir)
-
- self._run_script_and_wait(f"""
- ANDROID_TOOL_LOGGER="{test_logger.executable}"
- run_tool_with_logging "FAKE_TOOL" {test_tool.executable} arg1 arg2
- """)
-
- test_tool.assert_called_once_with_args("arg1 arg2")
- expected_logger_args = (
- "--tool_tag=FAKE_TOOL --start_timestamp=\d+\.\d+ --end_timestamp="
- "\d+\.\d+ --tool_args=arg1 arg2 --exit_code=0"
- )
- test_logger.assert_called_once_with_args(expected_logger_args)
-
- def test_run_tool_output_is_same_with_and_without_logging(self):
- test_tool = TestScript.create(self.working_dir, "echo 'tool called'")
- test_logger = TestScript.create(self.working_dir)
-
- run_tool_with_logging_stdout, run_tool_with_logging_stderr = (
- self._run_script_and_wait(f"""
- ANDROID_TOOL_LOGGER="{test_logger.executable}"
- run_tool_with_logging "FAKE_TOOL" {test_tool.executable} arg1 arg2
- """)
- )
-
- run_tool_without_logging_stdout, run_tool_without_logging_stderr = (
- self._run_script_and_wait(f"""
- ANDROID_TOOL_LOGGER="{test_logger.executable}"
- {test_tool.executable} arg1 arg2
- """)
- )
-
- self.assertEqual(
- run_tool_with_logging_stdout, run_tool_without_logging_stdout
- )
- self.assertEqual(
- run_tool_with_logging_stderr, run_tool_without_logging_stderr
- )
-
- def test_logger_output_is_suppressed(self):
- test_tool = TestScript.create(self.working_dir)
- test_logger = TestScript.create(self.working_dir, "echo 'logger called'")
-
- run_tool_with_logging_output, _ = self._run_script_and_wait(f"""
- ANDROID_TOOL_LOGGER="{test_logger.executable}"
- run_tool_with_logging "FAKE_TOOL" {test_tool.executable} arg1 arg2
- """)
-
- self.assertNotIn("logger called", run_tool_with_logging_output)
-
- def test_logger_error_is_suppressed(self):
- test_tool = TestScript.create(self.working_dir)
- test_logger = TestScript.create(
- self.working_dir, "echo 'logger failed' > /dev/stderr; exit 1"
- )
-
- _, err = self._run_script_and_wait(f"""
- ANDROID_TOOL_LOGGER="{test_logger.executable}"
- run_tool_with_logging "FAKE_TOOL" {test_tool.executable} arg1 arg2
- """)
-
- self.assertNotIn("logger failed", err)
-
- def test_log_success_when_tool_interrupted(self):
- test_tool = TestScript.create(self.working_dir, script_body="sleep 100")
- test_logger = TestScript.create(self.working_dir)
-
- process = self._run_script_in_build_env(f"""
- ANDROID_TOOL_LOGGER="{test_logger.executable}"
- run_tool_with_logging "FAKE_TOOL" {test_tool.executable} arg1 arg2
- """)
-
- pgid = os.getpgid(process.pid)
- # Give sometime for the subprocess to start.
- time.sleep(1)
- # Kill the subprocess and any processes created in the same group.
- os.killpg(pgid, signal.SIGINT)
-
- returncode, _, _ = self._wait_for_process(process)
- self.assertEqual(returncode, INTERRUPTED_RETURN_CODE)
-
- expected_logger_args = (
- "--tool_tag=FAKE_TOOL --start_timestamp=\d+\.\d+ --end_timestamp="
- "\d+\.\d+ --tool_args=arg1 arg2 --exit_code=130"
- )
- test_logger.assert_called_once_with_args(expected_logger_args)
-
- def test_logger_can_be_toggled_on(self):
- test_tool = TestScript.create(self.working_dir)
- test_logger = TestScript.create(self.working_dir)
-
- self._run_script_and_wait(f"""
- ANDROID_TOOL_LOGGER=""
- ANDROID_TOOL_LOGGER="{test_logger.executable}"
- run_tool_with_logging "FAKE_TOOL" {test_tool.executable} arg1 arg2
- """)
-
- test_logger.assert_called_with_times(1)
-
- def test_logger_can_be_toggled_off(self):
- test_tool = TestScript.create(self.working_dir)
- test_logger = TestScript.create(self.working_dir)
-
- self._run_script_and_wait(f"""
- ANDROID_TOOL_LOGGER="{test_logger.executable}"
- ANDROID_TOOL_LOGGER=""
- run_tool_with_logging "FAKE_TOOL" {test_tool.executable} arg1 arg2
- """)
-
- test_logger.assert_not_called()
-
- def test_integration_tool_event_logger_dry_run(self):
- test_tool = TestScript.create(self.working_dir)
- logger_path = self._import_logger()
-
- self._run_script_and_wait(f"""
- TMPDIR="{self.working_dir.name}"
- ANDROID_TOOL_LOGGER="{logger_path}"
- ANDROID_TOOL_LOGGER_EXTRA_ARGS="--dry_run"
- run_tool_with_logging "FAKE_TOOL" {test_tool.executable} arg1 arg2
- """)
-
- self._assert_logger_dry_run()
-
- def test_tool_args_do_not_fail_logger(self):
- test_tool = TestScript.create(self.working_dir)
- logger_path = self._import_logger()
-
- self._run_script_and_wait(f"""
- TMPDIR="{self.working_dir.name}"
- ANDROID_TOOL_LOGGER="{logger_path}"
- ANDROID_TOOL_LOGGER_EXTRA_ARGS="--dry_run"
- run_tool_with_logging "FAKE_TOOL" {test_tool.executable} --tool-arg1
- """)
-
- self._assert_logger_dry_run()
-
- def _import_logger(self) -> Path:
- logger = "tool_event_logger"
- logger_path = Path(self.working_dir.name).joinpath(logger)
- with resources.as_file(resources.files("testdata").joinpath(logger)) as p:
- shutil.copy(p, logger_path)
- Path.chmod(logger_path, 0o755)
- return logger_path
-
- def _assert_logger_dry_run(self):
- log_files = glob.glob(self.working_dir.name + "/tool_event_logger_*/*.log")
- self.assertEqual(len(log_files), 1)
-
- with open(log_files[0], "r") as f:
- lines = f.readlines()
- self.assertEqual(len(lines), 1)
- self.assertIn("dry run", lines[0])
-
- def _create_build_env_script(self) -> str:
- return f"""
- source {Path(self.working_dir.name).joinpath("build/make/envsetup.sh")}
- """
-
- def _run_script_and_wait(self, test_script: str) -> tuple[str, str]:
- process = self._run_script_in_build_env(test_script)
- returncode, out, err = self._wait_for_process(process)
- logging.debug("script stdout: %s", out)
- logging.debug("script stderr: %s", err)
- self.assertEqual(returncode, EXII_RETURN_CODE)
- return out, err
-
- def _run_script_in_build_env(self, test_script: str) -> subprocess.Popen:
- setup_build_env_script = self._create_build_env_script()
- return subprocess.Popen(
- setup_build_env_script + test_script,
- shell=True,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- text=True,
- start_new_session=True,
- executable="/bin/bash",
- )
-
- def _wait_for_process(
- self, process: subprocess.Popen
- ) -> tuple[int, str, str]:
- pgid = os.getpgid(process.pid)
- out, err = process.communicate()
- # Wait for all process in the same group to complete since the logger runs
- # as a separate detached process.
- self._wait_for_process_group(pgid)
- return (process.returncode, out, err)
-
- def _wait_for_process_group(self, pgid: int, timeout: int = 5):
- """Waits for all subprocesses within the process group to complete."""
- start_time = time.time()
- while True:
- if time.time() - start_time > timeout:
- raise TimeoutError(
- f"Process group did not complete after {timeout} seconds"
- )
- for pid in os.listdir("/proc"):
- if pid.isdigit():
- try:
- if os.getpgid(int(pid)) == pgid:
- time.sleep(0.1)
- break
- except (FileNotFoundError, PermissionError, ProcessLookupError):
- pass
- else:
- # All processes have completed.
- break
-
-
-@dataclasses.dataclass
-class TestScript:
- executable: Path
- output_file: Path
-
- def create(temp_dir: Path, script_body: str = ""):
- with tempfile.NamedTemporaryFile(dir=temp_dir.name, delete=False) as f:
- output_file = f.name
-
- with tempfile.NamedTemporaryFile(dir=temp_dir.name, delete=False) as f:
- executable = f.name
- executable_contents = textwrap.dedent(f"""
- #!/bin/bash
-
- echo "${{@}}" >> {output_file}
- {script_body}
- """)
- f.write(executable_contents.encode("utf-8"))
-
- Path.chmod(f.name, os.stat(f.name).st_mode | stat.S_IEXEC)
-
- return TestScript(executable, output_file)
-
- def assert_called_with_times(self, expected_call_times: int):
- lines = self._read_contents_from_output_file()
- assert len(lines) == expected_call_times, (
- f"Expect to call {expected_call_times} times, but actually called"
- f" {len(lines)} times."
- )
-
- def assert_called_with_args(self, expected_args: str):
- lines = self._read_contents_from_output_file()
- assert len(lines) > 0
- assert re.search(expected_args, lines[0]), (
- f"Expect to call with args {expected_args}, but actually called with"
- f" args {lines[0]}."
- )
-
- def assert_not_called(self):
- self.assert_called_with_times(0)
-
- def assert_called_once_with_args(self, expected_args: str):
- self.assert_called_with_times(1)
- self.assert_called_with_args(expected_args)
-
- def _read_contents_from_output_file(self) -> list[str]:
- with open(self.output_file, "r") as f:
- return f.readlines()
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tools/aconfig/.editorconfig b/tools/aconfig/.editorconfig
new file mode 100644
index 0000000..cc5985f
--- /dev/null
+++ b/tools/aconfig/.editorconfig
@@ -0,0 +1,9 @@
+# EditorConfig is awesome: https://EditorConfig.org
+
+# top-most EditorConfig file
+root = true
+
+[*.java]
+indent_style = tab
+indent_size = 4
+
diff --git a/tools/aconfig/TEST_MAPPING b/tools/aconfig/TEST_MAPPING
index 421e94a..448d8cf 100644
--- a/tools/aconfig/TEST_MAPPING
+++ b/tools/aconfig/TEST_MAPPING
@@ -94,12 +94,16 @@
{
// aconfig_storage read api cpp integration tests
"name": "aconfig_storage_read_api.test.cpp"
+ },
+ {
+ // aconfig_storage file cpp integration tests
+ "name": "aconfig_storage_file.test.cpp"
}
],
"postsubmit": [
{
- // aconfig_storage file cpp integration tests
- "name": "aconfig_storage_file.test.cpp"
+ // aconfig_storage read api java integration tests
+ "name": "aconfig_storage_read_api.test.java"
}
]
}
diff --git a/tools/aconfig/aconfig_device_paths/src/lib.rs b/tools/aconfig/aconfig_device_paths/src/lib.rs
index 7480b30..9ab9cea 100644
--- a/tools/aconfig/aconfig_device_paths/src/lib.rs
+++ b/tools/aconfig/aconfig_device_paths/src/lib.rs
@@ -30,9 +30,11 @@
.collect()
}
-/// Determine all paths that contain an aconfig protobuf file.
+/// Determines all paths that contain an aconfig protobuf file,
+/// filtering out nonexistent partition protobuf files.
pub fn parsed_flags_proto_paths() -> Result<Vec<PathBuf>> {
- let mut result: Vec<PathBuf> = read_partition_paths();
+ let mut result: Vec<PathBuf> =
+ read_partition_paths().into_iter().filter(|s| s.exists()).collect();
for dir in fs::read_dir("/apex")? {
let dir = dir?;
diff --git a/tools/aconfig/aconfig_storage_read_api/Android.bp b/tools/aconfig/aconfig_storage_read_api/Android.bp
index 9b84254..5e9eb54 100644
--- a/tools/aconfig/aconfig_storage_read_api/Android.bp
+++ b/tools/aconfig/aconfig_storage_read_api/Android.bp
@@ -104,6 +104,33 @@
afdo: true,
}
+soong_config_module_type {
+ name: "aconfig_lib_cc_shared_link_defaults",
+ module_type: "cc_defaults",
+ config_namespace: "Aconfig",
+ bool_variables: [
+ "read_from_new_storage",
+ ],
+ properties: [
+ "shared_libs",
+ ],
+}
+
+soong_config_bool_variable {
+ name: "read_from_new_storage",
+}
+
+aconfig_lib_cc_shared_link_defaults {
+ name: "aconfig_lib_cc_shared_link.defaults",
+ soong_config_variables: {
+ read_from_new_storage: {
+ shared_libs: [
+ "libaconfig_storage_read_api_cc",
+ ],
+ },
+ },
+}
+
cc_defaults {
name: "aconfig_lib_cc_static_link.defaults",
shared_libs: [
@@ -111,3 +138,28 @@
"liblog",
],
}
+
+rust_ffi_shared {
+ name: "libaconfig_storage_read_api_rust_jni",
+ crate_name: "aconfig_storage_read_api_rust_jni",
+ srcs: ["srcs/lib.rs"],
+ rustlibs: [
+ "libaconfig_storage_read_api",
+ "libanyhow",
+ "libjni",
+ ],
+ prefer_rlib: true,
+}
+
+java_library {
+ name: "libaconfig_storage_read_api_java",
+ srcs: [
+ "srcs/**/*.java",
+ ],
+ required: ["libaconfig_storage_read_api_rust_jni"],
+ min_sdk_version: "UpsideDownCake",
+ apex_available: [
+ "//apex_available:anyapex",
+ "//apex_available:platform",
+ ],
+}
diff --git a/tools/aconfig/aconfig_storage_read_api/srcs/android/aconfig/storage/AconfigStorageReadAPI.java b/tools/aconfig/aconfig_storage_read_api/srcs/android/aconfig/storage/AconfigStorageReadAPI.java
new file mode 100644
index 0000000..406ff24
--- /dev/null
+++ b/tools/aconfig/aconfig_storage_read_api/srcs/android/aconfig/storage/AconfigStorageReadAPI.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.aconfig.storage;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileChannel.MapMode;
+
+import android.aconfig.storage.PackageReadContext;
+import android.aconfig.storage.FlagReadContext;
+
+import dalvik.annotation.optimization.FastNative;
+
+public class AconfigStorageReadAPI {
+
+ // Storage file dir on device
+ private static final String STORAGEDIR = "/metadata/aconfig";
+
+ // Stoarge file type
+ public enum StorageFileType {
+ PACKAGE_MAP,
+ FLAG_MAP,
+ FLAG_VAL,
+ FLAG_INFO
+ }
+
+ // Map a storage file given file path
+ public static MappedByteBuffer mapStorageFile(String file) throws IOException {
+ FileInputStream stream = new FileInputStream(file);
+ FileChannel channel = stream.getChannel();
+ return channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
+ }
+
+ // Map a storage file given container and file type
+ public static MappedByteBuffer getMappedFile(
+ String container,
+ StorageFileType type) throws IOException{
+ switch (type) {
+ case PACKAGE_MAP:
+ return mapStorageFile(STORAGEDIR + "/maps/" + container + ".package.map");
+ case FLAG_MAP:
+ return mapStorageFile(STORAGEDIR + "/maps/" + container + ".flag.map");
+ case FLAG_VAL:
+ return mapStorageFile(STORAGEDIR + "/boot/" + container + ".val");
+ case FLAG_INFO:
+ return mapStorageFile(STORAGEDIR + "/boot/" + container + ".info");
+ default:
+ throw new IOException("Invalid storage file type");
+ }
+ }
+
+ // JNI interface to get package read context
+ // @param mappedFile: memory mapped package map file
+ // @param packageName: package name
+ // @throws IOException if the passed in file is not a valid package map file
+ @FastNative
+ private static native ByteBuffer getPackageReadContextImpl(
+ ByteBuffer mappedFile, String packageName) throws IOException;
+
+ // API to get package read context
+ // @param mappedFile: memory mapped package map file
+ // @param packageName: package name
+ // @throws IOException if the passed in file is not a valid package map file
+ static public PackageReadContext getPackageReadContext (
+ ByteBuffer mappedFile, String packageName) throws IOException {
+ ByteBuffer buffer = getPackageReadContextImpl(mappedFile, packageName);
+ buffer.order(ByteOrder.LITTLE_ENDIAN);
+ return new PackageReadContext(buffer.getInt(), buffer.getInt(4));
+ }
+
+ // JNI interface to get flag read context
+ // @param mappedFile: memory mapped flag map file
+ // @param packageId: package id to represent a specific package, obtained from
+ // package map file
+ // @param flagName: flag name
+ // @throws IOException if the passed in file is not a valid flag map file
+ @FastNative
+ private static native ByteBuffer getFlagReadContextImpl(
+ ByteBuffer mappedFile, int packageId, String flagName) throws IOException;
+
+ // API to get flag read context
+ // @param mappedFile: memory mapped flag map file
+ // @param packageId: package id to represent a specific package, obtained from
+ // package map file
+ // @param flagName: flag name
+ // @throws IOException if the passed in file is not a valid flag map file
+ public static FlagReadContext getFlagReadContext(
+ ByteBuffer mappedFile, int packageId, String flagName) throws IOException {
+ ByteBuffer buffer = getFlagReadContextImpl(mappedFile, packageId, flagName);
+ buffer.order(ByteOrder.LITTLE_ENDIAN);
+ return new FlagReadContext(buffer.getInt(), buffer.getInt(4));
+ }
+
+ // JNI interface to get boolean flag value
+ // @param mappedFile: memory mapped flag value file
+ // @param flagIndex: flag global index in the flag value array
+ // @throws IOException if the passed in file is not a valid flag value file or the
+ // flag index went over the file boundary.
+ @FastNative
+ public static native boolean getBooleanFlagValue(
+ ByteBuffer mappedFile, int flagIndex) throws IOException;
+
+ static {
+ System.loadLibrary("aconfig_storage_read_api_rust_jni");
+ }
+}
diff --git a/tools/aconfig/aconfig_storage_read_api/srcs/android/aconfig/storage/FlagReadContext.java b/tools/aconfig/aconfig_storage_read_api/srcs/android/aconfig/storage/FlagReadContext.java
new file mode 100644
index 0000000..60559a9
--- /dev/null
+++ b/tools/aconfig/aconfig_storage_read_api/srcs/android/aconfig/storage/FlagReadContext.java
@@ -0,0 +1,47 @@
+package android.aconfig.storage;
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class FlagReadContext {
+ public StoredFlagType mFlagType;
+ public int mFlagIndex;
+
+ public FlagReadContext(int flagType,
+ int flagIndex) {
+ mFlagType = StoredFlagType.fromInteger(flagType);
+ mFlagIndex = flagIndex;
+ }
+
+ // Flag type enum, consistent with the definition in aconfig_storage_file/src/lib.rs
+ public enum StoredFlagType {
+ ReadWriteBoolean,
+ ReadOnlyBoolean,
+ FixedReadOnlyBoolean;
+
+ public static StoredFlagType fromInteger(int x) {
+ switch(x) {
+ case 0:
+ return ReadWriteBoolean;
+ case 1:
+ return ReadOnlyBoolean;
+ case 2:
+ return FixedReadOnlyBoolean;
+ default:
+ return null;
+ }
+ }
+ }
+}
diff --git a/tools/aconfig/aconfig_storage_read_api/srcs/android/aconfig/storage/PackageReadContext.java b/tools/aconfig/aconfig_storage_read_api/srcs/android/aconfig/storage/PackageReadContext.java
new file mode 100644
index 0000000..b781d9b
--- /dev/null
+++ b/tools/aconfig/aconfig_storage_read_api/srcs/android/aconfig/storage/PackageReadContext.java
@@ -0,0 +1,27 @@
+package android.aconfig.storage;
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class PackageReadContext {
+ public int mPackageId;
+ public int mBooleanStartIndex;
+
+ public PackageReadContext(int packageId,
+ int booleanStartIndex) {
+ mPackageId = packageId;
+ mBooleanStartIndex = booleanStartIndex;
+ }
+}
diff --git a/tools/aconfig/aconfig_storage_read_api/srcs/lib.rs b/tools/aconfig/aconfig_storage_read_api/srcs/lib.rs
new file mode 100644
index 0000000..304a059
--- /dev/null
+++ b/tools/aconfig/aconfig_storage_read_api/srcs/lib.rs
@@ -0,0 +1,160 @@
+//! aconfig storage read api java rust interlop
+
+use aconfig_storage_read_api::flag_table_query::find_flag_read_context;
+use aconfig_storage_read_api::flag_value_query::find_boolean_flag_value;
+use aconfig_storage_read_api::package_table_query::find_package_read_context;
+use aconfig_storage_read_api::{FlagReadContext, PackageReadContext};
+
+use anyhow::Result;
+use jni::objects::{JByteBuffer, JClass, JString};
+use jni::sys::{jboolean, jint};
+use jni::JNIEnv;
+
+/// Call rust find package read context
+fn get_package_read_context_java(
+ env: &mut JNIEnv,
+ file: JByteBuffer,
+ package: JString,
+) -> Result<Option<PackageReadContext>> {
+ // SAFETY:
+ // The safety here is ensured as the package name is guaranteed to be a java string
+ let package_name: String = unsafe { env.get_string_unchecked(&package)?.into() };
+ let buffer_ptr = env.get_direct_buffer_address(&file)?;
+ let buffer_size = env.get_direct_buffer_capacity(&file)?;
+ // SAFETY:
+ // The safety here is ensured as only non null MemoryMappedBuffer will be passed in,
+ // so the conversion to slice is guaranteed to be valid
+ let buffer = unsafe { std::slice::from_raw_parts(buffer_ptr, buffer_size) };
+ Ok(find_package_read_context(buffer, &package_name)?)
+}
+
+/// Get package read context JNI
+#[no_mangle]
+#[allow(unused)]
+pub extern "system" fn Java_android_aconfig_storage_AconfigStorageReadAPI_getPackageReadContextImpl<
+ 'local,
+>(
+ mut env: JNIEnv<'local>,
+ class: JClass<'local>,
+ file: JByteBuffer<'local>,
+ package: JString<'local>,
+) -> JByteBuffer<'local> {
+ let mut package_id = -1;
+ let mut boolean_start_index = -1;
+
+ match get_package_read_context_java(&mut env, file, package) {
+ Ok(context_opt) => {
+ if let Some(context) = context_opt {
+ package_id = context.package_id as i32;
+ boolean_start_index = context.boolean_start_index as i32;
+ }
+ }
+ Err(errmsg) => {
+ env.throw(("java/io/IOException", errmsg.to_string())).expect("failed to throw");
+ }
+ }
+
+ let mut bytes = Vec::new();
+ bytes.extend_from_slice(&package_id.to_le_bytes());
+ bytes.extend_from_slice(&boolean_start_index.to_le_bytes());
+ let (addr, len) = {
+ let buf = bytes.leak();
+ (buf.as_mut_ptr(), buf.len())
+ };
+ // SAFETY:
+ // The safety here is ensured as the content is ensured to be valid
+ unsafe { env.new_direct_byte_buffer(addr, len).expect("failed to create byte buffer") }
+}
+
+/// Call rust find flag read context
+fn get_flag_read_context_java(
+ env: &mut JNIEnv,
+ file: JByteBuffer,
+ package_id: jint,
+ flag: JString,
+) -> Result<Option<FlagReadContext>> {
+ // SAFETY:
+ // The safety here is ensured as the flag name is guaranteed to be a java string
+ let flag_name: String = unsafe { env.get_string_unchecked(&flag)?.into() };
+ let buffer_ptr = env.get_direct_buffer_address(&file)?;
+ let buffer_size = env.get_direct_buffer_capacity(&file)?;
+ // SAFETY:
+ // The safety here is ensured as only non null MemoryMappedBuffer will be passed in,
+ // so the conversion to slice is guaranteed to be valid
+ let buffer = unsafe { std::slice::from_raw_parts(buffer_ptr, buffer_size) };
+ Ok(find_flag_read_context(buffer, package_id as u32, &flag_name)?)
+}
+
+/// Get flag read context JNI
+#[no_mangle]
+#[allow(unused)]
+pub extern "system" fn Java_android_aconfig_storage_AconfigStorageReadAPI_getFlagReadContextImpl<
+ 'local,
+>(
+ mut env: JNIEnv<'local>,
+ class: JClass<'local>,
+ file: JByteBuffer<'local>,
+ package_id: jint,
+ flag: JString<'local>,
+) -> JByteBuffer<'local> {
+ let mut flag_type = -1;
+ let mut flag_index = -1;
+
+ match get_flag_read_context_java(&mut env, file, package_id, flag) {
+ Ok(context_opt) => {
+ if let Some(context) = context_opt {
+ flag_type = context.flag_type as i32;
+ flag_index = context.flag_index as i32;
+ }
+ }
+ Err(errmsg) => {
+ env.throw(("java/io/IOException", errmsg.to_string())).expect("failed to throw");
+ }
+ }
+
+ let mut bytes = Vec::new();
+ bytes.extend_from_slice(&flag_type.to_le_bytes());
+ bytes.extend_from_slice(&flag_index.to_le_bytes());
+ let (addr, len) = {
+ let buf = bytes.leak();
+ (buf.as_mut_ptr(), buf.len())
+ };
+ // SAFETY:
+ // The safety here is ensured as the content is ensured to be valid
+ unsafe { env.new_direct_byte_buffer(addr, len).expect("failed to create byte buffer") }
+}
+
+/// Call rust find boolean flag value
+fn get_boolean_flag_value_java(
+ env: &mut JNIEnv,
+ file: JByteBuffer,
+ flag_index: jint,
+) -> Result<bool> {
+ let buffer_ptr = env.get_direct_buffer_address(&file)?;
+ let buffer_size = env.get_direct_buffer_capacity(&file)?;
+ // SAFETY:
+ // The safety here is ensured as only non null MemoryMappedBuffer will be passed in,
+ // so the conversion to slice is guaranteed to be valid
+ let buffer = unsafe { std::slice::from_raw_parts(buffer_ptr, buffer_size) };
+ Ok(find_boolean_flag_value(buffer, flag_index as u32)?)
+}
+
+/// Get flag value JNI
+#[no_mangle]
+#[allow(unused)]
+pub extern "system" fn Java_android_aconfig_storage_AconfigStorageReadAPI_getBooleanFlagValue<
+ 'local,
+>(
+ mut env: JNIEnv<'local>,
+ class: JClass<'local>,
+ file: JByteBuffer<'local>,
+ flag_index: jint,
+) -> jboolean {
+ match get_boolean_flag_value_java(&mut env, file, flag_index) {
+ Ok(value) => value as u8,
+ Err(errmsg) => {
+ env.throw(("java/io/IOException", errmsg.to_string())).expect("failed to throw");
+ 0u8
+ }
+ }
+}
diff --git a/tools/aconfig/aconfig_storage_read_api/tests/Android.bp b/tools/aconfig/aconfig_storage_read_api/tests/Android.bp
index 98944d6..ed0c728 100644
--- a/tools/aconfig/aconfig_storage_read_api/tests/Android.bp
+++ b/tools/aconfig/aconfig_storage_read_api/tests/Android.bp
@@ -1,7 +1,16 @@
+filegroup {
+ name: "read_api_test_storage_files",
+ srcs: ["package.map",
+ "flag.map",
+ "flag.val",
+ "flag.info"
+ ],
+}
+
rust_test {
name: "aconfig_storage_read_api.test.rust",
srcs: [
- "storage_read_api_test.rs"
+ "storage_read_api_test.rs",
],
rustlibs: [
"libanyhow",
@@ -10,10 +19,7 @@
"librand",
],
data: [
- "package.map",
- "flag.map",
- "flag.val",
- "flag.info",
+ ":read_api_test_storage_files",
],
test_suites: ["general-tests"],
}
@@ -30,10 +36,7 @@
"liblog",
],
data: [
- "package.map",
- "flag.map",
- "flag.val",
- "flag.info",
+ ":read_api_test_storage_files",
],
test_suites: [
"device-tests",
diff --git a/tools/aconfig/aconfig_storage_read_api/tests/java/AconfigStorageReadAPITest.java b/tools/aconfig/aconfig_storage_read_api/tests/java/AconfigStorageReadAPITest.java
new file mode 100644
index 0000000..a26b257
--- /dev/null
+++ b/tools/aconfig/aconfig_storage_read_api/tests/java/AconfigStorageReadAPITest.java
@@ -0,0 +1,213 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.aconfig.storage.test;
+
+import java.io.IOException;
+import java.nio.MappedByteBuffer;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import android.aconfig.storage.AconfigStorageReadAPI;
+import android.aconfig.storage.PackageReadContext;
+import android.aconfig.storage.FlagReadContext;
+import android.aconfig.storage.FlagReadContext.StoredFlagType;
+
+@RunWith(JUnit4.class)
+public class AconfigStorageReadAPITest{
+
+ private String mStorageDir = "/data/local/tmp/aconfig_java_api_test";
+
+ @Test
+ public void testPackageContextQuery() {
+ MappedByteBuffer packageMap = null;
+ try {
+ packageMap = AconfigStorageReadAPI.mapStorageFile(
+ mStorageDir + "/maps/mockup.package.map");
+ } catch(IOException ex){
+ assertTrue(ex.toString(), false);
+ }
+ assertTrue(packageMap != null);
+
+ try {
+ PackageReadContext context = AconfigStorageReadAPI.getPackageReadContext(
+ packageMap, "com.android.aconfig.storage.test_1");
+ assertEquals(context.mPackageId, 0);
+ assertEquals(context.mBooleanStartIndex, 0);
+
+ context = AconfigStorageReadAPI.getPackageReadContext(
+ packageMap, "com.android.aconfig.storage.test_2");
+ assertEquals(context.mPackageId, 1);
+ assertEquals(context.mBooleanStartIndex, 3);
+
+ context = AconfigStorageReadAPI.getPackageReadContext(
+ packageMap, "com.android.aconfig.storage.test_4");
+ assertEquals(context.mPackageId, 2);
+ assertEquals(context.mBooleanStartIndex, 6);
+ } catch (IOException ex) {
+ assertTrue(ex.toString(), false);
+ }
+ }
+
+ @Test
+ public void testNonExistPackageContextQuery() {
+ MappedByteBuffer packageMap = null;
+ try {
+ packageMap = AconfigStorageReadAPI.mapStorageFile(
+ mStorageDir + "/maps/mockup.package.map");
+ } catch(IOException ex){
+ assertTrue(ex.toString(), false);
+ }
+ assertTrue(packageMap != null);
+
+ try {
+ PackageReadContext context = AconfigStorageReadAPI.getPackageReadContext(
+ packageMap, "unknown");
+ assertEquals(context.mPackageId, -1);
+ assertEquals(context.mBooleanStartIndex, -1);
+ } catch(IOException ex){
+ assertTrue(ex.toString(), false);
+ }
+ }
+
+ @Test
+ public void testFlagContextQuery() {
+ MappedByteBuffer flagMap = null;
+ try {
+ flagMap = AconfigStorageReadAPI.mapStorageFile(
+ mStorageDir + "/maps/mockup.flag.map");
+ } catch(IOException ex){
+ assertTrue(ex.toString(), false);
+ }
+ assertTrue(flagMap!= null);
+
+ class Baseline {
+ public int mPackageId;
+ public String mFlagName;
+ public StoredFlagType mFlagType;
+ public int mFlagIndex;
+
+ public Baseline(int packageId,
+ String flagName,
+ StoredFlagType flagType,
+ int flagIndex) {
+ mPackageId = packageId;
+ mFlagName = flagName;
+ mFlagType = flagType;
+ mFlagIndex = flagIndex;
+ }
+ }
+
+ List<Baseline> baselines = new ArrayList();
+ baselines.add(new Baseline(0, "enabled_ro", StoredFlagType.ReadOnlyBoolean, 1));
+ baselines.add(new Baseline(0, "enabled_rw", StoredFlagType.ReadWriteBoolean, 2));
+ baselines.add(new Baseline(2, "enabled_rw", StoredFlagType.ReadWriteBoolean, 1));
+ baselines.add(new Baseline(1, "disabled_rw", StoredFlagType.ReadWriteBoolean, 0));
+ baselines.add(new Baseline(1, "enabled_fixed_ro", StoredFlagType.FixedReadOnlyBoolean, 1));
+ baselines.add(new Baseline(1, "enabled_ro", StoredFlagType.ReadOnlyBoolean, 2));
+ baselines.add(new Baseline(2, "enabled_fixed_ro", StoredFlagType.FixedReadOnlyBoolean, 0));
+ baselines.add(new Baseline(0, "disabled_rw", StoredFlagType.ReadWriteBoolean, 0));
+
+ try {
+ for (Baseline baseline : baselines) {
+ FlagReadContext context = AconfigStorageReadAPI.getFlagReadContext(
+ flagMap, baseline.mPackageId, baseline.mFlagName);
+ assertEquals(context.mFlagType, baseline.mFlagType);
+ assertEquals(context.mFlagIndex, baseline.mFlagIndex);
+ }
+ } catch (IOException ex) {
+ assertTrue(ex.toString(), false);
+ }
+ }
+
+ @Test
+ public void testNonExistFlagContextQuery() {
+ MappedByteBuffer flagMap = null;
+ try {
+ flagMap = AconfigStorageReadAPI.mapStorageFile(
+ mStorageDir + "/maps/mockup.flag.map");
+ } catch(IOException ex){
+ assertTrue(ex.toString(), false);
+ }
+ assertTrue(flagMap!= null);
+
+ try {
+ FlagReadContext context = AconfigStorageReadAPI.getFlagReadContext(
+ flagMap, 0, "unknown");
+ assertEquals(context.mFlagType, null);
+ assertEquals(context.mFlagIndex, -1);
+
+ context = AconfigStorageReadAPI.getFlagReadContext(
+ flagMap, 3, "enabled_ro");
+ assertEquals(context.mFlagType, null);
+ assertEquals(context.mFlagIndex, -1);
+ } catch (IOException ex) {
+ assertTrue(ex.toString(), false);
+ }
+ }
+
+ @Test
+ public void testBooleanFlagValueQuery() {
+ MappedByteBuffer flagVal = null;
+ try {
+ flagVal = AconfigStorageReadAPI.mapStorageFile(
+ mStorageDir + "/boot/mockup.val");
+ } catch (IOException ex) {
+ assertTrue(ex.toString(), false);
+ }
+ assertTrue(flagVal!= null);
+
+ boolean[] baselines = {false, true, true, false, true, true, true, true};
+ for (int i = 0; i < 8; ++i) {
+ try {
+ Boolean value = AconfigStorageReadAPI.getBooleanFlagValue(flagVal, i);
+ assertEquals(value, baselines[i]);
+ } catch (IOException ex) {
+ assertTrue(ex.toString(), false);
+ }
+ }
+ }
+
+ @Test
+ public void testInvalidBooleanFlagValueQuery() {
+ MappedByteBuffer flagVal = null;
+ try {
+ flagVal = AconfigStorageReadAPI.mapStorageFile(
+ mStorageDir + "/boot/mockup.val");
+ } catch (IOException ex) {
+ assertTrue(ex.toString(), false);
+ }
+ assertTrue(flagVal!= null);
+
+ try {
+ Boolean value = AconfigStorageReadAPI.getBooleanFlagValue(flagVal, 9);
+ assertTrue("should throw", false);
+ } catch (IOException ex) {
+ String expectedErrmsg = "invalid storage file byte offset";
+ assertTrue(ex.toString(), ex.toString().contains(expectedErrmsg));
+ }
+ }
+ }
diff --git a/tools/aconfig/aconfig_storage_read_api/tests/java/Android.bp b/tools/aconfig/aconfig_storage_read_api/tests/java/Android.bp
new file mode 100644
index 0000000..d94b2b4
--- /dev/null
+++ b/tools/aconfig/aconfig_storage_read_api/tests/java/Android.bp
@@ -0,0 +1,21 @@
+android_test {
+ name: "aconfig_storage_read_api.test.java",
+ srcs: ["AconfigStorageReadAPITest.java"],
+ static_libs: [
+ "androidx.test.rules",
+ "libaconfig_storage_read_api_java",
+ "junit",
+ ],
+ jni_libs: [
+ "libaconfig_storage_read_api_rust_jni",
+ ],
+ data: [
+ ":read_api_test_storage_files",
+ ],
+ platform_apis: true,
+ certificate: "platform",
+ test_suites: [
+ "general-tests",
+ ],
+ team: "trendy_team_android_core_experiments",
+}
diff --git a/tools/aconfig/aconfig_storage_read_api/tests/java/AndroidManifest.xml b/tools/aconfig/aconfig_storage_read_api/tests/java/AndroidManifest.xml
new file mode 100644
index 0000000..78bfb37
--- /dev/null
+++ b/tools/aconfig/aconfig_storage_read_api/tests/java/AndroidManifest.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2024 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="android.aconfig_storage.test">
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.aconfig_storage.test" />
+
+</manifest>
diff --git a/tools/aconfig/aconfig_storage_read_api/tests/java/AndroidTest.xml b/tools/aconfig/aconfig_storage_read_api/tests/java/AndroidTest.xml
new file mode 100644
index 0000000..99c9e25
--- /dev/null
+++ b/tools/aconfig/aconfig_storage_read_api/tests/java/AndroidTest.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<configuration description="Config for aconfig storage read java api tests">
+ <!-- Need root to start virtualizationservice -->
+ <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
+
+ <!-- Prepare test directories. -->
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="throw-if-cmd-fail" value="true" />
+ <option name="run-command" value="mkdir -p /data/local/tmp/aconfig_java_api" />
+ <option name="teardown-command" value="rm -rf /data/local/tmp/aconfig_java_api" />
+ </target_preparer>
+
+ <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+ <option name="test-file-name" value="aconfig_storage_read_api.test.java.apk" />
+ </target_preparer>
+
+ <target_preparer class="com.android.tradefed.targetprep.DisableSELinuxTargetPreparer" />
+
+ <!-- Test data files -->
+ <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+ <option name="cleanup" value="true" />
+ <option name="abort-on-push-failure" value="true" />
+ <option name="push-file" key="package.map"
+ value="/data/local/tmp/aconfig_java_api_test/maps/mockup.package.map" />
+ <option name="push-file" key="flag.map"
+ value="/data/local/tmp/aconfig_java_api_test/maps/mockup.flag.map" />
+ <option name="push-file" key="flag.val"
+ value="/data/local/tmp/aconfig_java_api_test/boot/mockup.val" />
+ </target_preparer>
+
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
+ <option name="package" value="android.aconfig_storage.test" />
+ <option name="runtime-hint" value="1m" />
+ </test>
+</configuration>
diff --git a/tools/aconfig/aflags/src/main.rs b/tools/aconfig/aflags/src/main.rs
index 05c15bb..810f2e3 100644
--- a/tools/aconfig/aflags/src/main.rs
+++ b/tools/aconfig/aflags/src/main.rs
@@ -233,8 +233,6 @@
}
fn set_flag(qualified_name: &str, value: &str) -> Result<()> {
- ensure!(nix::unistd::Uid::current().is_root(), "must be root to mutate flags");
-
let flags_binding = DeviceConfigSource::list_flags()?;
let flag = flags_binding.iter().find(|f| f.qualified_name() == qualified_name).ok_or(
anyhow!("no aconfig flag '{qualified_name}'. Does the flag have an .aconfig definition?"),
@@ -282,7 +280,9 @@
Ok(result)
}
-fn main() {
+fn main() -> Result<()> {
+ ensure!(nix::unistd::Uid::current().is_root(), "must be root");
+
let cli = Cli::parse();
let output = match cli.command {
Command::List { use_new_storage: true, container } => {
@@ -299,6 +299,8 @@
Ok(None) => (),
Err(message) => println!("Error: {message}"),
}
+
+ Ok(())
}
#[cfg(test)]
diff --git a/tools/check-flagged-apis/check-flagged-apis.sh b/tools/check-flagged-apis/check-flagged-apis.sh
index d9934a1..8078cd8 100755
--- a/tools/check-flagged-apis/check-flagged-apis.sh
+++ b/tools/check-flagged-apis/check-flagged-apis.sh
@@ -14,8 +14,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Run check-flagged-apis for public APIs and the three @SystemApi flavours
-# Usage: lunch <your-target> && source <this script>
+# Run check-flagged-apis for public APIs and the three @SystemApi flavours.
+#
+# This script expects an argument to tell it which subcommand of
+# check-flagged-apis to execute. Run the script without any arguments to see
+# the valid options.
+#
+# Remember to lunch to select the relevant release config before running this script.
source $(cd $(dirname $BASH_SOURCE) &> /dev/null && pwd)/../../shell_utils.sh
require_top
@@ -43,6 +48,10 @@
$MODULE_LIB_XML_VERSIONS
}
+function noop() {
+ true
+}
+
function aninja() {
local T="$(gettop)"
(\cd "${T}" && prebuilts/build-tools/linux-x86/bin/ninja -f out/combined-${TARGET_PRODUCT}.ninja "$@")
@@ -52,11 +61,11 @@
aninja -t query device_"$1"_all_targets | grep -A1 -e input: | tail -n1
}
-function run() {
+function run_check() {
local errors=0
echo "# current"
- check-flagged-apis \
+ check-flagged-apis check \
--api-signature $(path_to_api_signature_file "frameworks-base-api-current.txt") \
--flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
--api-versions $PUBLIC_XML_VERSIONS
@@ -64,7 +73,7 @@
echo
echo "# system-current"
- check-flagged-apis \
+ check-flagged-apis check \
--api-signature $(path_to_api_signature_file "frameworks-base-api-system-current.txt") \
--flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
--api-versions $SYSTEM_XML_VERSIONS
@@ -72,7 +81,7 @@
echo
echo "# system-server-current"
- check-flagged-apis \
+ check-flagged-apis check \
--api-signature $(path_to_api_signature_file "frameworks-base-api-system-server-current.txt") \
--flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
--api-versions $SYSTEM_SERVER_XML_VERSONS
@@ -80,7 +89,7 @@
echo
echo "# module-lib"
- check-flagged-apis \
+ check-flagged-apis check \
--api-signature $(path_to_api_signature_file "frameworks-base-api-module-lib-current.txt") \
--flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb \
--api-versions $MODULE_LIB_XML_VERSIONS
@@ -89,8 +98,39 @@
return $errors
}
-if [[ "$1" != "--skip-build" ]]; then
- build && run
-else
- run
+function run_list() {
+ echo "# current"
+ check-flagged-apis list \
+ --api-signature $(path_to_api_signature_file "frameworks-base-api-current.txt") \
+ --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb
+
+ echo
+ echo "# system-current"
+ check-flagged-apis list \
+ --api-signature $(path_to_api_signature_file "frameworks-base-api-system-current.txt") \
+ --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb
+
+ echo
+ echo "# system-server-current"
+ check-flagged-apis list \
+ --api-signature $(path_to_api_signature_file "frameworks-base-api-system-server-current.txt") \
+ --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb
+
+ echo
+ echo "# module-lib"
+ check-flagged-apis list \
+ --api-signature $(path_to_api_signature_file "frameworks-base-api-module-lib-current.txt") \
+ --flag-values $(gettop)/out/soong/.intermediates/all_aconfig_declarations.pb
+}
+
+build_cmd=build
+if [[ "$1" == "--skip-build" ]]; then
+ build_cmd=noop
+ shift 1
fi
+
+case "$1" in
+ check) $build_cmd && run_check ;;
+ list) $build_cmd && run_list ;;
+ *) echo "usage: $(basename $0): [--skip-build] check|list"; exit 1
+esac
diff --git a/tools/check-flagged-apis/src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt b/tools/check-flagged-apis/src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt
index 8e285f6..e07ac1d 100644
--- a/tools/check-flagged-apis/src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt
+++ b/tools/check-flagged-apis/src/com/android/checkflaggedapis/CheckFlaggedApisTest.kt
@@ -358,4 +358,23 @@
parseApiVersions(API_VERSIONS.byteInputStream()))
assertEquals(expected, actual)
}
+
+ @Test
+ fun testListFlaggedApis() {
+ val expected =
+ listOf(
+ "android.flag.bar DISABLED android/Clazz/Builder",
+ "android.flag.foo ENABLED android/Clazz",
+ "android.flag.foo ENABLED android/Clazz/Clazz()",
+ "android.flag.foo ENABLED android/Clazz/FOO",
+ "android.flag.foo ENABLED android/Clazz/getErrorCode()",
+ "android.flag.foo ENABLED android/Clazz/innerClassArg(Landroid/Clazz/Builder;)",
+ "android.flag.foo ENABLED android/Clazz/setData(I[[ILandroid/util/Utility;)",
+ "android.flag.foo ENABLED android/Clazz/setVariableData(I[Landroid/util/Atom;)")
+ val actual =
+ listFlaggedApis(
+ parseApiSignature("in-memory", API_SIGNATURE.byteInputStream()),
+ parseFlagValues(generateFlagsProto(ENABLED, DISABLED)))
+ assertEquals(expected, actual)
+ }
}
diff --git a/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt b/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt
index 1d2440d..1125d39 100644
--- a/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt
+++ b/tools/check-flagged-apis/src/com/android/checkflaggedapis/Main.kt
@@ -26,6 +26,7 @@
import com.android.tools.metalava.model.text.ApiFile
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.ProgramResult
+import com.github.ajalt.clikt.core.subcommands
import com.github.ajalt.clikt.parameters.options.help
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.required
@@ -141,6 +142,33 @@
}
}
+val ARG_API_SIGNATURE = "--api-signature"
+val ARG_API_SIGNATURE_HELP =
+ """
+Path to API signature file.
+Usually named *current.txt.
+Tip: `m frameworks-base-api-current.txt` will generate a file that includes all platform and mainline APIs.
+"""
+
+val ARG_FLAG_VALUES = "--flag-values"
+val ARG_FLAG_VALUES_HELP =
+ """
+Path to aconfig parsed_flags binary proto file.
+Tip: `m all_aconfig_declarations` will generate a file that includes all information about all flags.
+"""
+
+val ARG_API_VERSIONS = "--api-versions"
+val ARG_API_VERSIONS_HELP =
+ """
+Path to API versions XML file.
+Usually named xml-versions.xml.
+Tip: `m sdk dist` will generate a file that includes all platform and mainline APIs.
+"""
+
+class MainCommand : CliktCommand() {
+ override fun run() {}
+}
+
class CheckCommand :
CliktCommand(
help =
@@ -152,32 +180,18 @@
The tool will exit with a non-zero exit code if any flagged APIs are found to be used in the incorrect way.
""") {
private val apiSignaturePath by
- option("--api-signature")
- .help(
- """
- Path to API signature file.
- Usually named *current.txt.
- Tip: `m frameworks-base-api-current.txt` will generate a file that includes all platform and mainline APIs.
- """)
+ option(ARG_API_SIGNATURE)
+ .help(ARG_API_SIGNATURE_HELP)
.path(mustExist = true, canBeDir = false, mustBeReadable = true)
.required()
private val flagValuesPath by
- option("--flag-values")
- .help(
- """
- Path to aconfig parsed_flags binary proto file.
- Tip: `m all_aconfig_declarations` will generate a file that includes all information about all flags.
- """)
+ option(ARG_FLAG_VALUES)
+ .help(ARG_FLAG_VALUES_HELP)
.path(mustExist = true, canBeDir = false, mustBeReadable = true)
.required()
private val apiVersionsPath by
- option("--api-versions")
- .help(
- """
- Path to API versions XML file.
- Usually named xml-versions.xml.
- Tip: `m sdk dist` will generate a file that includes all platform and mainline APIs.
- """)
+ option(ARG_API_VERSIONS)
+ .help(ARG_API_VERSIONS_HELP)
.path(mustExist = true, canBeDir = false, mustBeReadable = true)
.required()
@@ -196,6 +210,40 @@
}
}
+class ListCommand :
+ CliktCommand(
+ help =
+ """
+List all flagged APIs and corresponding flags.
+
+The output format is "<fully-qualified-name-of-flag> <state-of-flag> <API>", one line per API.
+
+The output can be post-processed by e.g. piping it to grep to filter out only enabled APIs, or all APIs guarded by a given flag.
+""") {
+ private val apiSignaturePath by
+ option(ARG_API_SIGNATURE)
+ .help(ARG_API_SIGNATURE_HELP)
+ .path(mustExist = true, canBeDir = false, mustBeReadable = true)
+ .required()
+ private val flagValuesPath by
+ option(ARG_FLAG_VALUES)
+ .help(ARG_FLAG_VALUES_HELP)
+ .path(mustExist = true, canBeDir = false, mustBeReadable = true)
+ .required()
+
+ override fun run() {
+ val flaggedSymbols =
+ apiSignaturePath.toFile().inputStream().use {
+ parseApiSignature(apiSignaturePath.toString(), it)
+ }
+ val flags = flagValuesPath.toFile().inputStream().use { parseFlagValues(it) }
+ val output = listFlaggedApis(flaggedSymbols, flags)
+ if (output.isNotEmpty()) {
+ println(output.joinToString("\n"))
+ }
+ }
+}
+
internal fun parseApiSignature(path: String, input: InputStream): Set<Pair<Symbol, Flag>> {
val output = mutableSetOf<Pair<Symbol, Flag>>()
val visitor =
@@ -446,4 +494,35 @@
return errors
}
-fun main(args: Array<String>) = CheckCommand().main(args)
+/**
+ * Collect all known info about all @FlaggedApi annotated APIs.
+ *
+ * Each API will be represented as a String, on the format
+ * <pre>
+ * <fully-qualified-name-of-flag< <state-of-flag< <API<
+ * </pre>
+ *
+ * @param flaggedSymbolsInSource the set of symbols that are flagged in the source code
+ * @param flags the set of flags and their values
+ * @return a list of Strings encoding API data using the format described above, sorted
+ * alphabetically
+ */
+internal fun listFlaggedApis(
+ flaggedSymbolsInSource: Set<Pair<Symbol, Flag>>,
+ flags: Map<Flag, Boolean>
+): List<String> {
+ val output = mutableListOf<String>()
+ for ((symbol, flag) in flaggedSymbolsInSource) {
+ val flagState =
+ when (flags.get(flag)) {
+ true -> "ENABLED"
+ false -> "DISABLED"
+ null -> "UNKNOWN"
+ }
+ output.add("$flag $flagState ${symbol.toPrettyString()}")
+ }
+ output.sort()
+ return output
+}
+
+fun main(args: Array<String>) = MainCommand().subcommands(CheckCommand(), ListCommand()).main(args)
diff --git a/tools/check_elf_file.py b/tools/check_elf_file.py
index 51ec23b..1fd7950 100755
--- a/tools/check_elf_file.py
+++ b/tools/check_elf_file.py
@@ -67,7 +67,7 @@
ELF = collections.namedtuple(
'ELF',
- ('dt_soname', 'dt_needed', 'imported', 'exported', 'header'))
+ ('alignments', 'dt_soname', 'dt_needed', 'imported', 'exported', 'header'))
def _get_os_name():
@@ -195,7 +195,8 @@
@classmethod
def _read_llvm_readobj(cls, elf_file_path, header, llvm_readobj):
"""Run llvm-readobj and parse the output."""
- cmd = [llvm_readobj, '--dynamic-table', '--dyn-symbols', elf_file_path]
+ cmd = [llvm_readobj, '--program-headers', '--dynamic-table',
+ '--dyn-symbols', elf_file_path]
out = subprocess.check_output(cmd, text=True)
lines = out.splitlines()
return cls._parse_llvm_readobj(elf_file_path, header, lines)
@@ -205,9 +206,56 @@
def _parse_llvm_readobj(cls, elf_file_path, header, lines):
"""Parse the output of llvm-readobj."""
lines_it = iter(lines)
+ alignments = cls._parse_program_headers(lines_it)
dt_soname, dt_needed = cls._parse_dynamic_table(elf_file_path, lines_it)
imported, exported = cls._parse_dynamic_symbols(lines_it)
- return ELF(dt_soname, dt_needed, imported, exported, header)
+ return ELF(alignments, dt_soname, dt_needed, imported, exported, header)
+
+
+ _PROGRAM_HEADERS_START_PATTERN = 'ProgramHeaders ['
+ _PROGRAM_HEADERS_END_PATTERN = ']'
+ _PROGRAM_HEADER_START_PATTERN = 'ProgramHeader {'
+ _PROGRAM_HEADER_TYPE_PATTERN = re.compile('^\\s+Type:\\s+(.*)$')
+ _PROGRAM_HEADER_ALIGN_PATTERN = re.compile('^\\s+Alignment:\\s+(.*)$')
+ _PROGRAM_HEADER_END_PATTERN = '}'
+
+
+ @classmethod
+ def _parse_program_headers(cls, lines_it):
+ """Parse the dynamic table section."""
+ alignments = []
+
+ if not cls._find_prefix(cls._PROGRAM_HEADERS_START_PATTERN, lines_it):
+ raise ELFError()
+
+ for line in lines_it:
+ # Parse each program header
+ if line.strip() == cls._PROGRAM_HEADER_START_PATTERN:
+ p_align = None
+ p_type = None
+ for line in lines_it:
+ if line.strip() == cls._PROGRAM_HEADER_END_PATTERN:
+ if not p_align:
+ raise ELFError("Could not parse alignment from program header!")
+ if not p_type:
+ raise ELFError("Could not parse type from program header!")
+
+ if p_type.startswith("PT_LOAD "):
+ alignments.append(int(p_align))
+ break
+
+ match = cls._PROGRAM_HEADER_TYPE_PATTERN.match(line)
+ if match:
+ p_type = match.group(1)
+
+ match = cls._PROGRAM_HEADER_ALIGN_PATTERN.match(line)
+ if match:
+ p_align = match.group(1)
+
+ if line == cls._PROGRAM_HEADERS_END_PATTERN:
+ break
+
+ return alignments
_DYNAMIC_SECTION_START_PATTERN = 'DynamicSection ['
@@ -434,6 +482,24 @@
sys.exit(2)
+ def check_max_page_size(self, max_page_size):
+ for alignment in self._file_under_test.alignments:
+ if alignment % max_page_size != 0:
+ self._error(f'Load segment has alignment {alignment} but '
+ f'{max_page_size} required.')
+ self._note()
+ self._note('Fix suggestions:')
+ self._note(f' use linker flag "-Wl,-z,max-page-size={max_page_size}" '
+ f'when compiling this lib')
+ self._note()
+ self._note('If the fix above doesn\'t work, bypass this check with:')
+ self._note(' Android.bp: ignore_max_page_size: true,')
+ self._note(' Android.mk: LOCAL_IGNORE_MAX_PAGE_SIZE := true')
+ self._note(' Device mk: PRODUCT_CHECK_PREBUILT_MAX_PAGE_SIZE := false')
+
+ # TODO: instead of exiting immediately, we may want to collect the
+ # errors from all checks and emit them at once
+ sys.exit(2)
@staticmethod
def _find_symbol(lib, name, version):
@@ -514,6 +580,8 @@
help='Ignore the input file with unknown machine ID')
parser.add_argument('--allow-undefined-symbols', action='store_true',
help='Ignore unresolved undefined symbols')
+ parser.add_argument('--max-page-size', action='store', type=int,
+ help='Required page size alignment support')
# Other options
parser.add_argument('--llvm-readobj',
@@ -542,6 +610,9 @@
checker.check_dt_needed(args.system_shared_lib)
+ if args.max_page_size:
+ checker.check_max_page_size(args.max_page_size)
+
if not args.allow_undefined_symbols:
checker.check_symbols()
diff --git a/tools/envsetup/run_envsetup_tests b/tools/envsetup/run_envsetup_tests
new file mode 100755
index 0000000..5977448
--- /dev/null
+++ b/tools/envsetup/run_envsetup_tests
@@ -0,0 +1,229 @@
+#!/usr/bin/env python3
+
+# Copyright (C) 2024 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+import pathlib
+import subprocess
+import sys
+
+SOURCE_ENVSETUP="source build/make/envsetup.sh && "
+
+def update_display():
+ sys.stderr.write("passed\n")
+
+def go_to_root():
+ while True:
+ if os.path.exists("build/make/envsetup.sh"):
+ return
+ if os.getcwd() == "/":
+ sys.stderr.write("Can't find root of the source tree\n");
+ print("\nFAILED")
+ sys.exit(1)
+ os.chdir("..")
+
+def is_test(name, thing):
+ if not callable(thing):
+ return False
+ if name == "test":
+ return False
+ return name.startswith("test")
+
+
+def test(shell, command, expected_return, expected_stdout, expected_stderr, expected_env):
+ command += "; _rc=$?"
+ for env in expected_env.keys():
+ command += f"; echo ENV: {env}=\\\"${env}\\\""
+ command += "; exit $_rc"
+
+ cmd = [shell, "-c", command]
+ result = subprocess.run(cmd, capture_output=True, text=True)
+
+ status = True
+
+ if result.returncode != expected_return:
+ print()
+ print(f"Expected return code: {expected_return}")
+ print(f"Actual return code: {result.returncode}")
+ status = False
+
+ printed_stdout = False
+ if expected_stdout and expected_stdout not in result.stdout:
+ print()
+ print(f"Expected stdout to contain:\n{expected_stdout}")
+ print(f"\nActual stdout:\n{result.stdout}")
+ printed_stdout = True
+ status = False
+
+ if expected_stderr and expected_stderr not in result.stderr:
+ print()
+ print(f"Expected stderr to contain:\n{expected_stderr}")
+ print(f"\nActual stderr:\n{result.stderr}")
+ status = False
+
+ env_failure = False
+ for k, v in expected_env.items():
+ if f"{k}=\"{v}\"" not in result.stdout:
+ print()
+ print(f"Expected environment variable {k} to be: {v} --- {k}=\"{v}\"")
+ env_failure = True
+ status = False
+
+ if env_failure and not printed_stdout:
+ print()
+ print("See stdout:")
+ print(result.stdout)
+
+ if not status:
+ print()
+ print("Command to reproduce:")
+ print(command)
+ print()
+
+ return status
+
+NO_LUNCH = {
+ "TARGET_PRODUCT": "",
+ "TARGET_RELEASE": "",
+ "TARGET_BUILD_VARIANT": "",
+}
+
+def test_invalid_lunch_target(shell):
+ return test(shell, SOURCE_ENVSETUP + "lunch invalid-trunk_staging-eng",
+ expected_return=1, expected_stdout=None,
+ expected_stderr="Cannot locate config makefile for product",
+ expected_env=NO_LUNCH)
+
+
+def test_aosp_arm(shell):
+ return test(shell, SOURCE_ENVSETUP + "lunch aosp_arm-trunk_staging-eng",
+ expected_return=0, expected_stdout=None, expected_stderr=None,
+ expected_env={
+ "TARGET_PRODUCT": "aosp_arm",
+ "TARGET_RELEASE": "trunk_staging",
+ "TARGET_BUILD_VARIANT": "eng",
+ })
+
+
+def test_lunch2_empty(shell):
+ return test(shell, SOURCE_ENVSETUP + "lunch2",
+ expected_return=1, expected_stdout=None,
+ expected_stderr="No target specified. See lunch --help",
+ expected_env=NO_LUNCH)
+
+def test_lunch2_four_params(shell):
+ return test(shell, SOURCE_ENVSETUP + "lunch2 a b c d",
+ expected_return=1, expected_stdout=None,
+ expected_stderr="Too many parameters given. See lunch --help",
+ expected_env=NO_LUNCH)
+
+def test_lunch2_aosp_arm(shell):
+ return test(shell, SOURCE_ENVSETUP + "lunch2 aosp_arm",
+ expected_return=0, expected_stdout="=========", expected_stderr=None,
+ expected_env={
+ "TARGET_PRODUCT": "aosp_arm",
+ "TARGET_RELEASE": "trunk_staging",
+ "TARGET_BUILD_VARIANT": "eng",
+ })
+
+def test_lunch2_aosp_arm_trunk_staging(shell):
+ # Somewhat unfortunate because trunk_staging is the only config in
+ # aosp so we can't really test that this isn't just getting the default
+ return test(shell, SOURCE_ENVSETUP + "lunch2 aosp_arm trunk_staging",
+ expected_return=0, expected_stdout="=========", expected_stderr=None,
+ expected_env={
+ "TARGET_PRODUCT": "aosp_arm",
+ "TARGET_RELEASE": "trunk_staging",
+ "TARGET_BUILD_VARIANT": "eng",
+ })
+
+def test_lunch2_aosp_arm_trunk_staging_userdebug(shell):
+ return test(shell, SOURCE_ENVSETUP + "lunch2 aosp_arm trunk_staging userdebug",
+ expected_return=0, expected_stdout="=========", expected_stderr=None,
+ expected_env={
+ "TARGET_PRODUCT": "aosp_arm",
+ "TARGET_RELEASE": "trunk_staging",
+ "TARGET_BUILD_VARIANT": "userdebug",
+ })
+
+def test_list_products(shell):
+ return test(shell, "build/soong/bin/list_products",
+ expected_return=0, expected_stdout="aosp_arm", expected_stderr=None,
+ expected_env=NO_LUNCH)
+
+def test_list_releases_param(shell):
+ return test(shell, "build/soong/bin/list_releases aosp_arm",
+ expected_return=0, expected_stdout="trunk_staging", expected_stderr=None,
+ expected_env=NO_LUNCH)
+
+def test_list_releases_env(shell):
+ return test(shell, "TARGET_PRODUCT=aosp_arm build/soong/bin/list_releases",
+ expected_return=0, expected_stdout="trunk_staging", expected_stderr=None,
+ expected_env=NO_LUNCH)
+
+def test_list_releases_no_product(shell):
+ return test(shell, "build/soong/bin/list_releases",
+ expected_return=1, expected_stdout=None, expected_stderr=None,
+ expected_env=NO_LUNCH)
+
+def test_list_variants(shell):
+ return test(shell, "build/soong/bin/list_variants",
+ expected_return=0, expected_stdout="userdebug", expected_stderr=None,
+ expected_env=NO_LUNCH)
+
+
+def test_get_build_var_in_path(shell):
+ return test(shell, SOURCE_ENVSETUP + "which get_build_var ",
+ expected_return=0, expected_stdout="soong/bin", expected_stderr=None,
+ expected_env=NO_LUNCH)
+
+
+
+TESTS=sorted([(name, thing) for name, thing in locals().items() if is_test(name, thing)])
+
+def main():
+ if any([x.endswith("/soong/bin") for x in os.getenv("PATH").split(":")]):
+ sys.stderr.write("run_envsetup_tests must be run in a shell that has not sourced"
+ + " envsetup.sh\n\nFAILED\n")
+ return 1
+
+ go_to_root()
+
+ tests = TESTS
+ if len(sys.argv) > 1:
+ tests = [(name, func) for name, func in tests if name in sys.argv]
+
+ shells = ["/usr/bin/bash", "/usr/bin/zsh"]
+ total_count = len(tests) * len(shells)
+ index = 1
+ failed_tests = 0
+
+ for name, func in tests:
+ for shell in shells:
+ sys.stdout.write(f"\33[2K\r{index} of {total_count}: {name} in {shell}")
+ passed = func(shell)
+ if not passed:
+ failed_tests += 1
+ index += 1
+
+ if failed_tests > 0:
+ print(f"\n\nFAILED: {failed_tests} of {total_count}")
+ return 1
+ else:
+ print("\n\nSUCCESS")
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/tools/envsetup/spam_for_lunch b/tools/envsetup/spam_for_lunch
new file mode 100755
index 0000000..2e150a6
--- /dev/null
+++ b/tools/envsetup/spam_for_lunch
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# Copyright 2024, The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This ad is kind of big, so only show it if this appears to be a clean build.
+source $(cd $(dirname $BASH_SOURCE) &> /dev/null && pwd)/../../shell_utils.sh
+if [[ ! -e $(getoutdir)/soong/build.${TARGET_PRODUCT}.ninja ]]; then
+ echo
+ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+ echo " Wondering whether to use user, userdebug or eng?"
+ echo
+ echo " user The builds that ship to users. Reduced debugability."
+ echo " userdebug High fidelity to user builds but with some debugging options"
+ echo " enabled. Best suited for performance testing or day-to-day use"
+ echo " with debugging enabled."
+ echo " eng More debugging options enabled and faster build times, but"
+ echo " runtime performance tradeoffs. Best suited for day-to-day"
+ echo " local development when not doing performance testing."
+ echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
+ echo
+fi
+
diff --git a/tools/finalization/README.md b/tools/finalization/README.md
index cc97d1f..d0aed69 100644
--- a/tools/finalization/README.md
+++ b/tools/finalization/README.md
@@ -3,18 +3,19 @@
## Automation:
1. [Environment setup](./environment.sh). Set values for varios finalization constants.
-2. [Finalize SDK](./finalize-aidl-vndk-sdk-resources.sh). Prepare the branch for SDK release. SDK contains Android Java APIs and other stable APIs. Commonly referred as a 1st step.
-3. [Finalize Android](./finalize-sdk-rel.sh). Mark branch as "REL", i.e. prepares for Android release. Any signed build containing these changes will be considered an official Android Release. Referred as a 2nd finalization step.
-4. [Finalize SDK and submit](./step-1.sh). Do [Finalize SDK](./finalize-aidl-vndk-sdk-resources.sh) step, create CLs, organize them into topic and send to Gerrit.
- a. [Update SDK and submit](./update-step-1.sh). Same as above, but updates the existings CLs.
-5. [Finalize Android and submit](./step-2.sh). Do [Finalize Android](./finalize-sdk-rel.sh) step, create CLs, organize them into topic and send to Gerrit.
- a. [Update Android and submit](./update-step-2.sh). Same as above, but updates the existings CLs.
+1. [Finalize VINTF](./finalize-vintf-resources.sh). Prepare the branch for VINTF release.
+1. [Finalize SDK](./finalize-sdk-resources.sh). Prepare the branch for SDK release. SDK contains Android Java APIs and other stable APIs. Commonly referred as a 1st step.
+1. [Finalize Android](./finalize-sdk-rel.sh). Mark branch as "REL", i.e. prepares for Android release. Any signed build containing these changes will be considered an official Android Release. Referred as a 2nd finalization step.
+1. [Finalize VINTF and submit](./step-0.sh). Do Finalize VINTF step, create CLs, organize them into topic and send to Gerrit.
+1. [Finalize SDK and submit](./step-1.sh). Do Finalize SDK step, create CLs, organize them into topic and send to Gerrit.
+1. [Finalize Android and submit](./step-2.sh). Do [Finalize Android](./finalize-sdk-rel.sh) step, create CLs, organize them into topic and send to Gerrit.
## CI:
Performed in build targets in Finalization branches.
-1. [Finalization Step 1, git_main-fina-1-release](https://android-build.corp.google.com/build_explorer/branch/git_main-fina-1-release). Test [1st step/Finalize SDK](./finalize-aidl-vndk-sdk-resources.sh).
-3. [Finalization Step 2, git_main-fina-2-release](https://android-build.corp.google.com/build_explorer/branch/git_main-fina-2-release). Test [1st step/Finalize SDK](./finalize-aidl-vndk-sdk-resources.sh) and [2nd step/Finalize Android](./finalize-sdk-rel.sh). Use [local finalization](./localonly-steps.sh) to build and copy presubmits.
-5. [Local finalization steps](./localonly-steps.sh) are done only during local testing or in the CI lab. Normally these steps use artifacts from other builds.
+1. [Finalization Step 0, git_main-fina-0-release](https://android-build.corp.google.com/build_explorer/branch/git_main-fina-0-release). Test Finalize VINTF.
+1. [Finalization Step 1, git_main-fina-1-release](https://android-build.corp.google.com/build_explorer/branch/git_main-fina-1-release). Test Finalize VINTF, Finalize SDK.
+1. [Finalization Step 2, git_main-fina-2-release](https://android-build.corp.google.com/build_explorer/branch/git_main-fina-2-release). Test Finalize VINTF, Finalize SDK, and [2nd step/Finalize Android](./finalize-sdk-rel.sh). Use [local finalization](./localonly-steps.sh) to build and copy presubmits.
+1. [Local finalization steps](./localonly-steps.sh) are done only during local testing or in the CI lab. Normally these steps use artifacts from other builds.
## Utility:
[Full cleanup](./cleanup.sh). Remove all local changes and switch each project into head-less state. This is the best state to sync/rebase/finalize the branch.
diff --git a/tools/finalization/build-step-0.sh b/tools/finalization/build-step-0.sh
new file mode 100755
index 0000000..f81b720
--- /dev/null
+++ b/tools/finalization/build-step-0.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+# Copyright 2024 Google Inc. All rights reserved.
+
+set -ex
+
+function finalize_main_step0() {
+ local top="$(dirname "$0")"/../../../..
+ source $top/build/make/tools/finalization/environment.sh
+
+ if [ "$FINAL_STATE" = "unfinalized" ] ; then
+ # VINTF finalization
+ source $top/build/make/tools/finalization/finalize-vintf-resources.sh
+ fi;
+}
+
+finalize_main_step0
+
diff --git a/tools/finalization/build-step-1-and-2.sh b/tools/finalization/build-step-1-and-2.sh
index 84e2782..ca22678 100755
--- a/tools/finalization/build-step-1-and-2.sh
+++ b/tools/finalization/build-step-1-and-2.sh
@@ -7,11 +7,16 @@
source $top/build/make/tools/finalization/environment.sh
if [ "$FINAL_STATE" = "unfinalized" ] ; then
- # SDK codename -> int
- source $top/build/make/tools/finalization/finalize-aidl-vndk-sdk-resources.sh
+ # VINTF finalization
+ source $top/build/make/tools/finalization/finalize-vintf-resources.sh
fi;
- if [ "$FINAL_STATE" = "unfinalized" ] || [ "$FINAL_STATE" = "sdk" ] ; then
+ if [ "$FINAL_STATE" = "unfinalized" ] || [ "$FINAL_STATE" = "vintf" ] ; then
+ # SDK codename -> int
+ source $top/build/make/tools/finalization/finalize-sdk-resources.sh
+ fi;
+
+ if [ "$FINAL_STATE" = "unfinalized" ] || [ "$FINAL_STATE" = "vintf" ] || [ "$FINAL_STATE" = "sdk" ] ; then
# ADB, Platform/Mainline SDKs build and move to prebuilts
source $top/build/make/tools/finalization/localonly-steps.sh
diff --git a/tools/finalization/build-step-1.sh b/tools/finalization/build-step-1.sh
index 3d5eadb..7294698 100755
--- a/tools/finalization/build-step-1.sh
+++ b/tools/finalization/build-step-1.sh
@@ -7,8 +7,13 @@
source $top/build/make/tools/finalization/environment.sh
if [ "$FINAL_STATE" = "unfinalized" ] ; then
+ # VINTF finalization
+ source $top/build/make/tools/finalization/finalize-vintf-resources.sh
+ fi;
+
+ if [ "$FINAL_STATE" = "unfinalized" ] || [ "$FINAL_STATE" = "vintf" ] ; then
# Build finalization artifacts.
- source $top/build/make/tools/finalization/finalize-aidl-vndk-sdk-resources.sh
+ source $top/build/make/tools/finalization/finalize-sdk-resources.sh
fi;
}
diff --git a/tools/finalization/environment.sh b/tools/finalization/environment.sh
index d9c42c8..7961e8b 100755
--- a/tools/finalization/environment.sh
+++ b/tools/finalization/environment.sh
@@ -19,8 +19,14 @@
# Options:
# 'unfinalized' - branch is in development state,
-# 'sdk' - SDK/API is finalized
+# 'vintf' - VINTF is finalized
+# 'sdk' - VINTF and SDK/API are finalized
# 'rel' - branch is finalized, switched to REL
-export FINAL_STATE='unfinalized'
+export FINAL_STATE='vintf'
-export BUILD_FROM_SOURCE_STUB=true
\ No newline at end of file
+export BUILD_FROM_SOURCE_STUB=true
+
+# FINAL versions for VINTF
+# TODO(b/323985297): The version must match with that from the release configuration.
+# Instead of hardcoding the version here, read it from a release configuration.
+export FINAL_BOARD_API_LEVEL='202404'
diff --git a/tools/finalization/finalize-sdk-rel.sh b/tools/finalization/finalize-sdk-rel.sh
index 245305b..59fe28c 100755
--- a/tools/finalization/finalize-sdk-rel.sh
+++ b/tools/finalization/finalize-sdk-rel.sh
@@ -40,9 +40,6 @@
fi
git -C "$top/cts" mv hostsidetests/theme/assets/${FINAL_PLATFORM_CODENAME} hostsidetests/theme/assets/${FINAL_PLATFORM_SDK_VERSION}
- # system/sepolicy
- system/sepolicy/tools/finalize-sdk-rel.sh "$top" "$FINAL_PLATFORM_SDK_VERSION"
-
# prebuilts/abi-dumps/platform
mkdir -p "$top/prebuilts/abi-dumps/platform/$FINAL_PLATFORM_SDK_VERSION"
cp -r "$top/prebuilts/abi-dumps/platform/current/64/" "$top/prebuilts/abi-dumps/platform/$FINAL_PLATFORM_SDK_VERSION/"
@@ -52,10 +49,6 @@
# prebuilts/abi-dumps/ndk
#mkdir -p "$top/prebuilts/abi-dumps/ndk/$FINAL_PLATFORM_SDK_VERSION"
#cp -r "$top/prebuilts/abi-dumps/ndk/current/64/" "$top/prebuilts/abi-dumps/ndk/$FINAL_PLATFORM_SDK_VERSION/"
- #if [ "$FINAL_STATE" != "sdk" ] || [ "$FINAL_PLATFORM_CODENAME" == "$CURRENT_PLATFORM_CODENAME" ] ; then
- # prebuilts/abi-dumps/vndk
- #mv "$top/prebuilts/abi-dumps/vndk/$CURRENT_PLATFORM_CODENAME" "$top/prebuilts/abi-dumps/vndk/$FINAL_PLATFORM_SDK_VERSION"
- #fi;
}
finalize_sdk_rel
diff --git a/tools/finalization/finalize-aidl-vndk-sdk-resources.sh b/tools/finalization/finalize-sdk-resources.sh
similarity index 91%
rename from tools/finalization/finalize-aidl-vndk-sdk-resources.sh
rename to tools/finalization/finalize-sdk-resources.sh
index 75379ff..596f803 100755
--- a/tools/finalization/finalize-aidl-vndk-sdk-resources.sh
+++ b/tools/finalization/finalize-sdk-resources.sh
@@ -96,7 +96,7 @@
$modules_arg
}
-function finalize_aidl_vndk_sdk_resources() {
+function finalize_sdk_resources() {
local top="$(dirname "$0")"/../../../..
source $top/build/make/tools/finalization/environment.sh
@@ -111,13 +111,6 @@
# bionic/NDK
finalize_bionic_ndk
- # pre-finalization build target (trunk)
- local aidl_m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_RELEASE=trunk TARGET_BUILD_VARIANT=userdebug DIST_DIR=out/dist"
- AIDL_TRANSITIVE_FREEZE=true $aidl_m aidl-freeze-api
-
- # TODO(b/309880485)
- # Add back create_reference_dumps and $top/build/make/target/product/gsi/current.txt
-
# Finalize SDK
# frameworks/libs/modules-utils
@@ -129,10 +122,6 @@
local build_tools_source="$top/development/sdk/build_tools_source.prop_template"
sed -i -e 's/Pkg\.Revision.*/Pkg\.Revision=${PLATFORM_SDK_VERSION}.0.0/g' $build_tools_source
- # build/make
- sed -i -e "s/sepolicy_major_vers := .*/sepolicy_major_vers := ${FINAL_PLATFORM_SDK_VERSION}/g" "$top/build/make/core/config.mk"
- cp "$top/build/make/target/product/gsi/current.txt" "$top/build/make/target/product/gsi/$FINAL_PLATFORM_SDK_VERSION.txt"
-
# build/soong
local codename_version="\"${FINAL_PLATFORM_CODENAME}\": ${FINAL_PLATFORM_SDK_VERSION}"
if ! grep -q "$codename_version" "$top/build/soong/android/api_levels.go" ; then
@@ -179,5 +168,5 @@
$sdk_m update-api
}
-finalize_aidl_vndk_sdk_resources
+finalize_sdk_resources
diff --git a/tools/finalization/finalize-vintf-resources.sh b/tools/finalization/finalize-vintf-resources.sh
new file mode 100755
index 0000000..a55d8e1
--- /dev/null
+++ b/tools/finalization/finalize-vintf-resources.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+set -ex
+
+function finalize_vintf_resources() {
+ local top="$(dirname "$0")"/../../../..
+ source $top/build/make/tools/finalization/environment.sh
+ # environment needed to build dependencies and run scripts
+ # These should remain the same for all steps here to speed up build time
+ export ANDROID_BUILD_TOP="$top"
+ export ANDROID_HOST_OUT="$ANDROID_BUILD_TOP/out/host/linux-x86"
+ export ANDROID_PRODUCT_OUT="$ANDROID_BUILD_TOP/out/target/product/generic_arm64"
+ export PATH="$PATH:$ANDROID_HOST_OUT/bin/"
+ export TARGET_BUILD_VARIANT=userdebug
+ export DIST_DIR=out/dist
+ export TARGET_RELEASE=fina_0
+ export TARGET_PRODUCT=aosp_arm64
+
+ # TODO(b/314010764): finalize LL_NDK
+
+ # system/sepolicy
+ "$top/system/sepolicy/tools/finalize-vintf-resources.sh" "$top" "$FINAL_BOARD_API_LEVEL"
+
+ create_new_compat_matrix_and_kernel_configs
+
+ # pre-finalization build target (trunk)
+ local aidl_m="$top/build/soong/soong_ui.bash --make-mode"
+ AIDL_TRANSITIVE_FREEZE=true $aidl_m aidl-freeze-api
+}
+
+function create_new_compat_matrix_and_kernel_configs() {
+ # The compatibility matrix versions are bumped during vFRC
+ # These will change every time we have a new vFRC
+ local CURRENT_COMPATIBILITY_MATRIX_LEVEL='202404'
+ local NEXT_COMPATIBILITY_MATRIX_LEVEL='202504'
+ # The kernel configs need the letter of the Android release
+ local CURRENT_RELEASE_LETTER='v'
+ local NEXT_RELEASE_LETTER='w'
+
+
+ # build the targets required before touching the Android.bp/Android.mk files
+ local build_cmd="$top/build/soong/soong_ui.bash --make-mode"
+ $build_cmd bpmodify
+
+ "$top/prebuilts/build-tools/path/linux-x86/python3" "$top/hardware/interfaces/compatibility_matrices/bump.py" "$CURRENT_COMPATIBILITY_MATRIX_LEVEL" "$NEXT_COMPATIBILITY_MATRIX_LEVEL" "$CURRENT_RELEASE_LETTER" "$NEXT_RELEASE_LETTER"
+
+ # Freeze the current framework manifest file. This relies on the
+ # aosp_cf_x86_64-trunk_staging build target to get the right manifest
+ # fragments installed.
+ "$top/system/libhidl/vintfdata/freeze.sh" "$CURRENT_COMPATIBILITY_MATRIX_LEVEL"
+}
+
+function freeze_framework_manifest() {
+ ANDROID_PRODUCT_OUT=~/workspace/internal/main/out/target/product/vsoc_x86 ANDROID_BUILD_TOP=~/workspace/internal/main ANDROID_HOST_OUT=~/workspace/internal/main/out/host/linux-x86 ./freeze.sh 202404
+
+}
+
+
+finalize_vintf_resources
+
diff --git a/tools/finalization/step-0.sh b/tools/finalization/step-0.sh
new file mode 100755
index 0000000..e61c644
--- /dev/null
+++ b/tools/finalization/step-0.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+# Copyright 2024 Google Inc. All rights reserved.
+
+# Script to perform a 0th step of Android Finalization: VINTF finalization, create CLs and upload to Gerrit.
+
+set -ex
+
+function commit_step_0_changes() {
+ set +e
+ repo forall -c '\
+ if [[ $(git status --short) ]]; then
+ repo start "VINTF-$FINAL_BOARD_API_LEVEL-Finalization" ;
+ git add -A . ;
+ git commit -m "Vendor API level $FINAL_BOARD_API_LEVEL is now frozen" \
+ -m "Ignore-AOSP-First: VINTF $FINAL_BOARD_API_LEVEL Finalization
+Bug: $FINAL_BUG_ID
+Test: build";
+ repo upload --cbr --no-verify -o nokeycheck -t -y . ;
+ fi'
+}
+
+function finalize_step_0_main() {
+ local top="$(dirname "$0")"/../../../..
+ source $top/build/make/tools/finalization/environment.sh
+
+ local m="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
+
+ source $top/build/make/tools/finalization/finalize-vintf-resources.sh
+
+ # move all changes to finalization branch/topic and upload to gerrit
+ commit_step_0_changes
+
+ # build to confirm everything is OK
+ AIDL_FROZEN_REL=true $m
+}
+
+finalize_step_0_main
diff --git a/tools/finalization/step-1.sh b/tools/finalization/step-1.sh
index 0dd4b3a..0e483d5 100755
--- a/tools/finalization/step-1.sh
+++ b/tools/finalization/step-1.sh
@@ -21,10 +21,9 @@
local top="$(dirname "$0")"/../../../..
source $top/build/make/tools/finalization/environment.sh
- local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
+ local m="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
- # vndk etc finalization
- source $top/build/make/tools/finalization/finalize-aidl-vndk-sdk-resources.sh
+ source $top/build/make/tools/finalization/finalize-sdk-resources.sh
# move all changes to finalization branch/topic and upload to gerrit
commit_step_1_changes
diff --git a/tools/finalization/step-2.sh b/tools/finalization/step-2.sh
index d0b24ae..356cad0 100755
--- a/tools/finalization/step-2.sh
+++ b/tools/finalization/step-2.sh
@@ -19,7 +19,7 @@
local top="$(dirname "$0")"/../../../..
source $top/build/make/tools/finalization/environment.sh
- local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
+ local m="$top/build/soong/soong_ui.bash --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
# prebuilts etc
source $top/build/make/tools/finalization/finalize-sdk-rel.sh
diff --git a/tools/finalization/update-step-1.sh b/tools/finalization/update-step-1.sh
deleted file mode 100755
index b469988..0000000
--- a/tools/finalization/update-step-1.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/bash
-# Script to perform a 1st step of Android Finalization: API/SDK finalization, update CLs and upload to Gerrit.
-
-# WIP, does not work yet
-exit 10
-
-set -ex
-
-function update_step_1_changes() {
- set +e
- repo forall -c '\
- if [[ $(git status --short) ]]; then
- git stash -u ;
- repo start "$FINAL_PLATFORM_CODENAME-SDK-Finalization" ;
- git stash pop ;
- git add -A . ;
- git commit --amend --no-edit ;
- repo upload --cbr --no-verify -o nokeycheck -t -y . ;
- fi'
-}
-
-function update_step_1_main() {
- local top="$(dirname "$0")"/../../../..
- source $top/build/make/tools/finalization/environment.sh
-
-
- local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
-
- # vndk etc finalization
- source $top/build/make/tools/finalization/finalize-aidl-vndk-sdk-resources.sh
-
- # update existing CLs and upload to gerrit
- update_step_1_changes
-
- # build to confirm everything is OK
- AIDL_FROZEN_REL=true $m
-}
-
-update_step_1_main
diff --git a/tools/finalization/update-step-2.sh b/tools/finalization/update-step-2.sh
deleted file mode 100755
index d2b8592..0000000
--- a/tools/finalization/update-step-2.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/bash
-# Script to perform a 2nd step of Android Finalization: REL finalization, create CLs and upload to Gerrit.
-
-# WIP, does not work yet
-exit 10
-
-set -ex
-
-function update_step_2_changes() {
- set +e
- repo forall -c '\
- if [[ $(git status --short) ]]; then
- git stash -u ;
- repo start "$FINAL_PLATFORM_CODENAME-SDK-Finalization-Rel" ;
- git stash pop ;
- git add -A . ;
- git commit --amend --no-edit ;
- repo upload --cbr --no-verify -o nokeycheck -t -y . ;
- fi'
-}
-
-function update_step_2_main() {
- local top="$(dirname "$0")"/../../../..
- source $top/build/make/tools/finalization/environment.sh
-
- local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug"
-
- # prebuilts etc
- source $top/build/make/tools/finalization/finalize-sdk-rel.sh
-
- # move all changes to finalization branch/topic and upload to gerrit
- update_step_2_changes
-
- # build to confirm everything is OK
- AIDL_FROZEN_REL=true $m
-}
-
-update_step_2_main
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 2367691..a949c11 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -1784,12 +1784,7 @@
if has_ramdisk:
cmd.extend(["--ramdisk", ramdisk_img.name])
- img_unsigned = None
- if info_dict.get("vboot"):
- img_unsigned = tempfile.NamedTemporaryFile()
- cmd.extend(["--output", img_unsigned.name])
- else:
- cmd.extend(["--output", img.name])
+ cmd.extend(["--output", img.name])
if partition_name == "recovery":
if info_dict.get("include_recovery_dtbo") == "true":
@@ -1801,28 +1796,6 @@
RunAndCheckOutput(cmd)
- # Sign the image if vboot is non-empty.
- if info_dict.get("vboot"):
- path = "/" + partition_name
- img_keyblock = tempfile.NamedTemporaryFile()
- # We have switched from the prebuilt futility binary to using the tool
- # (futility-host) built from the source. Override the setting in the old
- # TF.zip.
- futility = info_dict["futility"]
- if futility.startswith("prebuilts/"):
- futility = "futility-host"
- cmd = [info_dict["vboot_signer_cmd"], futility,
- img_unsigned.name, info_dict["vboot_key"] + ".vbpubk",
- info_dict["vboot_key"] + ".vbprivk",
- info_dict["vboot_subkey"] + ".vbprivk",
- img_keyblock.name,
- img.name]
- RunAndCheckOutput(cmd)
-
- # Clean up the temp files.
- img_unsigned.close()
- img_keyblock.close()
-
# AVB: if enabled, calculate and add hash to boot.img or recovery.img.
if info_dict.get("avb_enable") == "true":
avbtool = info_dict["avb_avbtool"]
@@ -1971,7 +1944,7 @@
return None
-def _BuildVendorBootImage(sourcedir, partition_name, info_dict=None):
+def _BuildVendorBootImage(sourcedir, fs_config_file, partition_name, info_dict=None):
"""Build a vendor boot image from the specified sourcedir.
Take a ramdisk, dtb, and vendor_cmdline from the input (in 'sourcedir'), and
@@ -1987,7 +1960,7 @@
img = tempfile.NamedTemporaryFile()
ramdisk_format = GetRamdiskFormat(info_dict)
- ramdisk_img = _MakeRamdisk(sourcedir, ramdisk_format=ramdisk_format)
+ ramdisk_img = _MakeRamdisk(sourcedir, fs_config_file=fs_config_file, ramdisk_format=ramdisk_format)
# use MKBOOTIMG from environ, or "mkbootimg" if empty or not set
mkbootimg = os.getenv('MKBOOTIMG') or "mkbootimg"
@@ -2101,8 +2074,9 @@
if info_dict is None:
info_dict = OPTIONS.info_dict
+ fs_config = "META/" + tree_subdir.lower() + "_filesystem_config.txt"
data = _BuildVendorBootImage(
- os.path.join(unpack_dir, tree_subdir), "vendor_boot", info_dict)
+ os.path.join(unpack_dir, tree_subdir), os.path.join(unpack_dir, fs_config), "vendor_boot", info_dict)
if data:
return File(name, data)
return None
@@ -2126,7 +2100,7 @@
info_dict = OPTIONS.info_dict
data = _BuildVendorBootImage(
- os.path.join(unpack_dir, tree_subdir), "vendor_kernel_boot", info_dict)
+ os.path.join(unpack_dir, tree_subdir), None, "vendor_kernel_boot", info_dict)
if data:
return File(name, data)
return None
diff --git a/tools/sbom/sbom_data.py b/tools/sbom/sbom_data.py
index b5ac8a5..fc5c704 100644
--- a/tools/sbom/sbom_data.py
+++ b/tools/sbom/sbom_data.py
@@ -30,6 +30,7 @@
SPDXID_DOC = 'SPDXRef-DOCUMENT'
SPDXID_PRODUCT = 'SPDXRef-PRODUCT'
SPDXID_PLATFORM = 'SPDXRef-PLATFORM'
+SPDXID_LICENSE_APACHE = 'LicenseRef-Android-Apache-2.0'
PACKAGE_NAME_PRODUCT = 'PRODUCT'
PACKAGE_NAME_PLATFORM = 'PLATFORM'
@@ -50,7 +51,7 @@
cpe23Type = 'cpe23Type'
-@dataclass
+@dataclass(frozen=True)
class PackageExternalRef:
category: PackageExternalRefCategory
type: PackageExternalRefType
@@ -68,6 +69,7 @@
verification_code: str = None
file_ids: List[str] = field(default_factory=list)
external_refs: List[PackageExternalRef] = field(default_factory=list)
+ declared_license_ids: List[str] = field(default_factory=list)
@dataclass
@@ -75,6 +77,7 @@
id: str
name: str
checksum: str
+ concluded_license_ids: List[str] = field(default_factory=list)
class RelationshipType:
@@ -85,20 +88,27 @@
STATIC_LINK = 'STATIC_LINK'
-@dataclass
+@dataclass(frozen=True)
class Relationship:
id1: str
relationship: RelationshipType
id2: str
-@dataclass
+@dataclass(frozen=True)
class DocumentExternalReference:
id: str
uri: str
checksum: str
+@dataclass(frozen=True)
+class License:
+ id: str
+ text: str
+ name: str
+
+
@dataclass
class Document:
name: str
@@ -111,20 +121,30 @@
packages: List[Package] = field(default_factory=list)
files: List[File] = field(default_factory=list)
relationships: List[Relationship] = field(default_factory=list)
+ licenses: List[License] = field(default_factory=list)
def add_external_ref(self, external_ref):
if not any(external_ref.uri == ref.uri for ref in self.external_refs):
self.external_refs.append(external_ref)
def add_package(self, package):
- if not any(package.id == p.id for p in self.packages):
+ p = next((p for p in self.packages if package.id == p.id), None)
+ if not p:
self.packages.append(package)
+ else:
+ for license_id in package.declared_license_ids:
+ if license_id not in p.declared_license_ids:
+ p.declared_license_ids.append(license_id)
def add_relationship(self, rel):
if not any(rel.id1 == r.id1 and rel.id2 == r.id2 and rel.relationship == r.relationship
for r in self.relationships):
self.relationships.append(rel)
+ def add_license(self, license):
+ if not any(license.id == l.id for l in self.licenses):
+ self.licenses.append(license)
+
def generate_packages_verification_code(self):
for package in self.packages:
if not package.file_ids:
diff --git a/tools/sbom/sbom_data_test.py b/tools/sbom/sbom_data_test.py
index 69bc9d2..9d987c4 100644
--- a/tools/sbom/sbom_data_test.py
+++ b/tools/sbom/sbom_data_test.py
@@ -23,6 +23,7 @@
SUPPLIER_UPSTREAM = 'Organization: upstream'
SPDXID_PREBUILT_PACKAGE1 = 'SPDXRef-PREBUILT-package1'
+SPDXID_PREBUILT_PACKAGE2 = 'SPDXRef-PREBUILT-package2'
SPDXID_SOURCE_PACKAGE1 = 'SPDXRef-SOURCE-package1'
SPDXID_UPSTREAM_PACKAGE1 = 'SPDXRef-UPSTREAM-package1'
@@ -31,6 +32,9 @@
SPDXID_FILE3 = 'SPDXRef-file3'
SPDXID_FILE4 = 'SPDXRef-file4'
+SPDXID_LICENSE1 = "SPDXRef-License-1"
+SPDXID_LICENSE2 = "SPDXRef-License-2"
+
class SBOMDataTest(unittest.TestCase):
@@ -134,6 +138,47 @@
self.sbom_doc.generate_packages_verification_code()
self.assertEqual(expected_package_verification_code, self.sbom_doc.packages[0].verification_code)
+ def test_add_package_(self):
+ self.sbom_doc.add_package(sbom_data.Package(id=SPDXID_PREBUILT_PACKAGE2,
+ name='Prebuilt package2',
+ download_location=sbom_data.VALUE_NONE,
+ supplier=SUPPLIER_GOOGLE,
+ version=BUILD_FINGER_PRINT,
+ ))
+ p = next((p for p in self.sbom_doc.packages if p.id == SPDXID_PREBUILT_PACKAGE2), None)
+ self.assertNotEqual(p, None)
+ self.assertEqual(p.declared_license_ids, [])
+
+ # Add same package with license 1
+ self.sbom_doc.add_package(sbom_data.Package(id=SPDXID_PREBUILT_PACKAGE2,
+ name='Prebuilt package2',
+ download_location=sbom_data.VALUE_NONE,
+ supplier=SUPPLIER_GOOGLE,
+ version=BUILD_FINGER_PRINT,
+ declared_license_ids=[SPDXID_LICENSE1]
+ ))
+ self.assertEqual(p.declared_license_ids, [SPDXID_LICENSE1])
+
+ # Add same package with license 2
+ self.sbom_doc.add_package(sbom_data.Package(id=SPDXID_PREBUILT_PACKAGE2,
+ name='Prebuilt package2',
+ download_location=sbom_data.VALUE_NONE,
+ supplier=SUPPLIER_GOOGLE,
+ version=BUILD_FINGER_PRINT,
+ declared_license_ids=[SPDXID_LICENSE2]
+ ))
+ self.assertEqual(p.declared_license_ids, [SPDXID_LICENSE1, SPDXID_LICENSE2])
+
+ # Add same package with license 2 again
+ self.sbom_doc.add_package(sbom_data.Package(id=SPDXID_PREBUILT_PACKAGE2,
+ name='Prebuilt package2',
+ download_location=sbom_data.VALUE_NONE,
+ supplier=SUPPLIER_GOOGLE,
+ version=BUILD_FINGER_PRINT,
+ declared_license_ids=[SPDXID_LICENSE2]
+ ))
+ self.assertEqual(p.declared_license_ids, [SPDXID_LICENSE1, SPDXID_LICENSE2])
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/tools/sbom/sbom_writers.py b/tools/sbom/sbom_writers.py
index 1cb864d..26b3c57 100644
--- a/tools/sbom/sbom_writers.py
+++ b/tools/sbom/sbom_writers.py
@@ -64,6 +64,11 @@
# Relationship
RELATIONSHIP = 'Relationship'
+ # License
+ LICENSE_ID = 'LicenseID'
+ LICENSE_NAME = 'LicenseName'
+ LICENSE_EXTRACTED_TEXT = 'ExtractedText'
+
class TagValueWriter:
@staticmethod
@@ -99,6 +104,12 @@
tagvalues.append(f'{Tags.PACKAGE_VERSION}: {package.version}')
if package.supplier:
tagvalues.append(f'{Tags.PACKAGE_SUPPLIER}: {package.supplier}')
+
+ license = sbom_data.VALUE_NOASSERTION
+ if package.declared_license_ids:
+ license = ' OR '.join(package.declared_license_ids)
+ tagvalues.append(f'{Tags.PACKAGE_LICENSE_DECLARED}: {license}')
+
if package.verification_code:
tagvalues.append(f'{Tags.PACKAGE_VERIFICATION_CODE}: {package.verification_code}')
if package.external_refs:
@@ -155,8 +166,12 @@
f'{Tags.FILE_NAME}: {file.name}',
f'{Tags.SPDXID}: {file.id}',
f'{Tags.FILE_CHECKSUM}: {file.checksum}',
- '',
]
+ license = sbom_data.VALUE_NOASSERTION
+ if file.concluded_license_ids:
+ license = ' OR '.join(file.concluded_license_ids)
+ tagvalues.append(f'{Tags.FILE_LICENSE_CONCLUDED}: {license}')
+ tagvalues.append('')
return tagvalues
@@ -194,6 +209,22 @@
return tagvalues
@staticmethod
+ def marshal_license(license):
+ tagvalues = []
+ tagvalues.append(f'{Tags.LICENSE_ID}: {license.id}')
+ tagvalues.append(f'{Tags.LICENSE_NAME}: {license.name}')
+ tagvalues.append(f'{Tags.LICENSE_EXTRACTED_TEXT}: <text>{license.text}</text>')
+ return tagvalues
+
+ @staticmethod
+ def marshal_licenses(sbom_doc):
+ tagvalues = []
+ for license in sbom_doc.licenses:
+ tagvalues += TagValueWriter.marshal_license(license)
+ tagvalues.append('')
+ return tagvalues
+
+ @staticmethod
def write(sbom_doc, file, fragment=False):
content = []
if not fragment:
@@ -202,6 +233,7 @@
tagvalues, marshaled_relationships = TagValueWriter.marshal_packages(sbom_doc, fragment)
content += tagvalues
content += TagValueWriter.marshal_relationships(sbom_doc, marshaled_relationships)
+ content += TagValueWriter.marshal_licenses(sbom_doc)
file.write('\n'.join(content))
@@ -236,11 +268,13 @@
PACKAGE_EXTERNAL_REF_TYPE = 'referenceType'
PACKAGE_EXTERNAL_REF_LOCATOR = 'referenceLocator'
PACKAGE_HAS_FILES = 'hasFiles'
+ PACKAGE_LICENSE_DECLARED = 'licenseDeclared'
# File
FILES = 'files'
FILE_NAME = 'fileName'
FILE_CHECKSUMS = 'checksums'
+ FILE_LICENSE_CONCLUDED = 'licenseConcluded'
# Relationship
RELATIONSHIPS = 'relationships'
@@ -248,6 +282,12 @@
REL_RELATED_ELEMENT_ID = 'relatedSpdxElement'
REL_TYPE = 'relationshipType'
+ # License
+ LICENSES = 'hasExtractedLicensingInfos'
+ LICENSE_ID = 'licenseId'
+ LICENSE_NAME = 'name'
+ LICENSE_EXTRACTED_TEXT = 'extractedText'
+
class JSONWriter:
@staticmethod
@@ -294,6 +334,9 @@
package[PropNames.PACKAGE_VERSION] = p.version
if p.supplier:
package[PropNames.PACKAGE_SUPPLIER] = p.supplier
+ package[PropNames.PACKAGE_LICENSE_DECLARED] = sbom_data.VALUE_NOASSERTION
+ if p.declared_license_ids:
+ package[PropNames.PACKAGE_LICENSE_DECLARED] = ' OR '.join(p.declared_license_ids)
if p.verification_code:
package[PropNames.PACKAGE_VERIFICATION_CODE] = {
PropNames.PACKAGE_VERIFICATION_CODE_VALUE: p.verification_code
@@ -329,6 +372,9 @@
PropNames.ALGORITHM: checksum[0],
PropNames.CHECKSUM_VALUE: checksum[1],
}]
+ file[PropNames.FILE_LICENSE_CONCLUDED] = sbom_data.VALUE_NOASSERTION
+ if f.concluded_license_ids:
+ file[PropNames.FILE_LICENSE_CONCLUDED] = ' OR '.join(f.concluded_license_ids)
files.append(file)
return {PropNames.FILES: files}
@@ -347,10 +393,22 @@
return {PropNames.RELATIONSHIPS: relationships}
@staticmethod
+ def marshal_licenses(sbom_doc):
+ licenses = []
+ for l in sbom_doc.licenses:
+ licenses.append({
+ PropNames.LICENSE_ID: l.id,
+ PropNames.LICENSE_NAME: l.name,
+ PropNames.LICENSE_EXTRACTED_TEXT: f'<text>{l.text}</text>'
+ })
+ return {PropNames.LICENSES: licenses}
+
+ @staticmethod
def write(sbom_doc, file):
doc = {}
doc.update(JSONWriter.marshal_doc_headers(sbom_doc))
doc.update(JSONWriter.marshal_packages(sbom_doc))
doc.update(JSONWriter.marshal_files(sbom_doc))
doc.update(JSONWriter.marshal_relationships(sbom_doc))
+ doc.update(JSONWriter.marshal_licenses(sbom_doc))
file.write(json.dumps(doc, indent=4))
diff --git a/tools/sbom/sbom_writers_test.py b/tools/sbom/sbom_writers_test.py
index cf85e01..f9f5230 100644
--- a/tools/sbom/sbom_writers_test.py
+++ b/tools/sbom/sbom_writers_test.py
@@ -33,6 +33,14 @@
SPDXID_FILE3 = 'SPDXRef-file3'
SPDXID_FILE4 = 'SPDXRef-file4'
+SPDXID_LICENSE_1 = 'LicenseRef-Android-License-1'
+SPDXID_LICENSE_2 = 'LicenseRef-Android-License-2'
+SPDXID_LICENSE_3 = 'LicenseRef-Android-License-3'
+
+LICENSE_APACHE_TEXT = "LICENSE_APACHE"
+LICENSE1_TEXT = 'LICENSE 1'
+LICENSE2_TEXT = 'LICENSE 2'
+LICENSE3_TEXT = 'LICENSE 3'
class SBOMWritersTest(unittest.TestCase):
@@ -63,6 +71,7 @@
download_location=sbom_data.VALUE_NONE,
supplier=SUPPLIER_GOOGLE,
version=BUILD_FINGER_PRINT,
+ declared_license_ids=[sbom_data.SPDXID_LICENSE_APACHE]
))
self.sbom_doc.add_package(
@@ -71,6 +80,7 @@
download_location=sbom_data.VALUE_NONE,
supplier=SUPPLIER_GOOGLE,
version=BUILD_FINGER_PRINT,
+ declared_license_ids=[SPDXID_LICENSE_1],
))
self.sbom_doc.add_package(
@@ -79,6 +89,7 @@
download_location=sbom_data.VALUE_NONE,
supplier=SUPPLIER_GOOGLE,
version=BUILD_FINGER_PRINT,
+ declared_license_ids=[SPDXID_LICENSE_2, SPDXID_LICENSE_3],
external_refs=[sbom_data.PackageExternalRef(
category=sbom_data.PackageExternalRefCategory.SECURITY,
type=sbom_data.PackageExternalRefType.cpe22Type,
@@ -90,6 +101,7 @@
name='Upstream package1',
supplier=SUPPLIER_UPSTREAM,
version='1.1',
+ declared_license_ids=[SPDXID_LICENSE_2, SPDXID_LICENSE_3],
))
self.sbom_doc.add_relationship(sbom_data.Relationship(id1=SPDXID_SOURCE_PACKAGE1,
@@ -97,11 +109,11 @@
id2=SPDXID_UPSTREAM_PACKAGE1))
self.sbom_doc.files.append(
- sbom_data.File(id=SPDXID_FILE1, name='/bin/file1', checksum='SHA1: 11111'))
+ sbom_data.File(id=SPDXID_FILE1, name='/bin/file1', checksum='SHA1: 11111', concluded_license_ids=[sbom_data.SPDXID_LICENSE_APACHE]))
self.sbom_doc.files.append(
- sbom_data.File(id=SPDXID_FILE2, name='/bin/file2', checksum='SHA1: 22222'))
+ sbom_data.File(id=SPDXID_FILE2, name='/bin/file2', checksum='SHA1: 22222', concluded_license_ids=[SPDXID_LICENSE_1]))
self.sbom_doc.files.append(
- sbom_data.File(id=SPDXID_FILE3, name='/bin/file3', checksum='SHA1: 33333'))
+ sbom_data.File(id=SPDXID_FILE3, name='/bin/file3', checksum='SHA1: 33333', concluded_license_ids=[SPDXID_LICENSE_2, SPDXID_LICENSE_3]))
self.sbom_doc.files.append(
sbom_data.File(id=SPDXID_FILE4, name='file4.a', checksum='SHA1: 44444'))
@@ -120,6 +132,11 @@
id2=SPDXID_FILE4
))
+ self.sbom_doc.add_license(sbom_data.License(sbom_data.SPDXID_LICENSE_APACHE, LICENSE_APACHE_TEXT, "License-Apache"))
+ self.sbom_doc.add_license(sbom_data.License(SPDXID_LICENSE_1, LICENSE1_TEXT, "License-1"))
+ self.sbom_doc.add_license(sbom_data.License(SPDXID_LICENSE_2, LICENSE2_TEXT, "License-2"))
+ self.sbom_doc.add_license(sbom_data.License(SPDXID_LICENSE_3, LICENSE3_TEXT, "License-3"))
+
# SBOM fragment of a APK
self.unbundled_sbom_doc = sbom_data.Document(name='test doc',
namespace='http://www.google.com/sbom/spdx/android',
diff --git a/tools/sbom/testdata/expected_json_sbom.spdx.json b/tools/sbom/testdata/expected_json_sbom.spdx.json
index 53936c5..a877810 100644
--- a/tools/sbom/testdata/expected_json_sbom.spdx.json
+++ b/tools/sbom/testdata/expected_json_sbom.spdx.json
@@ -31,6 +31,7 @@
"filesAnalyzed": true,
"versionInfo": "build_finger_print",
"supplier": "Organization: Google",
+ "licenseDeclared": "NOASSERTION",
"packageVerificationCode": {
"packageVerificationCodeValue": "123456"
},
@@ -46,7 +47,8 @@
"downloadLocation": "NONE",
"filesAnalyzed": false,
"versionInfo": "build_finger_print",
- "supplier": "Organization: Google"
+ "supplier": "Organization: Google",
+ "licenseDeclared": "LicenseRef-Android-Apache-2.0"
},
{
"name": "Prebuilt package1",
@@ -54,7 +56,8 @@
"downloadLocation": "NONE",
"filesAnalyzed": false,
"versionInfo": "build_finger_print",
- "supplier": "Organization: Google"
+ "supplier": "Organization: Google",
+ "licenseDeclared": "LicenseRef-Android-License-1"
},
{
"name": "Source package1",
@@ -63,6 +66,7 @@
"filesAnalyzed": false,
"versionInfo": "build_finger_print",
"supplier": "Organization: Google",
+ "licenseDeclared": "LicenseRef-Android-License-2 OR LicenseRef-Android-License-3",
"externalRefs": [
{
"referenceCategory": "SECURITY",
@@ -77,7 +81,8 @@
"downloadLocation": "NOASSERTION",
"filesAnalyzed": false,
"versionInfo": "1.1",
- "supplier": "Organization: upstream"
+ "supplier": "Organization: upstream",
+ "licenseDeclared": "LicenseRef-Android-License-2 OR LicenseRef-Android-License-3"
}
],
"files": [
@@ -89,7 +94,8 @@
"algorithm": "SHA1",
"checksumValue": "11111"
}
- ]
+ ],
+ "licenseConcluded": "LicenseRef-Android-Apache-2.0"
},
{
"fileName": "/bin/file2",
@@ -99,7 +105,8 @@
"algorithm": "SHA1",
"checksumValue": "22222"
}
- ]
+ ],
+ "licenseConcluded": "LicenseRef-Android-License-1"
},
{
"fileName": "/bin/file3",
@@ -109,7 +116,8 @@
"algorithm": "SHA1",
"checksumValue": "33333"
}
- ]
+ ],
+ "licenseConcluded": "LicenseRef-Android-License-2 OR LicenseRef-Android-License-3"
},
{
"fileName": "file4.a",
@@ -119,7 +127,8 @@
"algorithm": "SHA1",
"checksumValue": "44444"
}
- ]
+ ],
+ "licenseConcluded": "NOASSERTION"
}
],
"relationships": [
@@ -148,5 +157,27 @@
"relatedSpdxElement": "SPDXRef-UPSTREAM-package1",
"relationshipType": "VARIANT_OF"
}
+ ],
+ "hasExtractedLicensingInfos": [
+ {
+ "licenseId": "LicenseRef-Android-Apache-2.0",
+ "name": "License-Apache",
+ "extractedText": "<text>LICENSE_APACHE</text>"
+ },
+ {
+ "licenseId": "LicenseRef-Android-License-1",
+ "name": "License-1",
+ "extractedText": "<text>LICENSE 1</text>"
+ },
+ {
+ "licenseId": "LicenseRef-Android-License-2",
+ "name": "License-2",
+ "extractedText": "<text>LICENSE 2</text>"
+ },
+ {
+ "licenseId": "LicenseRef-Android-License-3",
+ "name": "License-3",
+ "extractedText": "<text>LICENSE 3</text>"
+ }
]
}
\ No newline at end of file
diff --git a/tools/sbom/testdata/expected_tagvalue_sbom.spdx b/tools/sbom/testdata/expected_tagvalue_sbom.spdx
index e6fd17e..1c54410 100644
--- a/tools/sbom/testdata/expected_tagvalue_sbom.spdx
+++ b/tools/sbom/testdata/expected_tagvalue_sbom.spdx
@@ -10,6 +10,7 @@
FileName: file4.a
SPDXID: SPDXRef-file4
FileChecksum: SHA1: 44444
+LicenseConcluded: NOASSERTION
PackageName: PRODUCT
SPDXID: SPDXRef-PRODUCT
@@ -17,6 +18,7 @@
FilesAnalyzed: true
PackageVersion: build_finger_print
PackageSupplier: Organization: Google
+PackageLicenseDeclared: NOASSERTION
PackageVerificationCode: 123456
Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-PRODUCT
@@ -24,14 +26,17 @@
FileName: /bin/file1
SPDXID: SPDXRef-file1
FileChecksum: SHA1: 11111
+LicenseConcluded: LicenseRef-Android-Apache-2.0
FileName: /bin/file2
SPDXID: SPDXRef-file2
FileChecksum: SHA1: 22222
+LicenseConcluded: LicenseRef-Android-License-1
FileName: /bin/file3
SPDXID: SPDXRef-file3
FileChecksum: SHA1: 33333
+LicenseConcluded: LicenseRef-Android-License-2 OR LicenseRef-Android-License-3
PackageName: PLATFORM
SPDXID: SPDXRef-PLATFORM
@@ -39,6 +44,7 @@
FilesAnalyzed: false
PackageVersion: build_finger_print
PackageSupplier: Organization: Google
+PackageLicenseDeclared: LicenseRef-Android-Apache-2.0
PackageName: Prebuilt package1
SPDXID: SPDXRef-PREBUILT-package1
@@ -46,6 +52,7 @@
FilesAnalyzed: false
PackageVersion: build_finger_print
PackageSupplier: Organization: Google
+PackageLicenseDeclared: LicenseRef-Android-License-1
PackageName: Source package1
SPDXID: SPDXRef-SOURCE-package1
@@ -53,6 +60,7 @@
FilesAnalyzed: false
PackageVersion: build_finger_print
PackageSupplier: Organization: Google
+PackageLicenseDeclared: LicenseRef-Android-License-2 OR LicenseRef-Android-License-3
ExternalRef: SECURITY cpe22Type cpe:/a:jsoncpp_project:jsoncpp:1.9.4
PackageName: Upstream package1
@@ -61,6 +69,7 @@
FilesAnalyzed: false
PackageVersion: 1.1
PackageSupplier: Organization: upstream
+PackageLicenseDeclared: LicenseRef-Android-License-2 OR LicenseRef-Android-License-3
Relationship: SPDXRef-SOURCE-package1 VARIANT_OF SPDXRef-UPSTREAM-package1
@@ -68,3 +77,19 @@
Relationship: SPDXRef-file2 GENERATED_FROM SPDXRef-PREBUILT-package1
Relationship: SPDXRef-file3 GENERATED_FROM SPDXRef-SOURCE-package1
Relationship: SPDXRef-file1 STATIC_LINK SPDXRef-file4
+
+LicenseID: LicenseRef-Android-Apache-2.0
+LicenseName: License-Apache
+ExtractedText: <text>LICENSE_APACHE</text>
+
+LicenseID: LicenseRef-Android-License-1
+LicenseName: License-1
+ExtractedText: <text>LICENSE 1</text>
+
+LicenseID: LicenseRef-Android-License-2
+LicenseName: License-2
+ExtractedText: <text>LICENSE 2</text>
+
+LicenseID: LicenseRef-Android-License-3
+LicenseName: License-3
+ExtractedText: <text>LICENSE 3</text>
diff --git a/tools/sbom/testdata/expected_tagvalue_sbom_doc_describes_file.spdx b/tools/sbom/testdata/expected_tagvalue_sbom_doc_describes_file.spdx
index 428d7e3..36afc8b 100644
--- a/tools/sbom/testdata/expected_tagvalue_sbom_doc_describes_file.spdx
+++ b/tools/sbom/testdata/expected_tagvalue_sbom_doc_describes_file.spdx
@@ -10,6 +10,7 @@
FileName: file4.a
SPDXID: SPDXRef-file4
FileChecksum: SHA1: 44444
+LicenseConcluded: NOASSERTION
Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-file4
@@ -19,19 +20,23 @@
FilesAnalyzed: true
PackageVersion: build_finger_print
PackageSupplier: Organization: Google
+PackageLicenseDeclared: NOASSERTION
PackageVerificationCode: 123456
FileName: /bin/file1
SPDXID: SPDXRef-file1
FileChecksum: SHA1: 11111
+LicenseConcluded: LicenseRef-Android-Apache-2.0
FileName: /bin/file2
SPDXID: SPDXRef-file2
FileChecksum: SHA1: 22222
+LicenseConcluded: LicenseRef-Android-License-1
FileName: /bin/file3
SPDXID: SPDXRef-file3
FileChecksum: SHA1: 33333
+LicenseConcluded: LicenseRef-Android-License-2 OR LicenseRef-Android-License-3
PackageName: PLATFORM
SPDXID: SPDXRef-PLATFORM
@@ -39,6 +44,7 @@
FilesAnalyzed: false
PackageVersion: build_finger_print
PackageSupplier: Organization: Google
+PackageLicenseDeclared: LicenseRef-Android-Apache-2.0
PackageName: Prebuilt package1
SPDXID: SPDXRef-PREBUILT-package1
@@ -46,6 +52,7 @@
FilesAnalyzed: false
PackageVersion: build_finger_print
PackageSupplier: Organization: Google
+PackageLicenseDeclared: LicenseRef-Android-License-1
PackageName: Source package1
SPDXID: SPDXRef-SOURCE-package1
@@ -53,6 +60,7 @@
FilesAnalyzed: false
PackageVersion: build_finger_print
PackageSupplier: Organization: Google
+PackageLicenseDeclared: LicenseRef-Android-License-2 OR LicenseRef-Android-License-3
ExternalRef: SECURITY cpe22Type cpe:/a:jsoncpp_project:jsoncpp:1.9.4
PackageName: Upstream package1
@@ -61,6 +69,7 @@
FilesAnalyzed: false
PackageVersion: 1.1
PackageSupplier: Organization: upstream
+PackageLicenseDeclared: LicenseRef-Android-License-2 OR LicenseRef-Android-License-3
Relationship: SPDXRef-SOURCE-package1 VARIANT_OF SPDXRef-UPSTREAM-package1
@@ -68,3 +77,19 @@
Relationship: SPDXRef-file2 GENERATED_FROM SPDXRef-PREBUILT-package1
Relationship: SPDXRef-file3 GENERATED_FROM SPDXRef-SOURCE-package1
Relationship: SPDXRef-file1 STATIC_LINK SPDXRef-file4
+
+LicenseID: LicenseRef-Android-Apache-2.0
+LicenseName: License-Apache
+ExtractedText: <text>LICENSE_APACHE</text>
+
+LicenseID: LicenseRef-Android-License-1
+LicenseName: License-1
+ExtractedText: <text>LICENSE 1</text>
+
+LicenseID: LicenseRef-Android-License-2
+LicenseName: License-2
+ExtractedText: <text>LICENSE 2</text>
+
+LicenseID: LicenseRef-Android-License-3
+LicenseName: License-3
+ExtractedText: <text>LICENSE 3</text>
diff --git a/tools/sbom/testdata/expected_tagvalue_sbom_unbundled.spdx b/tools/sbom/testdata/expected_tagvalue_sbom_unbundled.spdx
index a00c291..4b14a4b 100644
--- a/tools/sbom/testdata/expected_tagvalue_sbom_unbundled.spdx
+++ b/tools/sbom/testdata/expected_tagvalue_sbom_unbundled.spdx
@@ -1,6 +1,7 @@
FileName: /bin/file1.apk
SPDXID: SPDXRef-file1
FileChecksum: SHA1: 11111
+LicenseConcluded: NOASSERTION
PackageName: Unbundled apk package
SPDXID: SPDXRef-SOURCE-package1
@@ -8,5 +9,6 @@
FilesAnalyzed: false
PackageVersion: build_finger_print
PackageSupplier: Organization: Google
+PackageLicenseDeclared: NOASSERTION
Relationship: SPDXRef-file1 GENERATED_FROM SPDXRef-SOURCE-package1
diff --git a/tools/zipalign/ZipAlign.cpp b/tools/zipalign/ZipAlign.cpp
index f32f90b..3d65bc0 100644
--- a/tools/zipalign/ZipAlign.cpp
+++ b/tools/zipalign/ZipAlign.cpp
@@ -200,7 +200,7 @@
}
if (verbose)
- printf("Verification %s\n", foundBad ? "FAILED" : "succesful");
+ printf("Verification %s\n", foundBad ? "FAILED" : "successful");
return foundBad ? 1 : 0;
}