| // | |
| // Copyright (C) 2017 The Android Open Source Project | |
| // | |
| // Licensed under the Apache License, Version 2.0 (the "License"); | |
| // you may not use this file except in compliance with the License. | |
| // You may obtain a copy of the License at | |
| // | |
| // http://www.apache.org/licenses/LICENSE-2.0 | |
| // | |
| // Unless required by applicable law or agreed to in writing, software | |
| // distributed under the License is distributed on an "AS IS" BASIS, | |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| // See the License for the specific language governing permissions and | |
| // limitations under the License. | |
| // | |
| package { | |
| default_applicable_licenses: ["Android-Apache-2.0"], | |
| } | |
| toolSources = [ | |
| "cmd/ApkInfo.cpp", | |
| "cmd/Command.cpp", | |
| "cmd/Compile.cpp", | |
| "cmd/Convert.cpp", | |
| "cmd/Diff.cpp", | |
| "cmd/Dump.cpp", | |
| "cmd/Link.cpp", | |
| "cmd/Optimize.cpp", | |
| "cmd/Util.cpp", | |
| ] | |
| cc_defaults { | |
| name: "aapt2_defaults", | |
| host_supported: true, | |
| cpp_std: "gnu++2b", | |
| cflags: [ | |
| "-Wall", | |
| "-Werror", | |
| "-Wno-unused-parameter", | |
| ], | |
| cppflags: [ | |
| "-Wno-missing-field-initializers", | |
| "-fno-exceptions", | |
| "-fno-rtti", | |
| "-Wno-deprecated-declarations", | |
| ], | |
| proto: { | |
| type: "lite", | |
| }, | |
| target: { | |
| host: { | |
| static_libs: [ | |
| "liblog", | |
| "libz", | |
| "libziparchive", | |
| ], | |
| }, | |
| windows: { | |
| compile_multilib: "64", | |
| enabled: true, | |
| cflags: ["-Wno-maybe-uninitialized"], | |
| ldflags: ["-static"], | |
| host_ldlibs: [ | |
| // Required by stack tracing code bundled with protobuf | |
| "-ldbghelp", | |
| ], | |
| }, | |
| darwin: { | |
| cflags: ["-D_DARWIN_UNLIMITED_STREAMS"], | |
| host_ldlibs: [ | |
| // Required by protobuf | |
| "-framework CoreFoundation", | |
| ], | |
| }, | |
| android: { | |
| proto: { | |
| static: true, | |
| }, | |
| static_libs: [ | |
| "libcom.android.sysprop.incremental", | |
| "libincfs", | |
| "libziparchive_for_incfs", | |
| ], | |
| // Libraries with stable ABIs are forbidden from being statically linked | |
| // into Android device executables (b/151051671). Therefore Android target | |
| // executable has to be dynamically linked. Do not add more shared libs | |
| // unless they cannot be statically linked due to stable ABIs. | |
| shared_libs: [ | |
| "liblog", | |
| "libz", | |
| ], | |
| }, | |
| }, | |
| header_libs: [ | |
| "jni_headers", | |
| ], | |
| static_libs: [ | |
| "android.content.res.flags-aconfig-cc-host-ro", | |
| "libandroidfw", | |
| "libutils", | |
| "libcutils", | |
| "libexpat", | |
| "libpng", | |
| "libbase", | |
| "libprotobuf-cpp-lite", | |
| "libbuildversion", | |
| "libidmap2_policies", | |
| ], | |
| stl: "libc++_static", | |
| } | |
| // ========================================================== | |
| // NOTE: Do not add any shared libraries for host targets. | |
| // AAPT2 is built to run on many environments | |
| // that may not have the required dependencies. | |
| // ========================================================== | |
| // ========================================================== | |
| // Build the static library: aapt2 | |
| // ========================================================== | |
| cc_library_static { | |
| name: "libaapt2", | |
| srcs: [ | |
| "compile/IdAssigner.cpp", | |
| "compile/InlineXmlFormatParser.cpp", | |
| "compile/PseudolocaleGenerator.cpp", | |
| "compile/Pseudolocalizer.cpp", | |
| "compile/XmlIdCollector.cpp", | |
| "configuration/ConfigurationParser.cpp", | |
| "dump/DumpManifest.cpp", | |
| "filter/AbiFilter.cpp", | |
| "filter/ConfigFilter.cpp", | |
| "format/Archive.cpp", | |
| "format/Container.cpp", | |
| "format/binary/BinaryResourceParser.cpp", | |
| "format/binary/ResChunkPullParser.cpp", | |
| "format/binary/ResEntryWriter.cpp", | |
| "format/binary/TableFlattener.cpp", | |
| "format/binary/XmlFlattener.cpp", | |
| "format/proto/ProtoDeserialize.cpp", | |
| "format/proto/ProtoSerialize.cpp", | |
| "io/File.cpp", | |
| "io/FileSystem.cpp", | |
| "io/StringStream.cpp", | |
| "io/Util.cpp", | |
| "io/ZipArchive.cpp", | |
| "link/AutoVersioner.cpp", | |
| "link/FeatureFlagsFilter.cpp", | |
| "link/FlaggedXmlVersioner.cpp", | |
| "link/FlagNotEnabledResourceRemover.cpp", | |
| "link/ManifestFixer.cpp", | |
| "link/NoDefaultResourceRemover.cpp", | |
| "link/PrivateAttributeMover.cpp", | |
| "link/ReferenceLinker.cpp", | |
| "link/ResourceExcluder.cpp", | |
| "link/TableMerger.cpp", | |
| "link/XmlCompatVersioner.cpp", | |
| "link/XmlNamespaceRemover.cpp", | |
| "link/XmlReferenceLinker.cpp", | |
| "optimize/MultiApkGenerator.cpp", | |
| "optimize/ResourceDeduper.cpp", | |
| "optimize/ResourceFilter.cpp", | |
| "optimize/Obfuscator.cpp", | |
| "optimize/VersionCollapser.cpp", | |
| "process/ProductFilter.cpp", | |
| "process/SymbolTable.cpp", | |
| "split/TableSplitter.cpp", | |
| "text/Printer.cpp", | |
| "text/Unicode.cpp", | |
| "text/Utf8Iterator.cpp", | |
| "util/Files.cpp", | |
| "util/Util.cpp", | |
| "Debug.cpp", | |
| "DominatorTree.cpp", | |
| "java/AnnotationProcessor.cpp", | |
| "java/ClassDefinition.cpp", | |
| "java/JavaClassGenerator.cpp", | |
| "java/ManifestClassGenerator.cpp", | |
| "java/ProguardRules.cpp", | |
| "LoadedApk.cpp", | |
| "Resource.cpp", | |
| "ResourceParser.cpp", | |
| "ResourceTable.cpp", | |
| "ResourceUtils.cpp", | |
| "ResourceValues.cpp", | |
| "SdkConstants.cpp", | |
| "trace/TraceBuffer.cpp", | |
| "xml/XmlActionExecutor.cpp", | |
| "xml/XmlDom.cpp", | |
| "xml/XmlPullParser.cpp", | |
| "xml/XmlUtil.cpp", | |
| "ApkInfo.proto", | |
| "Configuration.proto", | |
| "Resources.proto", | |
| "ResourceMetadata.proto", | |
| "ResourcesInternal.proto", | |
| "ValueTransformer.cpp", | |
| ], | |
| proto: { | |
| export_proto_headers: true, | |
| type: "lite", | |
| }, | |
| defaults: ["aapt2_defaults"], | |
| min_sdk_version: "apex_inherit", | |
| apex_available: ["com.android.webapp"], | |
| } | |
| // ========================================================== | |
| // Build the host tests: aapt2_tests | |
| // ========================================================== | |
| cc_test_host { | |
| name: "aapt2_tests", | |
| srcs: [ | |
| "test/Builders.cpp", | |
| "test/Common.cpp", | |
| "test/Fixture.cpp", | |
| "**/*_test.cpp", | |
| ] + toolSources, | |
| static_libs: [ | |
| "libaapt2", | |
| "libgmock", | |
| ], | |
| defaults: ["aapt2_defaults"], | |
| data: [ | |
| "integration-tests/CompileTest/**/*", | |
| "integration-tests/CommandTests/**/*", | |
| "integration-tests/ConvertTest/**/*", | |
| "integration-tests/DumpTest/**/*", | |
| ":resource-flagging-test-app-apk", | |
| ":resource-flagging-test-app-r-java", | |
| ], | |
| } | |
| // ========================================================== | |
| // Build the host and device executable: aapt2 | |
| // ========================================================== | |
| cc_binary { | |
| name: "aapt2", | |
| srcs: ["Main.cpp"] + toolSources, | |
| use_version_lib: true, | |
| static_libs: ["libaapt2"], | |
| defaults: ["aapt2_defaults"], | |
| dist: { | |
| targets: ["aapt2_artifacts"], | |
| }, | |
| min_sdk_version: "apex_inherit", | |
| apex_available: ["com.android.webapp"], | |
| } | |
| // ========================================================== | |
| // Dist the protos | |
| // ========================================================== | |
| genrule { | |
| name: "aapt2-protos", | |
| tools: [":soong_zip"], | |
| srcs: [ | |
| "ApkInfo.proto", | |
| "Configuration.proto", | |
| "ResourcesInternal.proto", | |
| "ResourceMetadata.proto", | |
| "Resources.proto", | |
| ], | |
| out: ["aapt2-protos.zip"], | |
| cmd: "mkdir $(genDir)/protos && " + | |
| "cp $(in) $(genDir)/protos && " + | |
| "$(location :soong_zip) -o $(out) -C $(genDir)/protos -D $(genDir)/protos", | |
| dist: { | |
| targets: [ | |
| "sdk_repo", | |
| "aapt2_artifacts", | |
| ], | |
| }, | |
| } |