Skip to content

Commit

Permalink
add --deep flag to dub build
Browse files Browse the repository at this point in the history
Allows to build all dependencies of a static library
  • Loading branch information
rtbo committed Aug 12, 2023
1 parent 52fd928 commit 1d4e213
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions source/dub/commandline.d
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,7 @@ class GenerateCommand : PackageBuildCommand {
protected {
string m_generator;
bool m_printPlatform, m_printBuilds, m_printConfigs;
bool m_deep; // only set in BuildCommand
}

this() @safe pure nothrow
Expand Down Expand Up @@ -1274,6 +1275,7 @@ class GenerateCommand : PackageBuildCommand {
gensettings.runArgs = app_args;
// legacy compatibility, default working directory is always CWD
gensettings.overrideToolWorkingDirectory = getWorkingDirectory();
gensettings.buildDeep = m_deep;

logDiagnostic("Generating using %s", m_generator);
dub.generateProject(m_generator, gensettings);
Expand Down Expand Up @@ -1316,6 +1318,9 @@ class BuildCommand : GenerateCommand {
args.getopt("n|non-interactive", &m_nonInteractive, [
"Don't enter interactive mode."
]);
args.getopt("d|deep", &m_deep, [
"Build all dependencies, even when main target is a static library."
]);
super.prepare(args);
m_generator = "build";
}
Expand Down
4 changes: 2 additions & 2 deletions source/dub/generators/build.d
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ class BuildGenerator : ProjectGenerator {
}

// build all targets
if (settings.rdmd || rootTT == TargetType.staticLibrary) {
if (settings.rdmd || (rootTT == TargetType.staticLibrary && !settings.buildDeep)) {
// RDMD always builds everything at once and static libraries don't need their
// dependencies to be built
// dependencies to be built, unless --deep flag is specified
NativePath tpath;
buildTarget(settings, root_ti.buildSettings.dup, m_project.rootPackage, root_ti.config, root_ti.packages, null, tpath);
return;
Expand Down
3 changes: 3 additions & 0 deletions source/dub/generators/generator.d
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,9 @@ struct GeneratorSettings {
/// single file dub package
bool single;

/// build all dependencies for static libraries
bool buildDeep;

string[] runArgs;
void delegate(int status, string output) compileCallback;
void delegate(int status, string output) linkCallback;
Expand Down

0 comments on commit 1d4e213

Please sign in to comment.