Skip to content

Commit 34920cb

Browse files
committed
A script's includes are resolved against the directories its resource compiler searches, the package directory first
1 parent 9b940b2 commit 34920cb

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

‎src/build/prepare/plan.cpp‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,12 @@ static std::expected<void, std::string> step13_windows_resources(PrepareState& s
15281528
const auto resRel = S.owner.empty() ? std::filesystem::path("res")
15291529
: std::filesystem::path("res") / S.owner;
15301530
const auto resDir = ctx.plan.outputDir / resRel;
1531+
// Where the resource compiler looks for a script's includes and
1532+
// files: the package's directory, then its include_dirs. The
1533+
// scan resolves them the same way.
1534+
std::vector<std::filesystem::path> rcIncludes{S.dir};
1535+
for (auto const& d : M.buildConfig.includeDirs)
1536+
rcIncludes.push_back(d.is_absolute() ? d : (S.dir / d));
15311537
std::error_code mkEc;
15321538
std::filesystem::create_directories(resDir, mkEc);
15331539

@@ -1591,9 +1597,7 @@ static std::expected<void, std::string> step13_windows_resources(PrepareState& s
15911597
mcpp::build::ResourceUnit ru;
15921598
ru.source = src;
15931599
ru.output = resRel / (std::string(stem) + std::string(outExt));
1594-
ru.includeDirs.push_back(S.dir);
1595-
for (auto const& d : M.buildConfig.includeDirs)
1596-
ru.includeDirs.push_back(d.is_absolute() ? d : (S.dir / d));
1600+
ru.includeDirs = rcIncludes;
15971601
ru.implicitInputs = std::move(inputs);
15981602
ctx.plan.resourceUnits.push_back(std::move(ru));
15991603
const auto& out = ctx.plan.resourceUnits.back().output;
@@ -1607,9 +1611,6 @@ static std::expected<void, std::string> step13_windows_resources(PrepareState& s
16071611

16081612
// Author-written scripts: compiled once, linked into every image.
16091613
for (auto const& rcSrc : scriptFiles) {
1610-
std::vector<std::filesystem::path> rcIncludes;
1611-
for (auto const& d : M.buildConfig.includeDirs)
1612-
rcIncludes.push_back(d.is_absolute() ? d : (S.dir / d));
16131614
auto scan = rsrc::scan_rc(rcSrc, rcIncludes);
16141615
if (scan.versionInfoNamedByString) {
16151616
// The mcpp#365 silent failure, caught on the way in. A

‎src/project.cppm‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,10 +702,10 @@ load_member_manifest(const mcpp::manifest::Manifest& workspace,
702702
// The values of a member's manifest that are one value per plan: the
703703
// toolchain request and the target rows, the C++ standard, the graph-wide
704704
// `[build]` keys (among them `linkage`, which chooses the C runtime every
705-
// object is compiled against), the profiles and the indices. Members whose keys are equal
706-
// are planned together; the key is a canonical string of those values and
707-
// nothing else, so a member's own flags, sources and dependencies never
708-
// separate it from another member.
705+
// object is compiled against), the profiles and the indices. Members whose
706+
// keys are equal are planned together; the key is a canonical string of those
707+
// values and nothing else, so a member's own flags, sources and dependencies
708+
// never separate it from another member.
709709
export std::string root_position_key(const mcpp::manifest::Manifest& m) {
710710
std::string s;
711711
auto field = [&](std::string_view name, std::string_view value) {

0 commit comments

Comments
 (0)