1*c2e18aaaSAndroid Build Coastguard Worker#!/usr/bin/env python3 2*c2e18aaaSAndroid Build Coastguard Worker# 3*c2e18aaaSAndroid Build Coastguard Worker# Copyright 2018 - The Android Open Source Project 4*c2e18aaaSAndroid Build Coastguard Worker# 5*c2e18aaaSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 6*c2e18aaaSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 7*c2e18aaaSAndroid Build Coastguard Worker# You may obtain a copy of the License at 8*c2e18aaaSAndroid Build Coastguard Worker# 9*c2e18aaaSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 10*c2e18aaaSAndroid Build Coastguard Worker# 11*c2e18aaaSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 12*c2e18aaaSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 13*c2e18aaaSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14*c2e18aaaSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 15*c2e18aaaSAndroid Build Coastguard Worker# limitations under the License. 16*c2e18aaaSAndroid Build Coastguard Worker"""The common definitions of AIDEgen""" 17*c2e18aaaSAndroid Build Coastguard Worker 18*c2e18aaaSAndroid Build Coastguard Worker# Env constant 19*c2e18aaaSAndroid Build Coastguard WorkerOUT_DIR_COMMON_BASE_ENV_VAR = 'OUT_DIR_COMMON_BASE' 20*c2e18aaaSAndroid Build Coastguard WorkerANDROID_DEFAULT_OUT = 'out' 21*c2e18aaaSAndroid Build Coastguard WorkerAIDEGEN_ROOT_PATH = 'tools/asuite/aidegen' 22*c2e18aaaSAndroid Build Coastguard WorkerUSER_HOME = '$USER_HOME$' 23*c2e18aaaSAndroid Build Coastguard WorkerTARGET_PRODUCT = 'TARGET_PRODUCT' 24*c2e18aaaSAndroid Build Coastguard WorkerTARGET_BUILD_VARIANT = 'TARGET_BUILD_VARIANT' 25*c2e18aaaSAndroid Build Coastguard WorkerGEN_JAVA_DEPS = 'SOONG_COLLECT_JAVA_DEPS' 26*c2e18aaaSAndroid Build Coastguard WorkerGEN_CC_DEPS = 'SOONG_COLLECT_CC_DEPS' 27*c2e18aaaSAndroid Build Coastguard WorkerGEN_COMPDB = 'SOONG_GEN_COMPDB' 28*c2e18aaaSAndroid Build Coastguard WorkerGEN_RUST = 'SOONG_GEN_RUST_PROJECT' 29*c2e18aaaSAndroid Build Coastguard WorkerAIDEGEN_TEST_MODE = 'AIDEGEN_TEST_MODE' 30*c2e18aaaSAndroid Build Coastguard Worker 31*c2e18aaaSAndroid Build Coastguard Worker# Constants for module's info. 32*c2e18aaaSAndroid Build Coastguard WorkerKEY_PATH = 'path' 33*c2e18aaaSAndroid Build Coastguard WorkerKEY_DEPENDENCIES = 'dependencies' 34*c2e18aaaSAndroid Build Coastguard WorkerKEY_DEPTH = 'depth' 35*c2e18aaaSAndroid Build Coastguard WorkerKEY_CLASS = 'class' 36*c2e18aaaSAndroid Build Coastguard WorkerKEY_INSTALLED = 'installed' 37*c2e18aaaSAndroid Build Coastguard WorkerKEY_SRCS = 'srcs' 38*c2e18aaaSAndroid Build Coastguard WorkerKEY_SRCJARS = 'srcjars' 39*c2e18aaaSAndroid Build Coastguard WorkerKEY_CLASSES_JAR = 'classes_jar' 40*c2e18aaaSAndroid Build Coastguard WorkerKEY_TAG = 'tags' 41*c2e18aaaSAndroid Build Coastguard WorkerKEY_COMPATIBILITY = 'compatibility_suites' 42*c2e18aaaSAndroid Build Coastguard WorkerKEY_AUTO_TEST_CONFIG = 'auto_test_config' 43*c2e18aaaSAndroid Build Coastguard WorkerKEY_MODULE_NAME = 'module_name' 44*c2e18aaaSAndroid Build Coastguard WorkerKEY_TEST_CONFIG = 'test_config' 45*c2e18aaaSAndroid Build Coastguard WorkerKEY_HEADER = 'header_search_path' 46*c2e18aaaSAndroid Build Coastguard WorkerKEY_SYSTEM = 'system_search_path' 47*c2e18aaaSAndroid Build Coastguard WorkerKEY_TESTS = 'tests' 48*c2e18aaaSAndroid Build Coastguard WorkerKEY_JARS = 'jars' 49*c2e18aaaSAndroid Build Coastguard WorkerKEY_DEP_SRCS = 'dep_srcs' 50*c2e18aaaSAndroid Build Coastguard WorkerKEY_IML_NAME = 'iml_name' 51*c2e18aaaSAndroid Build Coastguard WorkerKEY_EXCLUDES = 'excludes' 52*c2e18aaaSAndroid Build Coastguard Worker 53*c2e18aaaSAndroid Build Coastguard Worker# Java related classes. 54*c2e18aaaSAndroid Build Coastguard WorkerJAVA_TARGET_CLASSES = ['APPS', 'JAVA_LIBRARIES', 'ROBOLECTRIC'] 55*c2e18aaaSAndroid Build Coastguard Worker# C, C++ related classes. 56*c2e18aaaSAndroid Build Coastguard WorkerNATIVE_TARGET_CLASSES = [ 57*c2e18aaaSAndroid Build Coastguard Worker 'HEADER_LIBRARIES', 'NATIVE_TESTS', 'STATIC_LIBRARIES', 'SHARED_LIBRARIES' 58*c2e18aaaSAndroid Build Coastguard Worker] 59*c2e18aaaSAndroid Build Coastguard WorkerTARGET_CLASSES = JAVA_TARGET_CLASSES 60*c2e18aaaSAndroid Build Coastguard WorkerTARGET_CLASSES.extend(NATIVE_TARGET_CLASSES) 61*c2e18aaaSAndroid Build Coastguard Worker 62*c2e18aaaSAndroid Build Coastguard Worker# Constants for IDE util. 63*c2e18aaaSAndroid Build Coastguard WorkerIDE_ECLIPSE = 'Eclipse' 64*c2e18aaaSAndroid Build Coastguard WorkerIDE_INTELLIJ = 'IntelliJ' 65*c2e18aaaSAndroid Build Coastguard WorkerIDE_ANDROID_STUDIO = 'Android Studio' 66*c2e18aaaSAndroid Build Coastguard WorkerIDE_CLION = 'CLion' 67*c2e18aaaSAndroid Build Coastguard WorkerIDE_VSCODE = 'VS Code' 68*c2e18aaaSAndroid Build Coastguard WorkerIDE_UNDEFINED = 'Undefined IDE' 69*c2e18aaaSAndroid Build Coastguard WorkerIDE_NAME_DICT = { 70*c2e18aaaSAndroid Build Coastguard Worker 'j': IDE_INTELLIJ, 71*c2e18aaaSAndroid Build Coastguard Worker 's': IDE_ANDROID_STUDIO, 72*c2e18aaaSAndroid Build Coastguard Worker 'e': IDE_ECLIPSE, 73*c2e18aaaSAndroid Build Coastguard Worker 'c': IDE_CLION, 74*c2e18aaaSAndroid Build Coastguard Worker 'v': IDE_VSCODE, 75*c2e18aaaSAndroid Build Coastguard Worker 'u': IDE_UNDEFINED 76*c2e18aaaSAndroid Build Coastguard Worker} 77*c2e18aaaSAndroid Build Coastguard WorkerIDE_DICT = { 78*c2e18aaaSAndroid Build Coastguard Worker IDE_INTELLIJ: 'j', 79*c2e18aaaSAndroid Build Coastguard Worker IDE_ANDROID_STUDIO: 's', 80*c2e18aaaSAndroid Build Coastguard Worker IDE_ECLIPSE: 'e', 81*c2e18aaaSAndroid Build Coastguard Worker IDE_CLION: 'c', 82*c2e18aaaSAndroid Build Coastguard Worker IDE_VSCODE: 'v', 83*c2e18aaaSAndroid Build Coastguard Worker IDE_UNDEFINED: 'u' 84*c2e18aaaSAndroid Build Coastguard Worker} 85*c2e18aaaSAndroid Build Coastguard Worker 86*c2e18aaaSAndroid Build Coastguard Worker# Constants for asuite metrics. 87*c2e18aaaSAndroid Build Coastguard WorkerEXIT_CODE_EXCEPTION = -1 88*c2e18aaaSAndroid Build Coastguard WorkerEXIT_CODE_NORMAL = 0 89*c2e18aaaSAndroid Build Coastguard WorkerEXIT_CODE_AIDEGEN_EXCEPTION = 1 90*c2e18aaaSAndroid Build Coastguard WorkerAIDEGEN_TOOL_NAME = 'aidegen' 91*c2e18aaaSAndroid Build Coastguard WorkerANDROID_TREE = 'is_android_tree' 92*c2e18aaaSAndroid Build Coastguard WorkerTYPE_AIDEGEN_BUILD_TIME = 200 93*c2e18aaaSAndroid Build Coastguard WorkerTYPE_AIDEGEN_PRE_PROCESS_TIME = 201 94*c2e18aaaSAndroid Build Coastguard WorkerTYPE_AIDEGEN_POST_PROCESS_TIME = 202 95*c2e18aaaSAndroid Build Coastguard Worker 96*c2e18aaaSAndroid Build Coastguard Worker# Exit code of the asuite metrics for parsing xml file failed. 97*c2e18aaaSAndroid Build Coastguard WorkerXML_PARSING_FAILURE = 101 98*c2e18aaaSAndroid Build Coastguard Worker 99*c2e18aaaSAndroid Build Coastguard Worker# Exit code of the asuite metrics for locating Android SDK path failed. 100*c2e18aaaSAndroid Build Coastguard WorkerLOCATE_SDK_PATH_FAILURE = 102 101*c2e18aaaSAndroid Build Coastguard Worker 102*c2e18aaaSAndroid Build Coastguard Worker# Exit code of the asuite metrics for IDE launched failed. 103*c2e18aaaSAndroid Build Coastguard WorkerIDE_LAUNCH_FAILURE = 103 104*c2e18aaaSAndroid Build Coastguard Worker 105*c2e18aaaSAndroid Build Coastguard Worker# Constants for file names. 106*c2e18aaaSAndroid Build Coastguard WorkerMERGED_MODULE_INFO = 'merged_module_info.json' 107*c2e18aaaSAndroid Build Coastguard WorkerBLUEPRINT_JAVA_JSONFILE_NAME = 'module_bp_java_deps.json' 108*c2e18aaaSAndroid Build Coastguard WorkerBLUEPRINT_CC_JSONFILE_NAME = 'module_bp_cc_deps.json' 109*c2e18aaaSAndroid Build Coastguard WorkerCOMPDB_JSONFILE_NAME = 'compile_commands.json' 110*c2e18aaaSAndroid Build Coastguard WorkerRUST_PROJECT_JSON = 'rust-project.json' 111*c2e18aaaSAndroid Build Coastguard WorkerCMAKELISTS_FILE_NAME = 'clion_project_lists.txt' 112*c2e18aaaSAndroid Build Coastguard WorkerCLION_PROJECT_FILE_NAME = 'CMakeLists.txt' 113*c2e18aaaSAndroid Build Coastguard WorkerANDROID_BP = 'Android.bp' 114*c2e18aaaSAndroid Build Coastguard WorkerANDROID_MK = 'Android.mk' 115*c2e18aaaSAndroid Build Coastguard WorkerJAVA_FILES = '*.java' 116*c2e18aaaSAndroid Build Coastguard WorkerKOTLIN_FILES = '*.kt' 117*c2e18aaaSAndroid Build Coastguard WorkerVSCODE_CONFIG_DIR = '.vscode' 118*c2e18aaaSAndroid Build Coastguard WorkerANDROID_MANIFEST = 'AndroidManifest.xml' 119*c2e18aaaSAndroid Build Coastguard WorkerVERSION_FILE = 'VERSION' 120*c2e18aaaSAndroid Build Coastguard WorkerINTERMEDIATES = '.intermediates' 121*c2e18aaaSAndroid Build Coastguard WorkerTARGET_R_SRCJAR = 'R.srcjar' 122*c2e18aaaSAndroid Build Coastguard WorkerNAME_AAPT2 = 'aapt2' 123*c2e18aaaSAndroid Build Coastguard Worker 124*c2e18aaaSAndroid Build Coastguard Worker# Constants for file paths. 125*c2e18aaaSAndroid Build Coastguard WorkerRELATIVE_NATIVE_PATH = 'development/ide/clion' 126*c2e18aaaSAndroid Build Coastguard WorkerRELATIVE_COMPDB_PATH = 'development/ide/compdb' 127*c2e18aaaSAndroid Build Coastguard WorkerUNZIP_SRCJAR_PATH_HEAD = 'aidegen_' 128*c2e18aaaSAndroid Build Coastguard Worker 129*c2e18aaaSAndroid Build Coastguard Worker# Constants for whole Android tree. 130*c2e18aaaSAndroid Build Coastguard WorkerWHOLE_ANDROID_TREE_TARGET = '#WHOLE_ANDROID_TREE#' 131*c2e18aaaSAndroid Build Coastguard Worker 132*c2e18aaaSAndroid Build Coastguard Worker# Constants for ProjectInfo or ModuleData classes. 133*c2e18aaaSAndroid Build Coastguard WorkerSRCJAR_EXT = '.srcjar' 134*c2e18aaaSAndroid Build Coastguard WorkerJAR_EXT = '.jar' 135*c2e18aaaSAndroid Build Coastguard WorkerTARGET_LIBS = [JAR_EXT] 136*c2e18aaaSAndroid Build Coastguard Worker 137*c2e18aaaSAndroid Build Coastguard Worker# Constants for aidegen_functional_test. 138*c2e18aaaSAndroid Build Coastguard WorkerANDROID_COMMON = 'android_common' 139*c2e18aaaSAndroid Build Coastguard WorkerLINUX_GLIBC_COMMON = 'linux_glibc_common' 140*c2e18aaaSAndroid Build Coastguard Worker 141*c2e18aaaSAndroid Build Coastguard Worker# Constants for ide_util. 142*c2e18aaaSAndroid Build Coastguard WorkerNOHUP = 'nohup' 143*c2e18aaaSAndroid Build Coastguard WorkerECLIPSE_WS = '~/Documents/AIDEGen_Eclipse_workspace' 144*c2e18aaaSAndroid Build Coastguard WorkerIGNORE_STD_OUT_ERR_CMD = '2>/dev/null >&2' 145*c2e18aaaSAndroid Build Coastguard Worker 146*c2e18aaaSAndroid Build Coastguard Worker# Constants for environment. 147*c2e18aaaSAndroid Build Coastguard WorkerLUNCH_TARGET = 'lunch target' 148*c2e18aaaSAndroid Build Coastguard Worker 149*c2e18aaaSAndroid Build Coastguard Worker# Constants for the languages aidegen supports. 150*c2e18aaaSAndroid Build Coastguard WorkerJAVA = 'Java' 151*c2e18aaaSAndroid Build Coastguard WorkerC_CPP = 'C/C++' 152*c2e18aaaSAndroid Build Coastguard WorkerRUST = 'Rust' 153*c2e18aaaSAndroid Build Coastguard WorkerUNDEFINED = 'undefined' 154*c2e18aaaSAndroid Build Coastguard WorkerLANG_UNDEFINED = 'u' 155*c2e18aaaSAndroid Build Coastguard WorkerLANG_JAVA = 'j' 156*c2e18aaaSAndroid Build Coastguard WorkerLANG_CC = 'c' 157*c2e18aaaSAndroid Build Coastguard WorkerLANG_RUST = 'r' 158*c2e18aaaSAndroid Build Coastguard WorkerLANGUAGE_NAME_DICT = { 159*c2e18aaaSAndroid Build Coastguard Worker LANG_UNDEFINED: UNDEFINED, 160*c2e18aaaSAndroid Build Coastguard Worker LANG_JAVA: JAVA, 161*c2e18aaaSAndroid Build Coastguard Worker LANG_CC: C_CPP, 162*c2e18aaaSAndroid Build Coastguard Worker LANG_RUST: RUST 163*c2e18aaaSAndroid Build Coastguard Worker} 164*c2e18aaaSAndroid Build Coastguard Worker 165*c2e18aaaSAndroid Build Coastguard Worker# Constants for error message. 166*c2e18aaaSAndroid Build Coastguard WorkerINVALID_XML = 'The content of {XML_FILE} is not valid.' 167*c2e18aaaSAndroid Build Coastguard WorkerWARN_MSG = '\n{} {}\n' 168*c2e18aaaSAndroid Build Coastguard Worker 169*c2e18aaaSAndroid Build Coastguard Worker# Constants for default modules. 170*c2e18aaaSAndroid Build Coastguard WorkerFRAMEWORK_ALL = 'framework-all' 171*c2e18aaaSAndroid Build Coastguard WorkerCORE_ALL = 'core-all' 172*c2e18aaaSAndroid Build Coastguard WorkerFRAMEWORK_SRCJARS = 'framework_srcjars' 173*c2e18aaaSAndroid Build Coastguard Worker 174*c2e18aaaSAndroid Build Coastguard Worker# Constants for module's path. 175*c2e18aaaSAndroid Build Coastguard WorkerFRAMEWORK_PATH = 'frameworks/base' 176*c2e18aaaSAndroid Build Coastguard WorkerLIBCORE_PATH = 'libcore' 177*c2e18aaaSAndroid Build Coastguard Worker 178*c2e18aaaSAndroid Build Coastguard Worker# Constants for regular expression 179*c2e18aaaSAndroid Build Coastguard WorkerRE_INSIDE_PATH_CHECK = r'^{}($|/.+)' 180*c2e18aaaSAndroid Build Coastguard Worker 181*c2e18aaaSAndroid Build Coastguard Worker# Constants for Git 182*c2e18aaaSAndroid Build Coastguard WorkerGIT_FOLDER_NAME = '.git' 183*c2e18aaaSAndroid Build Coastguard Worker 184*c2e18aaaSAndroid Build Coastguard Worker# Constants for Idea 185*c2e18aaaSAndroid Build Coastguard WorkerIDEA_FOLDER = '.idea' 186