• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env sh
2
3# Copyright 2022 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Script to test the SysUI-Studio gradle build.
18# The script assumes `m` has already run
19# TODO: Be more specific about which modules are dependencies
20
21print_error() {
22  local RED='\033[0;31m'
23  local NC='\033[0m'
24  printf "${RED}$1${NC}\n"
25}
26
27print_good() {
28  local GREEN='\033[0;32m'
29  local NC='\033[0m'
30  printf "${GREEN}$1${NC}\n"
31}
32
33# The default list of Gradle tasks to run if no args are passed
34DEFAULT_TASKS=(
35  :SystemUI:assemble
36  :SystemUILib:assembleAndroidTest
37  :ComposeGallery:assemble
38  :ComposeGallery:assembleAndroidTest
39  :NexusLauncher:assembleGoogleWithQuickstepDebug
40  :NexusLauncher:assembleGoogleWithQuickstepDebugAndroidTest
41  :WallpaperPickerGoogle:assembleGoogleDebug
42  :PlatformScenarioTests:assembleDebug
43)
44
45GRADLE_TASKS="$@"
46if [[ -z "$GRADLE_TASKS" ]]; then
47  GRADLE_TASKS="${DEFAULT_TASKS[@]}"
48fi
49
50SCRIPT_DIR="$(cd $(dirname $0) && pwd)"
51ANDROID_BUILD_TOP="$(cd "${SCRIPT_DIR}/../../../../../"; pwd)"
52STUDIO_DEV_DIR="${ANDROID_BUILD_TOP}/vendor/unbundled_google/packages/SystemUIGoogle/studio-dev"
53
54# The temporary artifacts directory.
55GRADLE_BUILD_DIR="${ANDROID_BUILD_TOP}/out/gradle"
56mkdir -p "${GRADLE_BUILD_DIR}"
57
58export ANDROID_HOME="${GRADLE_BUILD_DIR}/MockSdk"
59
60# Sets the path to the user preferences directory for tools that are part of the Android SDK.
61export ANDROID_USER_HOME="${GRADLE_BUILD_DIR}/.android"
62
63export JAVA_HOME="${ANDROID_BUILD_TOP}/prebuilts/jdk/jdk17/linux-x86"
64export PATH="${JAVA_HOME}/bin:${ANDROID_BUILD_TOP}/out/host/linux-x86/bin:$PATH"
65
66"${STUDIO_DEV_DIR}"/studiow --no-download --update-sdk soong || exit $?
67
68export GRADLE_USER_HOME="${GRADLE_BUILD_DIR}/gradle-user-home"
69
70export STUDIO_LAUNCHED_WITH_WRAPPER=true
71
72cd "${STUDIO_DEV_DIR}/SysUIGradleProject"
73./gradlew \
74    --refresh-dependencies \
75    --project-cache-dir="${GRADLE_BUILD_DIR}"/gradle-project-cache \
76    $GRADLE_TASKS
77
78return_code=$?
79
80if [ "${return_code}" -eq 0 ]; then
81  print_good 'Success'
82else
83  print_error 'failed to build using gradlew'
84fi
85exit "${return_code}"
86