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'
92
93# Exit code of the asuite metrics for parsing xml file failed.
94XML_PARSING_FAILURE = 101
95
96# Exit code of the asuite metrics for locating Android SDK path failed.
97LOCATE_SDK_PATH_FAILURE = 102
98
99# Exit code of the asuite metrics for IDE launched failed.
100IDE_LAUNCH_FAILURE = 103
101
102# Constants for file names.
103MERGED_MODULE_INFO = 'merged_module_info.json'
104BLUEPRINT_JAVA_JSONFILE_NAME = 'module_bp_java_deps.json'
105BLUEPRINT_CC_JSONFILE_NAME = 'module_bp_cc_deps.json'
106COMPDB_JSONFILE_NAME = 'compile_commands.json'
107RUST_PROJECT_JSON = 'rust-project.json'
108CMAKELISTS_FILE_NAME = 'clion_project_lists.txt'
109CLION_PROJECT_FILE_NAME = 'CMakeLists.txt'
110ANDROID_BP = 'Android.bp'
111ANDROID_MK = 'Android.mk'
112JAVA_FILES = '*.java'
113VSCODE_CONFIG_DIR = '.vscode'
114ANDROID_MANIFEST = 'AndroidManifest.xml'
115VERSION_FILE = 'VERSION'
116
117# Constants for file paths.
118RELATIVE_NATIVE_PATH = 'development/ide/clion'
119RELATIVE_COMPDB_PATH = 'development/ide/compdb'
120
121# Constants for whole Android tree.
122WHOLE_ANDROID_TREE_TARGET = '#WHOLE_ANDROID_TREE#'
123
124# Constants for ProjectInfo or ModuleData classes.
125JAR_EXT = '.jar'
126TARGET_LIBS = [JAR_EXT]
127
128# Constants for aidegen_functional_test.
129ANDROID_COMMON = 'android_common'
130LINUX_GLIBC_COMMON = 'linux_glibc_common'
131
132# Constants for ide_util.
133NOHUP = 'nohup'
134ECLIPSE_WS = '~/Documents/AIDEGen_Eclipse_workspace'
135IGNORE_STD_OUT_ERR_CMD = '2>/dev/null >&2'
136
137# Constants for environment.
138LUNCH_TARGET = 'lunch target'
139
140# Constants for the languages aidegen supports.
141JAVA = 'Java'
142C_CPP = 'C/C++'
143UNDEFINED = 'undefined'
144LANGUAGE_NAME_DICT = {
145    'u': UNDEFINED,
146    'j': JAVA,
147    'c': C_CPP
148}
149
150# Constants for error message.
151INVALID_XML = 'The content of {XML_FILE} is not valid.'
152
153# Constants for default modules.
154FRAMEWORK_ALL = 'framework-all'
155CORE_ALL = 'core-all'
156FRAMEWORK_SRCJARS = 'framework_srcjars'
157
158# Constants for module's path.
159FRAMEWORK_PATH = 'frameworks/base'
160LIBCORE_PATH = 'libcore'
161
162# Constants for regular expression
163RE_INSIDE_PATH_CHECK = r'^{}($|/.+)'
164
165# Constants for Git
166GIT_FOLDER_NAME = '.git'
167
168# Constants for Idea
169IDEA_FOLDER = '.idea'
170