I'm using a cmd line tool for signing Android apks, from build.zig.
This cmd line tool takes the apk path and modifies it inplace. Which essentially means that the input and output file is the same.
The following code shows a step that performs the signing. Followed by another step that "installs" the signed apk file to the zig-out directory.
// sign apk
const copyAlignedApk = b.addWriteFiles();
const apkToSign_path = copyAlignedApk.addCopyFile(alignedApk_path, "test.apk");
const apksignCmd = b.addSystemCommand(&.{
toolsPaths.apksigner,
"sign",
"--ks-key-alias", keystore_keyAlias,
"--ks", keystore_path,
"--ks-pass", "pass:" ++ keystore_password,
"--min-sdk-version", minVersionStr,
});
apksignCmd.addFileArg(apkToSign_path);
const signedApk_path = alignedApk_path;
const step_apkToOut = b.addInstallFile(signedApk_path, "test.apk");
step_apkToOut.step.dependOn(&apksignCmd.step);
The signing step adds the argument as input (addFileArg), as there is no way to add an agument as in+out.
Also I made sure to add the dependency between signing and installing (step_apkToOut.step.dependOn(&apksignCmd.step);).
This doesn't seem to work. The apk that ends up in the zig-out directory is the unsigned one.
What can I do?