Complete smali build system
This commit is contained in:
parent
c9d4ddbd7c
commit
b73f336f4f
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
|||
build/
|
||||
source-apk/*.apk
|
||||
tools/*
|
||||
!tools/smali-2.5.2.jar
|
||||
!tools/apktool_2.9.3.jar
|
36
build.py
36
build.py
|
@ -99,6 +99,37 @@ class Task:
|
|||
print(f"Compiling {file}...")
|
||||
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():
|
||||
|
||||
match sys.argv[1]:
|
||||
|
@ -107,7 +138,10 @@ def main():
|
|||
case 'extract':
|
||||
Task.extractApk()
|
||||
case 'build':
|
||||
Task.compileSmali()
|
||||
Task.buildApk()
|
||||
|
||||
if ('a' in ''.join(sys.argv[2:])):
|
||||
Task.deployToAndroidStudio()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
File diff suppressed because it is too large
Load diff
BIN
tools/apktool_2.9.3.jar
Normal file
BIN
tools/apktool_2.9.3.jar
Normal file
Binary file not shown.
BIN
tools/smali-2.5.2.jar
Normal file
BIN
tools/smali-2.5.2.jar
Normal file
Binary file not shown.
Loading…
Reference in a new issue