#trouble with addSystemCommand in+out arg

1 messages · Page 1 of 1 (latest)

onyx kestrel
#

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?

jaunty blaze
#

If the APK signing command is modifying the file in-place, then the signed file path would be apkToSign_path, right? So I think this line

const signedApk_path = alignedApk_path;

should be

const signedApk_path = apkToSign_path;

if I'm understanding it correctly (alignedApk_path will be the original file which you copied to apkToSign_path for signing)