Complete smali build system

This commit is contained in:
maelstrom 2024-07-26 18:25:35 +02:00
parent c9d4ddbd7c
commit b73f336f4f
5 changed files with 38 additions and 17603 deletions

4
.gitignore vendored
View file

@ -1,3 +1,5 @@
build/ build/
source-apk/*.apk source-apk/*.apk
tools/* tools/*
!tools/smali-2.5.2.jar
!tools/apktool_2.9.3.jar

View file

@ -99,6 +99,37 @@ class Task:
print(f"Compiling {file}...") print(f"Compiling {file}...")
subprocess.run(['java', '-jar', 'tools/smali-2.5.2.jar', 'a', f'build/smali/{file}', '-o', f'build/dex/{dex}']) subprocess.run(['java', '-jar', 'tools/smali-2.5.2.jar', 'a', f'build/smali/{file}', '-o', f'build/dex/{dex}'])
def mergeResources():
Task.compileSmali()
# Copy original resources
# on first run only
if not Path('build/merged').exists():
print('Copying extracted resources...')
shutil.copytree('build/extracted', 'build/merged', dirs_exist_ok=True, ignore=shutil.ignore_patterns('smali', 'smali_classes*'))
print("Copying ykit resources...")
shutil.copytree('src/resources', 'build/merged', dirs_exist_ok=True)
print("Copying compiled dex files...")
shutil.copytree('build/dex', 'build/merged', dirs_exist_ok=True)
def buildApk():
Task.mergeResources()
debugFlag = ('-d',) if ('d' in ''.join(sys.argv[2:])) else ()
print("Building apk...")
subprocess.run(['java', '-jar', './tools/apktool_2.9.3.jar', 'b', *debugFlag, 'build/merged', '-o', 'build/apk/tumblr-ykit.apk'])
def deployToAndroidStudio():
projDir = Path.home() / 'ApkProjects/tumblr-ykit'
if not projDir.exists():
print("No project named 'tumblr-ykit' in ~/ApkProjects/")
shutil.copy('build/apk/tumblr-ykit.apk', projDir / 'tumblr-ykit.apk')
print("Deployed to Android Studio")
def main(): def main():
match sys.argv[1]: match sys.argv[1]:
@ -107,7 +138,10 @@ def main():
case 'extract': case 'extract':
Task.extractApk() Task.extractApk()
case 'build': case 'build':
Task.compileSmali() Task.buildApk()
if ('a' in ''.join(sys.argv[2:])):
Task.deployToAndroidStudio()
if __name__ == '__main__': if __name__ == '__main__':
main() main()

File diff suppressed because it is too large Load diff

BIN
tools/apktool_2.9.3.jar Normal file

Binary file not shown.

BIN
tools/smali-2.5.2.jar Normal file

Binary file not shown.