blob: ecae5b0e998d13260609f235451f5c457e8597bd [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},
26 "shared_libs": {"LOCAL_SHARED_LIBRARIES", bpparser.List},
27 "static_libs": {"LOCAL_STATIC_LIBRARIES", bpparser.List},
28 "whole_static_libs": {"LOCAL_WHOLE_STATIC_LIBRARIES", bpparser.List},
29 "system_shared_libs": {"LOCAL_SYSTEM_SHARED_LIBRARIES", bpparser.List},
Dan Willemsen57ad08c2015-06-10 16:20:14 -070030 "asflags": {"LOCAL_ASFLAGS", bpparser.List},
31 "clang_asflags": {"LOCAL_CLANG_ASFLAGS", bpparser.List},
32 "cflags": {"LOCAL_CFLAGS", bpparser.List},
33 "conlyflags": {"LOCAL_CONLYFLAGS", bpparser.List},
34 "cppflags": {"LOCAL_CPPFLAGS", bpparser.List},
35 "ldflags": {"LOCAL_LDFLAGS", bpparser.List},
36 "required": {"LOCAL_REQUIRED_MODULES", bpparser.List},
37 "tags": {"LOCAL_MODULE_TAGS", bpparser.List},
38 "host_ldlibs": {"LOCAL_LDLIBS", bpparser.List},
39 "clang_cflags": {"LOCAL_CLANG_CFLAGS", bpparser.List},
40 "yaccflags": {"LOCAL_YACCFLAGS", bpparser.List},
41 "java_resource_dirs": {"LOCAL_JAVA_RESOURCE_DIRS", bpparser.List},
42 "javacflags": {"LOCAL_JAVACFLAGS", bpparser.List},
43 "dxflags": {"LOCAL_DX_FLAGS", bpparser.List},
44 "java_libs": {"LOCAL_JAVA_LIBRARIES", bpparser.List},
45 "java_static_libs": {"LOCAL_STATIC_JAVA_LIBRARIES", bpparser.List},
46 "aidl_includes": {"LOCAL_AIDL_INCLUDES", bpparser.List},
47 "aaptflags": {"LOCAL_AAPT_FLAGS", bpparser.List},
48 "package_splits": {"LOCAL_PACKAGE_SPLITS", bpparser.List},
Andres Moralesda8706f2015-04-29 12:46:49 -070049
50 // ==== BOOL PROPERTIES ====
51 "host": {"LOCAL_IS_HOST_MODULE", bpparser.Bool},
52 "clang": {"LOCAL_CLANG", bpparser.Bool},
Colin Crosseb050832015-06-22 17:26:12 -070053 "static_executable": {"LOCAL_FORCE_STATIC_EXECUTABLE", bpparser.Bool},
Andres Moralesda8706f2015-04-29 12:46:49 -070054 "asan": {"LOCAL_ADDRESS_SANITIZER", bpparser.Bool},
55 "native_coverage": {"LOCAL_NATIVE_COVERAGE", bpparser.Bool},
56 "nocrt": {"LOCAL_NO_CRT", bpparser.Bool},
57 "allow_undefined_symbols": {"LOCAL_ALLOW_UNDEFINED_SYMBOLS", bpparser.Bool},
Colin Crosseb050832015-06-22 17:26:12 -070058 "rtti": {"LOCAL_RTTI_FLAG", bpparser.Bool},
59 "no_standard_libraries": {"LOCAL_NO_STANDARD_LIBRARIES", bpparser.Bool},
60 "export_package_resources": {"LOCAL_EXPORT_PACKAGE_RESOURCES", bpparser.Bool},
61 "no_default_compiler_flags": {"LOCAL_NO_DEFAULT_COMPILER_FLAGS", bpparser.Bool},
Andres Moralesda8706f2015-04-29 12:46:49 -070062}
63
Dan Willemsen57ad08c2015-06-10 16:20:14 -070064var rewriteProperties = map[string]struct {
65 string
Colin Crossb0931242015-06-29 14:18:27 -070066 f func(name string, prop *bpparser.Property, suffix *string) ([]string, error)
Dan Willemsen57ad08c2015-06-10 16:20:14 -070067}{
Colin Crossc41f6302015-06-30 12:19:47 -070068 "include_dirs": {"LOCAL_C_INCLUDES", appendAssign},
Dan Willemsen57ad08c2015-06-10 16:20:14 -070069 "local_include_dirs": {"LOCAL_C_INCLUDES", prependLocalPath},
70 "export_include_dirs": {"LOCAL_EXPORT_C_INCLUDE_DIRS", prependLocalPath},
Dan Willemsen1d9f2792015-06-22 15:40:14 -070071 "suffix": {"LOCAL_MODULE_STEM", prependLocalModule},
Dan Willemsen57ad08c2015-06-10 16:20:14 -070072}
73
Dan Willemsen0a544692015-06-24 15:50:07 -070074var ignoredProperties = map[string]bool{
75 "host_supported": true,
76}
77
Andres Moralesaf11df12015-04-30 12:14:34 -070078var moduleTypeToRule = map[string]string{
Andres Moralesda8706f2015-04-29 12:46:49 -070079 "cc_library_shared": "BUILD_SHARED_LIBRARY",
80 "cc_library_static": "BUILD_STATIC_LIBRARY",
81 "cc_library_host_shared": "BUILD_HOST_SHARED_LIBRARY",
82 "cc_library_host_static": "BUILD_HOST_STATIC_LIBRARY",
83 "cc_binary": "BUILD_EXECUTABLE",
84 "cc_binary_host": "BUILD_HOST_EXECUTABLE",
85 "cc_test": "BUILD_NATIVE_TEST",
86 "cc_test_host": "BUILD_HOST_NATIVE_TEST",
Colin Cross2ba19d92015-05-07 15:44:20 -070087 "cc_benchmark": "BUILD_NATIVE_BENCHMARK",
88 "cc_benchmark_host": "BUILD_HOST_NATIVE_BENCHMARK",
Andres Moralesda8706f2015-04-29 12:46:49 -070089 "java_library": "BUILD_JAVA_LIBRARY",
90 "java_library_static": "BUILD_STATIC_JAVA_LIBRARY",
91 "java_library_host": "BUILD_HOST_JAVA_LIBRARY",
92 "java_library_host_dalvik": "BUILD_HOST_DALVIK_JAVA_LIBRARY",
93 "android_app": "BUILD_PACKAGE",
94 "prebuilt": "BUILD_PREBUILT",
95}
Andres Moralesaf11df12015-04-30 12:14:34 -070096
Colin Cross70a5f072015-06-29 17:44:56 -070097var ignoredModuleType = map[string]bool{
98 "bootstrap_go_binary": true,
99 "bootstrap_go_package": true,
100 "toolchain_library": true,
101}
102
Andres Moralesaf11df12015-04-30 12:14:34 -0700103var suffixProperties = map[string]map[string]string{
104 "multilib": {"lib32": "32", "lib64": "64"},
105 "arch": {"arm": "arm", "arm64": "arm64", "mips": "mips", "mips64": "mips64",
106 "x86": "x86", "x86_64": "x86_64"},
107}
108
109var hostScopedPropertyConditionals = map[string]string{
Dan Willemsen0a544692015-06-24 15:50:07 -0700110 "host": "",
Andres Moralesaf11df12015-04-30 12:14:34 -0700111 "darwin": "ifeq ($(HOST_OS), darwin)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700112 "not_darwin": "ifneq ($(HOST_OS), darwin)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700113 "windows": "ifeq ($(HOST_OS), windows)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700114 "not_windows": "ifneq ($(HOST_OS), windows)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700115 "linux": "ifeq ($(HOST_OS), linux)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700116 "not_linux": "ifneq ($(HOST_OS), linux)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700117}
118
119// TODO: host target?
120var targetScopedPropertyConditionals = map[string]string{
Dan Willemsen68fdfcc2015-06-11 14:05:01 -0700121 "android": "",
Dan Willemsen499c0942015-06-22 16:26:36 -0700122 "android32": "ifneq ($(TARGET_IS_64_BIT), true)",
123 "not_android32": "ifeq ($(TARGET_IS_64_BIT), true)",
124 "android64": "ifeq ($(TARGET_IS_64_BIT), true)",
125 "not_android64": "ifneq ($(TARGET_IS_64_BIT), true)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700126}
127
128var disabledHostConditionals = map[string]string{
129 "darwin": "ifneq ($(HOST_OS), darwin)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700130 "not_darwin": "ifeq ($(HOST_OS), darwin)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700131 "windows": "ifneq ($(HOST_OS), windows)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700132 "not_windows": "ifeq ($(HOST_OS), windows)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700133 "linux": "ifneq ($(HOST_OS), linux)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700134 "not_linux": "ifeq ($(HOST_OS), linux)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700135}
136
137var disabledTargetConditionals = map[string]string{
Dan Willemsen499c0942015-06-22 16:26:36 -0700138 "android32": "ifeq ($(TARGET_IS_64_BIT), true)",
139 "not_android32": "ifeq ($(TARGET_IS_64_BIT), false)",
140 "android64": "ifeq ($(TARGET_IS_64_BIT), false)",
141 "not_android64": "ifeq ($(TARGET_IS_64_BIT), true)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700142}
143
144var targetToHostModuleRule = map[string]string{
145 "BUILD_SHARED_LIBRARY": "BUILD_HOST_SHARED_LIBRARY",
146 "BUILD_STATIC_LIBRARY": "BUILD_HOST_STATIC_LIBRARY",
147 "BUILD_EXECUTABLE": "BUILD_HOST_EXECUTABLE",
148 "BUILD_NATIVE_TEST": "BUILD_HOST_NATIVE_TEST",
149 "BUILD_JAVA_LIBRARY": "BUILD_HOST_JAVA_LIBRARY",
150}