blob: 7bd04639fc07159cfbc5bdb2d4154cc5f109c2b7 [file] [log] [blame]
Andres Moralesda8706f2015-04-29 12:46:49 -07001package main
2
3import bpparser "github.com/google/blueprint/parser"
4
5var standardProperties = map[string]struct {
6 string
7 bpparser.ValueType
8}{
9 // ==== STRING PROPERTIES ====
10 "name": {"LOCAL_MODULE", bpparser.String},
11 "stem": {"LOCAL_MODULE_STEM", bpparser.String},
12 "class": {"LOCAL_MODULE_CLASS", bpparser.String},
13 "stl": {"LOCAL_CXX_STL", bpparser.String},
14 "strip": {"LOCAL_STRIP_MODULE", bpparser.String},
15 "compile_multilib": {"LOCAL_MULTILIB", bpparser.String},
16 "instruction_set": {"LOCAL_ARM_MODE_HACK", bpparser.String},
17 "sdk_version": {"LOCAL_SDK_VERSION", bpparser.String},
18 //"stl": "LOCAL_NDK_STL_VARIANT", TODO
19 "manifest": {"LOCAL_JAR_MANIFEST", bpparser.String},
20 "jarjar_rules": {"LOCAL_JARJAR_RULES", bpparser.String},
21 "certificate": {"LOCAL_CERTIFICATE", bpparser.String},
22 //"name": "LOCAL_PACKAGE_NAME", TODO
23
24 // ==== LIST PROPERTIES ====
Dan Willemsen57ad08c2015-06-10 16:20:14 -070025 "srcs": {"LOCAL_SRC_FILES", bpparser.List},
Dan Willemsen2ef08f42015-06-30 18:15:24 -070026 "exclude_srcs": {"LOCAL_SRC_FILES_EXCLUDE", bpparser.List},
Dan Willemsen57ad08c2015-06-10 16:20:14 -070027 "shared_libs": {"LOCAL_SHARED_LIBRARIES", bpparser.List},
28 "static_libs": {"LOCAL_STATIC_LIBRARIES", bpparser.List},
29 "whole_static_libs": {"LOCAL_WHOLE_STATIC_LIBRARIES", bpparser.List},
30 "system_shared_libs": {"LOCAL_SYSTEM_SHARED_LIBRARIES", bpparser.List},
Dan Willemsen57ad08c2015-06-10 16:20:14 -070031 "asflags": {"LOCAL_ASFLAGS", bpparser.List},
32 "clang_asflags": {"LOCAL_CLANG_ASFLAGS", bpparser.List},
33 "cflags": {"LOCAL_CFLAGS", bpparser.List},
34 "conlyflags": {"LOCAL_CONLYFLAGS", bpparser.List},
35 "cppflags": {"LOCAL_CPPFLAGS", bpparser.List},
36 "ldflags": {"LOCAL_LDFLAGS", bpparser.List},
37 "required": {"LOCAL_REQUIRED_MODULES", bpparser.List},
38 "tags": {"LOCAL_MODULE_TAGS", bpparser.List},
39 "host_ldlibs": {"LOCAL_LDLIBS", bpparser.List},
40 "clang_cflags": {"LOCAL_CLANG_CFLAGS", bpparser.List},
41 "yaccflags": {"LOCAL_YACCFLAGS", bpparser.List},
42 "java_resource_dirs": {"LOCAL_JAVA_RESOURCE_DIRS", bpparser.List},
43 "javacflags": {"LOCAL_JAVACFLAGS", bpparser.List},
44 "dxflags": {"LOCAL_DX_FLAGS", bpparser.List},
45 "java_libs": {"LOCAL_JAVA_LIBRARIES", bpparser.List},
46 "java_static_libs": {"LOCAL_STATIC_JAVA_LIBRARIES", bpparser.List},
47 "aidl_includes": {"LOCAL_AIDL_INCLUDES", bpparser.List},
48 "aaptflags": {"LOCAL_AAPT_FLAGS", bpparser.List},
49 "package_splits": {"LOCAL_PACKAGE_SPLITS", bpparser.List},
Andres Moralesda8706f2015-04-29 12:46:49 -070050
51 // ==== BOOL PROPERTIES ====
52 "host": {"LOCAL_IS_HOST_MODULE", bpparser.Bool},
53 "clang": {"LOCAL_CLANG", bpparser.Bool},
Colin Crosseb050832015-06-22 17:26:12 -070054 "static_executable": {"LOCAL_FORCE_STATIC_EXECUTABLE", bpparser.Bool},
Andres Moralesda8706f2015-04-29 12:46:49 -070055 "asan": {"LOCAL_ADDRESS_SANITIZER", bpparser.Bool},
56 "native_coverage": {"LOCAL_NATIVE_COVERAGE", bpparser.Bool},
57 "nocrt": {"LOCAL_NO_CRT", bpparser.Bool},
58 "allow_undefined_symbols": {"LOCAL_ALLOW_UNDEFINED_SYMBOLS", bpparser.Bool},
Colin Crosseb050832015-06-22 17:26:12 -070059 "rtti": {"LOCAL_RTTI_FLAG", bpparser.Bool},
60 "no_standard_libraries": {"LOCAL_NO_STANDARD_LIBRARIES", bpparser.Bool},
61 "export_package_resources": {"LOCAL_EXPORT_PACKAGE_RESOURCES", bpparser.Bool},
62 "no_default_compiler_flags": {"LOCAL_NO_DEFAULT_COMPILER_FLAGS", bpparser.Bool},
Andres Moralesda8706f2015-04-29 12:46:49 -070063}
64
Dan Willemsen57ad08c2015-06-10 16:20:14 -070065var rewriteProperties = map[string]struct {
66 string
Colin Cross3cc00f12015-07-07 12:22:51 -070067 f func(name string, prop *bpparser.Property, val string) (propAssignment, error)
Dan Willemsen57ad08c2015-06-10 16:20:14 -070068}{
Colin Crossc41f6302015-06-30 12:19:47 -070069 "include_dirs": {"LOCAL_C_INCLUDES", appendAssign},
Dan Willemsen57ad08c2015-06-10 16:20:14 -070070 "local_include_dirs": {"LOCAL_C_INCLUDES", prependLocalPath},
71 "export_include_dirs": {"LOCAL_EXPORT_C_INCLUDE_DIRS", prependLocalPath},
Dan Willemsen1d9f2792015-06-22 15:40:14 -070072 "suffix": {"LOCAL_MODULE_STEM", prependLocalModule},
Colin Crossaee540a2015-07-06 17:48:31 -070073 "version_script": {"LOCAL_LDFLAGS", versionScript},
Dan Willemsen57ad08c2015-06-10 16:20:14 -070074}
75
Dan Willemsen0a544692015-06-24 15:50:07 -070076var ignoredProperties = map[string]bool{
77 "host_supported": true,
78}
79
Andres Moralesaf11df12015-04-30 12:14:34 -070080var moduleTypeToRule = map[string]string{
Andres Moralesda8706f2015-04-29 12:46:49 -070081 "cc_library_shared": "BUILD_SHARED_LIBRARY",
82 "cc_library_static": "BUILD_STATIC_LIBRARY",
83 "cc_library_host_shared": "BUILD_HOST_SHARED_LIBRARY",
84 "cc_library_host_static": "BUILD_HOST_STATIC_LIBRARY",
85 "cc_binary": "BUILD_EXECUTABLE",
86 "cc_binary_host": "BUILD_HOST_EXECUTABLE",
87 "cc_test": "BUILD_NATIVE_TEST",
88 "cc_test_host": "BUILD_HOST_NATIVE_TEST",
Colin Cross2ba19d92015-05-07 15:44:20 -070089 "cc_benchmark": "BUILD_NATIVE_BENCHMARK",
90 "cc_benchmark_host": "BUILD_HOST_NATIVE_BENCHMARK",
Andres Moralesda8706f2015-04-29 12:46:49 -070091 "java_library": "BUILD_JAVA_LIBRARY",
92 "java_library_static": "BUILD_STATIC_JAVA_LIBRARY",
93 "java_library_host": "BUILD_HOST_JAVA_LIBRARY",
94 "java_library_host_dalvik": "BUILD_HOST_DALVIK_JAVA_LIBRARY",
95 "android_app": "BUILD_PACKAGE",
96 "prebuilt": "BUILD_PREBUILT",
97}
Andres Moralesaf11df12015-04-30 12:14:34 -070098
Colin Cross70a5f072015-06-29 17:44:56 -070099var ignoredModuleType = map[string]bool{
100 "bootstrap_go_binary": true,
101 "bootstrap_go_package": true,
102 "toolchain_library": true,
103}
104
Andres Moralesaf11df12015-04-30 12:14:34 -0700105var suffixProperties = map[string]map[string]string{
106 "multilib": {"lib32": "32", "lib64": "64"},
107 "arch": {"arm": "arm", "arm64": "arm64", "mips": "mips", "mips64": "mips64",
108 "x86": "x86", "x86_64": "x86_64"},
109}
110
Colin Crossec193632015-07-06 17:49:43 -0700111var cpuVariantConditionals = map[string]struct {
112 conditional string
113 suffix string
114 secondArch bool
115}{
116 "armv5te": {"ifeq ($(TARGET_ARCH_VARIANT),armv5te)", "$(TARGET_ARCH)", true},
117 "armv7_a": {"ifeq ($(TARGET_ARCH_VARIANT),armv7-a)", "$(TARGET_ARCH)", true},
118 "armv7_a_neon": {"ifeq ($(TARGET_ARCH_VARIANT),armv7-a-neon)", "$(TARGET_ARCH)", true},
119 "cortex_a7": {"ifeq ($(TARGET_CPU_VARIANT),cortex-a7)", "$(TARGET_ARCH)", true},
120 "cortex_a8": {"ifeq ($(TARGET_CPU_VARIANT),cortex-a8)", "$(TARGET_ARCH)", true},
121 "cortex_a9": {"ifeq ($(TARGET_CPU_VARIANT),cortex-a9)", "$(TARGET_ARCH)", true},
122 "cortex_a15": {"ifeq ($(TARGET_CPU_VARIANT),cortex-a15)", "$(TARGET_ARCH)", true},
123 "krait": {"ifeq ($(TARGET_CPU_VARIANT),krait)", "$(TARGET_ARCH)", true},
124 "denver": {"ifeq ($(TARGET_CPU_VARIANT),denver)", "$(TARGET_ARCH)", true},
125 "denver64": {"ifeq ($(TARGET_CPU_VARIANT),denver64)", "$(TARGET_ARCH)", true},
126 "mips_rev6": {"ifdef ARCH_MIPS_REV6", "mips", false},
127 "atom": {"ifeq ($(TARGET_ARCH_VARIANT),atom)", "$(TARGET_ARCH)", true},
128 "silvermont": {"ifeq ($(TARGET_ARCH_VARIANT),silvermont)", "$(TARGET_ARCH)", true},
Colin Cross01432f62015-07-09 17:56:26 -0700129 "x86_sse3": {"ifeq ($(ARCH_X86_HAVE_SSE3),true)", "x86", true},
130 "x86_sse4": {"ifeq ($(ARCH_X86_HAVE_SSE4),true)", "x86", true},
Colin Crossec193632015-07-06 17:49:43 -0700131}
132
Andres Moralesaf11df12015-04-30 12:14:34 -0700133var hostScopedPropertyConditionals = map[string]string{
Dan Willemsen0a544692015-06-24 15:50:07 -0700134 "host": "",
Andres Moralesaf11df12015-04-30 12:14:34 -0700135 "darwin": "ifeq ($(HOST_OS), darwin)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700136 "not_darwin": "ifneq ($(HOST_OS), darwin)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700137 "windows": "ifeq ($(HOST_OS), windows)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700138 "not_windows": "ifneq ($(HOST_OS), windows)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700139 "linux": "ifeq ($(HOST_OS), linux)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700140 "not_linux": "ifneq ($(HOST_OS), linux)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700141}
142
143// TODO: host target?
144var targetScopedPropertyConditionals = map[string]string{
Dan Willemsen68fdfcc2015-06-11 14:05:01 -0700145 "android": "",
Dan Willemsen499c0942015-06-22 16:26:36 -0700146 "android32": "ifneq ($(TARGET_IS_64_BIT), true)",
147 "not_android32": "ifeq ($(TARGET_IS_64_BIT), true)",
148 "android64": "ifeq ($(TARGET_IS_64_BIT), true)",
149 "not_android64": "ifneq ($(TARGET_IS_64_BIT), true)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700150}
151
152var disabledHostConditionals = map[string]string{
153 "darwin": "ifneq ($(HOST_OS), darwin)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700154 "not_darwin": "ifeq ($(HOST_OS), darwin)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700155 "windows": "ifneq ($(HOST_OS), windows)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700156 "not_windows": "ifeq ($(HOST_OS), windows)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700157 "linux": "ifneq ($(HOST_OS), linux)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700158 "not_linux": "ifeq ($(HOST_OS), linux)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700159}
160
161var disabledTargetConditionals = map[string]string{
Dan Willemsen499c0942015-06-22 16:26:36 -0700162 "android32": "ifeq ($(TARGET_IS_64_BIT), true)",
163 "not_android32": "ifeq ($(TARGET_IS_64_BIT), false)",
164 "android64": "ifeq ($(TARGET_IS_64_BIT), false)",
165 "not_android64": "ifeq ($(TARGET_IS_64_BIT), true)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700166}
167
168var targetToHostModuleRule = map[string]string{
169 "BUILD_SHARED_LIBRARY": "BUILD_HOST_SHARED_LIBRARY",
170 "BUILD_STATIC_LIBRARY": "BUILD_HOST_STATIC_LIBRARY",
171 "BUILD_EXECUTABLE": "BUILD_HOST_EXECUTABLE",
172 "BUILD_NATIVE_TEST": "BUILD_HOST_NATIVE_TEST",
173 "BUILD_JAVA_LIBRARY": "BUILD_HOST_JAVA_LIBRARY",
174}