• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#
3# Copyright 2018 - 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"""The common definitions of AIDEgen"""
17
18# Env constant
19OUT_DIR_COMMON_BASE_ENV_VAR = 'OUT_DIR_COMMON_BASE'
20ANDROID_DEFAULT_OUT = 'out'
21AIDEGEN_ROOT_PATH = 'tools/asuite/aidegen'
22USER_HOME = '$USER_HOME$'
23TARGET_PRODUCT = 'TARGET_PRODUCT'
24TARGET_BUILD_VARIANT = 'TARGET_BUILD_VARIANT'
25GEN_JAVA_DEPS = 'SOONG_COLLECT_JAVA_DEPS'
26GEN_CC_DEPS = 'SOONG_COLLECT_CC_DEPS'
27GEN_COMPDB = 'SOONG_GEN_COMPDB'
28GEN_RUST = 'SOONG_GEN_RUST_PROJECT'
29AIDEGEN_TEST_MODE = 'AIDEGEN_TEST_MODE'
30
31# Constants for module's info.
32KEY_PATH = 'path'
33KEY_DEPENDENCIES = 'dependencies'
34KEY_DEPTH = 'depth'
35KEY_CLASS = 'class'
36KEY_INSTALLED = 'installed'
37KEY_SRCS = 'srcs'
38KEY_SRCJARS = 'srcjars'
39KEY_CLASSES_JAR = 'classes_jar'
40KEY_TAG = 'tags'
41KEY_COMPATIBILITY = 'compatibility_suites'
42KEY_AUTO_TEST_CONFIG = 'auto_test_config'
43KEY_MODULE_NAME = 'module_name'
44KEY_TEST_CONFIG = 'test_config'
45KEY_HEADER = 'header_search_path'
46KEY_SYSTEM = 'system_search_path'
47KEY_TESTS = 'tests'
48KEY_JARS = 'jars'
49KEY_DEP_SRCS = 'dep_srcs'
50KEY_IML_NAME = 'iml_name'
51KEY_EXCLUDES = 'excludes'
52
53# Java related classes.
54JAVA_TARGET_CLASSES = ['APPS', 'JAVA_LIBRARIES', 'ROBOLECTRIC']
55# C, C++ related classes.
56NATIVE_TARGET_CLASSES = [
57    'HEADER_LIBRARIES', 'NATIVE_TESTS', 'STATIC_LIBRARIES', 'SHARED_LIBRARIES'
58]
59TARGET_CLASSES = JAVA_TARGET_CLASSES
60TARGET_CLASSES.extend(NATIVE_TARGET_CLASSES)
61
62# Constants for IDE util.
63IDE_ECLIPSE = 'Eclipse'
64IDE_INTELLIJ = 'IntelliJ'
65IDE_ANDROID_STUDIO = 'Android Studio'
66IDE_CLION = 'CLion'
67IDE_VSCODE = 'VS Code'
68IDE_UNDEFINED = 'Undefined IDE'
69IDE_NAME_DICT = {
70    'j': IDE_INTELLIJ,
71    's': IDE_ANDROID_STUDIO,
72    'e': IDE_ECLIPSE,
73    'c': IDE_CLION,
74    'v': IDE_VSCODE,
75    'u': IDE_UNDEFINED
76}
77IDE_DICT = {
78    IDE_INTELLIJ: 'j',
79    IDE_ANDROID_STUDIO: 's',
80    IDE_ECLIPSE: 'e',
81    IDE_CLION: 'c',
82    IDE_VSCODE: 'v',
83    IDE_UNDEFINED: 'u'
84}
85
86# Constants for asuite metrics.
87EXIT_CODE_EXCEPTION = -1
88EXIT_CODE_NORMAL = 0
89EXIT_CODE_AIDEGEN_EXCEPTION = 1
90AIDEGEN_TOOL_NAME = 'aidegen'
91ANDROID_TREE = 'is_android_tree'
92TYPE_AIDEGEN_BUILD_TIME = 200
93TYPE_AIDEGEN_PRE_PROCESS_TIME = 201
94TYPE_AIDEGEN_POST_PROCESS_TIME = 202
95
96# Exit code of the asuite metrics for parsing xml file failed.
97XML_PARSING_FAILURE = 101
98
99# Exit code of the asuite metrics for locating Android SDK path failed.
100LOCATE_SDK_PATH_FAILURE = 102
101
102# Exit code of the asuite metrics for IDE launched failed.
103IDE_LAUNCH_FAILURE = 103
104
105# Constants for file names.
106MERGED_MODULE_INFO = 'merged_module_info.json'
107BLUEPRINT_JAVA_JSONFILE_NAME = 'module_bp_java_deps.json'
108BLUEPRINT_CC_JSONFILE_NAME = 'module_bp_cc_deps.json'
109COMPDB_JSONFILE_NAME = 'compile_commands.json'
110RUST_PROJECT_JSON = 'rust-project.json'
111CMAKELISTS_FILE_NAME = 'clion_project_lists.txt'
112CLION_PROJECT_FILE_NAME = 'CMakeLists.txt'
113ANDROID_BP = 'Android.bp'
114ANDROID_MK = 'Android.mk'
115JAVA_FILES = '*.java'
116KOTLIN_FILES = '*.kt'
117VSCODE_CONFIG_DIR = '.vscode'
118ANDROID_MANIFEST = 'AndroidManifest.xml'
119VERSION_FILE = 'VERSION'
120INTERMEDIATES = '.intermediates'
121TARGET_R_SRCJAR = 'R.srcjar'
122NAME_AAPT2 = 'aapt2'
123
124# Constants for file paths.
125RELATIVE_NATIVE_PATH = 'development/ide/clion'
126RELATIVE_COMPDB_PATH = 'development/ide/compdb'
127UNZIP_SRCJAR_PATH_HEAD = 'aidegen_'
128
129# Constants for whole Android tree.
130WHOLE_ANDROID_TREE_TARGET = '#WHOLE_ANDROID_TREE#'
131
132# Constants for ProjectInfo or ModuleData classes.
133SRCJAR_EXT = '.srcjar'
134JAR_EXT = '.jar'
135TARGET_LIBS = [JAR_EXT]
136
137# Constants for aidegen_functional_test.
138ANDROID_COMMON = 'android_common'
139LINUX_GLIBC_COMMON = 'linux_glibc_common'
140
141# Constants for ide_util.
142NOHUP = 'nohup'
143ECLIPSE_WS = '~/Documents/AIDEGen_Eclipse_workspace'
144IGNORE_STD_OUT_ERR_CMD = '2>/dev/null >&2'
145
146# Constants for environment.
147LUNCH_TARGET = 'lunch target'
148
149# Constants for the languages aidegen supports.
150JAVA = 'Java'
151C_CPP = 'C/C++'
152RUST = 'Rust'
153UNDEFINED = 'undefined'
154LANG_UNDEFINED = 'u'
155LANG_JAVA = 'j'
156LANG_CC = 'c'
157LANG_RUST = 'r'
158LANGUAGE_NAME_DICT = {
159    LANG_UNDEFINED: UNDEFINED,
160    LANG_JAVA: JAVA,
161    LANG_CC: C_CPP,
162    LANG_RUST: RUST
163}
164
165# Constants for error message.
166INVALID_XML = 'The content of {XML_FILE} is not valid.'
167WARN_MSG = '\n{} {}\n'
168
169# Constants for default modules.
170FRAMEWORK_ALL = 'framework-all'
171CORE_ALL = 'core-all'
172FRAMEWORK_SRCJARS = 'framework_srcjars'
173
174# Constants for module's path.
175FRAMEWORK_PATH = 'frameworks/base'
176LIBCORE_PATH = 'libcore'
177
178# Constants for regular expression
179RE_INSIDE_PATH_CHECK = r'^{}($|/.+)'
180
181# Constants for Git
182GIT_FOLDER_NAME = '.git'
183
184# Constants for Idea
185IDEA_FOLDER = '.idea'
186