-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional non-cross-compilation support? #165
Comments
I went ahead and finished my demo enough to post the proof of concept since it is sort of working. Build official NDK sample with cross-compilation disabled
pkg install wget git
wget https://github.com/user-attachments/files/17145163/ndk_27b_all.deb.txt -O ndk_27b_all.deb
apt install ./ndk_27b_all.deb
git clone -b android-mk https://github.com/android/ndk-samples.git
cd ndk-samples/hello-jni/jni/
ndk-build Build and run
|
Unfinished
|
I forgot to mention this earlier but recently I have tested # (after installing the ndk_27b_all.deb from above)
echo "Pkg.Desc = Android NDK" >> $PREFIX/lib/ndk/source.properties
echo "Pkg.Revision = 27.1.0" >> $PREFIX/lib/ndk/source.properties
pkg install cmake
cd ExampleCMakeProject
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$PREFIX/lib/ndk/build/cmake/android.toolchain.cmake \
-DANDROID_NDK=$PREFIX/lib/ndk/ \
-DANDROID_ABI=$(getprop ro.product.cpu.abi) \
-DANDROID_STL=c++_shared \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=$HOME \
-DCMAKE_C_COMPILER=$PREFIX/bin/clang \
-DCMAKE_CXX_COMPILER=$PREFIX/bin/clang++ \
..
make
cp $PREFIX/lib/libc++_shared.so $HOME # Remeber to place this into your .apk's lib subdirectory for the same name you see in your getprop ro.product.cpu.abi command, next to your other .so files, when you build your .apk file, until some time when there is a way to use c++_static! |
Looks really great! Ever consider to make a PR to TUR? |
I think that, since many Android NDK projects may specify In my example here, I used the Java-based portion of the SDK unmodified from lzhiyong, but I think for the full potential of this technique to be realized, it needs to be refactored to be fully combined with the way you use the SDK from the other issue. The way I use the NDK here is basically similar to how you use the SDK, so further refactoring and repackaging can probably merge them together into a cohesive dependency tree. |
I have recently personally discovered/created a technique that creates an NDK that can run inside Termux and compile
Application.mk
NDK projects that fits in a zip of only 200 MB or possibly even less, compared to the 500 MB zip that comes from this page.The major tradeoff that achieves this can be explained as, the resulting NDK loses cross-compilation support and therefore what that means is that it becomes only capable of building
.so
binaries that can be packaged into apps that run on the same device where Termux is running, and loses the ability to build.so
files for apps for other devices - but with the potential benefit that the amount of downloading and storage needed is reduced significantly. Unpacking the release from this repo, removing some of the files and repacking it might achieve similar results, but my method also involves several other space-saving optimizations and download speed optimizations that cannot be achieved solely by editing the release zip from here.I can add that, contrary to what one might expect, my technique does not require a separate github release file for each Termux app architecture; hypothetically, my technique could exist as a single github release file download for all architectures and still keep the space optimization despite the removal of cross-compilation support. If that sounds very confusing, it will be made clear when I show all the details.
The reason I opened this issue is because I would like to find out whether anyone wants this option so, whether anyone only needs to build apps for their own device and would gladly take that tradeoff to save space, or on the other hand, maybe everyone absolutely always needs all four
.so
files, thex86
one, thex86_64
one, thearmeabi-v7a
one and thearm64-v8a
one, so maybe nobody would ever need this.If many people want to know how to do this then I will polish and test my method more and then post all of the code here so that people can see how to do it, but if nobody wants this and it's a terrible idea, then this issue can be closed.
Also I forgot to mention that this method also works when you change the package name of Termux app from
com.termux
to something else, so it is involved with what I was talking about in #163 and if a cross-compiler is also built a similar way, it will have a similar capabilityThe text was updated successfully, but these errors were encountered: