Giter Site home page Giter Site logo

preBuildCommands about unit-threaded HOT 11 CLOSED

andre2007 avatar andre2007 commented on June 10, 2024
preBuildCommands

from unit-threaded.

Comments (11)

andre2007 avatar andre2007 commented on June 10, 2024

I am not 100% sure whether preBuildCommands in user dub.json is needed at all. A preGenerateCommands in your dub package should always be automatically called when user dub package is build.

from unit-threaded.

atilaneves avatar atilaneves commented on June 10, 2024

What preBuildCommands?

from unit-threaded.

andre2007 avatar andre2007 commented on June 10, 2024

The README.md says this preBuildCommand is necessary to use the library in dub projects:

 ​"​preBuildCommands​"​: [​"​$DUB run --compiler=$$DC unit-threaded -c gen_ut_main -- -f bin/ut.d -d $DUB​"​],

from unit-threaded.

atilaneves avatar atilaneves commented on June 10, 2024

Ah, that. I haven't used that so long myself that I'd forgotten about it. It seems the dub bug that was preventing me from doing so is now fixed.

Are you suggesting to put a preGenerateCommands in unit-threaded itself to always generate the main file for reflection?

I don't understand how $SOURCE_FILES helps.

from unit-threaded.

andre2007 avatar andre2007 commented on June 10, 2024

From the README.md it sounds like the whole purpose of gen_ut_main is to find out the modules of the dub package. This information is also located in the mentioned environment variable.

Unfortunately, due to the nature of D's compile-time reflection, to use this library a test runner file listing all modules to reflect on must exist. Since this is a tedious task and easily automated, unit-threaded has a dub configuration called gen_ut_main to do just that.

from unit-threaded.

andre2007 avatar andre2007 commented on June 10, 2024

You could give it a try (preGenerateCommands), this would ease the usage of this library.

from unit-threaded.

atilaneves avatar atilaneves commented on June 10, 2024

I tried using $SOURCE_FILES in preBuildCommands and preGenerateCommands in a different project and dub complained about an invalid variable.

from unit-threaded.

andre2007 avatar andre2007 commented on June 10, 2024

@atilaneves
Just as explanation: As far as I remember there is a distinction between dub variables and environment variables.
You can not use them everywhere.

But the environment variable definitely exists https://github.com/dlang/dub/blob/79e312d042f66a0ea56879f13c2167bc66d35146/source/dub/generators/generator.d#L830

from unit-threaded.

atilaneves avatar atilaneves commented on June 10, 2024

I saw the code and the PR. Unfortunately the PR had no tests to accompany it, so I don't know what the diff actually does, if anything.

What I know is that trying to use $SOURCE_FILES in the two directives where it'd make sense fails. Where else is it available?

In the documentation it lists $SOURCE_FILES in the same column as a few variables that do work in those directives. And what precedes that is "Inside of custom command directives".

Right now I don't know how to use $SOURCE_FILES. Given it shows up nowhere as an actual variable in the dub git repository I'd guess that nobody else does either.

from unit-threaded.

gizmomogwai avatar gizmomogwai commented on June 10, 2024

I just did a quick dub init test project and there

preBuildCommands "echo $$SOURCE_FILES"

prints the sources of the dub package when building. hope that helps. Not sure why a $$ is needed.

Full example:
dub.sdl:

name "source-files-test"
license "MIT"
preGenerateCommands "echo preGenerateCommands: $$SOURCE_FILES"
preBuildCommands "echo preBuildCommands: $$SOURCE_FILES"

source/app.d:

import std.stdio;

void main()
{
	writeln("Edit source/app.d to start your project.");
}
> dub run
Running pre-generate commands for source-files-test...
preGenerateCommands: /Users/myuser/tmp/bla/source/app.d
Performing "debug" build using /Users/myuser/dlang/dmd-2.096.1/osx/bin/dmd for x86_64.
source-files-test ~master: building configuration "application"...
Running pre-build commands...
preBuildCommands: source/app.d
Linking...

Interestingly the path for preGenerateCommands is absolute, wheras the path in preBuildCommands is relative.

from unit-threaded.

atilaneves avatar atilaneves commented on June 10, 2024

@gizmomogwai Thanks! Weird that it needs to be escaped but other variables don't.

from unit-threaded.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.