floooh / fips

High-level build system for distributed, multi-platform C/C++ projects.
MIT License
468 stars 82 forks source link

Set working directory for fips run #297

Open kathrindc opened 2 weeks ago

kathrindc commented 2 weeks ago

Hi there! I might just be overlooking something, but is there a way to set the working directory for ./fips run to the project folder? I have some assets that need to be loaded in during runtime, which would end up in the same folder as the executable in the finished deployment. As of now, I am calling ./fips build and then manually invoking the produced binary in the correct path.

edit: grammar

floooh commented 1 week ago

It's an obscure feature and I don't think it's documented anywhere, but you can add a run: section to the fips.yml file in the root directory where you can provide a cwd for specific run targets, for instance like this:

https://github.com/fips-libs/fips-bgfx/blob/master/fips.yml

...where cwd: . is the project directory.

For more advanced things you're probably better off writing a 'generator script' (misleading name, since originally those were meant as code generator scripts, but they can also be used to build a simple 'asset pipeline', for instance this project contains two common utility scripts, one for copying asset files, and one for generating a header with embedded binary data:

https://github.com/fips-libs/fips-utils

...e.g. the file copy script looks like this:

https://github.com/fips-libs/fips-utils/blob/master/fips-files/generators/copy.py

...since you have full access to the (internal) fips API, you could also use that to run executables by doing the same thing that fips run does:

https://github.com/floooh/fips/blob/3d05e74bc2f07a0b31138eed795e0a7d0368f753/verbs/run.py#L27-L28

...but if the executable is 'bootstrapped' in the same build process setting up the right dependencies could be tricky... I don't think I have an example around for that situation.