Skip to content

Commit 8873713

Browse files
committed
Add TARGET_PLATFORM_VERSION to lunch
lunch can now take combos in the form: $TARGET_PRODUCT $TARGET_PRODUCT-$TARGET_BUILD_VARIANT $TARGET_PRODUCT-$TARGET_BUILD_VARIANT-$TARGET_PLATFORM_VERSION If all 3 are not specified the unspecified ones will take the default values provided by the build system (eng, and currently OPR1). In addition, error handling for invalid products, variants and versions is moved to the build system. Bug: 34972208 Test: build/make/tests/envsetup_tests.sh Change-Id: Ib0aaa98633448ba9bd8df911704c9cb3a8ebbe85
1 parent 2c28027 commit 8873713

File tree

6 files changed

+68
-31
lines changed

6 files changed

+68
-31
lines changed

Diff for: buildspec.mk.default

+7-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ ifndef TARGET_BUILD_VARIANT
3636
#TARGET_BUILD_VARIANT:=eng
3737
endif
3838

39+
# Choose a targeted release. If you don't pick one, the default is the
40+
# soonest future release.
41+
ifndef TARGET_PLATFORM_RELEASE
42+
#TARGET_PLATFORM_RELEASE:=OPR1
43+
endif
44+
3945
# Choose additional targets to always install, even when building
4046
# minimal targets like "make droid". This takes simple target names
4147
# like "Browser" or "MyApp", the names used by LOCAL_MODULE or
@@ -105,4 +111,4 @@ endif
105111
# variable will be changed. After you have modified this file with the new
106112
# changes (see buildspec.mk.default), update this to the new value from
107113
# buildspec.mk.default.
108-
BUILD_ENV_SEQUENCE_NUMBER := 12
114+
BUILD_ENV_SEQUENCE_NUMBER := 13

Diff for: core/dumpvar.mk

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ print_build_config_vars := \
66
TARGET_PRODUCT \
77
TARGET_BUILD_VARIANT \
88
TARGET_BUILD_TYPE \
9+
TARGET_PLATFORM_VERSION \
910
TARGET_BUILD_APPS \
1011
TARGET_ARCH \
1112
TARGET_ARCH_VARIANT \

Diff for: core/envsetup.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ include $(BUILD_SYSTEM)/version_defaults.mk
2020
# people who haven't re-run those will have to do so before they
2121
# can build. Make sure to also update the corresponding value in
2222
# buildspec.mk.default and envsetup.sh.
23-
CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 12
23+
CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 13
2424

2525
# ---------------------------------------------------------------
2626
# The product defaults to generic on hardware

Diff for: core/version_defaults.mk

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ endef
5858
ALL_VERSIONS := O P
5959
ALL_VERSIONS := $(foreach v,$(ALL_VERSIONS),$(call version-list,$(v)))
6060

61+
DEFAULT_PLATFORM_VERSION := OPR1
62+
6163
# HACK: forward P to PPR1 until the build server config is updated
6264
ifeq (P,$(TARGET_PLATFORM_VERSION))
6365
TARGET_PLATFORM_VERSION := PPR1
@@ -67,7 +69,7 @@ ifeq (,$(TARGET_PLATFORM_VERSION))
6769
# Default targeted platform version
6870
# TODO: PLATFORM_VERSION, PLATFORM_SDK_VERSION, etc. should be conditional
6971
# on this
70-
TARGET_PLATFORM_VERSION := OPR1
72+
TARGET_PLATFORM_VERSION := $(DEFAULT_PLATFORM_VERSION)
7173
endif
7274

7375
ifeq (,$(filter $(ALL_VERSIONS), $(TARGET_PLATFORM_VERSION)))

Diff for: envsetup.sh

+20-28
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ function set_stuff_for_environment()
296296

297297
function set_sequence_number()
298298
{
299-
export BUILD_ENV_SEQUENCE_NUMBER=12
299+
export BUILD_ENV_SEQUENCE_NUMBER=13
300300
}
301301

302302
function settitle()
@@ -569,50 +569,42 @@ function lunch()
569569
then
570570
selection=${LUNCH_MENU_CHOICES[$(($answer-1))]}
571571
fi
572-
elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$")
573-
then
572+
else
574573
selection=$answer
575574
fi
576575

577-
if [ -z "$selection" ]
578-
then
579-
echo
580-
echo "Invalid lunch combo: $answer"
581-
return 1
582-
fi
583-
584576
export TARGET_BUILD_APPS=
585577

586-
local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//")
587-
check_variant $variant
588-
if [ $? -ne 0 ]
578+
local product variant_and_version variant version
579+
580+
product=${selection%%-*} # Trim everything after first dash
581+
variant_and_version=${selection#*-} # Trim everything up to first dash
582+
if [ "$variant_and_version" != "$selection" ]; then
583+
variant=${variant_and_version%%-*}
584+
if [ "$variant" != "$variant_and_version" ]; then
585+
version=${variant_and_version#*-}
586+
fi
587+
fi
588+
589+
if [ -z "$product" ]
589590
then
590591
echo
591-
echo "** Invalid variant: '$variant'"
592-
echo "** Must be one of ${VARIANT_CHOICES[@]}"
593-
variant=
592+
echo "Invalid lunch combo: $selection"
593+
return 1
594594
fi
595595

596-
local product=$(echo -n $selection | sed -e "s/-.*$//")
597596
TARGET_PRODUCT=$product \
598597
TARGET_BUILD_VARIANT=$variant \
598+
TARGET_PLATFORM_VERSION=$version \
599599
build_build_var_cache
600600
if [ $? -ne 0 ]
601601
then
602-
echo
603-
echo "** Don't have a product spec for: '$product'"
604-
echo "** Do you have the right repo manifest?"
605-
product=
606-
fi
607-
608-
if [ -z "$product" -o -z "$variant" ]
609-
then
610-
echo
611602
return 1
612603
fi
613604

614-
export TARGET_PRODUCT=$product
615-
export TARGET_BUILD_VARIANT=$variant
605+
export TARGET_PRODUCT=$(get_build_var TARGET_PRODUCT)
606+
export TARGET_BUILD_VARIANT=$(get_build_var TARGET_BUILD_VARIANT)
607+
export TARGET_PLATFORM_VERSION=$(get_build_var TARGET_PLATFORM_VERSION)
616608
export TARGET_BUILD_TYPE=release
617609

618610
echo

Diff for: tests/envsetup_tests.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash -e
2+
3+
source $(dirname $0)/../envsetup.sh
4+
5+
unset TARGET_PRODUCT TARGET_BUILD_VARIANT TARGET_PLATFORM_VERSION
6+
7+
function check_lunch
8+
(
9+
echo lunch $1
10+
set +e
11+
lunch $1 > /dev/null 2> /dev/null
12+
set -e
13+
[ "$TARGET_PRODUCT" = "$2" ] || ( echo "lunch $1: expected TARGET_PRODUCT='$2', got '$TARGET_PRODUCT'" && exit 1 )
14+
[ "$TARGET_BUILD_VARIANT" = "$3" ] || ( echo "lunch $1: expected TARGET_BUILD_VARIANT='$3', got '$TARGET_BUILD_VARIANT'" && exit 1 )
15+
[ "$TARGET_PLATFORM_VERSION" = "$4" ] || ( echo "lunch $1: expected TARGET_PLATFORM_VERSION='$4', got '$TARGET_PLATFORM_VERSION'" && exit 1 )
16+
)
17+
18+
default_version=$(get_build_var DEFAULT_PLATFORM_VERSION)
19+
valid_version=PPR1
20+
21+
# lunch tests
22+
check_lunch "aosp_arm64" "aosp_arm64" "eng" "$default_version"
23+
check_lunch "aosp_arm64-userdebug" "aosp_arm64" "userdebug" "$default_version"
24+
check_lunch "aosp_arm64-userdebug-$valid_version" "aosp_arm64" "userdebug" "$valid_version"
25+
check_lunch "abc" "" "" ""
26+
check_lunch "aosp_arm64-abc" "" "" ""
27+
check_lunch "aosp_arm64-userdebug-abc" "" "" ""
28+
check_lunch "aosp_arm64-abc-$valid_version" "" "" ""
29+
check_lunch "abc-userdebug-$valid_version" "" "" ""
30+
check_lunch "-" "" "" ""
31+
check_lunch "--" "" "" ""
32+
check_lunch "-userdebug" "" "" ""
33+
check_lunch "-userdebug-" "" "" ""
34+
check_lunch "-userdebug-$valid_version" "" "" ""
35+
check_lunch "aosp_arm64-userdebug-$valid_version-" "" "" ""
36+
check_lunch "aosp_arm64-userdebug-$valid_version-abc" "" "" ""

0 commit comments

Comments
 (0)