Andres Morales | da8706f | 2015-04-29 12:46:49 -0700 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import bpparser "github.com/google/blueprint/parser" |
| 4 | |
| 5 | var 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 Willemsen | 57ad08c | 2015-06-10 16:20:14 -0700 | [diff] [blame] | 25 | "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 Willemsen | 57ad08c | 2015-06-10 16:20:14 -0700 | [diff] [blame] | 30 | "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 Morales | da8706f | 2015-04-29 12:46:49 -0700 | [diff] [blame] | 49 | |
| 50 | // ==== BOOL PROPERTIES ==== |
| 51 | "host": {"LOCAL_IS_HOST_MODULE", bpparser.Bool}, |
| 52 | "clang": {"LOCAL_CLANG", bpparser.Bool}, |
Colin Cross | eb05083 | 2015-06-22 17:26:12 -0700 | [diff] [blame] | 53 | "static_executable": {"LOCAL_FORCE_STATIC_EXECUTABLE", bpparser.Bool}, |
Andres Morales | da8706f | 2015-04-29 12:46:49 -0700 | [diff] [blame] | 54 | "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 Cross | eb05083 | 2015-06-22 17:26:12 -0700 | [diff] [blame] | 58 | "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 Morales | da8706f | 2015-04-29 12:46:49 -0700 | [diff] [blame] | 62 | } |
| 63 | |
Dan Willemsen | 57ad08c | 2015-06-10 16:20:14 -0700 | [diff] [blame] | 64 | var rewriteProperties = map[string]struct { |
| 65 | string |
Colin Cross | b093124 | 2015-06-29 14:18:27 -0700 | [diff] [blame] | 66 | f func(name string, prop *bpparser.Property, suffix *string) ([]string, error) |
Dan Willemsen | 57ad08c | 2015-06-10 16:20:14 -0700 | [diff] [blame] | 67 | }{ |
Colin Cross | c41f630 | 2015-06-30 12:19:47 -0700 | [diff] [blame^] | 68 | "include_dirs": {"LOCAL_C_INCLUDES", appendAssign}, |
Dan Willemsen | 57ad08c | 2015-06-10 16:20:14 -0700 | [diff] [blame] | 69 | "local_include_dirs": {"LOCAL_C_INCLUDES", prependLocalPath}, |
| 70 | "export_include_dirs": {"LOCAL_EXPORT_C_INCLUDE_DIRS", prependLocalPath}, |
Dan Willemsen | 1d9f279 | 2015-06-22 15:40:14 -0700 | [diff] [blame] | 71 | "suffix": {"LOCAL_MODULE_STEM", prependLocalModule}, |
Dan Willemsen | 57ad08c | 2015-06-10 16:20:14 -0700 | [diff] [blame] | 72 | } |
| 73 | |
Dan Willemsen | 0a54469 | 2015-06-24 15:50:07 -0700 | [diff] [blame] | 74 | var ignoredProperties = map[string]bool{ |
| 75 | "host_supported": true, |
| 76 | } |
| 77 | |
Andres Morales | af11df1 | 2015-04-30 12:14:34 -0700 | [diff] [blame] | 78 | var moduleTypeToRule = map[string]string{ |
Andres Morales | da8706f | 2015-04-29 12:46:49 -0700 | [diff] [blame] | 79 | "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 Cross | 2ba19d9 | 2015-05-07 15:44:20 -0700 | [diff] [blame] | 87 | "cc_benchmark": "BUILD_NATIVE_BENCHMARK", |
| 88 | "cc_benchmark_host": "BUILD_HOST_NATIVE_BENCHMARK", |
Andres Morales | da8706f | 2015-04-29 12:46:49 -0700 | [diff] [blame] | 89 | "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 Morales | af11df1 | 2015-04-30 12:14:34 -0700 | [diff] [blame] | 96 | |
Colin Cross | 70a5f07 | 2015-06-29 17:44:56 -0700 | [diff] [blame] | 97 | var ignoredModuleType = map[string]bool{ |
| 98 | "bootstrap_go_binary": true, |
| 99 | "bootstrap_go_package": true, |
| 100 | "toolchain_library": true, |
| 101 | } |
| 102 | |
Andres Morales | af11df1 | 2015-04-30 12:14:34 -0700 | [diff] [blame] | 103 | var 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 | |
| 109 | var hostScopedPropertyConditionals = map[string]string{ |
Dan Willemsen | 0a54469 | 2015-06-24 15:50:07 -0700 | [diff] [blame] | 110 | "host": "", |
Andres Morales | af11df1 | 2015-04-30 12:14:34 -0700 | [diff] [blame] | 111 | "darwin": "ifeq ($(HOST_OS), darwin)", |
Dan Willemsen | 499c094 | 2015-06-22 16:26:36 -0700 | [diff] [blame] | 112 | "not_darwin": "ifneq ($(HOST_OS), darwin)", |
Andres Morales | af11df1 | 2015-04-30 12:14:34 -0700 | [diff] [blame] | 113 | "windows": "ifeq ($(HOST_OS), windows)", |
Dan Willemsen | 499c094 | 2015-06-22 16:26:36 -0700 | [diff] [blame] | 114 | "not_windows": "ifneq ($(HOST_OS), windows)", |
Andres Morales | af11df1 | 2015-04-30 12:14:34 -0700 | [diff] [blame] | 115 | "linux": "ifeq ($(HOST_OS), linux)", |
Dan Willemsen | 499c094 | 2015-06-22 16:26:36 -0700 | [diff] [blame] | 116 | "not_linux": "ifneq ($(HOST_OS), linux)", |
Andres Morales | af11df1 | 2015-04-30 12:14:34 -0700 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | // TODO: host target? |
| 120 | var targetScopedPropertyConditionals = map[string]string{ |
Dan Willemsen | 68fdfcc | 2015-06-11 14:05:01 -0700 | [diff] [blame] | 121 | "android": "", |
Dan Willemsen | 499c094 | 2015-06-22 16:26:36 -0700 | [diff] [blame] | 122 | "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 Morales | af11df1 | 2015-04-30 12:14:34 -0700 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | var disabledHostConditionals = map[string]string{ |
| 129 | "darwin": "ifneq ($(HOST_OS), darwin)", |
Dan Willemsen | 499c094 | 2015-06-22 16:26:36 -0700 | [diff] [blame] | 130 | "not_darwin": "ifeq ($(HOST_OS), darwin)", |
Andres Morales | af11df1 | 2015-04-30 12:14:34 -0700 | [diff] [blame] | 131 | "windows": "ifneq ($(HOST_OS), windows)", |
Dan Willemsen | 499c094 | 2015-06-22 16:26:36 -0700 | [diff] [blame] | 132 | "not_windows": "ifeq ($(HOST_OS), windows)", |
Andres Morales | af11df1 | 2015-04-30 12:14:34 -0700 | [diff] [blame] | 133 | "linux": "ifneq ($(HOST_OS), linux)", |
Dan Willemsen | 499c094 | 2015-06-22 16:26:36 -0700 | [diff] [blame] | 134 | "not_linux": "ifeq ($(HOST_OS), linux)", |
Andres Morales | af11df1 | 2015-04-30 12:14:34 -0700 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | var disabledTargetConditionals = map[string]string{ |
Dan Willemsen | 499c094 | 2015-06-22 16:26:36 -0700 | [diff] [blame] | 138 | "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 Morales | af11df1 | 2015-04-30 12:14:34 -0700 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | var 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 | } |