Loading tools/aapt2/Android.mk +45 −34 Original line number Diff line number Diff line Loading @@ -131,33 +131,40 @@ hostStaticLibs := \ libbase \ libprotobuf-cpp-lite_static # Do not add any shared libraries. AAPT2 is built to run on many # environments that may not have the required dependencies. hostSharedLibs := ifneq ($(strip $(USE_MINGW)),) hostStaticLibs += libz else hostLdLibs += -lz endif # Statically link libz for MinGW (Win SDK under Linux), # and dynamically link for all others. hostStaticLibs_windows := libz hostLdLibs_linux := -lz hostLdLibs_darwin := -lz cFlags := -Wall -Werror -Wno-unused-parameter -UNDEBUG cppFlags := -std=c++14 -Wno-missing-field-initializers -fno-exceptions -fno-rtti cFlags_darwin := -D_DARWIN_UNLIMITED_STREAMS cFlags_windows := -Wno-maybe-uninitialized # Incorrectly marking use of Maybe.value() as error. cppFlags := -std=c++11 -Wno-missing-field-initializers -fno-exceptions -fno-rtti protoIncludes := $(call generated-sources-dir-for,STATIC_LIBRARIES,libaapt2,HOST) # ========================================================== # NOTE: Do not add any shared libraries. # AAPT2 is built to run on many environments # that may not have the required dependencies. # ========================================================== # ========================================================== # Build the host static library: libaapt2 # ========================================================== include $(CLEAR_VARS) LOCAL_MODULE_CLASS := STATIC_LIBRARIES LOCAL_MODULE := libaapt2 LOCAL_MODULE_CLASS := STATIC_LIBRARIES LOCAL_MODULE_HOST_OS := darwin linux windows LOCAL_CFLAGS := $(cFlags) LOCAL_CFLAGS_darwin := $(cFlags_darwin) LOCAL_CFLAGS_windows := $(cFlags_windows) LOCAL_CPPFLAGS := $(cppFlags) LOCAL_C_INCLUDES := $(protoIncludes) LOCAL_SRC_FILES := $(sources) LOCAL_STATIC_LIBRARIES += $(hostStaticLibs) LOCAL_CFLAGS += $(cFlags) LOCAL_CPPFLAGS += $(cppFlags) LOCAL_C_INCLUDES += $(protoIncludes) LOCAL_STATIC_LIBRARIES := $(hostStaticLibs) LOCAL_STATIC_LIBRARIES_windows := $(hostStaticLibs_windows) include $(BUILD_HOST_STATIC_LIBRARY) # ========================================================== Loading @@ -166,16 +173,18 @@ include $(BUILD_HOST_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := libaapt2_tests LOCAL_MODULE_TAGS := tests LOCAL_MODULE_HOST_OS := darwin linux windows LOCAL_CFLAGS := $(cFlags) LOCAL_CFLAGS_darwin := $(cFlags_darwin) LOCAL_CFLAGS_windows := $(cFlags_windows) LOCAL_CPPFLAGS := $(cppFlags) LOCAL_C_INCLUDES := $(protoIncludes) LOCAL_SRC_FILES := $(testSources) LOCAL_STATIC_LIBRARIES += libaapt2 $(hostStaticLibs) LOCAL_SHARED_LIBRARIES += $(hostSharedLibs) LOCAL_LDLIBS += $(hostLdLibs) LOCAL_CFLAGS += $(cFlags) LOCAL_CPPFLAGS += $(cppFlags) LOCAL_C_INCLUDES += $(protoIncludes) LOCAL_STATIC_LIBRARIES := libaapt2 $(hostStaticLibs) LOCAL_STATIC_LIBRARIES_windows := $(hostStaticLibs_windows) LOCAL_LDLIBS := $(hostLdLibs) LOCAL_LDLIBS_darwin := $(hostLdLibs_darwin) LOCAL_LDLIBS_linux := $(hostLdLibs_linux) include $(BUILD_HOST_NATIVE_TEST) # ========================================================== Loading @@ -183,16 +192,18 @@ include $(BUILD_HOST_NATIVE_TEST) # ========================================================== include $(CLEAR_VARS) LOCAL_MODULE := aapt2 LOCAL_MODULE_HOST_OS := darwin linux windows LOCAL_CFLAGS := $(cFlags) LOCAL_CFLAGS_darwin := $(cFlags_darwin) LOCAL_CFLAGS_windows := $(cFlags_windows) LOCAL_CPPFLAGS := $(cppFlags) LOCAL_C_INCLUDES := $(protoIncludes) LOCAL_SRC_FILES := $(main) $(toolSources) LOCAL_STATIC_LIBRARIES += libaapt2 $(hostStaticLibs) LOCAL_SHARED_LIBRARIES += $(hostSharedLibs) LOCAL_LDLIBS += $(hostLdLibs) LOCAL_CFLAGS += $(cFlags) LOCAL_CPPFLAGS += $(cppFlags) LOCAL_C_INCLUDES += $(protoIncludes) LOCAL_STATIC_LIBRARIES := libaapt2 $(hostStaticLibs) LOCAL_STATIC_LIBRARIES_windows := $(hostStaticLibs_windows) LOCAL_LDLIBS := $(hostLdLibs) LOCAL_LDLIBS_darwin := $(hostLdLibs_darwin) LOCAL_LDLIBS_linux := $(hostLdLibs_linux) include $(BUILD_HOST_EXECUTABLE) ifeq ($(ONE_SHOT_MAKEFILE),) Loading tools/aapt2/StringPool_test.cpp +12 −8 Original line number Diff line number Diff line Loading @@ -20,8 +20,6 @@ #include <gtest/gtest.h> #include <string> using namespace android; namespace aapt { TEST(StringPoolTest, InsertOneString) { Loading Loading @@ -171,24 +169,28 @@ TEST(StringPoolTest, DoNotDedupeStyleWithSameStringAsNonStyle) { } TEST(StringPoolTest, FlattenEmptyStringPoolUtf8) { using namespace android; // For NO_ERROR on Windows. StringPool pool; BigBuffer buffer(1024); StringPool::flattenUtf8(&buffer, pool); std::unique_ptr<uint8_t[]> data = util::copy(buffer); android::ResStringPool test; ASSERT_EQ(test.setTo(data.get(), buffer.size()), android::NO_ERROR); ResStringPool test; ASSERT_EQ(test.setTo(data.get(), buffer.size()), NO_ERROR); } TEST(StringPoolTest, FlattenOddCharactersUtf16) { using namespace android; // For NO_ERROR on Windows. StringPool pool; pool.makeRef(u"\u093f"); BigBuffer buffer(1024); StringPool::flattenUtf16(&buffer, pool); std::unique_ptr<uint8_t[]> data = util::copy(buffer); android::ResStringPool test; ASSERT_EQ(test.setTo(data.get(), buffer.size()), android::NO_ERROR); ResStringPool test; ASSERT_EQ(test.setTo(data.get(), buffer.size()), NO_ERROR); size_t len = 0; const char16_t* str = test.stringAt(0, &len); EXPECT_EQ(1u, len); Loading @@ -199,6 +201,8 @@ TEST(StringPoolTest, FlattenOddCharactersUtf16) { constexpr const char16_t* sLongString = u"バッテリーを長持ちさせるため、バッテリーセーバーは端末のパフォーマンスを抑え、バイブレーション、位置情報サービス、大半のバックグラウンドデータを制限します。メール、SMSや、同期を使 用するその他のアプリは、起動しても更新されないことがあります。バッテリーセーバーは端末の充電中は自動的にOFFになります。"; TEST(StringPoolTest, FlattenUtf8) { using namespace android; // For NO_ERROR on Windows. StringPool pool; StringPool::Ref ref1 = pool.makeRef(u"hello"); Loading @@ -219,8 +223,8 @@ TEST(StringPoolTest, FlattenUtf8) { std::unique_ptr<uint8_t[]> data = util::copy(buffer); { android::ResStringPool test; ASSERT_EQ(test.setTo(data.get(), buffer.size()), android::NO_ERROR); ResStringPool test; ASSERT_EQ(test.setTo(data.get(), buffer.size()), NO_ERROR); EXPECT_EQ(util::getString(test, 0), u"hello"); EXPECT_EQ(util::getString(test, 1), u"goodbye"); Loading tools/aapt2/compile/PseudolocaleGenerator.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ #include "compile/PseudolocaleGenerator.h" #include "compile/Pseudolocalizer.h" #include <algorithm> namespace aapt { std::unique_ptr<StyledString> pseudolocalizeStyledString(StyledString* string, Loading tools/aapt2/flatten/TableFlattener.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include "util/BigBuffer.h" #include <android-base/macros.h> #include <algorithm> #include <type_traits> #include <numeric> Loading tools/aapt2/flatten/XmlFlattener.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include "xml/XmlDom.h" #include <androidfw/ResourceTypes.h> #include <algorithm> #include <utils/misc.h> #include <vector> Loading Loading
tools/aapt2/Android.mk +45 −34 Original line number Diff line number Diff line Loading @@ -131,33 +131,40 @@ hostStaticLibs := \ libbase \ libprotobuf-cpp-lite_static # Do not add any shared libraries. AAPT2 is built to run on many # environments that may not have the required dependencies. hostSharedLibs := ifneq ($(strip $(USE_MINGW)),) hostStaticLibs += libz else hostLdLibs += -lz endif # Statically link libz for MinGW (Win SDK under Linux), # and dynamically link for all others. hostStaticLibs_windows := libz hostLdLibs_linux := -lz hostLdLibs_darwin := -lz cFlags := -Wall -Werror -Wno-unused-parameter -UNDEBUG cppFlags := -std=c++14 -Wno-missing-field-initializers -fno-exceptions -fno-rtti cFlags_darwin := -D_DARWIN_UNLIMITED_STREAMS cFlags_windows := -Wno-maybe-uninitialized # Incorrectly marking use of Maybe.value() as error. cppFlags := -std=c++11 -Wno-missing-field-initializers -fno-exceptions -fno-rtti protoIncludes := $(call generated-sources-dir-for,STATIC_LIBRARIES,libaapt2,HOST) # ========================================================== # NOTE: Do not add any shared libraries. # AAPT2 is built to run on many environments # that may not have the required dependencies. # ========================================================== # ========================================================== # Build the host static library: libaapt2 # ========================================================== include $(CLEAR_VARS) LOCAL_MODULE_CLASS := STATIC_LIBRARIES LOCAL_MODULE := libaapt2 LOCAL_MODULE_CLASS := STATIC_LIBRARIES LOCAL_MODULE_HOST_OS := darwin linux windows LOCAL_CFLAGS := $(cFlags) LOCAL_CFLAGS_darwin := $(cFlags_darwin) LOCAL_CFLAGS_windows := $(cFlags_windows) LOCAL_CPPFLAGS := $(cppFlags) LOCAL_C_INCLUDES := $(protoIncludes) LOCAL_SRC_FILES := $(sources) LOCAL_STATIC_LIBRARIES += $(hostStaticLibs) LOCAL_CFLAGS += $(cFlags) LOCAL_CPPFLAGS += $(cppFlags) LOCAL_C_INCLUDES += $(protoIncludes) LOCAL_STATIC_LIBRARIES := $(hostStaticLibs) LOCAL_STATIC_LIBRARIES_windows := $(hostStaticLibs_windows) include $(BUILD_HOST_STATIC_LIBRARY) # ========================================================== Loading @@ -166,16 +173,18 @@ include $(BUILD_HOST_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := libaapt2_tests LOCAL_MODULE_TAGS := tests LOCAL_MODULE_HOST_OS := darwin linux windows LOCAL_CFLAGS := $(cFlags) LOCAL_CFLAGS_darwin := $(cFlags_darwin) LOCAL_CFLAGS_windows := $(cFlags_windows) LOCAL_CPPFLAGS := $(cppFlags) LOCAL_C_INCLUDES := $(protoIncludes) LOCAL_SRC_FILES := $(testSources) LOCAL_STATIC_LIBRARIES += libaapt2 $(hostStaticLibs) LOCAL_SHARED_LIBRARIES += $(hostSharedLibs) LOCAL_LDLIBS += $(hostLdLibs) LOCAL_CFLAGS += $(cFlags) LOCAL_CPPFLAGS += $(cppFlags) LOCAL_C_INCLUDES += $(protoIncludes) LOCAL_STATIC_LIBRARIES := libaapt2 $(hostStaticLibs) LOCAL_STATIC_LIBRARIES_windows := $(hostStaticLibs_windows) LOCAL_LDLIBS := $(hostLdLibs) LOCAL_LDLIBS_darwin := $(hostLdLibs_darwin) LOCAL_LDLIBS_linux := $(hostLdLibs_linux) include $(BUILD_HOST_NATIVE_TEST) # ========================================================== Loading @@ -183,16 +192,18 @@ include $(BUILD_HOST_NATIVE_TEST) # ========================================================== include $(CLEAR_VARS) LOCAL_MODULE := aapt2 LOCAL_MODULE_HOST_OS := darwin linux windows LOCAL_CFLAGS := $(cFlags) LOCAL_CFLAGS_darwin := $(cFlags_darwin) LOCAL_CFLAGS_windows := $(cFlags_windows) LOCAL_CPPFLAGS := $(cppFlags) LOCAL_C_INCLUDES := $(protoIncludes) LOCAL_SRC_FILES := $(main) $(toolSources) LOCAL_STATIC_LIBRARIES += libaapt2 $(hostStaticLibs) LOCAL_SHARED_LIBRARIES += $(hostSharedLibs) LOCAL_LDLIBS += $(hostLdLibs) LOCAL_CFLAGS += $(cFlags) LOCAL_CPPFLAGS += $(cppFlags) LOCAL_C_INCLUDES += $(protoIncludes) LOCAL_STATIC_LIBRARIES := libaapt2 $(hostStaticLibs) LOCAL_STATIC_LIBRARIES_windows := $(hostStaticLibs_windows) LOCAL_LDLIBS := $(hostLdLibs) LOCAL_LDLIBS_darwin := $(hostLdLibs_darwin) LOCAL_LDLIBS_linux := $(hostLdLibs_linux) include $(BUILD_HOST_EXECUTABLE) ifeq ($(ONE_SHOT_MAKEFILE),) Loading
tools/aapt2/StringPool_test.cpp +12 −8 Original line number Diff line number Diff line Loading @@ -20,8 +20,6 @@ #include <gtest/gtest.h> #include <string> using namespace android; namespace aapt { TEST(StringPoolTest, InsertOneString) { Loading Loading @@ -171,24 +169,28 @@ TEST(StringPoolTest, DoNotDedupeStyleWithSameStringAsNonStyle) { } TEST(StringPoolTest, FlattenEmptyStringPoolUtf8) { using namespace android; // For NO_ERROR on Windows. StringPool pool; BigBuffer buffer(1024); StringPool::flattenUtf8(&buffer, pool); std::unique_ptr<uint8_t[]> data = util::copy(buffer); android::ResStringPool test; ASSERT_EQ(test.setTo(data.get(), buffer.size()), android::NO_ERROR); ResStringPool test; ASSERT_EQ(test.setTo(data.get(), buffer.size()), NO_ERROR); } TEST(StringPoolTest, FlattenOddCharactersUtf16) { using namespace android; // For NO_ERROR on Windows. StringPool pool; pool.makeRef(u"\u093f"); BigBuffer buffer(1024); StringPool::flattenUtf16(&buffer, pool); std::unique_ptr<uint8_t[]> data = util::copy(buffer); android::ResStringPool test; ASSERT_EQ(test.setTo(data.get(), buffer.size()), android::NO_ERROR); ResStringPool test; ASSERT_EQ(test.setTo(data.get(), buffer.size()), NO_ERROR); size_t len = 0; const char16_t* str = test.stringAt(0, &len); EXPECT_EQ(1u, len); Loading @@ -199,6 +201,8 @@ TEST(StringPoolTest, FlattenOddCharactersUtf16) { constexpr const char16_t* sLongString = u"バッテリーを長持ちさせるため、バッテリーセーバーは端末のパフォーマンスを抑え、バイブレーション、位置情報サービス、大半のバックグラウンドデータを制限します。メール、SMSや、同期を使 用するその他のアプリは、起動しても更新されないことがあります。バッテリーセーバーは端末の充電中は自動的にOFFになります。"; TEST(StringPoolTest, FlattenUtf8) { using namespace android; // For NO_ERROR on Windows. StringPool pool; StringPool::Ref ref1 = pool.makeRef(u"hello"); Loading @@ -219,8 +223,8 @@ TEST(StringPoolTest, FlattenUtf8) { std::unique_ptr<uint8_t[]> data = util::copy(buffer); { android::ResStringPool test; ASSERT_EQ(test.setTo(data.get(), buffer.size()), android::NO_ERROR); ResStringPool test; ASSERT_EQ(test.setTo(data.get(), buffer.size()), NO_ERROR); EXPECT_EQ(util::getString(test, 0), u"hello"); EXPECT_EQ(util::getString(test, 1), u"goodbye"); Loading
tools/aapt2/compile/PseudolocaleGenerator.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ #include "compile/PseudolocaleGenerator.h" #include "compile/Pseudolocalizer.h" #include <algorithm> namespace aapt { std::unique_ptr<StyledString> pseudolocalizeStyledString(StyledString* string, Loading
tools/aapt2/flatten/TableFlattener.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include "util/BigBuffer.h" #include <android-base/macros.h> #include <algorithm> #include <type_traits> #include <numeric> Loading
tools/aapt2/flatten/XmlFlattener.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include "xml/XmlDom.h" #include <androidfw/ResourceTypes.h> #include <algorithm> #include <utils/misc.h> #include <vector> Loading