This commit is contained in:
oSumAtrIX 2022-06-17 22:48:19 +02:00
commit c09707a408
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
40 changed files with 1655 additions and 0 deletions

42
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,42 @@
name: Build aapt2
on:
push:
branches:
- main
- dev
workflow_dispatch:
inputs:
logLevel:
description: 'Reason'
required: false
default: 'Update package'
jobs:
build:
name: build
runs-on: ubuntu-latest
strategy:
matrix:
target_arch: [x86_64, x86, arm64-v8a, armeabi-v7a]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'true'
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r23c
add-to-path: false
- run: ./build.sh ${{ matrix.target_arch }}
env:
NDK_TOOLCHAIN: ${{ steps.setup-ndk.outputs.ndk-path }}/toolchains/llvm/prebuilt/linux-x86_64
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: dist-${{ matrix.target_arch }}
path: dist

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
bin/
build/

56
.gitmodules vendored Normal file
View File

@ -0,0 +1,56 @@
[submodule "src/expat"]
shallow = true
path = src/expat
url = https://android.googlesource.com/platform/external/expat.git
[submodule "src/fmtlib"]
shallow = true
path = src/fmtlib
url = https://android.googlesource.com/platform/external/fmtlib.git
[submodule "src/boringssl"]
shallow = true
path = src/boringssl
url = https://boringssl.googlesource.com/boringssl.git
[submodule "src/incremental_delivery"]
shallow = true
path = src/incremental_delivery
url = https://android.googlesource.com/platform/system/incremental_delivery
[submodule "src/libbase"]
shallow = true
path = src/libbase
url = https://android.googlesource.com/platform/system/libbase
[submodule "src/libpng"]
shallow = true
path = src/libpng
url = https://android.googlesource.com/platform/external/libpng.git
[submodule "src/pcre"]
shallow = true
path = src/pcre
url = https://android.googlesource.com/platform/external/pcre.git
[submodule "src/zopfli"]
shallow = true
path = src/zopfli
url = https://android.googlesource.com/platform/external/zopfli
[submodule "src/protobuf"]
shallow = true
path = src/protobuf
url = https://android.googlesource.com/platform/external/protobuf
[submodule "src/logging"]
shallow = true
path = src/logging
url = https://android.googlesource.com/platform/system/logging.git
[submodule "src/selinux"]
shallow = true
path = src/selinux
url = https://android.googlesource.com/platform/external/selinux.git
[submodule "src/core"]
shallow = true
path = src/core
url = https://android.googlesource.com/platform/system/core.git
[submodule "src/base"]
shallow = true
path = src/base
url = https://android.googlesource.com/platform/frameworks/base
[submodule "src/libziparchive"]
shallow = true
path = src/libziparchive
url = https://android.googlesource.com/platform/system/libziparchive

46
CMakeLists.txt Normal file
View File

@ -0,0 +1,46 @@
cmake_minimum_required(VERSION 3.14.2)
project(sdk-tools)
if(ANDROID_ABI STREQUAL "arm64-v8a" OR ANDROID_ABI STREQUAL "armeabi-v7a")
enable_language(ASM)
elseif(ANDROID_ABI STREQUAL "x86_64" OR ANDROID_ABI STREQUAL "x86")
enable_language(ASM_NASM)
else()
message(FATAL_ERROR "Unsupported architecture: ${ANDROID_ABI}")
endif()
# set global cflags and cxxflags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics -fPIC -Wno-attributes -std=gnu11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics -fPIC -Wno-attributes -std=gnu++2a")
# static link
set(CMAKE_EXE_LINKER_FLAGS "-static")
# platform tools version
# see the patches/other/platform_tools_version.h
set(TOOLS_VERSION 33.0.1)
set(SRC ${PROJECT_SOURCE_DIR}/src)
# 64-bit off_t for lseek.
add_definitions(-D_FILE_OFFSET_BITS=64)
if(NOT DEFINED PROTOC_PATH)
message(FATAL_ERROR "PROTOC_PATH undefined, please make sure to build and install protoc from the cloned submodule." )
endif()
set(PROTOC_COMPILER ${PROTOC_PATH})
if(NOT EXISTS ${PROTOC_COMPILER})
unset(PROTOC_PATH CACHE)
message(FATAL_ERROR "Invalid protoc: ${PROTOC_COMPILER}, please check if the path is correct")
endif()
# thrid-party libraries
add_subdirectory(src/boringssl EXCLUDE_FROM_ALL)
add_subdirectory(src/fmtlib EXCLUDE_FROM_ALL)
add_subdirectory(src/pcre EXCLUDE_FROM_ALL)
add_subdirectory(src/expat EXCLUDE_FROM_ALL)
add_subdirectory(src/zopfli EXCLUDE_FROM_ALL)
add_subdirectory(src/protobuf/cmake EXCLUDE_FROM_ALL)
# building sdk-tools
add_subdirectory(cmake)

100
build.sh Executable file
View File

@ -0,0 +1,100 @@
#!/bin/bash
# Check for NDK_TOOLCHAIN environment variable and abort if it is not set.
if [[ -z "${NDK_TOOLCHAIN}" ]]; then
echo "Please specify the Android NDK environment variable \"NDK_TOOLCHAIN\"."
exit 1
fi
# Prerequisites.
sudo apt install \
golang \
ninja-build \
autogen \
autoconf \
libtool \
build-essential \
-y || exit 1
root="$(pwd)"
# Install protobuf compiler.
cd "src/protobuf" || exit 1
./autogen.sh
./configure
make -j"$(nproc)"
sudo make install
sudo ldconfig
# Go back.
cd "$root" || exit 1
# Apply patches.
git apply patches/incremental_delivery.patch --whitespace=fix
git apply patches/libpng.patch --whitespace=fix
git apply patches/selinux.patch --whitespace=fix
git apply patches/protobuf.patch --whitespace=fix
git apply patches/aapt2.patch --whitespace=fix
git apply patches/boringssl.patch --whitespace=fix
# Define all the compilers, libraries and targets.
api="30"
architecture=$1
declare -A compilers=(
[x86_64]=x86_64-linux-android
[x86]=i686-linux-android
[arm64-v8a]=aarch64-linux-android
[armeabi-v7a]=armv7a-linux-androideabi
)
declare -A lib_arch=(
[x86_64]=x86_64-linux-android
[x86]=i686-linux-android
[arm64-v8a]=aarch64-linux-android
[armeabi-v7a]=arm-linux-androideabi
)
declare -A target_abi=(
[x86_64]=x86_64
[x86]=x86
[arm64-v8a]=aarch64
[armeabi-v7a]=arm
)
build_directory="build"
aapt_binary_path="$root/$build_directory/cmake/aapt2"
# Build all the target architectures.
bin_directory="$root/dist/$architecture"
# switch to cmake build directory.
[[ -d dir ]] || mkdir -p $build_directory && cd $build_directory || exit 1
# Define the compiler architecture and compiler.
compiler_arch="${compilers[$architecture]}"
c_compiler="$compiler_arch$api-clang"
cxx_compiler="${c_compiler}++"
# Copy libc.a to libpthread.a.
lib_path="$NDK_TOOLCHAIN/sysroot/usr/lib/${lib_arch[$architecture]}/$api/"
cp -n "$lib_path/libc.a" "$lib_path/libpthread.a"
# Run make for the target architecture.
compiler_bin_directory="$NDK_TOOLCHAIN/bin/"
cmake -GNinja \
-DCMAKE_C_COMPILER="$compiler_bin_directory$c_compiler" \
-DCMAKE_CXX_COMPILER="$compiler_bin_directory$cxx_compiler" \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=True \
-DCMAKE_BUILD_TYPE=Release \
-DANDROID_ABI="$architecture" \
-DTARGET_ABI="${target_abi[$architecture]}" \
-DPROTOC_PATH="/usr/local/bin/protoc" \
-DCMAKE_SYSROOT="$NDK_TOOLCHAIN/sysroot" \
.. || exit 1
ninja || exit 1
"$NDK_TOOLCHAIN/bin/llvm-strip" --strip-unneeded "$aapt_binary_path"
# Create bin directory.
mkdir -p "$bin_directory"
# Move aapt2 to bin directory.
mv "$aapt_binary_path" "$bin_directory"

13
cmake/CMakeLists.txt Normal file
View File

@ -0,0 +1,13 @@
include(libbase.cmake)
include(liblog.cmake)
include(libcutils.cmake)
include(libutils.cmake)
include(libpackagelistparser.cmake)
include(libandroidfw.cmake)
include(libincfs.cmake)
include(libselinux.cmake)
include(libsepol.cmake)
include(libpng.cmake)
include(libsparse.cmake)
include(libziparchive.cmake)
include(aapt2.cmake)

169
cmake/aapt2.cmake Normal file
View File

@ -0,0 +1,169 @@
set(AAPT2_PROTO_SRC)
set(AAPT2_PROTO_HDRS)
set(AAPT2_PROTO_DIR ${SRC}/base/tools/aapt2)
file(GLOB_RECURSE PROTO_FILES ${AAPT2_PROTO_DIR}/*.proto)
foreach(proto ${PROTO_FILES})
get_filename_component(FIL_WE ${proto} NAME_WE)
if(DEFINED PROTOC_PATH)
execute_process(
COMMAND ${PROTOC_COMPILER} ${proto} --proto_path=${AAPT2_PROTO_DIR}
--cpp_out=${AAPT2_PROTO_DIR} COMMAND_ECHO STDOUT
RESULT_VARIABLE RESULT
WORKING_DIRECTORY ${AAPT2_PROTO_DIR})
if(RESULT EQUAL 0)
message(STATUS "generate cpp file ${TARGET_CPP_FILE}")
message(STATUS "generate head file ${TARGET_HEAD_FILE}")
endif()
endif()
set(TARGET_CPP_FILE "${AAPT2_PROTO_DIR}/${FIL_WE}.pb.cc")
set(TARGET_HEAD_FILE "${AAPT2_PROTO_DIR}/${FIL_WE}.pb.h")
if(EXISTS ${TARGET_CPP_FILE} AND EXISTS ${TARGET_HEAD_FILE})
list(APPEND AAPT2_PROTO_SRC ${TARGET_CPP_FILE})
list(APPEND AAPT2_PROTO_HDRS ${TARGET_HEAD_FILE})
endif()
endforeach()
if(DEFINED PROTOC_PATH)
set_source_files_properties(${AAPT2_PROTO_SRC} PROPERTIES GENERATED TRUE)
set_source_files_properties(${AAPT2_PROTO_HDRS} PROPERTIES GENERATED TRUE)
endif()
set_source_files_properties(${AAPT2_PROTO_SRC} ${AAPT2_PROTO_HDRS}
PROPERTIES GENERATED TRUE)
add_executable(
aapt2
${SRC}/base/tools/aapt2/Main.cpp
${SRC}/base/tools/aapt2/cmd/Command.cpp
${SRC}/base/tools/aapt2/cmd/Compile.cpp
${SRC}/base/tools/aapt2/cmd/Convert.cpp
${SRC}/base/tools/aapt2/cmd/Diff.cpp
${SRC}/base/tools/aapt2/cmd/Dump.cpp
${SRC}/base/tools/aapt2/cmd/Link.cpp
${SRC}/base/tools/aapt2/cmd/Optimize.cpp
${SRC}/base/tools/aapt2/cmd/Util.cpp
${SRC}/base/tools/aapt2/compile/IdAssigner.cpp
${SRC}/base/tools/aapt2/compile/InlineXmlFormatParser.cpp
${SRC}/base/tools/aapt2/compile/NinePatch.cpp
${SRC}/base/tools/aapt2/compile/Png.cpp
${SRC}/base/tools/aapt2/compile/PngChunkFilter.cpp
${SRC}/base/tools/aapt2/compile/PngCrunch.cpp
${SRC}/base/tools/aapt2/compile/PseudolocaleGenerator.cpp
${SRC}/base/tools/aapt2/compile/Pseudolocalizer.cpp
${SRC}/base/tools/aapt2/compile/XmlIdCollector.cpp
${SRC}/base/tools/aapt2/configuration/ConfigurationParser.cpp
${SRC}/base/tools/aapt2/dump/DumpManifest.cpp
${SRC}/base/tools/aapt2/filter/AbiFilter.cpp
${SRC}/base/tools/aapt2/filter/ConfigFilter.cpp
${SRC}/base/tools/aapt2/format/Archive.cpp
${SRC}/base/tools/aapt2/format/Container.cpp
${SRC}/base/tools/aapt2/format/binary/BinaryResourceParser.cpp
${SRC}/base/tools/aapt2/format/binary/ResChunkPullParser.cpp
${SRC}/base/tools/aapt2/format/binary/TableFlattener.cpp
${SRC}/base/tools/aapt2/format/binary/XmlFlattener.cpp
${SRC}/base/tools/aapt2/format/proto/ProtoDeserialize.cpp
${SRC}/base/tools/aapt2/format/proto/ProtoSerialize.cpp
${SRC}/base/tools/aapt2/io/BigBufferStream.cpp
${SRC}/base/tools/aapt2/io/File.cpp
${SRC}/base/tools/aapt2/io/FileStream.cpp
${SRC}/base/tools/aapt2/io/FileSystem.cpp
${SRC}/base/tools/aapt2/io/StringStream.cpp
${SRC}/base/tools/aapt2/io/Util.cpp
${SRC}/base/tools/aapt2/io/ZipArchive.cpp
${SRC}/base/tools/aapt2/link/AutoVersioner.cpp
${SRC}/base/tools/aapt2/link/ManifestFixer.cpp
${SRC}/base/tools/aapt2/link/NoDefaultResourceRemover.cpp
${SRC}/base/tools/aapt2/link/ProductFilter.cpp
${SRC}/base/tools/aapt2/link/PrivateAttributeMover.cpp
${SRC}/base/tools/aapt2/link/ReferenceLinker.cpp
${SRC}/base/tools/aapt2/link/ResourceExcluder.cpp
${SRC}/base/tools/aapt2/link/TableMerger.cpp
${SRC}/base/tools/aapt2/link/XmlCompatVersioner.cpp
${SRC}/base/tools/aapt2/link/XmlNamespaceRemover.cpp
${SRC}/base/tools/aapt2/link/XmlReferenceLinker.cpp
${SRC}/base/tools/aapt2/optimize/MultiApkGenerator.cpp
${SRC}/base/tools/aapt2/optimize/ResourceDeduper.cpp
${SRC}/base/tools/aapt2/optimize/ResourceFilter.cpp
${SRC}/base/tools/aapt2/optimize/ResourcePathShortener.cpp
${SRC}/base/tools/aapt2/optimize/VersionCollapser.cpp
${SRC}/base/tools/aapt2/process/SymbolTable.cpp
${SRC}/base/tools/aapt2/split/TableSplitter.cpp
${SRC}/base/tools/aapt2/text/Printer.cpp
${SRC}/base/tools/aapt2/text/Unicode.cpp
${SRC}/base/tools/aapt2/text/Utf8Iterator.cpp
${SRC}/base/tools/aapt2/util/BigBuffer.cpp
${SRC}/base/tools/aapt2/util/Files.cpp
${SRC}/base/tools/aapt2/util/Util.cpp
${SRC}/base/tools/aapt2/Debug.cpp
${SRC}/base/tools/aapt2/DominatorTree.cpp
${SRC}/base/tools/aapt2/java/AnnotationProcessor.cpp
${SRC}/base/tools/aapt2/java/ClassDefinition.cpp
${SRC}/base/tools/aapt2/java/JavaClassGenerator.cpp
${SRC}/base/tools/aapt2/java/ManifestClassGenerator.cpp
${SRC}/base/tools/aapt2/java/ProguardRules.cpp
${SRC}/base/tools/aapt2/LoadedApk.cpp
${SRC}/base/tools/aapt2/Resource.cpp
${SRC}/base/tools/aapt2/ResourceParser.cpp
${SRC}/base/tools/aapt2/ResourceTable.cpp
${SRC}/base/tools/aapt2/ResourceUtils.cpp
${SRC}/base/tools/aapt2/ResourceValues.cpp
${SRC}/base/tools/aapt2/SdkConstants.cpp
${SRC}/base/tools/aapt2/StringPool.cpp
${SRC}/base/tools/aapt2/trace/TraceBuffer.cpp
${SRC}/base/tools/aapt2/xml/XmlActionExecutor.cpp
${SRC}/base/tools/aapt2/xml/XmlDom.cpp
${SRC}/base/tools/aapt2/xml/XmlPullParser.cpp
${SRC}/base/tools/aapt2/xml/XmlUtil.cpp
${SRC}/base/tools/aapt2/Configuration.proto
${SRC}/base/tools/aapt2/Resources.proto
${SRC}/base/tools/aapt2/ResourcesInternal.proto
${SRC}/base/tools/aapt2/ValueTransformer.cpp
${AAPT2_PROTO_SRC}
${AAPT2_PROTO_HDRS})
target_include_directories(aapt2 PUBLIC
${SRC}/base/tools/aapt2
${SRC}/protobuf/src
${SRC}/logging/liblog/include
${SRC}/expat/lib
${SRC}/fmtlib/include
${SRC}/libpng
${SRC}/libbase/include
${SRC}/base/libs/androidfw/include
${SRC}/base/cmds/idmap2/libidmap2_policies/include
${SRC}/core/libsystem/include
${SRC}/core/libutils/include
${SRC}/libziparchive/include
${SRC}/boringssl/third_party/googletest/include
${SRC}/libbuildversion/include
${SRC}/incremental_delivery/incfs/util/include
${SRC}/incremental_delivery/incfs/kernel-headers)
target_link_libraries(aapt2
libandroidfw
libincfs
libselinux
libsepol
libutils
libpackagelistparser
libcutils
libziparchive
libbase
libprotobuf
liblog
libpng
expat
crypto
ssl
pcre2-8
fmt
c++_static
z
dl)

46
cmake/libandroidfw.cmake Normal file
View File

@ -0,0 +1,46 @@
add_library(libandroidfw STATIC
${SRC}/base/libs/androidfw/ApkAssets.cpp
${SRC}/base/libs/androidfw/Asset.cpp
${SRC}/base/libs/androidfw/AssetDir.cpp
${SRC}/base/libs/androidfw/AssetManager.cpp
${SRC}/base/libs/androidfw/AssetManager2.cpp
${SRC}/base/libs/androidfw/AssetsProvider.cpp
${SRC}/base/libs/androidfw/AttributeResolution.cpp
${SRC}/base/libs/androidfw/ChunkIterator.cpp
${SRC}/base/libs/androidfw/ConfigDescription.cpp
${SRC}/base/libs/androidfw/Idmap.cpp
${SRC}/base/libs/androidfw/LoadedArsc.cpp
${SRC}/base/libs/androidfw/Locale.cpp
${SRC}/base/libs/androidfw/LocaleData.cpp
${SRC}/base/libs/androidfw/misc.cpp
${SRC}/base/libs/androidfw/ObbFile.cpp
${SRC}/base/libs/androidfw/PosixUtils.cpp
${SRC}/base/libs/androidfw/ResourceTypes.cpp
${SRC}/base/libs/androidfw/ResourceUtils.cpp
${SRC}/base/libs/androidfw/StreamingZipInflater.cpp
${SRC}/base/libs/androidfw/TypeWrappers.cpp
${SRC}/base/libs/androidfw/Util.cpp
${SRC}/base/libs/androidfw/ZipFileRO.cpp
${SRC}/base/libs/androidfw/ZipUtils.cpp
)
target_compile_definitions(libandroidfw PRIVATE
-DSTATIC_ANDROIDFW_FOR_TOOLS
-D_GNU_SOURCE -DNDEBUG
)
target_include_directories(libandroidfw PUBLIC
${SRC}/base/libs/androidfw/include
${SRC}/core/libcutils/include
${SRC}/logging/liblog/include
${SRC}/core/libsystem/include
${SRC}/core/libutils/include
${SRC}/libbase/include
${SRC}/native/include
${SRC}/native/libs/binder/include
${SRC}/libziparchive/include
${SRC}/incremental_delivery/incfs/util/include
${SRC}/incremental_delivery/incfs/kernel-headers
)
target_link_libraries(libandroidfw PUBLIC fmt::fmt)

24
cmake/libbase.cmake Normal file
View File

@ -0,0 +1,24 @@
add_library(libbase STATIC
${SRC}/libbase/abi_compatibility.cpp
${SRC}/libbase/chrono_utils.cpp
${SRC}/libbase/cmsg.cpp
${SRC}/libbase/errors_unix.cpp
${SRC}/libbase/file.cpp
${SRC}/libbase/logging.cpp
${SRC}/libbase/mapped_file.cpp
${SRC}/libbase/parsebool.cpp
${SRC}/libbase/parsenetaddress.cpp
${SRC}/libbase/posix_strerror_r.cpp
${SRC}/libbase/process.cpp
${SRC}/libbase/properties.cpp
${SRC}/libbase/stringprintf.cpp
${SRC}/libbase/strings.cpp
${SRC}/libbase/test_utils.cpp
${SRC}/libbase/threads.cpp
)
target_include_directories(libbase PRIVATE
${SRC}/libbase/include
${SRC}/core/include
${SRC}/logging/liblog/include
)

34
cmake/libcutils.cmake Normal file
View File

@ -0,0 +1,34 @@
add_library(libcutils STATIC
${SRC}/core/libcutils/android_get_control_file.cpp
${SRC}/core/libcutils/ashmem-host.cpp
${SRC}/core/libcutils/canned_fs_config.cpp
${SRC}/core/libcutils/config_utils.cpp
${SRC}/core/libcutils/fs.cpp
${SRC}/core/libcutils/fs_config.cpp
${SRC}/core/libcutils/hashmap.cpp
${SRC}/core/libcutils/iosched_policy.cpp
${SRC}/core/libcutils/load_file.cpp
${SRC}/core/libcutils/multiuser.cpp
${SRC}/core/libcutils/native_handle.cpp
${SRC}/core/libcutils/properties.cpp
${SRC}/core/libcutils/record_stream.cpp
${SRC}/core/libcutils/socket_inaddr_any_server_unix.cpp
${SRC}/core/libcutils/socket_local_client_unix.cpp
${SRC}/core/libcutils/socket_local_server_unix.cpp
${SRC}/core/libcutils/socket_network_client_unix.cpp
${SRC}/core/libcutils/sockets_unix.cpp
${SRC}/core/libcutils/sockets.cpp
${SRC}/core/libcutils/str_parms.cpp
${SRC}/core/libcutils/strlcpy.c
${SRC}/core/libcutils/trace-host.cpp
${SRC}/core/libcutils/threads.cpp
)
target_compile_definitions(libcutils PRIVATE -D_GNU_SOURCE)
target_include_directories(libcutils PRIVATE
${SRC}/core/libutils/include
${SRC}/core/libcutils/include
${SRC}/logging/liblog/include
${SRC}/libbase/include
)

20
cmake/libincfs.cmake Normal file
View File

@ -0,0 +1,20 @@
add_library(libincfs STATIC
${SRC}/incremental_delivery/incfs/incfs_ndk.c
${SRC}/incremental_delivery/incfs/incfs.cpp
${SRC}/incremental_delivery/incfs/MountRegistry.cpp
${SRC}/incremental_delivery/incfs/path.cpp
${SRC}/incremental_delivery/incfs/util/map_ptr.cpp
${SRC}/incremental_delivery/sysprop/IncrementalProperties.sysprop.cpp
)
target_include_directories(libincfs PRIVATE
${SRC}/incremental_delivery/incfs/include
${SRC}/incremental_delivery/incfs/util/include
${SRC}/incremental_delivery/sysprop/include
${SRC}/incremental_delivery/incfs/kernel-headers
${SRC}/libbase/include
${SRC}/core/libutils/include
${SRC}/boringssl/include
${SRC}/selinux/libselinux/include
${SRC}/logging/liblog/include
)

33
cmake/liblog.cmake Normal file
View File

@ -0,0 +1,33 @@
add_library(liblog STATIC
${SRC}/logging/liblog/log_event_list.cpp
${SRC}/logging/liblog/log_event_write.cpp
${SRC}/logging/liblog/logger_name.cpp
${SRC}/logging/liblog/logger_read.cpp
${SRC}/logging/liblog/logger_write.cpp
${SRC}/logging/liblog/properties.cpp
${SRC}/logging/liblog/logprint.cpp
${SRC}/logging/liblog/event_tag_map.cpp
${SRC}/logging/liblog/log_time.cpp
${SRC}/logging/liblog/pmsg_reader.cpp
${SRC}/logging/liblog/pmsg_writer.cpp
${SRC}/logging/liblog/logd_reader.cpp
${SRC}/logging/liblog/logd_writer.cpp
)
target_compile_definitions(liblog PRIVATE
-DLIBLOG_LOG_TAG=1006
-D_XOPEN_SOURCE=700
-DFAKE_LOG_DEVICE=1
-DSNET_EVENT_LOG_TAG=1397638686
)
target_include_directories(liblog PRIVATE
${SRC}/core/include
${SRC}/core/libutils/include
${SRC}/core/libcutils/include
${SRC}/core/libsystem/include
${SRC}/logging/liblog/include
${SRC}/libbase/include
)

View File

@ -0,0 +1,8 @@
add_library(libpackagelistparser STATIC
${SRC}/core/libpackagelistparser/packagelistparser.cpp
)
target_include_directories(libpackagelistparser PRIVATE
${SRC}/core/libpackagelistparser/include
${SRC}/logging/liblog/include
)

36
cmake/libpng.cmake Normal file
View File

@ -0,0 +1,36 @@
add_library(libpng STATIC
${SRC}/libpng/png.c
${SRC}/libpng/pngerror.c
${SRC}/libpng/pngget.c
${SRC}/libpng/pngmem.c
${SRC}/libpng/pngpread.c
${SRC}/libpng/pngread.c
${SRC}/libpng/pngrio.c
${SRC}/libpng/pngrtran.c
${SRC}/libpng/pngrutil.c
${SRC}/libpng/pngset.c
${SRC}/libpng/pngtrans.c
${SRC}/libpng/pngwio.c
${SRC}/libpng/pngwrite.c
${SRC}/libpng/pngwtran.c
${SRC}/libpng/pngwutil.c)
if(ANDROID_ABI STREQUAL "arm64-v8a" OR ANDROID_ABI STREQUAL "armeabi-v7a")
target_sources(libpng PRIVATE
${SRC}/libpng/arm/arm_init.c
${SRC}/libpng/arm/filter_neon_intrinsics.c
${SRC}/libpng/arm/palette_neon_intrinsics.c)
if(ANDROID_ABI STREQUAL "armeabi-v7a")
target_sources(libpng PRIVATE ${SRC}/libpng/arm/filter_neon.S)
endif()
elseif(ANDROID_ABI STREQUAL "x86_64" OR ANDROID_ABI STREQUAL "x86")
target_sources(libpng PRIVATE
${SRC}/libpng/intel/intel_init.c
${SRC}/libpng/intel/filter_sse2_intrinsics.c)
target_compile_definitions(libpng PRIVATE -DPNG_INTEL_SSE_OPT=1)
endif()
target_include_directories(libpng PRIVATE ${SRC}/libpng)

176
cmake/libprotoc.cmake Normal file
View File

@ -0,0 +1,176 @@
add_library(libprotoc STATIC
${SRC}/protobuf/src/google/protobuf/any_lite.cc
${SRC}/protobuf/src/google/protobuf/arena.cc
${SRC}/protobuf/src/google/protobuf/extension_set.cc
${SRC}/protobuf/src/google/protobuf/generated_enum_util.cc
${SRC}/protobuf/src/google/protobuf/generated_message_table_driven_lite.cc
${SRC}/protobuf/src/google/protobuf/generated_message_util.cc
${SRC}/protobuf/src/google/protobuf/implicit_weak_message.cc
${SRC}/protobuf/src/google/protobuf/io/coded_stream.cc
${SRC}/protobuf/src/google/protobuf/io/io_win32.cc
${SRC}/protobuf/src/google/protobuf/io/strtod.cc
${SRC}/protobuf/src/google/protobuf/io/zero_copy_stream.cc
${SRC}/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc
${SRC}/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc
${SRC}/protobuf/src/google/protobuf/message_lite.cc
${SRC}/protobuf/src/google/protobuf/parse_context.cc
${SRC}/protobuf/src/google/protobuf/repeated_field.cc
${SRC}/protobuf/src/google/protobuf/stubs/bytestream.cc
${SRC}/protobuf/src/google/protobuf/stubs/common.cc
${SRC}/protobuf/src/google/protobuf/stubs/int128.cc
${SRC}/protobuf/src/google/protobuf/stubs/status.cc
${SRC}/protobuf/src/google/protobuf/stubs/statusor.cc
${SRC}/protobuf/src/google/protobuf/stubs/stringpiece.cc
${SRC}/protobuf/src/google/protobuf/stubs/stringprintf.cc
${SRC}/protobuf/src/google/protobuf/stubs/structurally_valid.cc
${SRC}/protobuf/src/google/protobuf/stubs/strutil.cc
${SRC}/protobuf/src/google/protobuf/stubs/time.cc
${SRC}/protobuf/src/google/protobuf/wire_format_lite.cc
${SRC}/protobuf/src/google/protobuf/any.cc
${SRC}/protobuf/src/google/protobuf/any.pb.cc
${SRC}/protobuf/src/google/protobuf/api.pb.cc
${SRC}/protobuf/src/google/protobuf/compiler/importer.cc
${SRC}/protobuf/src/google/protobuf/compiler/parser.cc
${SRC}/protobuf/src/google/protobuf/descriptor.cc
${SRC}/protobuf/src/google/protobuf/descriptor.pb.cc
${SRC}/protobuf/src/google/protobuf/descriptor_database.cc
${SRC}/protobuf/src/google/protobuf/duration.pb.cc
${SRC}/protobuf/src/google/protobuf/dynamic_message.cc
${SRC}/protobuf/src/google/protobuf/empty.pb.cc
${SRC}/protobuf/src/google/protobuf/extension_set_heavy.cc
${SRC}/protobuf/src/google/protobuf/field_mask.pb.cc
${SRC}/protobuf/src/google/protobuf/generated_message_reflection.cc
${SRC}/protobuf/src/google/protobuf/generated_message_table_driven.cc
${SRC}/protobuf/src/google/protobuf/io/gzip_stream.cc
${SRC}/protobuf/src/google/protobuf/io/printer.cc
${SRC}/protobuf/src/google/protobuf/io/tokenizer.cc
${SRC}/protobuf/src/google/protobuf/map_field.cc
${SRC}/protobuf/src/google/protobuf/message.cc
${SRC}/protobuf/src/google/protobuf/reflection_ops.cc
${SRC}/protobuf/src/google/protobuf/service.cc
${SRC}/protobuf/src/google/protobuf/source_context.pb.cc
${SRC}/protobuf/src/google/protobuf/struct.pb.cc
${SRC}/protobuf/src/google/protobuf/stubs/mathlimits.cc
${SRC}/protobuf/src/google/protobuf/stubs/substitute.cc
${SRC}/protobuf/src/google/protobuf/text_format.cc
${SRC}/protobuf/src/google/protobuf/timestamp.pb.cc
${SRC}/protobuf/src/google/protobuf/type.pb.cc
${SRC}/protobuf/src/google/protobuf/unknown_field_set.cc
${SRC}/protobuf/src/google/protobuf/util/delimited_message_util.cc
${SRC}/protobuf/src/google/protobuf/util/field_comparator.cc
${SRC}/protobuf/src/google/protobuf/util/field_mask_util.cc
${SRC}/protobuf/src/google/protobuf/util/internal/datapiece.cc
${SRC}/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.cc
${SRC}/protobuf/src/google/protobuf/util/internal/error_listener.cc
${SRC}/protobuf/src/google/protobuf/util/internal/field_mask_utility.cc
${SRC}/protobuf/src/google/protobuf/util/internal/json_escaping.cc
${SRC}/protobuf/src/google/protobuf/util/internal/json_objectwriter.cc
${SRC}/protobuf/src/google/protobuf/util/internal/json_stream_parser.cc
${SRC}/protobuf/src/google/protobuf/util/internal/object_writer.cc
${SRC}/protobuf/src/google/protobuf/util/internal/proto_writer.cc
${SRC}/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc
${SRC}/protobuf/src/google/protobuf/util/internal/protostream_objectwriter.cc
${SRC}/protobuf/src/google/protobuf/util/internal/type_info.cc
${SRC}/protobuf/src/google/protobuf/util/internal/type_info_test_helper.cc
${SRC}/protobuf/src/google/protobuf/util/internal/utility.cc
${SRC}/protobuf/src/google/protobuf/util/json_util.cc
${SRC}/protobuf/src/google/protobuf/util/message_differencer.cc
${SRC}/protobuf/src/google/protobuf/util/time_util.cc
${SRC}/protobuf/src/google/protobuf/util/type_resolver_util.cc
${SRC}/protobuf/src/google/protobuf/wire_format.cc
${SRC}/protobuf/src/google/protobuf/wrappers.pb.cc
${SRC}/protobuf/src/google/protobuf/compiler/code_generator.cc
${SRC}/protobuf/src/google/protobuf/compiler/command_line_interface.cc
${SRC}/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc
${SRC}/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc
${SRC}/protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc
${SRC}/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc
${SRC}/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc
${SRC}/protobuf/src/google/protobuf/compiler/cpp/cpp_map_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc
${SRC}/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc
${SRC}/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc
${SRC}/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_enum.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_enum_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_field_base.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_generator.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_helpers.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_map_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_message.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_message_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc
${SRC}/protobuf/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_context.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_doc_comment.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_enum.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_enum_field_lite.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_enum_lite.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_extension.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_extension_lite.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_file.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_generator.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_generator_factory.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_helpers.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_map_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_map_field_lite.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_message.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_message_builder.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_message_builder_lite.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_message_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_message_field_lite.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_message_lite.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_name_resolver.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_primitive_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_service.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_string_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/java/java_string_field_lite.cc
${SRC}/protobuf/src/google/protobuf/compiler/js/js_generator.cc
${SRC}/protobuf/src/google/protobuf/compiler/js/well_known_types_embed.cc
${SRC}/protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum.cc
${SRC}/protobuf/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/objectivec/objectivec_extension.cc
${SRC}/protobuf/src/google/protobuf/compiler/objectivec/objectivec_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/objectivec/objectivec_file.cc
${SRC}/protobuf/src/google/protobuf/compiler/objectivec/objectivec_generator.cc
${SRC}/protobuf/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
${SRC}/protobuf/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/objectivec/objectivec_message.cc
${SRC}/protobuf/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc
${SRC}/protobuf/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
${SRC}/protobuf/src/google/protobuf/compiler/php/php_generator.cc
${SRC}/protobuf/src/google/protobuf/compiler/plugin.cc
${SRC}/protobuf/src/google/protobuf/compiler/plugin.pb.cc
${SRC}/protobuf/src/google/protobuf/compiler/python/python_generator.cc
${SRC}/protobuf/src/google/protobuf/compiler/ruby/ruby_generator.cc
${SRC}/protobuf/src/google/protobuf/compiler/subprocess.cc
${SRC}/protobuf/src/google/protobuf/compiler/zip_writer.cc
)
target_compile_definitions(libprotoc PRIVATE -DHAVE_ZLIB=1)
target_include_directories(libprotoc PRIVATE
${SRC}/protobuf/android
${SRC}/protobuf/src
)
add_executable(protoc ${SRC}/protobuf/src/google/protobuf/compiler/main.cc)
target_include_directories(protoc PRIVATE
${SRC}/protobuf/android
${SRC}/protobuf/src
)
target_link_libraries(protoc libprotoc liblog dl z)

74
cmake/libselinux.cmake Normal file
View File

@ -0,0 +1,74 @@
add_library(libselinux STATIC
${SRC}/selinux/libselinux/src/booleans.c
${SRC}/selinux/libselinux/src/callbacks.c
${SRC}/selinux/libselinux/src/freecon.c
${SRC}/selinux/libselinux/src/label_backends_android.c
${SRC}/selinux/libselinux/src/label.c
${SRC}/selinux/libselinux/src/label_support.c
${SRC}/selinux/libselinux/src/matchpathcon.c
${SRC}/selinux/libselinux/src/setrans_client.c
${SRC}/selinux/libselinux/src/sha1.c
${SRC}/selinux/libselinux/src/android/android.c
${SRC}/selinux/libselinux/src/avc.c
${SRC}/selinux/libselinux/src/avc_internal.c
${SRC}/selinux/libselinux/src/avc_sidtab.c
${SRC}/selinux/libselinux/src/canonicalize_context.c
${SRC}/selinux/libselinux/src/checkAccess.c
${SRC}/selinux/libselinux/src/check_context.c
${SRC}/selinux/libselinux/src/compute_av.c
${SRC}/selinux/libselinux/src/compute_create.c
${SRC}/selinux/libselinux/src/compute_member.c
${SRC}/selinux/libselinux/src/context.c
${SRC}/selinux/libselinux/src/deny_unknown.c
${SRC}/selinux/libselinux/src/disable.c
${SRC}/selinux/libselinux/src/enabled.c
${SRC}/selinux/libselinux/src/fgetfilecon.c
${SRC}/selinux/libselinux/src/fsetfilecon.c
${SRC}/selinux/libselinux/src/getenforce.c
${SRC}/selinux/libselinux/src/getfilecon.c
${SRC}/selinux/libselinux/src/get_initial_context.c
${SRC}/selinux/libselinux/src/getpeercon.c
${SRC}/selinux/libselinux/src/init.c
${SRC}/selinux/libselinux/src/lgetfilecon.c
${SRC}/selinux/libselinux/src/load_policy.c
${SRC}/selinux/libselinux/src/lsetfilecon.c
${SRC}/selinux/libselinux/src/mapping.c
${SRC}/selinux/libselinux/src/policyvers.c
${SRC}/selinux/libselinux/src/procattr.c
${SRC}/selinux/libselinux/src/reject_unknown.c
${SRC}/selinux/libselinux/src/sestatus.c
${SRC}/selinux/libselinux/src/setenforce.c
${SRC}/selinux/libselinux/src/setfilecon.c
${SRC}/selinux/libselinux/src/stringrep.c
${SRC}/selinux/libselinux/src/label_file.c
${SRC}/selinux/libselinux/src/regex.c
${SRC}/selinux/libselinux/src/selinux_config.c
${SRC}/selinux/libselinux/src/seusers.c
${SRC}/selinux/libselinux/src/android/android_platform.c
)
target_compile_definitions(libselinux PRIVATE
-DAUDITD_LOG_TAG=1003
-D_GNU_SOURCE
-DHOST
-DUSE_PCRE2
-DNO_PERSISTENTLY_STORED_PATTERNS
-DDISABLE_SETRANS
-DDISABLE_BOOL
-DNO_MEDIA_BACKEND
-DNO_X_BACKEND
-DNO_DB_BACKEND
-DPCRE2_CODE_UNIT_WIDTH=8
)
target_include_directories(libselinux PRIVATE
${SRC}/selinux/libselinux/include
${SRC}/selinux/libsepol/include
${SRC}/core/libcutils/include
${SRC}/logging/liblog/include
${SRC}/core/libpackagelistparser/include
${SRC}/pcre/include
)
target_include_directories(libselinux PRIVATE
${SRC}/selinux/libselinux/src
)

75
cmake/libsepol.cmake Normal file
View File

@ -0,0 +1,75 @@
add_library(libsepol STATIC
${SRC}/selinux/libsepol/src/assertion.c
${SRC}/selinux/libsepol/src/avrule_block.c
${SRC}/selinux/libsepol/src/avtab.c
${SRC}/selinux/libsepol/src/boolean_record.c
${SRC}/selinux/libsepol/src/booleans.c
${SRC}/selinux/libsepol/src/conditional.c
${SRC}/selinux/libsepol/src/constraint.c
${SRC}/selinux/libsepol/src/context.c
${SRC}/selinux/libsepol/src/context_record.c
${SRC}/selinux/libsepol/src/debug.c
${SRC}/selinux/libsepol/src/ebitmap.c
${SRC}/selinux/libsepol/src/expand.c
${SRC}/selinux/libsepol/src/handle.c
${SRC}/selinux/libsepol/src/hashtab.c
${SRC}/selinux/libsepol/src/hierarchy.c
${SRC}/selinux/libsepol/src/iface_record.c
${SRC}/selinux/libsepol/src/interfaces.c
${SRC}/selinux/libsepol/src/kernel_to_cil.c
${SRC}/selinux/libsepol/src/kernel_to_common.c
${SRC}/selinux/libsepol/src/kernel_to_conf.c
${SRC}/selinux/libsepol/src/link.c
${SRC}/selinux/libsepol/src/mls.c
${SRC}/selinux/libsepol/src/module.c
${SRC}/selinux/libsepol/src/module_to_cil.c
${SRC}/selinux/libsepol/src/node_record.c
${SRC}/selinux/libsepol/src/nodes.c
${SRC}/selinux/libsepol/src/optimize.c
${SRC}/selinux/libsepol/src/polcaps.c
${SRC}/selinux/libsepol/src/policydb.c
${SRC}/selinux/libsepol/src/policydb_convert.c
${SRC}/selinux/libsepol/src/policydb_public.c
${SRC}/selinux/libsepol/src/policydb_validate.c
${SRC}/selinux/libsepol/src/port_record.c
${SRC}/selinux/libsepol/src/ports.c
${SRC}/selinux/libsepol/src/services.c
${SRC}/selinux/libsepol/src/sidtab.c
${SRC}/selinux/libsepol/src/symtab.c
${SRC}/selinux/libsepol/src/user_record.c
${SRC}/selinux/libsepol/src/users.c
${SRC}/selinux/libsepol/src/util.c
${SRC}/selinux/libsepol/src/write.c
${SRC}/selinux/libsepol/cil/src/android.c
${SRC}/selinux/libsepol/cil/src/cil_binary.c
${SRC}/selinux/libsepol/cil/src/cil_build_ast.c
${SRC}/selinux/libsepol/cil/src/cil.c
${SRC}/selinux/libsepol/cil/src/cil_copy_ast.c
${SRC}/selinux/libsepol/cil/src/cil_find.c
${SRC}/selinux/libsepol/cil/src/cil_fqn.c
${SRC}/selinux/libsepol/cil/src/cil_lexer.l
${SRC}/selinux/libsepol/cil/src/cil_list.c
${SRC}/selinux/libsepol/cil/src/cil_log.c
${SRC}/selinux/libsepol/cil/src/cil_mem.c
${SRC}/selinux/libsepol/cil/src/cil_parser.c
${SRC}/selinux/libsepol/cil/src/cil_policy.c
${SRC}/selinux/libsepol/cil/src/cil_post.c
${SRC}/selinux/libsepol/cil/src/cil_reset_ast.c
${SRC}/selinux/libsepol/cil/src/cil_resolve_ast.c
${SRC}/selinux/libsepol/cil/src/cil_stack.c
${SRC}/selinux/libsepol/cil/src/cil_strpool.c
${SRC}/selinux/libsepol/cil/src/cil_symtab.c
${SRC}/selinux/libsepol/cil/src/cil_tree.c
${SRC}/selinux/libsepol/cil/src/cil_verify.c
${SRC}/selinux/libsepol/cil/src/cil_write_ast.c
)
target_compile_definitions(libsepol PRIVATE -D_GNU_SOURCE)
target_include_directories(libsepol PUBLIC
${SRC}/selinux/libselinux/include
${SRC}/selinux/libsepol/include
)
target_include_directories(libsepol PRIVATE
${SRC}/selinux/libsepol/src
${SRC}/selinux/libsepol/cil/include
)

13
cmake/libsparse.cmake Normal file
View File

@ -0,0 +1,13 @@
add_library(libsparse STATIC
${SRC}/core/libsparse/backed_block.cpp
${SRC}/core/libsparse/output_file.cpp
${SRC}/core/libsparse/sparse.cpp
${SRC}/core/libsparse/sparse_crc32.cpp
${SRC}/core/libsparse/sparse_err.cpp
${SRC}/core/libsparse/sparse_read.cpp
)
target_include_directories(libsparse PRIVATE
${SRC}/core/libsparse/include
${SRC}/libbase/include
)

35
cmake/libutils.cmake Normal file
View File

@ -0,0 +1,35 @@
add_library(libutils STATIC
${SRC}/core/libutils/Errors.cpp
${SRC}/core/libutils/FileMap.cpp
${SRC}/core/libutils/JenkinsHash.cpp
${SRC}/core/libutils/LightRefBase.cpp
${SRC}/core/libutils/NativeHandle.cpp
${SRC}/core/libutils/Printer.cpp
${SRC}/core/libutils/RefBase.cpp
${SRC}/core/libutils/SharedBuffer.cpp
${SRC}/core/libutils/StopWatch.cpp
${SRC}/core/libutils/String8.cpp
${SRC}/core/libutils/String16.cpp
${SRC}/core/libutils/StrongPointer.cpp
${SRC}/core/libutils/SystemClock.cpp
${SRC}/core/libutils/Threads.cpp
${SRC}/core/libutils/Timers.cpp
${SRC}/core/libutils/Tokenizer.cpp
${SRC}/core/libutils/Unicode.cpp
${SRC}/core/libutils/VectorImpl.cpp
${SRC}/core/libutils/misc.cpp
${SRC}/core/libutils/Trace.cpp
${SRC}/core/libutils/Looper.cpp
)
target_include_directories(libutils PRIVATE
${SRC}/core/include
${SRC}/core/libsystem/include
${SRC}/core/libvndksupport/include
${SRC}/core/libprocessgroup/include
${SRC}/core/libcutils/include
${SRC}/core/libutils/include
${SRC}/logging/liblog/include
${SRC}/libbase/include
)

22
cmake/libziparchive.cmake Normal file
View File

@ -0,0 +1,22 @@
add_library(libziparchive STATIC
${SRC}/libziparchive/zip_archive.cc
${SRC}/libziparchive/zip_archive_stream_entry.cc
${SRC}/libziparchive/zip_cd_entry_map.cc
${SRC}/libziparchive/zip_writer.cc
${SRC}/libziparchive/zip_error.cpp
${SRC}/libziparchive/incfs_support/signal_handling.cpp
)
target_compile_definitions(libziparchive PRIVATE
-DZLIB_CONST
-D_FILE_OFFSET_BITS=64
-DZIPARCHIVE_DISABLE_CALLBACK_API=1
)
target_include_directories(libziparchive PRIVATE
${SRC}/libziparchive/include
${SRC}/libziparchive/incfs_support/include
${SRC}/libbase/include
${SRC}/logging/liblog/include
${SRC}/boringssl/third_party/googletest/include
)

187
patches/aapt2.patch Normal file
View File

@ -0,0 +1,187 @@
Submodule src/base contains modified content
diff --git a/src/base/libs/androidfw/ResourceTypes.cpp b/src/base/libs/androidfw/ResourceTypes.cpp
index cae2d0bc16b3..13c5f8fc84e8 100644
--- a/src/base/libs/androidfw/ResourceTypes.cpp
+++ b/src/base/libs/androidfw/ResourceTypes.cpp
@@ -43,7 +43,7 @@
#include <utils/String16.h>
#include <utils/String8.h>
-#ifdef __ANDROID__
+#if 0
#include <binder/TextOutput.h>
#endif
diff --git a/src/base/tools/aapt2/ResourceTable.cpp b/src/base/tools/aapt2/ResourceTable.cpp
index 8ab1493c6ab3..3a855f0f6866 100644
--- a/src/base/tools/aapt2/ResourceTable.cpp
+++ b/src/base/tools/aapt2/ResourceTable.cpp
@@ -460,9 +460,7 @@ bool ResourceTable::AddResource(NewResource&& res, IDiagnostics* diag) {
const bool validate = validation_ == Validation::kEnabled;
const Source source = res.value ? res.value->GetSource() : Source{};
if (validate && !res.allow_mangled && !IsValidResourceEntryName(res.name.entry)) {
- diag->Error(DiagMessage(source)
- << "resource '" << res.name << "' has invalid entry name '" << res.name.entry);
- return false;
+ return true;
}
if (res.id.has_value() && !res.id->first.is_valid()) {
diff --git a/src/base/tools/aapt2/ResourceUtils.cpp b/src/base/tools/aapt2/ResourceUtils.cpp
index e0e80ac02dea..f74d7f106220 100644
--- a/src/base/tools/aapt2/ResourceUtils.cpp
+++ b/src/base/tools/aapt2/ResourceUtils.cpp
@@ -222,7 +222,7 @@ bool ParseAttributeReference(const StringPiece& str, ResourceNameRef* out_ref) {
}
if (!type.empty() && type != "attr") {
- return false;
+ // Apktool: Don't die out if private resource.
}
if (entry.empty()) {
diff --git a/src/base/tools/aapt2/Resources.proto b/src/base/tools/aapt2/Resources.proto
index 95b794964068..3cdadfd637e3 100644
--- a/src/base/tools/aapt2/Resources.proto
+++ b/src/base/tools/aapt2/Resources.proto
@@ -16,7 +16,7 @@
syntax = "proto3";
-import "frameworks/base/tools/aapt2/Configuration.proto";
+import "Configuration.proto";
package aapt.pb;
@@ -636,4 +636,4 @@ message StyleString {
message UntranslatableSection {
uint64 start_index = 1;
uint64 end_index = 2;
-}
\ No newline at end of file
+}
diff --git a/src/base/tools/aapt2/ResourcesInternal.proto b/src/base/tools/aapt2/ResourcesInternal.proto
index b0ed3da33368..97aa5af7724f 100644
--- a/src/base/tools/aapt2/ResourcesInternal.proto
+++ b/src/base/tools/aapt2/ResourcesInternal.proto
@@ -16,8 +16,8 @@
syntax = "proto3";
-import "frameworks/base/tools/aapt2/Configuration.proto";
-import "frameworks/base/tools/aapt2/Resources.proto";
+import "Configuration.proto";
+import "Resources.proto";
package aapt.pb.internal;
diff --git a/src/base/tools/aapt2/cmd/Link.cpp b/src/base/tools/aapt2/cmd/Link.cpp
index e4d0f3b6bd23..aa43ee07bfac 100644
--- a/src/base/tools/aapt2/cmd/Link.cpp
+++ b/src/base/tools/aapt2/cmd/Link.cpp
@@ -2326,9 +2326,9 @@ int LinkCommand::Action(const std::vector<std::string>& args) {
if (package_id_int > std::numeric_limits<uint8_t>::max()
|| package_id_int == kFrameworkPackageId
|| (!options_.allow_reserved_package_id && package_id_int < kAppPackageId)) {
- context.GetDiagnostics()->Error(
+ context.GetDiagnostics()->Warn(
DiagMessage() << StringPrintf(
- "invalid package ID 0x%02x. Must be in the range 0x7f-0xff.", package_id_int));
+ "invalid package ID 0x%02x. Must be in the range 0x7f-0xff. Ignoring...", package_id_int));
return 1;
}
context.SetPackageId(static_cast<uint8_t>(package_id_int));
@@ -2410,6 +2410,23 @@ int LinkCommand::Action(const std::vector<std::string>& args) {
".mpg", ".mpeg", ".mp4", ".m4a", ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2", ".wma", ".wmv",
".webm", ".mkv"});
+ // Populate no compress extensions specified in the extensions file.
+ if (options_.extensions_to_not_compress_path) {
+ std::ifstream extensionsFile(options_.extensions_to_not_compress_path.value());
+
+ if (extensionsFile.fail()) {
+ context.GetDiagnostics()->Error(
+ DiagMessage() << "could not open extensions file "
+ << options_.extensions_to_not_compress_path.value()
+ << " for reading");
+ return 1;
+ }
+
+ for (std::string line; getline(extensionsFile, line);) {
+ options_.extensions_to_not_compress.insert(line);
+ }
+ }
+
// Turn off auto versioning for static-libs.
if (context.GetPackageType() == PackageType::kStaticLib) {
options_.no_auto_version = true;
diff --git a/src/base/tools/aapt2/cmd/Link.h b/src/base/tools/aapt2/cmd/Link.h
index 768b4b2c7bfd..6dd220515674 100644
--- a/src/base/tools/aapt2/cmd/Link.h
+++ b/src/base/tools/aapt2/cmd/Link.h
@@ -71,6 +71,7 @@ struct LinkOptions {
bool do_not_compress_anything = false;
std::unordered_set<std::string> extensions_to_not_compress;
Maybe<std::regex> regex_to_not_compress;
+ Maybe<std::string> extensions_to_not_compress_path;
// Static lib options.
bool no_static_lib_packages = false;
@@ -272,6 +273,8 @@ class LinkCommand : public Command {
&options_.manifest_fixer_options.rename_overlay_target_package);
AddOptionalFlagList("-0", "File suffix not to compress.",
&options_.extensions_to_not_compress);
+ AddOptionalFlag("-e", "File containing list of extensions not to compress.",
+ &options_.extensions_to_not_compress_path);
AddOptionalSwitch("--no-compress", "Do not compress any resources.",
&options_.do_not_compress_anything);
AddOptionalSwitch("--keep-raw-values", "Preserve raw attribute values in xml files.",
diff --git a/src/base/tools/aapt2/java/JavaClassGenerator.cpp b/src/base/tools/aapt2/java/JavaClassGenerator.cpp
index de6524dc7027..0a968c11a13b 100644
--- a/src/base/tools/aapt2/java/JavaClassGenerator.cpp
+++ b/src/base/tools/aapt2/java/JavaClassGenerator.cpp
@@ -58,6 +58,8 @@ static const std::set<StringPiece> sJavaIdentifiers = {
"true", "false", "null"};
static bool IsValidSymbol(const StringPiece& symbol) {
+ // Apktool: Everything is a valid symbol
+ return true;
return sJavaIdentifiers.find(symbol) == sJavaIdentifiers.end();
}
diff --git a/src/base/tools/aapt2/link/PrivateAttributeMover.cpp b/src/base/tools/aapt2/link/PrivateAttributeMover.cpp
index 675b02a7e161..fb2b11da5ee4 100644
--- a/src/base/tools/aapt2/link/PrivateAttributeMover.cpp
+++ b/src/base/tools/aapt2/link/PrivateAttributeMover.cpp
@@ -81,7 +81,6 @@ bool PrivateAttributeMover::Consume(IAaptContext* context, ResourceTable* table)
}
ResourceTableType* priv_attr_type = package->FindOrCreateType(ResourceType::kAttrPrivate);
- CHECK(priv_attr_type->entries.empty());
priv_attr_type->entries = std::move(private_attr_entries);
}
return true;
diff --git a/src/base/tools/aapt2/util/Util.cpp b/src/base/tools/aapt2/util/Util.cpp
index d7a8e6fe6ada..74457add2e6b 100644
--- a/src/base/tools/aapt2/util/Util.cpp
+++ b/src/base/tools/aapt2/util/Util.cpp
@@ -23,7 +23,6 @@
#include "android-base/stringprintf.h"
#include "androidfw/StringPiece.h"
-#include "build/version.h"
#include "text/Unicode.h"
#include "text/Utf8Iterator.h"
@@ -231,10 +230,7 @@ std::string GetToolFingerprint() {
// Update minor version whenever a feature or flag is added.
static const char* const sMinorVersion = "19";
- // The build id of aapt2 binary.
- static const std::string sBuildId = android::build::GetBuildNumber();
-
- return android::base::StringPrintf("%s.%s-%s", sMajorVersion, sMinorVersion, sBuildId.c_str());
+ return android::base::StringPrintf("%s.%s", sMajorVersion, sMinorVersion);
}
static size_t ConsumeDigits(const char* start, const char* end) {

38
patches/boringssl.patch Normal file
View File

@ -0,0 +1,38 @@
Submodule src/boringssl contains modified content
diff --git a/src/boringssl/CMakeLists.txt b/src/boringssl/CMakeLists.txt
index dad27f815..11e517b52 100644
--- a/src/boringssl/CMakeLists.txt
+++ b/src/boringssl/CMakeLists.txt
@@ -499,12 +499,26 @@ else()
message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
endif()
-if(ANDROID AND NOT ANDROID_NDK_REVISION AND ARCH STREQUAL "arm")
- # The third-party Android-NDK CMake files somehow fail to set the -march flag
- # for assembly files. Without this flag, the compiler believes that it's
- # building for ARMv5.
- set(CMAKE_ASM_FLAGS "-march=${CMAKE_SYSTEM_PROCESSOR} ${CMAKE_ASM_FLAGS}")
-endif()
+# set ARCH and MARCH
+set(ARCH ${TARGET_ABI})
+set(MARCH ${ARCH})
+if(TARGET_ABI STREQUAL "arm")
+ set(MARCH "armv7-a")
+elseif(TARGET_ABI STREQUAL "aarch64")
+ set(MARCH "armv8-a")
+elseif(TARGET_ABI STREQUAL "x86")
+ set(MARCH "i686")
+elseif(TARGET_ABI STREQUAL "x86_64")
+ set(MARCH "x86_64")
+endif()
+
+# set -march flag
+ if(ANDROID AND NOT ANDROID_NDK_REVISION AND ARCH STREQUAL "arm")
+ # The third-party Android-NDK CMake files somehow fail to set the -march flag
+ # for assembly files. Without this flag, the compiler believes that it's
+ # building for ARMv5.
+ set(CMAKE_ASM_FLAGS "-march=${MARCH} ${CMAKE_ASM_FLAGS}")
+ endif()
if(USE_CUSTOM_LIBCXX)
if(NOT CLANG)

View File

@ -0,0 +1,246 @@
Submodule src/incremental_delivery contains modified content
diff --git a/src/incremental_delivery/sysprop/IncrementalProperties.sysprop.cpp b/src/incremental_delivery/sysprop/IncrementalProperties.sysprop.cpp
new file mode 100644
index 0000000..dfe0671
--- /dev/null
+++ b/src/incremental_delivery/sysprop/IncrementalProperties.sysprop.cpp
@@ -0,0 +1,217 @@
+// Generated by the sysprop generator. DO NOT EDIT!
+
+#include <IncrementalProperties.sysprop.h>
+#include <strings.h>
+
+#include <cctype>
+#include <cerrno>
+#include <cstdio>
+#include <cstring>
+#include <limits>
+#include <utility>
+#ifdef __BIONIC__
+#include <sys/system_properties.h>
+[[maybe_unused]] static bool SetProp(const char* key, const char* value) {
+ return __system_property_set(key, value) == 0;
+}
+#else
+#include <android-base/properties.h>
+[[maybe_unused]] static bool SetProp(const char* key, const char* value) {
+ android::base::SetProperty(key, value);
+ return true;
+}
+#endif
+
+#include <android-base/parseint.h>
+#include <log/log.h>
+
+namespace {
+
+using namespace android::sysprop::IncrementalProperties;
+
+template <typename T>
+T DoParse(const char* str);
+
+template <typename T>
+constexpr bool is_vector = false;
+
+template <typename T>
+constexpr bool is_vector<std::vector<T>> = true;
+
+template <>
+[[maybe_unused]] std::optional<bool> DoParse(const char* str) {
+ static constexpr const char* kYes[] = {"1", "true"};
+ static constexpr const char* kNo[] = {"0", "false"};
+
+ for (const char* yes : kYes) {
+ if (strcasecmp(yes, str) == 0) return std::make_optional(true);
+ }
+
+ for (const char* no : kNo) {
+ if (strcasecmp(no, str) == 0) return std::make_optional(false);
+ }
+
+ return std::nullopt;
+}
+
+template <>
+[[maybe_unused]] std::optional<std::int32_t> DoParse(const char* str) {
+ std::int32_t ret;
+ return android::base::ParseInt(str, &ret) ? std::make_optional(ret) : std::nullopt;
+}
+
+template <>
+[[maybe_unused]] std::optional<std::uint32_t> DoParse(const char* str) {
+ std::uint32_t ret;
+ return android::base::ParseUint(str, &ret) ? std::make_optional(ret) : std::nullopt;
+}
+
+template <>
+[[maybe_unused]] std::optional<std::int64_t> DoParse(const char* str) {
+ std::int64_t ret;
+ return android::base::ParseInt(str, &ret) ? std::make_optional(ret) : std::nullopt;
+}
+
+template <>
+[[maybe_unused]] std::optional<std::uint64_t> DoParse(const char* str) {
+ std::uint64_t ret;
+ return android::base::ParseUint(str, &ret) ? std::make_optional(ret) : std::nullopt;
+}
+
+template <>
+[[maybe_unused]] std::optional<double> DoParse(const char* str) {
+ int old_errno = errno;
+ errno = 0;
+ char* end;
+ double ret = std::strtod(str, &end);
+ if (errno != 0) {
+ return std::nullopt;
+ }
+ if (str == end || *end != '\0') {
+ errno = EINVAL;
+ return std::nullopt;
+ }
+ errno = old_errno;
+ return std::make_optional(ret);
+}
+
+template <>
+[[maybe_unused]] std::optional<std::string> DoParse(const char* str) {
+ return *str == '\0' ? std::nullopt : std::make_optional(str);
+}
+
+template <typename Vec>
+[[maybe_unused]] Vec DoParseList(const char* str) {
+ Vec ret;
+ if (*str == '\0') return ret;
+ const char* p = str;
+ for (;;) {
+ const char* r = p;
+ std::string value;
+ while (*r != ',') {
+ if (*r == '\\') ++r;
+ if (*r == '\0') break;
+ value += *r++;
+ }
+ ret.emplace_back(DoParse<typename Vec::value_type>(value.c_str()));
+ if (*r == '\0') break;
+ p = r + 1;
+ }
+ return ret;
+}
+
+template <typename T>
+inline T TryParse(const char* str) {
+ if constexpr (is_vector<T>) {
+ return DoParseList<T>(str);
+ } else {
+ return DoParse<T>(str);
+ }
+}
+
+[[maybe_unused]] std::string FormatValue(const std::optional<std::int32_t>& value) {
+ return value ? std::to_string(*value) : "";
+}
+
+[[maybe_unused]] std::string FormatValue(const std::optional<std::uint32_t>& value) {
+ return value ? std::to_string(*value) : "";
+}
+
+[[maybe_unused]] std::string FormatValue(const std::optional<std::int64_t>& value) {
+ return value ? std::to_string(*value) : "";
+}
+
+[[maybe_unused]] std::string FormatValue(const std::optional<std::uint64_t>& value) {
+ return value ? std::to_string(*value) : "";
+}
+
+[[maybe_unused]] std::string FormatValue(const std::optional<double>& value) {
+ if (!value) return "";
+ char buf[1024];
+ std::sprintf(buf, "%.*g", std::numeric_limits<double>::max_digits10, *value);
+ return buf;
+}
+
+[[maybe_unused]] std::string FormatValue(const std::optional<bool>& value) {
+ return value ? (*value ? "true" : "false") : "";
+}
+
+template <typename T>
+[[maybe_unused]] std::string FormatValue(const std::vector<T>& value) {
+ if (value.empty()) return "";
+
+ std::string ret;
+ bool first = true;
+
+ for (auto&& element : value) {
+ if (!first)
+ ret += ',';
+ else
+ first = false;
+ if constexpr (std::is_same_v<T, std::optional<std::string>>) {
+ if (element) {
+ for (char c : *element) {
+ if (c == '\\' || c == ',') ret += '\\';
+ ret += c;
+ }
+ }
+ } else {
+ ret += FormatValue(element);
+ }
+ }
+
+ return ret;
+}
+
+template <typename T>
+T GetProp(const char* key, const char* legacy = nullptr) {
+ std::string value;
+#ifdef __BIONIC__
+ auto pi = __system_property_find(key);
+ if (pi != nullptr) {
+ __system_property_read_callback(
+ pi,
+ [](void* cookie, const char*, const char* value, std::uint32_t) {
+ *static_cast<std::string*>(cookie) = value;
+ },
+ &value);
+ }
+#else
+ value = android::base::GetProperty(key, "");
+#endif
+ if (value.empty() && legacy) {
+ ALOGV("prop %s doesn't exist; fallback to legacy prop %s", key, legacy);
+ return GetProp<T>(legacy);
+ }
+ return TryParse<T>(value.c_str());
+}
+
+} // namespace
+
+namespace android::sysprop::IncrementalProperties {
+
+std::optional<std::string> enable() {
+ return GetProp<std::optional<std::string>>("ro.incremental.enable");
+}
+
+} // namespace android::sysprop::IncrementalProperties
\ No newline at end of file
diff --git a/src/incremental_delivery/sysprop/include/IncrementalProperties.sysprop.h b/src/incremental_delivery/sysprop/include/IncrementalProperties.sysprop.h
new file mode 100644
index 0000000..19e2fea
--- /dev/null
+++ b/src/incremental_delivery/sysprop/include/IncrementalProperties.sysprop.h
@@ -0,0 +1,14 @@
+// Generated by the sysprop generator. DO NOT EDIT!
+
+#pragma once
+
+#include <cstdint>
+#include <optional>
+#include <string>
+#include <vector>
+
+namespace android::sysprop::IncrementalProperties {
+
+std::optional<std::string> enable();
+
+} // namespace android::sysprop::IncrementalProperties
\ No newline at end of file

27
patches/libpng.patch Normal file
View File

@ -0,0 +1,27 @@
Submodule src/libpng contains modified content
diff --git a/src/libpng/CMakeLists.txt b/src/libpng/CMakeLists.txt
index 6451fcf1b..bccd2ef74 100644
--- a/src/libpng/CMakeLists.txt
+++ b/src/libpng/CMakeLists.txt
@@ -36,18 +36,18 @@ include(GNUInstallDirs)
# Allow users to specify location of Zlib.
# Useful if zlib is being built alongside this as a sub-project.
-option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" OFF)
+option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" ON)
if(NOT PNG_BUILD_ZLIB)
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIR})
endif()
-if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
+if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU AND NOT ANDROID)
find_library(M_LIBRARY m)
else()
# libm is not needed and/or not available
- set(M_LIBRARY "")
+ set(M_LIBRARY "m")
endif()
# COMMAND LINE OPTIONS

14
patches/protobuf.patch Normal file
View File

@ -0,0 +1,14 @@
Submodule src/protobuf contains modified content
diff --git a/src/protobuf/cmake/CMakeLists.txt b/src/protobuf/cmake/CMakeLists.txt
index ebc7b0c98..cda9ba109 100644
--- a/src/protobuf/cmake/CMakeLists.txt
+++ b/src/protobuf/cmake/CMakeLists.txt
@@ -29,7 +29,7 @@ else()
endif()
# Options
-option(protobuf_BUILD_TESTS "Build tests" ON)
+option(protobuf_BUILD_TESTS "Build tests" OFF)
option(protobuf_BUILD_CONFORMANCE "Build conformance tests" OFF)
option(protobuf_BUILD_EXAMPLES "Build examples" OFF)
option(protobuf_BUILD_PROTOC_BINARIES "Build libprotoc and protoc compiler" ON)

105
patches/selinux.patch Normal file
View File

@ -0,0 +1,105 @@
Submodule src/selinux contains modified content
diff --git a/src/selinux/libsepol/src/private.h b/src/selinux/libsepol/src/private.h
index a8cc1472..317eb7c0 100644
--- a/src/selinux/libsepol/src/private.h
+++ b/src/selinux/libsepol/src/private.h
@@ -4,7 +4,6 @@
#include <sepol/policydb/policydb.h>
-
#ifdef __APPLE__
#include <sys/types.h>
#include <machine/endian.h>
@@ -16,8 +15,8 @@
#include <errno.h>
#ifdef __APPLE__
-#define __BYTE_ORDER BYTE_ORDER
-#define __LITTLE_ENDIAN LITTLE_ENDIAN
+#define __BYTE_ORDER BYTE_ORDER
+#define __LITTLE_ENDIAN LITTLE_ENDIAN
#endif
#if __BYTE_ORDER == __LITTLE_ENDIAN
@@ -37,17 +36,17 @@
#endif
#undef min
-#define min(a,b) (((a) < (b)) ? (a) : (b))
+#define min(a, b) (((a) < (b)) ? (a) : (b))
#undef max
-#define max(a,b) ((a) >= (b) ? (a) : (b))
+#define max(a, b) ((a) >= (b) ? (a) : (b))
-#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
-# define is_saturated(x) (x == (typeof(x))-1 || (x) > (1U << 16))
+#define is_saturated(x) (x == (typeof(x))-1 || (x) > (1U << 16))
#else
-# define is_saturated(x) (x == (typeof(x))-1)
+#define is_saturated(x) (x == (typeof(x))-1)
#endif
#define zero_or_saturated(x) ((x == 0) || is_saturated(x))
@@ -57,16 +56,17 @@
/* Use to ignore intentional unsigned under- and overflows while running under UBSAN. */
#if defined(__clang__) && defined(__clang_major__) && (__clang_major__ >= 4)
#if (__clang_major__ >= 12)
-#define ignore_unsigned_overflow_ __attribute__((no_sanitize("unsigned-integer-overflow", "unsigned-shift-base")))
+#define ignore_unsigned_overflow_ __attribute__((no_sanitize("unsigned-integer-overflow", "unsigned-shift-base")))
#else
-#define ignore_unsigned_overflow_ __attribute__((no_sanitize("unsigned-integer-overflow")))
+#define ignore_unsigned_overflow_ __attribute__((no_sanitize("unsigned-integer-overflow")))
#endif
#else
#define ignore_unsigned_overflow_
#endif
/* Policy compatibility information. */
-struct policydb_compat_info {
+struct policydb_compat_info
+{
unsigned int type;
unsigned int version;
unsigned int sym_num;
@@ -75,31 +75,11 @@ struct policydb_compat_info {
};
extern const struct policydb_compat_info *policydb_lookup_compat(unsigned int version,
- unsigned int type,
- unsigned int target_platform);
+ unsigned int type,
+ unsigned int target_platform);
/* Reading from a policy "file". */
extern int next_entry(void *buf, struct policy_file *fp, size_t bytes);
extern size_t put_entry(const void *ptr, size_t size, size_t n,
- struct policy_file *fp);
-extern int str_read(char **strp, struct policy_file *fp, size_t len);
-
-static inline void* mallocarray(size_t nmemb, size_t size) {
- if (size && nmemb > (size_t)-1 / size) {
- errno = ENOMEM;
- return NULL;
- }
-
- return malloc(nmemb * size);
-}
-
-#ifndef HAVE_REALLOCARRAY
-static inline void* reallocarray(void *ptr, size_t nmemb, size_t size) {
- if (size && nmemb > (size_t)-1 / size) {
- errno = ENOMEM;
- return NULL;
- }
-
- return realloc(ptr, nmemb * size);
-}
-#endif
+ struct policy_file *fp);
+extern int str_read(char **strp, struct policy_file *fp, size_t len);
\ No newline at end of file

1
src/base Submodule

@ -0,0 +1 @@
Subproject commit d2915246863e751d0de0689dcbce03ed775ef5df

1
src/boringssl Submodule

@ -0,0 +1 @@
Subproject commit 59e37765f1dbc63a121153f664505cf65499e66c

1
src/core Submodule

@ -0,0 +1 @@
Subproject commit cef4850d9ff93abd130a3aa02c2a9938d05f6743

1
src/expat Submodule

@ -0,0 +1 @@
Subproject commit 01b2b0b20366eb53dcb1b035562d1c1ba3eef5ba

1
src/fmtlib Submodule

@ -0,0 +1 @@
Subproject commit 0c022da6e7ebffb69174b485b16bc6b1c5395aa2

@ -0,0 +1 @@
Subproject commit 0c13909a84775840c6889a049634741a3c2ec1cc

1
src/libbase Submodule

@ -0,0 +1 @@
Subproject commit 91dd3ec47778ca65e3aae19f194995fbbb174e70

1
src/libpng Submodule

@ -0,0 +1 @@
Subproject commit ddf60efd0382e7699308ca4d72d88e22ed8cc7a6

1
src/libziparchive Submodule

@ -0,0 +1 @@
Subproject commit a995a52802ae884cf71a9cc836e93a8b2f904b6f

1
src/logging Submodule

@ -0,0 +1 @@
Subproject commit 7c5c7094ef903bef02428f873ccd47c90443ba34

1
src/pcre Submodule

@ -0,0 +1 @@
Subproject commit 35cca826d10f3d9325a846b3a0f8ab07e25553fe

1
src/protobuf Submodule

@ -0,0 +1 @@
Subproject commit 6cb79dee0c4cfc5acfc2bfd48be5a676f58efb92

1
src/selinux Submodule

@ -0,0 +1 @@
Subproject commit e52b1a6bb582fa9a76f5644ff3f335d03e02cabc

1
src/zopfli Submodule

@ -0,0 +1 @@
Subproject commit 0ba865af92b306705feea4a6d6f6b02c82902ad1