Build Specific Task Support
darkplayground opened this issue · comments
I need to run an image optimization script on the renpy game source but It needs to only run when building for android. I looked at the docs for custom tasks but I didn't see any obvious way to run build-specific tasks. Ideally I would be able to run the android build last (assuming multiple builds were chosen in the config) and create a custom task that would run right before the android build step that runs the image optimization script on the source. That way the Mac/pc builds have the full size assets and the android build has the smaller assets. Since I'm running this in CI, it doesn't matter if any changes are made to the images during the process as they are thrown away at the end of the pipeline build.
I thought about potentially running a task to copy the source files to another directory and do the image covert there to leave the original ones available for the Mac/pc build but there doesn't appear to be any way to direct a specific build type to a specific folder anyway so that wouldn't work. It seems like the custom build tasks are an all-or-nothing type system.
Is there any way to achieve what I want with this tool?
Not at the moment, unfortunately. RenKit is supposed to be a rebuild of the existing Python tools and as part of that development I have plans to support more flexible custom tasks, either via shell script or via custom Python scripts that can be called at varying stages in the build process. Those are currently not implemented but are on my docket as far as new features go.
Once implemented they will likely receive state information, such as what build is currently being attempted, so that would end up supporting this use case.
In case you want to accomplish this right now, you could probably cheeze it by simply running renconstruct twice with two config files. The first would do all the regular builds. Then you process your images. Then you run it again with a second config which only does the Android builds. That way you can do whatever you want in between runs and since Android goes last, you don't have to worry about state corruption.
This is the problem I'm having right now with your proposed solution of running renconstruct twice. It nukes the output directory between runs so I'd have to duplicate my upload logic between the runs which is not very dry:
Maybe having this as a config options would be helpful?
Yeah, that would make sense. I'll add a switch that disables the directory re-creation so it can be reused. I think I might actually make that the default since intuitively you would likely expect it to just create the directory if it doesn't exist but just use it as-is when it has already been created beforehand.