blob: 8afda77697eee93b1df3a98f833c496659622bdd [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},
30 "include_dirs": {"LOCAL_C_INCLUDES", bpparser.List},
31 "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
67 f func(name string, prop *bpparser.Property, suffix *string) (computedProps []string)
68}{
69 "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
97var suffixProperties = map[string]map[string]string{
98 "multilib": {"lib32": "32", "lib64": "64"},
99 "arch": {"arm": "arm", "arm64": "arm64", "mips": "mips", "mips64": "mips64",
100 "x86": "x86", "x86_64": "x86_64"},
101}
102
103var hostScopedPropertyConditionals = map[string]string{
Dan Willemsen0a544692015-06-24 15:50:07 -0700104 "host": "",
Andres Moralesaf11df12015-04-30 12:14:34 -0700105 "darwin": "ifeq ($(HOST_OS), darwin)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700106 "not_darwin": "ifneq ($(HOST_OS), darwin)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700107 "windows": "ifeq ($(HOST_OS), windows)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700108 "not_windows": "ifneq ($(HOST_OS), windows)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700109 "linux": "ifeq ($(HOST_OS), linux)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700110 "not_linux": "ifneq ($(HOST_OS), linux)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700111}
112
113// TODO: host target?
114var targetScopedPropertyConditionals = map[string]string{
Dan Willemsen68fdfcc2015-06-11 14:05:01 -0700115 "android": "",
Dan Willemsen499c0942015-06-22 16:26:36 -0700116 "android32": "ifneq ($(TARGET_IS_64_BIT), true)",
117 "not_android32": "ifeq ($(TARGET_IS_64_BIT), true)",
118 "android64": "ifeq ($(TARGET_IS_64_BIT), true)",
119 "not_android64": "ifneq ($(TARGET_IS_64_BIT), true)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700120}
121
122var disabledHostConditionals = map[string]string{
123 "darwin": "ifneq ($(HOST_OS), darwin)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700124 "not_darwin": "ifeq ($(HOST_OS), darwin)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700125 "windows": "ifneq ($(HOST_OS), windows)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700126 "not_windows": "ifeq ($(HOST_OS), windows)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700127 "linux": "ifneq ($(HOST_OS), linux)",
Dan Willemsen499c0942015-06-22 16:26:36 -0700128 "not_linux": "ifeq ($(HOST_OS), linux)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700129}
130
131var disabledTargetConditionals = map[string]string{
Dan Willemsen499c0942015-06-22 16:26:36 -0700132 "android32": "ifeq ($(TARGET_IS_64_BIT), true)",
133 "not_android32": "ifeq ($(TARGET_IS_64_BIT), false)",
134 "android64": "ifeq ($(TARGET_IS_64_BIT), false)",
135 "not_android64": "ifeq ($(TARGET_IS_64_BIT), true)",
Andres Moralesaf11df12015-04-30 12:14:34 -0700136}
137
138var targetToHostModuleRule = map[string]string{
139 "BUILD_SHARED_LIBRARY": "BUILD_HOST_SHARED_LIBRARY",
140 "BUILD_STATIC_LIBRARY": "BUILD_HOST_STATIC_LIBRARY",
141 "BUILD_EXECUTABLE": "BUILD_HOST_EXECUTABLE",
142 "BUILD_NATIVE_TEST": "BUILD_HOST_NATIVE_TEST",
143 "BUILD_JAVA_LIBRARY": "BUILD_HOST_JAVA_LIBRARY",
144}