xref: /aosp_15_r20/external/google-smali/README.md (revision 37f5703ca959d1ce24046e7595880d209e15c133)
1*37f5703cSAndroid Build Coastguard Worker### About
2*37f5703cSAndroid Build Coastguard Worker
3*37f5703cSAndroid Build Coastguard Workersmali/baksmali is an assembler/disassembler for the dex format used by dalvik, Android's Java VM implementation. The syntax is loosely based on Jasmin's/dedexer's syntax, and supports the full functionality of the dex format (annotations, debug info, line info, etc.)
4*37f5703cSAndroid Build Coastguard Worker
5*37f5703cSAndroid Build Coastguard Worker**NOTE**: This is a fork of https://github.com/JesusFreke/smali for patches needed by Google as the original repository is currently not maintained. After forking the namespace was changed from `org.jf` to `com.android.tools.smali`. The artifacts are released on [Google Maven](https://maven.google.com) under the following coordinates:
6*37f5703cSAndroid Build Coastguard Worker
7*37f5703cSAndroid Build Coastguard Worker* [`com.android.tools.smali:smali:<version>`](https://maven.google.com/web/index.html?q=smali#com.android.tools.smali:smali)
8*37f5703cSAndroid Build Coastguard Worker* [`com.android.tools.smali:smali-dexlib2:<version>`](https://maven.google.com/web/index.html?q=smali-dexlib2#com.android.tools.smali:smali-dexlib2)
9*37f5703cSAndroid Build Coastguard Worker* [`com.android.tools.smali:smali-baksmali:<version>`](https://maven.google.com/web/index.html?q=smali-baksmali#com.android.tools.smali:smali)
10*37f5703cSAndroid Build Coastguard Worker* [`com.android.tools.smali:smali-util:<version>`](https://maven.google.com/web/index.html?q=smali-util#com.android.tools.smali:smali-util)
11*37f5703cSAndroid Build Coastguard Worker
12*37f5703cSAndroid Build Coastguard WorkerAfter the fork the first version released was 3.0.0, which was version 2.5.2 from the original repo with a few patches and the namespace change.
13*37f5703cSAndroid Build Coastguard Worker
14*37f5703cSAndroid Build Coastguard Worker#### Support
15*37f5703cSAndroid Build Coastguard Worker- [github Issue tracker](https://github.com/google/smali/issues) - For any bugs/issues/feature requests
16*37f5703cSAndroid Build Coastguard Worker
17*37f5703cSAndroid Build Coastguard Worker#### Some useful links for getting started with smali
18*37f5703cSAndroid Build Coastguard Worker
19*37f5703cSAndroid Build Coastguard Worker- [Official dex bytecode reference](https://source.android.com/devices/tech/dalvik/dalvik-bytecode.html)
20*37f5703cSAndroid Build Coastguard Worker- [Registers wiki page](https://github.com/JesusFreke/smali/wiki/Registers)
21*37f5703cSAndroid Build Coastguard Worker- [Types, Methods and Fields wiki page](https://github.com/JesusFreke/smali/wiki/TypesMethodsAndFields)
22*37f5703cSAndroid Build Coastguard Worker- [Official dex format reference](https://source.android.com/devices/tech/dalvik/dex-format.html)
23*37f5703cSAndroid Build Coastguard Worker
24*37f5703cSAndroid Build Coastguard Worker### Building
25*37f5703cSAndroid Build Coastguard Worker```
26*37f5703cSAndroid Build Coastguard Worker./gradlew assemble
27*37f5703cSAndroid Build Coastguard Worker```
28*37f5703cSAndroid Build Coastguard Worker### Command Line Version
29*37f5703cSAndroid Build Coastguard Worker
30*37f5703cSAndroid Build Coastguard WorkerTo run the `smali` and `baksmali` tools from the command line build the fat
31*37f5703cSAndroid Build Coastguard Workerjars. The fat jars will be named with the current version followed by the first
32*37f5703cSAndroid Build Coastguard Worker8 characters of the current git hash followed by an optional `-dirty` if the
33*37f5703cSAndroid Build Coastguard Workerrepository was dirty when building and ending in  -fat . The fat jar can be
34*37f5703cSAndroid Build Coastguard Workerinvoked with `java -jar`.
35*37f5703cSAndroid Build Coastguard Worker```
36*37f5703cSAndroid Build Coastguard Worker./gradlew smali:fatJar
37*37f5703cSAndroid Build Coastguard Workerjava -jar smali/build/libs/smali-x.y.z-aaaaaaaa-dirty-fat.jar
38*37f5703cSAndroid Build Coastguard Worker```
39*37f5703cSAndroid Build Coastguard Worker
40*37f5703cSAndroid Build Coastguard Worker### Testing
41*37f5703cSAndroid Build Coastguard Worker
42*37f5703cSAndroid Build Coastguard WorkerTo execute all tests run
43*37f5703cSAndroid Build Coastguard Worker```
44*37f5703cSAndroid Build Coastguard Worker./gradlew test
45*37f5703cSAndroid Build Coastguard Worker```
46*37f5703cSAndroid Build Coastguard Worker
47*37f5703cSAndroid Build Coastguard Worker### Testing Maven Release
48*37f5703cSAndroid Build Coastguard WorkerPush a release version to your local maven repository (add
49*37f5703cSAndroid Build Coastguard Worker`-Dmaven.repo.local=<dir>` to override the default local maven repository
50*37f5703cSAndroid Build Coastguard Workerlocation)
51*37f5703cSAndroid Build Coastguard Worker```
52*37f5703cSAndroid Build Coastguard Worker./gradlew release publishToMavenLocal
53*37f5703cSAndroid Build Coastguard Worker```
54*37f5703cSAndroid Build Coastguard Worker
55*37f5703cSAndroid Build Coastguard Worker### Prepare and build a release version
56*37f5703cSAndroid Build Coastguard WorkerTo prepare a release update `build.gradle` with the next release version and commit that.
57*37f5703cSAndroid Build Coastguard WorkerThen create a tag for that commit with the version.
58*37f5703cSAndroid Build Coastguard Worker```
59*37f5703cSAndroid Build Coastguard Workergit tag <version> <commit>
60*37f5703cSAndroid Build Coastguard Workergit push origin <version>
61*37f5703cSAndroid Build Coastguard Worker```
62*37f5703cSAndroid Build Coastguard WorkerRelease versions can then be built by the Google R8 team using:
63*37f5703cSAndroid Build Coastguard Worker```
64*37f5703cSAndroid Build Coastguard Workertools/trigger.py --smali=<version> --release
65*37f5703cSAndroid Build Coastguard Worker```
66*37f5703cSAndroid Build Coastguard Workerin the R8 repository.
67*37f5703cSAndroid Build Coastguard Worker
68*37f5703cSAndroid Build Coastguard WorkerThe status of the build on the bot is at https://ci.chromium.org/p/r8/builders/ci/smali.
69*37f5703cSAndroid Build Coastguard Worker
70*37f5703cSAndroid Build Coastguard Worker### Releasing versions on Google Maven
71*37f5703cSAndroid Build Coastguard WorkerTBD.
72