Skip to content

Commit 7b890ec

Browse files
committed
🐛 Don't check loader for 32-bit layers
refs #33
1 parent 08b1e83 commit 7b890ec

19 files changed

+103
-88
lines changed

src/APILayer.hpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace FredEmmott::OpenXRLayers {
99

10+
class APILayerStore;
11+
1012
/** The basic information about an API layer.
1113
*
1214
* This contains the information that is available in the list of
@@ -21,7 +23,17 @@ struct APILayer {
2123
Win32_NotDWORD,
2224
};
2325

24-
std::filesystem::path mJSONPath;
26+
APILayer() = delete;
27+
APILayer(
28+
const APILayerStore* source,
29+
const std::filesystem::path& manifestPath,
30+
const Value value)
31+
: mSource(source),
32+
mManifestPath(manifestPath),
33+
mValue(value) {}
34+
35+
const APILayerStore* mSource {nullptr};
36+
std::filesystem::path mManifestPath;
2537
Value mValue;
2638

2739
constexpr bool IsEnabled() const noexcept {

src/APILayerStore.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class APILayerStore {
1616
// e.g. "Win64-HKLM"
1717
virtual std::string GetDisplayName() const noexcept = 0;
1818
virtual std::vector<APILayer> GetAPILayers() const noexcept = 0;
19+
// e.g. if we're a 64-bit build, we won't see 32-bit layers
20+
virtual bool IsForCurrentArchitecture() const noexcept = 0;
1921

2022
virtual bool Poll() const noexcept = 0;
2123

src/GUI.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void GUI::LayerSet::GUILayersList() {
8383
auto& layer = mLayers.at(i);
8484
auto layerErrors
8585
= std::ranges::filter_view(mLintErrors, [&layer](const auto& error) {
86-
return error->GetAffectedLayers().contains(layer.mJSONPath);
86+
return error->GetAffectedLayers().contains(layer.mManifestPath);
8787
});
8888

8989
ImGui::PushID(i);
@@ -96,7 +96,7 @@ void GUI::LayerSet::GUILayersList() {
9696
mStore->SetAPILayers(mLayers);
9797
}
9898

99-
auto label = layer.mJSONPath.string();
99+
auto label = layer.mManifestPath.string();
100100

101101
if (!layerErrors.empty()) {
102102
label = fmt::format("{} {}", Config::GLYPH_ERROR, label);
@@ -207,7 +207,7 @@ void GUI::LayerSet::GUIErrorsTab() {
207207
if (ImGui::BeginTabItem("Warnings")) {
208208
ImGui::BeginChild("##ScrollArea", {-FLT_MIN, -FLT_MIN});
209209
if (mSelectedLayer) {
210-
ImGui::Text("For %s:", mSelectedLayer->mJSONPath.string().c_str());
210+
ImGui::Text("For %s:", mSelectedLayer->mManifestPath.string().c_str());
211211
} else {
212212
ImGui::Text("All layers:");
213213
}
@@ -216,7 +216,7 @@ void GUI::LayerSet::GUIErrorsTab() {
216216
if (mSelectedLayer) {
217217
auto view = std::ranges::filter_view(
218218
mLintErrors, [layer = mSelectedLayer](const auto& error) {
219-
return error->GetAffectedLayers().contains(layer->mJSONPath);
219+
return error->GetAffectedLayers().contains(layer->mManifestPath);
220220
});
221221
selectedErrors = {view.begin(), view.end()};
222222
} else {
@@ -341,12 +341,12 @@ void GUI::LayerSet::GUIDetailsTab() {
341341
ImGui::Text("JSON File");
342342
ImGui::TableNextColumn();
343343
if (ImGui::Button("Copy##CopyJSONFile")) {
344-
ImGui::SetClipboardText(mSelectedLayer->mJSONPath.string().c_str());
344+
ImGui::SetClipboardText(mSelectedLayer->mManifestPath.string().c_str());
345345
}
346346
ImGui::SameLine();
347-
ImGui::Text("%s", mSelectedLayer->mJSONPath.string().c_str());
347+
ImGui::Text("%s", mSelectedLayer->mManifestPath.string().c_str());
348348

349-
const APILayerDetails details {mSelectedLayer->mJSONPath};
349+
const APILayerDetails details {mSelectedLayer->mManifestPath};
350350
if (details.mState != APILayerDetails::State::Loaded) {
351351
const auto error = details.StateAsString();
352352
ImGui::TableNextRow();
@@ -500,7 +500,7 @@ void GUI::LayerSet::AddLayersClicked() {
500500
auto paths = Platform::Get().GetNewAPILayerJSONPaths();
501501
for (auto it = paths.begin(); it != paths.end();) {
502502
auto existingLayer = std::ranges::find_if(
503-
mLayers, [it](const auto& layer) { return layer.mJSONPath == *it; });
503+
mLayers, [it](const auto& layer) { return layer.mManifestPath == *it; });
504504
if (existingLayer != mLayers.end()) {
505505
it = paths.erase(it);
506506
continue;
@@ -513,11 +513,7 @@ void GUI::LayerSet::AddLayersClicked() {
513513
}
514514
auto nextLayers = mLayers;
515515
for (const auto& path: paths) {
516-
nextLayers.push_back(
517-
APILayer {
518-
.mJSONPath = path,
519-
.mValue = APILayer::Value::Enabled,
520-
});
516+
nextLayers.emplace_back(mStore, path, APILayer::Value::Enabled);
521517
}
522518

523519
bool changed = false;
@@ -560,7 +556,7 @@ void GUI::LayerSet::GUIRemoveLayerPopup() {
560556
"Are you sure you want to completely remove '%s'?\n\nThis can not "
561557
"be "
562558
"undone.",
563-
mSelectedLayer->mJSONPath.string().c_str());
559+
mSelectedLayer->mManifestPath.string().c_str());
564560
ImGui::Separator();
565561
const auto dpiScaling = Platform::Get().GetDPIScaling();
566562
ImGui::SetCursorPosX((256 + 128) * dpiScaling);

src/Linter.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ static void UnregisterLinter(Linter* linter) {
2020
LintError::LintError(
2121
const std::string& description,
2222
const std::set<std::filesystem::path>& affectedLayers)
23-
: mDescription(description), mAffectedLayers(affectedLayers) {
24-
}
23+
: mDescription(description),
24+
mAffectedLayers(affectedLayers) {}
2525

2626
std::string LintError::GetDescription() const {
2727
return mDescription;
@@ -46,7 +46,7 @@ std::vector<std::shared_ptr<LintError>> RunAllLinters(
4646

4747
std::vector<std::tuple<APILayer, APILayerDetails>> layersWithDetails;
4848
for (const auto& layer: layers) {
49-
layersWithDetails.push_back({layer, {layer.mJSONPath}});
49+
layersWithDetails.push_back({layer, {layer.mManifestPath}});
5050
}
5151

5252
auto it = std::back_inserter(errors);
@@ -69,24 +69,25 @@ OrderingLintError::OrderingLintError(
6969
: allAffectedLayers),
7070
mLayerToMove(layerToMove),
7171
mPosition(position),
72-
mRelativeTo(relativeTo) {
73-
}
72+
mRelativeTo(relativeTo) {}
7473

7574
std::vector<APILayer> OrderingLintError::Fix(
7675
const std::vector<APILayer>& oldLayers) {
7776
auto newLayers = oldLayers;
7877

79-
auto moveIt = std::ranges::find_if(
80-
newLayers, [this](const auto& it) { return it.mJSONPath == mLayerToMove; });
78+
auto moveIt = std::ranges::find_if(newLayers, [this](const auto& it) {
79+
return it.mManifestPath == mLayerToMove;
80+
});
8181

8282
if (moveIt == newLayers.end()) {
8383
return oldLayers;
8484
}
8585
const auto movedLayer = *moveIt;
8686
newLayers.erase(moveIt);
8787

88-
auto anchorIt = std::ranges::find_if(
89-
newLayers, [this](const auto& it) { return it.mJSONPath == mRelativeTo; });
88+
auto anchorIt = std::ranges::find_if(newLayers, [this](const auto& it) {
89+
return it.mManifestPath == mRelativeTo;
90+
});
9091

9192
if (anchorIt == newLayers.end()) {
9293
return oldLayers;
@@ -107,8 +108,7 @@ std::vector<APILayer> OrderingLintError::Fix(
107108
KnownBadLayerLintError::KnownBadLayerLintError(
108109
const std::string& description,
109110
const std::filesystem::path& layer)
110-
: FixableLintError(description, {layer}) {
111-
}
111+
: FixableLintError(description, {layer}) {}
112112

113113
std::vector<APILayer> KnownBadLayerLintError::Fix(
114114
const std::vector<APILayer>& allLayers) {
@@ -118,7 +118,7 @@ std::vector<APILayer> KnownBadLayerLintError::Fix(
118118

119119
auto newLayers = allLayers;
120120
auto it = std::ranges::find_if(
121-
newLayers, [&path](const auto& layer) { return layer.mJSONPath == path; });
121+
newLayers, [&path](const auto& layer) { return layer.mManifestPath == path; });
122122

123123
if (it != newLayers.end()) {
124124
it->mValue = APILayer::Value::Disabled;
@@ -129,8 +129,7 @@ std::vector<APILayer> KnownBadLayerLintError::Fix(
129129
InvalidLayerLintError::InvalidLayerLintError(
130130
const std::string& description,
131131
const std::filesystem::path& layer)
132-
: FixableLintError(description, {layer}) {
133-
}
132+
: FixableLintError(description, {layer}) {}
134133

135134
std::vector<APILayer> InvalidLayerLintError::Fix(
136135
const std::vector<APILayer>& allLayers) {
@@ -140,7 +139,7 @@ std::vector<APILayer> InvalidLayerLintError::Fix(
140139

141140
auto newLayers = allLayers;
142141
auto it = std::ranges::find_if(
143-
newLayers, [&path](const auto& layer) { return layer.mJSONPath == path; });
142+
newLayers, [&path](const auto& layer) { return layer.mManifestPath == path; });
144143

145144
if (it != newLayers.end()) {
146145
newLayers.erase(it);
@@ -151,8 +150,7 @@ std::vector<APILayer> InvalidLayerLintError::Fix(
151150
InvalidLayerStateLintError::InvalidLayerStateLintError(
152151
const std::string& description,
153152
const std::filesystem::path& layer)
154-
: FixableLintError(description, {layer}) {
155-
}
153+
: FixableLintError(description, {layer}) {}
156154

157155
std::vector<APILayer> InvalidLayerStateLintError::Fix(
158156
const std::vector<APILayer>& allLayers) {
@@ -162,7 +160,7 @@ std::vector<APILayer> InvalidLayerStateLintError::Fix(
162160

163161
auto newLayers = allLayers;
164162
auto it = std::ranges::find_if(
165-
newLayers, [&path](const auto& layer) { return layer.mJSONPath == path; });
163+
newLayers, [&path](const auto& layer) { return layer.mManifestPath == path; });
166164

167165
if (it != newLayers.end()) {
168166
it->mValue = APILayer::Value::Disabled;

src/SaveReport.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ static std::string GenerateReportText(const APILayerStore* store) {
4545
value = Config::GLYPH_ERROR;
4646
break;
4747
}
48-
ret += std::format("\n{} {}", value, layer.mJSONPath.string());
48+
ret += std::format("\n{} {}", value, layer.mManifestPath.string());
4949

50-
const APILayerDetails details {layer.mJSONPath};
50+
const APILayerDetails details {layer.mManifestPath};
5151
if (details.mState != APILayerDetails::State::Loaded) {
5252
ret += fmt::format(
5353
"\n\t- {} {}", Config::GLYPH_ERROR, details.StateAsString());
@@ -94,7 +94,7 @@ static std::string GenerateReportText(const APILayerStore* store) {
9494

9595
auto layerErrors
9696
= std::ranges::filter_view(errors, [layer](const auto& error) {
97-
return error->GetAffectedLayers().contains(layer.mJSONPath);
97+
return error->GetAffectedLayers().contains(layer.mManifestPath);
9898
});
9999

100100
if (layerErrors.empty()) {

src/linters/BadInstallationLinter.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,29 @@ class BadInstallationLinter final : public Linter {
1616
const std::vector<std::tuple<APILayer, APILayerDetails>>& layers) {
1717
std::vector<std::shared_ptr<LintError>> errors;
1818
for (const auto& [layer, details]: layers) {
19-
if (!std::filesystem::exists(layer.mJSONPath)) {
19+
if (!std::filesystem::exists(layer.mManifestPath)) {
2020
errors.push_back(std::make_shared<InvalidLayerLintError>(
2121
fmt::format(
22-
"JSON file `{}` does not exist", layer.mJSONPath.string()),
23-
layer.mJSONPath));
22+
"JSON file `{}` does not exist", layer.mManifestPath.string()),
23+
layer.mManifestPath));
2424
continue;
2525
}
2626

2727
if (details.mState != APILayerDetails::State::Loaded) {
2828
errors.push_back(std::make_shared<InvalidLayerLintError>(
2929
fmt::format(
3030
"Unable to load details from the JSON file `{}`",
31-
layer.mJSONPath.string()),
32-
layer.mJSONPath));
31+
layer.mManifestPath.string()),
32+
layer.mManifestPath));
3333
continue;
3434
}
3535

3636
if (details.mLibraryPath.empty()) {
3737
errors.push_back(std::make_shared<InvalidLayerLintError>(
3838
fmt::format(
3939
"Layer does not specify an implementation in `{}`",
40-
layer.mJSONPath.string()),
41-
layer.mJSONPath));
40+
layer.mManifestPath.string()),
41+
layer.mManifestPath));
4242
continue;
4343
}
4444

@@ -47,7 +47,7 @@ class BadInstallationLinter final : public Linter {
4747
fmt::format(
4848
"Implementation file `{}` does not exist",
4949
details.mLibraryPath.string()),
50-
layer.mJSONPath));
50+
layer.mManifestPath));
5151
continue;
5252
}
5353
}

src/linters/DisabledByEnvironmentLinter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DisabledByEnvironmentLinter final : public Linter {
2525
"Layer is disabled, because required environment variable `{}` "
2626
"is not set",
2727
enableEnv),
28-
PathSet {layer.mJSONPath}));
28+
PathSet {layer.mManifestPath}));
2929
}
3030

3131
const auto& disableEnv = details.mDisableEnvironment;
@@ -34,8 +34,8 @@ class DisabledByEnvironmentLinter final : public Linter {
3434
std::make_shared<LintError>(
3535
fmt::format(
3636
"Layer `{}` does not define a `disable_environment` key",
37-
layer.mJSONPath.string()),
38-
PathSet {layer.mJSONPath}));
37+
layer.mManifestPath.string()),
38+
PathSet {layer.mManifestPath}));
3939
continue;
4040
}
4141

@@ -45,7 +45,7 @@ class DisabledByEnvironmentLinter final : public Linter {
4545
std::make_shared<LintError>(
4646
fmt::format(
4747
"Layer is disabled by environment variable `{}`", disableEnv),
48-
PathSet {layer.mJSONPath}));
48+
PathSet {layer.mManifestPath}));
4949
}
5050
}
5151
return errors;

src/linters/DuplicatesLinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class DuplicatesLinter final : public Linter {
2727
}
2828

2929
if (byName.contains(details.mName)) {
30-
byName.at(details.mName).emplace(layer.mJSONPath);
30+
byName.at(details.mName).emplace(layer.mManifestPath);
3131
} else {
32-
byName[details.mName] = {layer.mJSONPath};
32+
byName[details.mName] = {layer.mManifestPath};
3333
}
3434
}
3535

src/linters/OrderingLinter.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ static auto MakeOrderingLintError(
152152
const std::tuple<APILayer, APILayerDetails>& relativeTo,
153153
const FacetTrace& trace) {
154154
const auto toMoveName = std::get<1>(layerToMove).mName;
155-
const auto toMovePath = std::get<0>(layerToMove).mJSONPath;
155+
const auto toMovePath = std::get<0>(layerToMove).mManifestPath;
156156
const auto relativeToName = std::get<1>(relativeTo).mName;
157-
const auto relativeToPath = std::get<0>(relativeTo).mJSONPath;
157+
const auto relativeToPath = std::get<0>(relativeTo).mManifestPath;
158158

159159
auto msg = std::format(
160160
"{} ({}) must be {} {} ({})",
@@ -259,10 +259,10 @@ class OrderingLinter final : public Linter {
259259
"{} ({}) and {} ({}) are incompatible; you must remove or "
260260
"disable one.",
261261
details.mName,
262-
layer.mJSONPath.string(),
262+
layer.mManifestPath.string(),
263263
otherDetails.mName,
264-
other.mJSONPath.string()),
265-
PathSet {layer.mJSONPath, other.mJSONPath}));
264+
other.mManifestPath.string()),
265+
PathSet {layer.mManifestPath, other.mManifestPath}));
266266
}
267267

268268
// LINT RULE: ConflictsPerApp
@@ -283,12 +283,12 @@ class OrderingLinter final : public Linter {
283283
"using "
284284
"{} are disabled in {}.",
285285
details.mName,
286-
layer.mJSONPath.string(),
286+
layer.mManifestPath.string(),
287287
otherDetails.mName,
288-
other.mJSONPath.string(),
288+
other.mManifestPath.string(),
289289
details.mName,
290290
otherDetails.mName),
291-
PathSet {layer.mJSONPath, other.mJSONPath}));
291+
PathSet {layer.mManifestPath, other.mManifestPath}));
292292
}
293293
}
294294

0 commit comments

Comments
 (0)