Skip to content

Commit d1a78a7

Browse files
committed
Fix non-Windows build errors.
1 parent 486fbf9 commit d1a78a7

File tree

4 files changed

+64
-42
lines changed

4 files changed

+64
-42
lines changed

include/vcpkg/base/message-data.inc.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,11 +1443,6 @@ DECLARE_MESSAGE(GitCommitUpdateVersionDatabase,
14431443
(),
14441444
"This is a command line; only the 'update version database' part should be localized",
14451445
"git commit -m \"Update version database\"")
1446-
DECLARE_MESSAGE(GitFailedToFetch,
1447-
(msg::value, msg::url),
1448-
"{value} is a git ref like 'origin/main'",
1449-
"failed to fetch ref {value} from repository {url}")
1450-
DECLARE_MESSAGE(GitFailedToInitializeLocalRepository, (msg::path), "", "failed to initialize local repository {path}")
14511446
DECLARE_MESSAGE(
14521447
GitRegistryMustHaveBaseline,
14531448
(msg::url, msg::commit_sha),

locales/messages.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -866,10 +866,6 @@
866866
"_GhaBinaryCacheDeprecated.comment": "The term 'x-gha' is a vcpkg configuration option An example of {url} is https://github.com/microsoft/vcpkg.",
867867
"GitCommitUpdateVersionDatabase": "git commit -m \"Update version database\"",
868868
"_GitCommitUpdateVersionDatabase.comment": "This is a command line; only the 'update version database' part should be localized",
869-
"GitFailedToFetch": "failed to fetch ref {value} from repository {url}",
870-
"_GitFailedToFetch.comment": "{value} is a git ref like 'origin/main' An example of {url} is https://github.com/microsoft/vcpkg.",
871-
"GitFailedToInitializeLocalRepository": "failed to initialize local repository {path}",
872-
"_GitFailedToInitializeLocalRepository.comment": "An example of {path} is /foo/bar.",
873869
"GitRegistryMustHaveBaseline": "The git registry \"{url}\" must have a \"baseline\" field that is a valid git commit SHA (40 hexadecimal characters).\nTo use the current latest versions, set baseline to that repo's HEAD, \"{commit_sha}\".",
874870
"_GitRegistryMustHaveBaseline.comment": "An example of {url} is https://github.com/microsoft/vcpkg. An example of {commit_sha} is 7cfad47ae9f68b183983090afd6337cd60fd4949.",
875871
"GitUnexpectedCommandOutputCmd": "git produced unexpected output when running {command_line}",

src/vcpkg/base/files.cpp

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4284,133 +4284,137 @@ namespace vcpkg
42844284
std::make_error_code(std::errc::not_supported), "read_lines", {file_path});
42854285
}
42864286

4287-
std::uint64_t file_size(const Path&, std::error_code& ec) const
4287+
std::uint64_t file_size(const Path&, std::error_code& ec) const override
42884288
{
42894289
assign_not_supported(ec);
42904290
return 0;
42914291
}
42924292

4293-
std::string read_contents(const Path&, std::error_code& ec) const
4293+
std::string read_contents(const Path&, std::error_code& ec) const override
42944294
{
42954295
assign_not_supported(ec);
42964296
return std::string();
42974297
}
42984298

4299-
std::string best_effort_read_contents_if_shebang(const Path&) const { return std::string(); }
4299+
std::string best_effort_read_contents_if_shebang(const Path&) const override { return std::string(); }
43004300

4301-
Path find_file_recursively_up(const Path&, const Path&, std::error_code& ec) const
4301+
Path find_file_recursively_up(const Path&, const Path&, std::error_code& ec) const override
43024302
{
43034303
assign_not_supported(ec);
43044304
return Path();
43054305
}
43064306

4307-
std::vector<Path> get_files_recursive(const Path&, std::error_code& ec) const
4307+
std::vector<Path> get_files_recursive(const Path&, std::error_code& ec) const override
43084308
{
43094309
assign_not_supported(ec);
43104310
return std::vector<Path>();
43114311
}
43124312

4313-
std::vector<Path> get_files_recursive_lexically_proximate(const Path&, std::error_code& ec) const
4313+
std::vector<Path> get_files_recursive_lexically_proximate(const Path&, std::error_code& ec) const override
43144314
{
43154315
assign_not_supported(ec);
43164316
return std::vector<Path>();
43174317
}
43184318

4319-
std::vector<Path> get_files_non_recursive(const Path&, std::error_code& ec) const
4319+
std::vector<Path> get_files_non_recursive(const Path&, std::error_code& ec) const override
43204320
{
43214321
assign_not_supported(ec);
43224322
return std::vector<Path>();
43234323
}
43244324

4325-
std::vector<Path> get_directories_recursive(const Path&, std::error_code& ec) const
4325+
std::vector<Path> get_directories_recursive(const Path&, std::error_code& ec) const override
43264326
{
43274327
assign_not_supported(ec);
43284328
return std::vector<Path>();
43294329
}
43304330

4331-
std::vector<Path> get_directories_recursive_lexically_proximate(const Path&, std::error_code& ec) const
4331+
std::vector<Path> get_directories_recursive_lexically_proximate(const Path&, std::error_code& ec) const override
43324332
{
43334333
assign_not_supported(ec);
43344334
return std::vector<Path>();
43354335
}
43364336

4337-
std::vector<Path> get_directories_non_recursive(const Path&, std::error_code& ec) const
4337+
std::vector<Path> get_directories_non_recursive(const Path&, std::error_code& ec) const override
43384338
{
43394339
assign_not_supported(ec);
43404340
return std::vector<Path>();
43414341
}
43424342

4343-
std::vector<Path> get_regular_files_recursive(const Path&, std::error_code& ec) const
4343+
std::vector<Path> get_regular_files_recursive(const Path&, std::error_code& ec) const override
43444344
{
43454345
assign_not_supported(ec);
43464346
return std::vector<Path>();
43474347
}
43484348

4349-
std::vector<Path> get_regular_files_recursive_lexically_proximate(const Path&, std::error_code& ec) const
4349+
std::vector<Path> get_regular_files_recursive_lexically_proximate(const Path&,
4350+
std::error_code& ec) const override
43504351
{
43514352
assign_not_supported(ec);
43524353
return std::vector<Path>();
43534354
}
43544355

4355-
std::vector<Path> get_regular_files_non_recursive(const Path&, std::error_code& ec) const
4356+
std::vector<Path> get_regular_files_non_recursive(const Path&, std::error_code& ec) const override
43564357
{
43574358
assign_not_supported(ec);
43584359
return std::vector<Path>();
43594360
}
43604361

4361-
bool is_directory(const Path&) const { return false; }
4362-
bool is_regular_file(const Path&) const { return false; }
4363-
bool is_empty(const Path&, std::error_code& ec) const
4362+
bool is_directory(const Path&) const override { return false; }
4363+
bool is_regular_file(const Path&) const override { return false; }
4364+
bool is_empty(const Path&, std::error_code& ec) const override
43644365
{
43654366
assign_not_supported(ec);
43664367
return false;
43674368
}
43684369

4369-
FileType status(const Path&, std::error_code& ec) const
4370+
FileType status(const Path&, std::error_code& ec) const override
43704371
{
43714372
assign_not_supported(ec);
43724373
return FileType::unknown;
43734374
}
43744375

4375-
FileType symlink_status(const Path&, std::error_code& ec) const
4376+
FileType symlink_status(const Path&, std::error_code& ec) const override
43764377
{
43774378
assign_not_supported(ec);
43784379
return FileType::unknown;
43794380
}
43804381

4381-
Path almost_canonical(const Path&, std::error_code& ec) const
4382+
Path almost_canonical(const Path&, std::error_code& ec) const override
43824383
{
43834384
assign_not_supported(ec);
43844385
return Path();
43854386
}
43864387

4387-
Path current_path(std::error_code& ec) const
4388+
Path current_path(std::error_code& ec) const override
43884389
{
43894390
assign_not_supported(ec);
43904391
return Path();
43914392
}
43924393

4393-
Path absolute(const Path& p, std::error_code& ec) const
4394+
Path absolute(const Path& p, std::error_code& ec) const override
43944395
{
43954396
assign_not_supported(ec);
43964397
return p;
43974398
}
43984399

4399-
std::vector<Path> find_from_PATH(View<StringView>) const { return std::vector<Path>{}; }
4400-
ReadFilePointer open_for_read(const Path&, std::error_code& ec) const
4400+
std::vector<Path> find_from_PATH(View<StringView>) const override { return std::vector<Path>{}; }
4401+
ReadFilePointer open_for_read(const Path&, std::error_code& ec) const override
44014402
{
44024403
assign_not_supported(ec);
44034404
return ReadFilePointer{};
44044405
}
44054406

4406-
void write_lines(const Path&, const std::vector<std::string>&, std::error_code& ec) const
4407+
void write_lines(const Path&, const std::vector<std::string>&, std::error_code& ec) const override
44074408
{
44084409
assign_not_supported(ec);
44094410
}
44104411

4411-
void write_contents(const Path&, StringView, std::error_code& ec) const { assign_not_supported(ec); }
4412+
void write_contents(const Path&, StringView, std::error_code& ec) const override { assign_not_supported(ec); }
44124413

4413-
void write_contents_and_dirs(const Path&, StringView, std::error_code& ec) const { assign_not_supported(ec); }
4414+
void write_contents_and_dirs(const Path&, StringView, std::error_code& ec) const override
4415+
{
4416+
assign_not_supported(ec);
4417+
}
44144418

44154419
void rename(const Path&, const Path&, std::error_code& ec) const override { assign_not_supported(ec); }
44164420

src/vcpkg/tools.cpp

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ namespace vcpkg
392392
}
393393

394394
virtual Optional<std::string> get_version(DiagnosticContext& context,
395+
const Filesystem& fs,
395396
const ToolCache& cache,
396397
const Path& exe_path) const = 0;
397398

@@ -426,7 +427,10 @@ namespace vcpkg
426427
virtual std::array<int, 3> default_min_version() const override { return {0}; }
427428
virtual bool ignore_version() const override { return true; }
428429

429-
virtual Optional<std::string> get_version(DiagnosticContext&, const ToolCache&, const Path&) const override
430+
virtual Optional<std::string> get_version(DiagnosticContext&,
431+
const Filesystem&,
432+
const ToolCache&,
433+
const Path&) const override
430434
{
431435
return {"0"};
432436
}
@@ -462,6 +466,7 @@ namespace vcpkg
462466
#endif
463467

464468
virtual Optional<std::string> get_version(DiagnosticContext& context,
469+
const Filesystem&,
465470
const ToolCache&,
466471
const Path& exe_path) const override
467472
{
@@ -507,6 +512,7 @@ namespace vcpkg
507512

508513
#endif
509514
virtual Optional<std::string> get_version(DiagnosticContext& context,
515+
const Filesystem&,
510516
const ToolCache&,
511517
const Path& exe_path) const override
512518
{
@@ -545,6 +551,7 @@ namespace vcpkg
545551
#endif // ^^^ !defined(_WIN32)
546552

547553
virtual Optional<std::string> get_version(DiagnosticContext& context,
554+
const Filesystem&,
548555
const ToolCache&,
549556
const Path& exe_path) const override
550557
{
@@ -561,13 +568,23 @@ namespace vcpkg
561568
virtual std::array<int, 3> default_min_version() const override { return {4, 6, 2}; }
562569

563570
virtual Optional<std::string> get_version(DiagnosticContext& context,
571+
const Filesystem& fs,
564572
const ToolCache& cache,
565573
const Path& exe_path) const override
566574
{
567-
(void)cache;
568575
Command cmd;
569-
#if !defined(_WIN32)
570-
cmd.string_arg(cache.get_tool_path(context, Tools::MONO));
576+
#if defined(_WIN32)
577+
(void)fs;
578+
(void)cache;
579+
#else
580+
const auto* mono_path = cache.get_tool_path(context, fs, Tools::Mono);
581+
if (!mono_path)
582+
{
583+
context.report(DiagnosticLine{DiagKind::Note, msgMonoInstructions});
584+
return nullopt;
585+
}
586+
587+
cmd.string_arg(*mono_path);
571588
#endif // ^^^ !_WIN32
572589
cmd.string_arg(exe_path).string_arg("help").string_arg("-ForceEnglishOutput");
573590
auto maybe_output = run_to_extract_version(context, Tools::NUGET, exe_path, std::move(cmd));
@@ -610,6 +627,7 @@ namespace vcpkg
610627
#endif
611628

612629
virtual Optional<std::string> get_version(DiagnosticContext& context,
630+
const Filesystem&,
613631
const ToolCache&,
614632
const Path& exe_path) const override
615633
{
@@ -644,6 +662,7 @@ namespace vcpkg
644662
#endif
645663

646664
virtual Optional<std::string> get_version(DiagnosticContext& context,
665+
const Filesystem&,
647666
const ToolCache&,
648667
const Path& exe_path) const override
649668
{
@@ -663,6 +682,7 @@ namespace vcpkg
663682
virtual std::array<int, 3> default_min_version() const override { return {0, 0, 0}; }
664683

665684
virtual Optional<std::string> get_version(DiagnosticContext& context,
685+
const Filesystem&,
666686
const ToolCache&,
667687
const Path& exe_path) const override
668688
{
@@ -695,6 +715,7 @@ namespace vcpkg
695715
virtual std::array<int, 3> default_min_version() const override { return {4, 56, 0}; }
696716

697717
virtual Optional<std::string> get_version(DiagnosticContext& context,
718+
const Filesystem&,
698719
const ToolCache&,
699720
const Path& exe_path) const override
700721
{
@@ -714,6 +735,7 @@ namespace vcpkg
714735
virtual std::array<int, 3> default_min_version() const override { return {2, 4, 4}; }
715736

716737
virtual Optional<std::string> get_version(DiagnosticContext& context,
738+
const Filesystem&,
717739
const ToolCache&,
718740
const Path& exe_path) const override
719741
{
@@ -733,6 +755,7 @@ namespace vcpkg
733755
virtual std::array<int, 3> default_min_version() const override { return {2, 64, 0}; }
734756

735757
virtual Optional<std::string> get_version(DiagnosticContext& context,
758+
const Filesystem&,
736759
const ToolCache&,
737760
const Path& exe_path) const override
738761
{
@@ -759,6 +782,7 @@ namespace vcpkg
759782
virtual std::array<int, 3> default_min_version() const override { return {0, 11, 0}; }
760783

761784
virtual Optional<std::string> get_version(DiagnosticContext& context,
785+
const Filesystem&,
762786
const ToolCache&,
763787
const Path& exe_path) const override
764788
{
@@ -786,6 +810,7 @@ namespace vcpkg
786810
virtual std::array<int, 3> default_min_version() const override { return {7, 0, 3}; }
787811

788812
virtual Optional<std::string> get_version(DiagnosticContext& context,
813+
const Filesystem&,
789814
const ToolCache&,
790815
const Path& exe_path) const override
791816
{
@@ -842,6 +867,7 @@ namespace vcpkg
842867
#endif // ^^^ _WIN32
843868

844869
virtual Optional<std::string> get_version(DiagnosticContext& context,
870+
const Filesystem&,
845871
const ToolCache&,
846872
const Path& exe_path) const override
847873
{
@@ -912,6 +938,7 @@ namespace vcpkg
912938
#endif
913939

914940
virtual Optional<std::string> get_version(DiagnosticContext& context,
941+
const Filesystem&,
915942
const ToolCache&,
916943
const Path& exe_path) const override
917944
{
@@ -953,7 +980,7 @@ namespace vcpkg
953980
*/
954981
template<typename Func, typename Func2>
955982
Optional<PathAndVersion> find_first_with_sufficient_version(DiagnosticContext& context,
956-
const ReadOnlyFilesystem& fs,
983+
const Filesystem& fs,
957984
const ToolProvider& tool_provider,
958985
const std::vector<Path>& candidates,
959986
Func&& accept_version,
@@ -964,7 +991,7 @@ namespace vcpkg
964991
if (!fs.exists(candidate, IgnoreErrors{})) continue;
965992
if (!tool_provider.cheap_is_acceptable(candidate)) continue;
966993
AttemptDiagnosticContext adc{context};
967-
auto maybe_version = tool_provider.get_version(adc, *this, candidate);
994+
auto maybe_version = tool_provider.get_version(adc, fs, *this, candidate);
968995
const auto version = maybe_version.get();
969996
if (!version)
970997
{
@@ -1194,7 +1221,7 @@ namespace vcpkg
11941221
auto maybe_downloaded_path = download_tool(context, fs, *tool_data);
11951222
if (auto downloaded_path = maybe_downloaded_path.get())
11961223
{
1197-
auto maybe_downloaded_version = tool.get_version(context, *this, *downloaded_path);
1224+
auto maybe_downloaded_version = tool.get_version(context, fs, *this, *downloaded_path);
11981225
if (auto downloaded_version = maybe_downloaded_version.get())
11991226
{
12001227
return PathAndVersion{std::move(*downloaded_path), std::move(*downloaded_version)};

0 commit comments

Comments
 (0)