Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DUB_PACKAGE/DUB_PACKAGE_DIR is wrong for (pre|post)BuildCommands #658

Open
Abscissa opened this issue Aug 20, 2015 · 4 comments
Open

DUB_PACKAGE/DUB_PACKAGE_DIR is wrong for (pre|post)BuildCommands #658

Abscissa opened this issue Aug 20, 2015 · 4 comments

Comments

@Abscissa
Copy link
Contributor

Within (pre|post)BuildCommands, the DUB_PACKAGE/DUB_PACKAGE_DIR envvars are set to the root package instead of the current package. But they do work correctly within (pre|post)GenerateCommands.

The cause appears to be BuildGenerator.buildTarget(), BuildGenerator.performCachedBuild() and BuildGenerator.performDirectBuild() passing the wrong Package into runBuildCommands(). Still looking into this further.

@Abscissa
Copy link
Contributor Author

Oh, I see what's going on. DUB combines all (pre|post)BuildCommands into one big (pre|post)BuildCommands list (well, one "pre" and one "post") as part of the BuildSettings for the root package. Then it makes one call to runBuildCommands(), just for the root package, passing all the build commands for all dependencies at once.

I'm not sure what to do about that.

@MartinNowak
Copy link
Member

This makes sense b/c building many small libraries is just one strategy, another one would be to build everything at once.

@Abscissa
Copy link
Contributor Author

Regardless of why BuildCommands should or shouldn't be batched together, DUB_PACKAGE/DUB_PACKAGE_DIR still need to be correct. Currently, they are often incorrect.

@nicolasjinchereau
Copy link

I'm trying to use $DUB_PACKAGE in both preGenerateCommands and preBuildCommands, but in both places, I get this error:

Invalid variable: DUB_PACKAGE

I have this in a library project:

"preBuildCommands":` [ "(cd src/cpp && make -f build.mk)" ],

When I build this library directly, the above command runs fine. If I use the same project as a dependency, get an error because dub tries to run that command in the directory of the dependant project.

Running (cd src/cpp && make -f build.mk)
/bin/sh: line 0: cd: src/cpp: No such file or directory

Paths in dub.json should not change meaning depending on whether the project is compiled directly or as a dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants