c3lang / c3c

Compiler for the C3 language
https://c3-lang.org
GNU Lesser General Public License v3.0
3.03k stars 183 forks source link

Having exec or just empty type in project.json targets #1577

Closed tonis2 closed 3 weeks ago

tonis2 commented 1 month ago

c3c project.json supports having array of exec functions in, but currently the type of targets can only be static-lib or executable, so the compiler shows some errors when trying to use only exec: [] target

Would it make sense to accept empty or exec type parameter there and the compiler would just run exec commands then ?

Example project.json

    "targets": {
        "shaders": {
            "exec": [
                "slangc examples/shader1.slang  -profile glsl_460 -target spirv -o /shaders/shader1.spv",
                                "slangc examples/shader2.slang  -profile glsl_460 -target spirv -o /shaders/shader2.spv"
            ]
        },
           "install": {
            "exec": [
                "scripts/download_dependencies.c3", 
                "scripts/build_something.c3"
            ]
        },
                "cube": {
            "type": "executable",
            "sources": ["examples/cube/main.c3"]
        },
    }
lerno commented 1 month ago

I didn't think about it, but yes, it makes sense that there would be a target type that doesn't do anything (doesn't compile anything but runs exec etc)

lerno commented 3 weeks ago

This is now implemented with the type "prepare". Please try it out and check that it works as expected.

tonis2 commented 3 weeks ago

Yep worked well for me, closing the issue