As described in this post, recent updates to ARTist’s internal workings require an update of this documentation. This note will vanish as soon as the new documentation is published.
Until that, you can still use the description below to some extend, but expect some things to not work anymore.
How to create your own CodeLib and generate native CodeLib source files
You can use our Example CodeLib as a base for your own codelib or just start one from scratch.
In order to be compatible with the
codelib-gen Source Generator, you are only allowed to put one class definition into the java source file.
git clone https://github.com/Project-ARTist/CodeLib.git
Modify the example CodeLib as you wish. it is fully functional in this state to demonstrate all parameter types, trace-logging and more.
You should only implemented static methods: \
Calls to the codelib are done via a static instance field, but without calls to the dynamic CodeLib constructor.
Only the static java constructor is called
The dynamic constructor(s)
package.class.<init> are never called by the framework.
- Python 3+
In order to use the java class with artist and be able to inject method calls to it, you need to generate native source files, based on the java sources.
codelib-gen basically only generates the method signatures in the class File Format that is internally used by the Java VM and art.
The generated native source files can then get placed in the folder
Artist is shipped with the codelib.* sourcefiles for the default codelib, so you need to replace them with your own generated version.
git clone https://github.com/Project-ARTist/codelib-gen.git cd codelib-gen chmod +x codelib-gen.py ./codelib-gen.py <CodeLib>/app/src/main/java/saarland/cispa/artist/codelib/CodeLib.java # You now have the codelib.h & codelib.cc files. ls -l codelib.* -rw-r--r-- 1 user users 3720 3. Apr 12:25 codelib.cc -rw-r--r-- 1 user users 2787 3. Apr 12:25 codelib.h # Copy them to your artist folder: <AOSP>/art/compiler/optimizing/artist/env/ # along the codelib_environment, etc files cp codelib.* <AOSP>/art/compiler/optimizing/artist/env/
$ ./codelib-gen.py -h CodeLibGen (1.0.0 RC1) Python Version: 3.6.0 (default, Jan 16 2017, 12:12:55) [GCC 6.3.1 20170109] usage: codelib-gen.py [-h] [-s <source_root>] <path-to-java-source> Artist helper tool. Generates codelib.h/.cc files for the specified java source file. positional arguments: <path-to-java-source> Path to the java source file for which the codelib.h/.cc should get generated\”Class must be in package-names subfolders, e.g.: ./java/lang/Object.java optional arguments: -h, --help show this help message and exit -s <source_root>, --source_root <source_root> Path to the folder, where the first java package-name folder is. E.g.: "app/src/main/java/" if your file is in folder ">app/src/main/java/<java/lang/Object.java"