Skip to content

Commit

Permalink
Keep the default option for dependencies when serializing a sdl recipe
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Horodniceanu <[email protected]>
  • Loading branch information
the-horo authored and dlang-bot committed Aug 21, 2024
1 parent 665173f commit cb01957
Showing 1 changed file with 15 additions and 0 deletions.
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

0 comments on commit cb01957

Please sign in to comment.