use zig package manager

This commit is contained in:
Mitchell Hashimoto 2023-08-03 16:53:26 -07:00
parent 51584a2f78
commit 01c16aaeeb
No known key found for this signature in database
GPG key ID: 523D5DC389D273BC
5 changed files with 21 additions and 33 deletions

3
.gitmodules vendored
View file

@ -1,3 +0,0 @@
[submodule "vendor/mach-glfw"]
path = vendor/mach-glfw
url = https://github.com/hexops/mach-glfw.git

View file

@ -1,26 +1,12 @@
const std = @import("std"); const std = @import("std");
const system_sdk = @import("vendor/mach-glfw/system_sdk.zig"); const xcode_frameworks = @import("xcode_frameworks");
/// Use this with addPackage in your project.
pub const pkg = std.build.Pkg{
.name = "objc",
.source = .{ .path = thisDir() ++ "/src/main.zig" },
};
/// Returns the module for libxev. The recommended approach is to depend
/// on libxev in your build.zig.zon file, then use
/// `b.dependency("libxev").module("xev")`. But if you're not using
/// a build.zig.zon yet this will work.
pub fn module(b: *std.Build) *std.Build.Module {
return b.createModule(.{
.source_file = .{ .path = (comptime thisDir()) ++ "/src/main.zig" },
});
}
pub fn build(b: *std.Build) !void { pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
_ = b.addModule("objc", .{ .source_file = .{ .path = "src/main.zig" } });
const tests = b.addTest(.{ const tests = b.addTest(.{
.name = "objc-test", .name = "objc-test",
.root_source_file = .{ .path = "src/main.zig" }, .root_source_file = .{ .path = "src/main.zig" },
@ -28,14 +14,10 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize, .optimize = optimize,
}); });
tests.linkSystemLibrary("objc"); tests.linkSystemLibrary("objc");
system_sdk.include(b, tests, .{}); try xcode_frameworks.addPaths(b, tests);
b.installArtifact(tests); b.installArtifact(tests);
const test_step = b.step("test", "Run tests"); const test_step = b.step("test", "Run tests");
const tests_run = b.addRunArtifact(tests); const tests_run = b.addRunArtifact(tests);
test_step.dependOn(&tests_run.step); test_step.dependOn(&tests_run.step);
} }
fn thisDir() []const u8 {
return std.fs.path.dirname(@src().file) orelse ".";
}

10
build.zig.zon Normal file
View file

@ -0,0 +1,10 @@
.{
.name = "zig-objc",
.version = "0.0.0",
.dependencies = .{
.xcode_frameworks = .{
.url = "https://github.com/mitchellh/zig-build-xcode-frameworks/archive/8a5fac6c4e7110be073b93cdbb317264731b2e14.tar.gz",
.hash = "122057e2244209296c552203b246870f6bc0326f9bd8eb41bc1e9e1de5c2a62c5be3",
},
},
}

View file

@ -80,16 +80,16 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1661151577, "lastModified": 1689088367,
"narHash": "sha256-++S0TuJtuz9IpqP8rKktWyHZKpgdyrzDFUXVY07MTRI=", "narHash": "sha256-Y2tl2TlKCWEHrOeM9ivjCLlRAKH3qoPUE/emhZECU14=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "54060e816971276da05970a983487a25810c38a7", "rev": "5c9ddb86679c400d6b7360797b8a22167c2053f8",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixpkgs-unstable", "ref": "release-23.05",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -109,11 +109,11 @@
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1688126918, "lastModified": 1691064519,
"narHash": "sha256-A4j6rWShGZf2wf7RwTd1sWhN9qLAINDYsExqZD6N09k=", "narHash": "sha256-kGl2GigkW6O7uVc5W4mFdn9SN2fOBpKdvbhSxZj/huQ=",
"owner": "mitchellh", "owner": "mitchellh",
"repo": "zig-overlay", "repo": "zig-overlay",
"rev": "601ed4533722f87b9e97580d30ddd687e58c6b16", "rev": "8a0bae25fcebaacdd117df045271778ffbb10735",
"type": "github" "type": "github"
}, },
"original": { "original": {

1
vendor/mach-glfw vendored

@ -1 +0,0 @@
Subproject commit 70ff87ba8af0820bbcfdbdf3b15555cb4c19f7ab