Skip to content

Commit

Permalink
feat: Build gnu tar via cmake
Browse files Browse the repository at this point in the history
Change-Id: I41ea37eef43637b01e5ad03f64f878779b9864b4
  • Loading branch information
XayahSuSuSu committed Dec 14, 2024
1 parent d03e099 commit 40c58c1
Show file tree
Hide file tree
Showing 55 changed files with 35,057 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "source/native/src/main/jni/external/tar/tar"]
path = source/native/src/main/jni/external/tar/tar
url = https://github.com/XayahSuSuSu/tar
29 changes: 27 additions & 2 deletions build/build_bin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,30 @@ build_zstd() {
rm -rf zstd-$ZSTD_VERSION
}

build_external() {
cp -r $ROOT_PATH/../source/native/src/main/jni jni
cd jni
sed -i '/^# add_subdirectory(external)/s/^# //' CMakeLists.txt
sed -i '/^add_subdirectory(nativelib)/s/^/# /' CMakeLists.txt
mkdir builddir && cd builddir
cmake \
-DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=$TARGET_ARCH \
-DANDROID_NATIVE_API_LEVEL=$API \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX= \
-DCMAKE_EXE_LINKER_FLAGS="$BUILD_LDFLAGS_STATIC" \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} $BUILD_CFLAGS" \
-DCMAKE_CXX_FLAGS="${CMAKE_C_FLAGS} $BUILD_CFLAGS" \
..
make -j8
make install prefix= DESTDIR=$LOCAL_PATH/external

$STRIP $LOCAL_PATH/external/bin/tar
cd ../../
rm -rf jni
}

build_busybox() {
git clone https://github.com/XayahSuSuSu/ndk-box-kitchen -b $NDK_VERSION && cd ndk-box-kitchen
wget https://git.busybox.net/busybox/snapshot/busybox-$BUSYBOX_VERSION.tar.bz2
Expand All @@ -228,13 +252,14 @@ build_busybox() {
build_built_in() {
build_zstd
build_busybox
build_external
}

package_built_in() {
# Built-in modules
mkdir -p built_in/$TARGET_ARCH
echo "$BIN_VERSION" > built_in/version
zip -pj built_in/$TARGET_ARCH/bin built_in/version zstd/bin/zstd busybox/bin/busybox
zip -pj built_in/$TARGET_ARCH/bin built_in/version zstd/bin/zstd busybox/bin/busybox external/bin/tar
strip-nondeterminism built_in/$TARGET_ARCH/bin.zip
}

Expand Down Expand Up @@ -262,7 +287,7 @@ package() {
esac
}
##################################################

ROOT_PATH=$(dirname $(readlink -f "$0"))
# Start to build
set_up_utils

Expand Down
2 changes: 1 addition & 1 deletion source/native/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ android {
}
externalNativeBuild {
cmake {
path("src/main/cpp/CMakeLists.txt")
path("src/main/jni/CMakeLists.txt")
version = "3.22.1"
}
}
Expand Down
15 changes: 0 additions & 15 deletions source/native/src/main/cpp/CMakeLists.txt

This file was deleted.

6 changes: 6 additions & 0 deletions source/native/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.22.1)

project("native")

add_subdirectory(nativelib)
# add_subdirectory(external)
1 change: 1 addition & 0 deletions source/native/src/main/jni/external/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(tar)
Loading

0 comments on commit 40c58c1

Please sign in to comment.