diff options
| author | Sahnvour <Sahnvour@users.noreply.github.com> | 2019-11-12 20:16:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-12 20:16:01 +0100 |
| commit | 956ba8b0e7ada08f2f85cd41ee73af6453db0c16 (patch) | |
| tree | 5fc46585794c24875bf8136d6435333c9dbae759 /lib/std/target.zig | |
| parent | e32b4829f4f91ee412ead7a3851f6e271d9fb07e (diff) | |
| parent | def5462d053d744a9f4c2c6874355a23d3371b3d (diff) | |
| download | zig-956ba8b0e7ada08f2f85cd41ee73af6453db0c16.tar.gz zig-956ba8b0e7ada08f2f85cd41ee73af6453db0c16.zip | |
Merge pull request #3447 from Sahnvour/vcpkg
build: initial support for using vcpkg libraries
Diffstat (limited to 'lib/std/target.zig')
| -rw-r--r-- | lib/std/target.zig | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/std/target.zig b/lib/std/target.zig index 4d600d4d38..5c0ac3d905 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -218,6 +218,40 @@ pub const Target = union(enum) { ); } + /// Returned slice must be freed by the caller. + pub fn vcpkgTriplet(allocator: *mem.Allocator, target: Target, linkage: std.build.VcpkgLinkage) ![]const u8 { + const arch = switch (target.getArch()) { + .i386 => "x86", + .x86_64 => "x64", + + .arm, + .armeb, + .thumb, + .thumbeb, + .aarch64_32, + => "arm", + + .aarch64, + .aarch64_be, + => "arm64", + + else => return error.VcpkgNoSuchArchitecture, + }; + + const os = switch (target.getOs()) { + .windows => "windows", + .linux => "linux", + .macosx => "macos", + else => return error.VcpkgNoSuchOs, + }; + + if (linkage == .Static) { + return try mem.join(allocator, "-", [_][]const u8{ arch, os, "static" }); + } else { + return try mem.join(allocator, "-", [_][]const u8{ arch, os }); + } + } + pub fn allocDescription(self: Target, allocator: *mem.Allocator) ![]u8 { // TODO is there anything else worthy of the description that is not // already captured in the triple? |
