dlang / dub

Package and build management system for D
MIT License
673 stars 230 forks source link

Add targetType: run for tooling #2554

Open rikkimax opened 1 year ago

rikkimax commented 1 year ago

It would be nice to not have to use preBuildCommands to describe a tool that you want to run as part of your build process.

Adding a new targetType that would execute the executable after compilation (but not included in any (sub)package that depends upon it) would solve this.

For instance instead of:

        {
            "name": "makeUnicodeTables",
            "targetType": "sourceLibrary",
            "sourcePaths": [],
            "importPaths": [],
            "extraDependencyFiles": [
                "source/sidero/base/text/unicode/readonly.d",
                "source/sidero/base/text/unicode/builder.d"
            ],
            "preBuildCommands": [
                "$DUB_EXE run --single tools/unicode.d"
            ]
        },

We could use:

        {
            "name": "makeUnicodeTables",
            "targetType": "run",
            "sourceFiles": ["tools/unicode.d"],
            "sourcePaths": [],
            "importPaths": [],
            "extraDependencyFiles": [
                "source/sidero/base/text/unicode/readonly.d",
                "source/sidero/base/text/unicode/builder.d"
            ],
        },

Unfortunately, preBuildCommands kills my current approach as it will force it to be rebuilt as long as it's defined within the single package file.

Geod24 commented 1 year ago

I'm not sure I follow. How does the second recipe know to run tools/unicode.d ? preBuildCommands is currently the preferred approach and should not lead to rebuilds.

rikkimax commented 1 year ago

Use it as a dependency.

I'm seeing this in my code, preBuildCommands is indeed forcing a rebuild each time, it slows down an already slow build by quite noticeable amounts, I end up just disabling it.

We discussed this a bit recently on Discord (@WebFreak001) about expanding out commands including the ability to build + run D code due to issues surrounding $DC -run not being available on all compilers. By adding the ability to specify them as maps instead of just a string. That could resolve this problem by allowing disabling of the triggering of a build.