authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-01 13:01:39-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:18-07:00
log579f572cf203eda11da7e4e919fdfc12e15f03e2
tree7675d0ea786fb391a7f0749035d925203e448a8e
parentc20ad51c621ba18d2c90cc96d1b550831dc5d7a3

zig build system: remove vcpkg integration

Instead of vcpkg, users are encouraged to use the Zig package manager to fulfill dependencies on Windows.

3 files changed, 0 insertions(+), 113 deletions(-)

lib/std/Build.zig-17
......@@ -67,7 +67,6 @@ cache_root: Cache.Directory,
6767global_cache_root: Cache.Directory,
6868cache: *Cache,
6969zig_lib_dir: ?LazyPath,
70vcpkg_root: VcpkgRoot = .unattempted,
7170pkg_config_pkg_list: ?(PkgConfigError![]const PkgConfigPkg) = null,
7271args: ?[][]const u8 = null,
7372debug_log_scopes: []const []const u8 = &.{},
......@@ -841,10 +840,6 @@ pub fn addRunArtifact(b: *Build, exe: *Step.Compile) *Step.Run {
841840 run_step.enableTestRunnerMode();
842841 }
843842
844 if (exe.vcpkg_bin_path) |path| {
845 run_step.addPathDir(path);
846 }
847
848843 return run_step;
849844}
850845
......@@ -1978,18 +1973,6 @@ pub fn constructCMacro(allocator: Allocator, name: []const u8, value: ?[]const u
19781973 return macro;
19791974}
19801975
1981pub const VcpkgRoot = union(VcpkgRootStatus) {
1982 unattempted: void,
1983 not_found: void,
1984 found: []const u8,
1985};
1986
1987pub const VcpkgRootStatus = enum {
1988 unattempted,
1989 not_found,
1990 found,
1991};
1992
19931976pub const InstallDir = union(enum) {
19941977 prefix: void,
19951978 lib: void,
lib/std/Build/Step/Compile.zig-59
......@@ -16,7 +16,6 @@ const PkgConfigPkg = std.Build.PkgConfigPkg;
1616const PkgConfigError = std.Build.PkgConfigError;
1717const RunError = std.Build.RunError;
1818const Module = std.Build.Module;
19const VcpkgRoot = std.Build.VcpkgRoot;
2019const InstallDir = std.Build.InstallDir;
2120const GeneratedFile = std.Build.GeneratedFile;
2221const Compile = @This();
......@@ -63,7 +62,6 @@ test_server_mode: bool,
6362wasi_exec_model: ?std.builtin.WasiExecModel = null,
6463
6564installed_headers: ArrayList(*Step),
66vcpkg_bin_path: ?[]const u8 = null,
6765
6866// keep in sync with src/Compilation.zig:RcIncludes
6967/// Behavior of automatic detection of include directories when compiling .rc files.
......@@ -936,44 +934,6 @@ pub fn addFrameworkPath(self: *Compile, directory_source: LazyPath) void {
936934 directory_source.addStepDependencies(&self.step);
937935}
938936
939/// If Vcpkg was found on the system, it will be added to include and lib
940/// paths for the specified target.
941pub fn addVcpkgPaths(self: *Compile, linkage: Compile.Linkage) !void {
942 const b = self.step.owner;
943 // Ideally in the Unattempted case we would call the function recursively
944 // after findVcpkgRoot and have only one switch statement, but the compiler
945 // cannot resolve the error set.
946 switch (b.vcpkg_root) {
947 .unattempted => {
948 b.vcpkg_root = if (try findVcpkgRoot(b.allocator)) |root|
949 VcpkgRoot{ .found = root }
950 else
951 .not_found;
952 },
953 .not_found => return error.VcpkgNotFound,
954 .found => {},
955 }
956
957 switch (b.vcpkg_root) {
958 .unattempted => unreachable,
959 .not_found => return error.VcpkgNotFound,
960 .found => |root| {
961 const allocator = b.allocator;
962 const triplet = try self.target.vcpkgTriplet(allocator, if (linkage == .static) .Static else .Dynamic);
963 defer b.allocator.free(triplet);
964
965 const include_path = b.pathJoin(&.{ root, "installed", triplet, "include" });
966 errdefer allocator.free(include_path);
967 try self.include_dirs.append(.{ .path = .{ .path = include_path } });
968
969 const lib_path = b.pathJoin(&.{ root, "installed", triplet, "lib" });
970 try self.lib_paths.append(.{ .path = lib_path });
971
972 self.vcpkg_bin_path = b.pathJoin(&.{ root, "installed", triplet, "bin" });
973 },
974 }
975}
976
977937pub fn setExecCmd(self: *Compile, args: []const ?[]const u8) void {
978938 const b = self.step.owner;
979939 assert(self.kind == .@"test");
......@@ -1814,25 +1774,6 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
18141774 }
18151775}
18161776
1817/// Returned slice must be freed by the caller.
1818fn findVcpkgRoot(allocator: Allocator) !?[]const u8 {
1819 const appdata_path = try fs.getAppDataDir(allocator, "vcpkg");
1820 defer allocator.free(appdata_path);
1821
1822 const path_file = try fs.path.join(allocator, &[_][]const u8{ appdata_path, "vcpkg.path.txt" });
1823 defer allocator.free(path_file);
1824
1825 const file = fs.cwd().openFile(path_file, .{}) catch return null;
1826 defer file.close();
1827
1828 const size = @as(usize, @intCast(try file.getEndPos()));
1829 const vcpkg_path = try allocator.alloc(u8, size);
1830 const size_read = try file.read(vcpkg_path);
1831 std.debug.assert(size == size_read);
1832
1833 return vcpkg_path;
1834}
1835
18361777pub fn doAtomicSymLinks(
18371778 step: *Step,
18381779 output_path: []const u8,
lib/std/zig/CrossTarget.zig-37
......@@ -636,43 +636,6 @@ pub fn wantSharedLibSymLinks(self: CrossTarget) bool {
636636 return self.getOsTag() != .windows;
637637}
638638
639pub const VcpkgLinkage = std.builtin.LinkMode;
640
641/// Returned slice must be freed by the caller.
642pub fn vcpkgTriplet(self: CrossTarget, allocator: mem.Allocator, linkage: VcpkgLinkage) ![]u8 {
643 const arch = switch (self.getCpuArch()) {
644 .x86 => "x86",
645 .x86_64 => "x64",
646
647 .arm,
648 .armeb,
649 .thumb,
650 .thumbeb,
651 .aarch64_32,
652 => "arm",
653
654 .aarch64,
655 .aarch64_be,
656 => "arm64",
657
658 else => return error.UnsupportedVcpkgArchitecture,
659 };
660
661 const os = switch (self.getOsTag()) {
662 .windows => "windows",
663 .linux => "linux",
664 .macos => "macos",
665 else => return error.UnsupportedVcpkgOperatingSystem,
666 };
667
668 const static_suffix = switch (linkage) {
669 .Static => "-static",
670 .Dynamic => "",
671 };
672
673 return std.fmt.allocPrint(allocator, "{s}-{s}{s}", .{ arch, os, static_suffix });
674}
675
676639pub fn isGnuLibC(self: CrossTarget) bool {
677640 return Target.isGnuLibC_os_tag_abi(self.getOsTag(), self.getAbi());
678641}