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

Keep the default option for dependencies when serializing a sdl recipe #2961

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions source/dub/recipe/sdl.d
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ private Tag[] toSDL(const scope ref BuildSettingsTemplate bs)
},
);
if (d.optional) attribs ~= new Attribute(null, "optional", Value(true));
if (d.default_) attribs ~= new Attribute(null, "default", Value(true));
auto t = new Tag(null, "dependency", [Value(pack)], attribs);
if (d.settings !is typeof(d.settings).init)
t.add(d.settings.toSDL());
Expand Down Expand Up @@ -697,6 +698,20 @@ lflags "-b" "-c"
`);
}

unittest { // test that default is preserved after serialization
immutable sdl = `name "optional-deps"
dependency "foo-bar" version="1.1.2" optional=true default=true`;
PackageRecipe rec;
parseSDLTest(rec, sdl);
with (rec.buildSettings) {
assert(dependencies["foo-bar"].optional);
assert(dependencies["foo-bar"].default_);
}
immutable back = toSDL(rec).toSDLDocument();
import std.algorithm : canFind;
assert(back.canFind("default=true"));
}

unittest {
auto sdl = "name \"test\"\nsourcePaths";
PackageRecipe rec;
Expand Down
Loading