-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from KuhakuPixel/feature
Enable Optimization for [Modder] and add script to create release binary
- Loading branch information
Showing
89 changed files
with
626 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,9 @@ | |
*~ | ||
*.swp | ||
*.swo | ||
|
||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
# ACE Engine | ||
# ![this icon is generated by DALL-E-2](./docs/icon.png) | ||
|
||
game hacking and memory scanner/editor for linux and android | ||
|
||
- I plan to make it work on linux first, before porting to | ||
android, and first make a program that is runnable through adb | ||
|
||
docs on building/running/testing [here](./docs/) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
""" | ||
Make ACE's release for linux desktop and android (multi archs) automatically | ||
This script run cmake and makefile to generate the build | ||
for running a bash command in a directory | ||
don't use cd but use cwd parameter | ||
https://stackoverflow.com/questions/21406887/subprocess-changing-directory | ||
""" | ||
|
||
import subprocess | ||
import os | ||
import shutil | ||
import multiprocessing | ||
from typing import List | ||
from util import assert_is_dir_and_exist, assert_is_file_and_exist, mkdir_overwrite | ||
|
||
LINUX_RELEASE_DIR = "./linux" | ||
ANDROID_RELEASE_DIR = "./android" | ||
|
||
ANDROID_ARCH_ABI_ARR = [ | ||
"armeabi-v7a", | ||
"arm64-v8a", | ||
"x86", | ||
"x86_64", | ||
] | ||
# need to be set to at least 23 | ||
# for process_vm_read support | ||
# see ACE's cmake for more detail | ||
ANDROID_PLATFORM = "android-23" | ||
|
||
CMAKELIST_PATH = "./ACE/engine/" | ||
BUILD_DIR = "./build" | ||
|
||
|
||
def gen_make_and_make_ACE( | ||
build_dir: str, | ||
install_dir: str, | ||
CMAKElist_dir_path: str, | ||
toolchain_path: str = None, | ||
extra_args: List[str] = None, | ||
# by default, use all cpu for fastest compilation | ||
# https://unix.stackexchange.com/questions/208568/how-to-determine-the-maximum-number-to-pass-to-make-j-option | ||
# https://stackoverflow.com/a/1006337/14073678 | ||
cpu_count_for_compile: int = multiprocessing.cpu_count(), | ||
): | ||
|
||
# recreate build and release directory in case its previously | ||
# not empty | ||
mkdir_overwrite(build_dir) | ||
mkdir_overwrite(install_dir) | ||
# get abs path when possible | ||
assert_is_dir_and_exist(install_dir) | ||
install_path = os.path.abspath(install_dir) | ||
|
||
assert_is_dir_and_exist(CMAKElist_dir_path) | ||
CMAKElist_path = os.path.abspath(CMAKElist_dir_path) | ||
|
||
if toolchain_path != None: | ||
assert_is_file_and_exist(toolchain_path) | ||
toolchain_path = os.path.abspath(toolchain_path) | ||
print(f"install path: {install_path}") | ||
# generate makefile and run make | ||
CMAKE_cmd_args = [ | ||
"cmake", | ||
CMAKElist_path, | ||
"-DCMAKE_BUILD_TYPE=Release", | ||
# set install prefix | ||
# https://stackoverflow.com/questions/6003374/what-is-cmake-equivalent-of-configure-prefix-dir-make-all-install | ||
"-DCMAKE_INSTALL_PREFIX:PATH=" + install_path, | ||
] | ||
# append extra arguments | ||
if extra_args != None: | ||
CMAKE_cmd_args += extra_args | ||
pass | ||
# use custom toolchain if provided | ||
if toolchain_path != None: | ||
CMAKE_cmd_args.append("-DCMAKE_TOOLCHAIN_FILE=" + toolchain_path) | ||
# run cmake | ||
subprocess.run(CMAKE_cmd_args, cwd=build_dir) | ||
# make the program and install to the specified target | ||
subprocess.run( | ||
["make", "all", "install", f"-j{cpu_count_for_compile}"], cwd=build_dir | ||
) | ||
|
||
|
||
def make_release(release_dir: str, android_toolchain_file: str): | ||
# ============================ android ===================== | ||
# recreate build dir for building engine | ||
android_release_dir = os.path.join(release_dir, ANDROID_RELEASE_DIR) | ||
for arch in ANDROID_ARCH_ABI_ARR: | ||
# create directory for specific arch release | ||
current_android_release_dir = os.path.join(android_release_dir, arch) | ||
# | ||
gen_make_and_make_ACE( | ||
build_dir=BUILD_DIR, | ||
install_dir=current_android_release_dir, | ||
CMAKElist_dir_path=CMAKELIST_PATH, | ||
toolchain_path=android_toolchain_file, | ||
extra_args=[ | ||
"-DANDROID_ABI=" + arch, | ||
"-DANDROID_PLATFORM=" + ANDROID_PLATFORM, | ||
], | ||
) | ||
|
||
# ============================ linux ===================== | ||
# recreate build dir for building engine | ||
linux_release_dir = os.path.join(release_dir, LINUX_RELEASE_DIR) | ||
gen_make_and_make_ACE( | ||
build_dir=BUILD_DIR, | ||
install_dir=linux_release_dir, | ||
CMAKElist_dir_path=CMAKELIST_PATH, | ||
toolchain_path=None, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Developer Guide | ||
|
||
## Build instruction | ||
### clone repo | ||
#### https | ||
``` | ||
git clone --recurse-submodules https://github.com/KuhakuPixel/AceTheGame.git | ||
``` | ||
#### ssh | ||
``` | ||
git clone --recurse-submodules [email protected]:KuhakuPixel/AceTheGame.git | ||
``` | ||
## Project Structure | ||
specific build instruction is provided at the readme of each subproject. | ||
|
||
Folder | Description | ||
----------------------------- | ----------------------------------------------- | ||
[ACE](./ACE/) | Memory scanner and editor for linux and android | ||
[Modder](./Modder) | Attaching a memory scanner and editor service in the apk itself so you can read/write memory without roo | ||
|
||
## Making Release | ||
|
||
### With Docker | ||
- need to have docker installed | ||
|
||
#### build the docker image | ||
|
||
``` | ||
python ./docker_build.py | ||
``` | ||
|
||
#### Grabbing the build binaries | ||
|
||
1. run the image first | ||
|
||
``` | ||
python ./docker_run_shell.py | ||
``` | ||
2. | ||
running | ||
``` | ||
docker ps | ||
``` | ||
|
||
should give | ||
(the container ID might be different, so you need to adjust your arguments) | ||
``` | ||
CONTAINER ID IMAGE COMMAND CREATED STATUS | ||
e46afdd42728 ace_the_game "bash" About a minute ago Up About a minute | ||
``` | ||
3. copying the folder to your machine | ||
|
||
``` | ||
sudo docker cp e46afdd42728:/release . | ||
``` | ||
|
||
now you should have `release` folder in the current directory | ||
|
||
|
||
### Without Docker | ||
A python script `./make_release.py` is provided to automatically create binary release for each project | ||
(You need to download [NDK](https://developer.android.com/ndk/downloads) | ||
|
||
``` | ||
python ./make_release.py [PATH_TO_android.toolchain.cmake] | ||
``` | ||
|
||
example: | ||
``` | ||
python ./make_release.py ~/Android/Sdk/ndk/25.1.8937393/build/cmake/android.toolchain.cmake | ||
``` | ||
|
||
the script will create `release` folder | ||
|
||
|
||
|
Oops, something went wrong.