All Projects → lizhangqu → aapt-cmake-buildscript

lizhangqu / aapt-cmake-buildscript

Licence: other
aapt cmake构建系统,支持mac和linux(ubuntu 16.0.4)构建,支持linux(ubuntu 16.0.4)交叉编译windows版本,支持x86和x86_64构建

Programming Languages

CMake
9771 projects

Projects that are alternatives of or similar to aapt-cmake-buildscript

aapt-repo-manifest
aapt cmake 构建 核心repo manifest, 支持mac和linux(ubuntu 16.0.4)构建,支持linux(ubuntu 16.0.4)交叉编译windows的版本
Stars: ✭ 18 (-35.71%)
Mutual labels:  repo, aosp, aapt, mingw-w64, aapt2
ng-mono-repo-starter
Angular Mono Repo Starter
Stars: ✭ 79 (+182.14%)
Mutual labels:  repo
AOSP-Kayboard-7.1.2
Full functional AOSP Keyboard with glide typing
Stars: ✭ 33 (+17.86%)
Mutual labels:  aosp
device xiaomi begonia
Dependency of Xiaomi Redmi Note 8 Pro (begonia)
Stars: ✭ 26 (-7.14%)
Mutual labels:  aosp
Kopano
Scripts for Kopano
Stars: ✭ 25 (-10.71%)
Mutual labels:  repo
decimation.github.io
Cydia repo
Stars: ✭ 18 (-35.71%)
Mutual labels:  repo
repogen
Easy-to-use signed APT repository generator with a web-based package browser.
Stars: ✭ 34 (+21.43%)
Mutual labels:  repo
addon-check
Automatic checks for new repository submissions
Stars: ✭ 45 (+60.71%)
Mutual labels:  repo
Silica
A static site generator for MobileAPT repos.
Stars: ✭ 129 (+360.71%)
Mutual labels:  repo
bashy
Extremely fast and simple git prompt for bash and zsh
Stars: ✭ 43 (+53.57%)
Mutual labels:  repo
awesome-git-commands
🍴 Indispensable git commands for everyday use
Stars: ✭ 53 (+89.29%)
Mutual labels:  repo
github-interact-cli
🎩 Interact with GItHub right inside your terminal
Stars: ✭ 43 (+53.57%)
Mutual labels:  repo
tainted
Tool to determine which Go packages need to be rebuilt in a monorepo
Stars: ✭ 53 (+89.29%)
Mutual labels:  repo
CyberPunkNetrunner
Cyberpunk 2077 Netrunner Hacking Tool (Easy to use and install). Don't use it on illegal and malicious activity. Inspired by the game CyberPunk 2077 https://www.cyberpunk.net/
Stars: ✭ 69 (+146.43%)
Mutual labels:  repo
Instant-Face-Unlock
Xposed Module's InstantFaceUnlock Code
Stars: ✭ 23 (-17.86%)
Mutual labels:  aosp
Animations
Beautiful animations from AOSP
Stars: ✭ 35 (+25%)
Mutual labels:  aosp
setup-mingw
GitHub action to set up MinGW-w64
Stars: ✭ 51 (+82.14%)
Mutual labels:  mingw-w64
pulseaudio-win32
An up-to-date PulseAudio build for Windows with an installer, service, socket support, bug fixes, and new features.
Stars: ✭ 38 (+35.71%)
Mutual labels:  mingw-w64
discord-emoji
[Library/Deno] A near exact emoji tables of Discord for string-based insertion of emotes without having to escape Unicode.
Stars: ✭ 37 (+32.14%)
Mutual labels:  cross-compile
git-repo-name
Get the repository name from the git remote origin URL
Stars: ✭ 21 (-25%)
Mutual labels:  repo

aapt cmake buildscript

查看manifest仓库请转移到 https://github.com/lizhangqu/aapt-repo-manifest

for mac

创建大小写敏感磁盘

hdiutil create -volname "aapt" -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 10g aapt.dmg

挂载

hdiutil attach aapt.dmg.sparseimage -mountpoint /Volumes/aapt

卸载

hdiutil detach /Volumes/aapt

for linux(Ubuntu 16.0.4)

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install openjdk-8-jdk
sudo apt-get install cmake
sudo apt-get install clang
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip

for windows(Ubuntu 16.0.4下使用MinGw进行交叉编译)

当前windows可执行文件和动态库的版本只能在linux(Ubuntu 16.0.4)上进行交叉编译产生,需要安装MinGw

sudo apt-get install mingw-w64

安装完成后,mingw-gcc和mingw-g++默认使用的线程模型是win32的,但是我们需要使用posix的线程模型,因此分别执行以下命令,将工具链指向带-posix后缀的工具链

sudo update-alternatives --config x86_64-w64-mingw32-gcc
sudo update-alternatives --config x86_64-w64-mingw32-g++
sudo update-alternatives --config x86_64-w64-mingw32-gfortran
sudo update-alternatives --config x86_64-w64-mingw32-gnat

sudo update-alternatives --config i686-w64-mingw32-gcc
sudo update-alternatives --config i686-w64-mingw32-g++
sudo update-alternatives --config i686-w64-mingw32-gfortran
sudo update-alternatives --config i686-w64-mingw32-gnat

如果交叉编译构建过程中发生了如下错误

error: ‘_Atomic’ does not name a type
 typedef _Atomic _Bool atomic_bool;

请将system/core/libcutils/include/cutils/atomic.h头文件中的#include <stdatomic.h>部分

改为

#if defined(_WIN32)
    #ifdef __cplusplus
    #include <atomic>
    using namespace std;
    #else
    #include <stdatomic.h>
    #endif
#else
    #include <stdatomic.h>
#endif

构建

安装repo

mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

初始化repo项目

#进入工作目录
cd /Volumes/aapt
#如果存在repo bundle下载不下来的情况,请使用下面的命令进行手动clone
#git clone http://mirrors.ustc.edu.cn/aosp/git-repo.git/ .repo/repo
#初始化并同步源码树,约3G
repo init -u https://github.com/lizhangqu/aapt-repo-manifest.git -b android-9.0.0_r10
repo sync -j8

执行构建,构建过程中发生错误请自行根据提示安装对应的依赖库,下面是mac和linux的构建步骤

#进入工作目录
cd /Volumes/aapt
#使用cmake生成构建文件,并最小化编译产物,这一步的生成主要是为了生成protobuffer相关文件
cmake -H"./" -B"./build-cmake" -DCMAKE_BUILD_TYPE=MinSizeRel
#生成aapt2所需的protobuffer头文件和cpp文件
cmake --build "./build-cmake" --target protobuffer_h -- -j 8
#重新生成构建文件,因为之前生成的时候,protobuffer相关文件不存在,需要重新生成,如果可以直接编译通过,这一步可省略
cmake -H"./" -B"./build-cmake" -DCMAKE_BUILD_TYPE=MinSizeRel
#编译aapt
cmake --build "./build-cmake" --target aapt -- -j 8
#编译aapt2
cmake --build "./build-cmake" --target aapt2 -- -j 8
#编译aapt2_jni
cmake --build "./build-cmake" --target aapt2_jni -- -j 8

交叉编译时,如果需要指定交叉编译工具链的路径,则使用如下命令传递对应参数

cmake -H"./" -B"./build-cmake" -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=windows.toolchain.cmake

windows可执行文件需要在Ubuntu 16.0.4下进行交叉编译,进行交叉编译前,需要将system/core/libcutils/include/cutils/atomic.h头文件中的#include <stdatomic.h>部分修改为

#if defined(_WIN32)
    #ifdef __cplusplus
    #include <atomic>
    using namespace std;
    #else
    #include <stdatomic.h>
    #endif
#else
    #include <stdatomic.h>
#endif

原因是引用的头文件stdatomic.h不是标准的c++部分,而clang可以支持兼容掉这部分,但是交叉编译工具链MinGW g++不支持,因此需要引用标准的C++中的atomic头文件。

并且交叉编译工具链不支持在linux下执行windows的可执行文件,因此aapt2需要的protobuffer头文件需要在linux用linux可执行文件生成,具体的完整流程如下

#进入工作目录
cd /Volumes/aapt
#使用cmake生成linux构建文件,并最小化编译产物
cmake -H"./" -B"./build-cmake-linux" -DCMAKE_BUILD_TYPE=MinSizeRel
#使用linux环境生成aapt2所需的头文件
cmake --build "./build-cmake-linux" --target protobuffer_h -- -j 8

#使用cmake生成windows交叉编译构建文件,并最小化编译产物
cmake -H"./" -B"./build-cmake-windows" -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=windows.toolchain.cmake

#编译aapt
cmake --build "./build-cmake-windows" --target aapt -- -j 8
#编译aapt2
cmake --build "./build-cmake-windows" --target aapt2 -- -j 8
#编译aapt2_jni
cmake --build "./build-cmake-windows" --target aapt2_jni -- -j 8
#最终windows下的可执行文件和动态库生成都位于build-cmake-windows目录下

如果需要编译32位的可执行文件,在生产cmake文件的时候,添加-DUSE_32BITS=1参数,如

#linux或者mac
cmake -H"./" -B"./build-cmake-unix-x86" -DCMAKE_BUILD_TYPE=MinSizeRel -DUSE_32BITS=1
#windows交叉编译
cmake -H"./" -B"./build-cmake-windows-x86" -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=windows.toolchain.cmake -DUSE_32BITS=1
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].