Skip to content

Commit 2dbafac

Browse files
feat: initial code
1 parent 2e39d37 commit 2dbafac

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
zig-out
2+
zig-cache
3+
result
4+
result-*

build.zig

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const std = @import("std");
2+
const Phantom = @import("phantom");
3+
4+
pub fn build(b: *std.Build) void {
5+
const target = b.standardTargetOptions(.{});
6+
const optimize = b.standardOptimizeOption(.{});
7+
const backend = b.option(Phantom.BackendType, "backend", "The backend to use for the example") orelse .headless;
8+
9+
const phantom_i18n = b.dependency("phantom.i18n", .{
10+
.target = target,
11+
.optimize = optimize,
12+
});
13+
14+
const phantom = b.dependency("phantom", .{
15+
.target = target,
16+
.optimize = optimize,
17+
});
18+
19+
_ = b.addModule("phantom.i18n", .{
20+
.source_file = .{
21+
.path = phantom_i18n.builder.pathFromRoot(phantom_i18n.module("phantom.i18n").source_file.path),
22+
},
23+
});
24+
25+
_ = b.addModule("phantom", .{
26+
.source_file = .{
27+
.path = phantom.builder.pathFromRoot(phantom.module("phantom").source_file.path),
28+
},
29+
});
30+
31+
const options = b.addOptions();
32+
options.addOption(Phantom.BackendType, "backend", backend);
33+
34+
const exe = b.addExecutable(.{
35+
.name = "example",
36+
.root_source_file = .{
37+
.path = b.pathFromRoot("src/example.zig"),
38+
},
39+
.target = target,
40+
.optimize = optimize,
41+
});
42+
43+
exe.addModule("phantom", phantom.module("phantom"));
44+
exe.addModule("phantom.i18n", phantom_i18n.module("phantom.i18n"));
45+
exe.addOptions("options", options);
46+
b.installArtifact(exe);
47+
}

build.zig.zon

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.{
2+
.name = "phantom.examples",
3+
.version = "0.1.0",
4+
.paths = .{"."},
5+
.dependencies = .{
6+
.@"phantom.i18n" = .{
7+
.url = "https://github.com/PhantomUIx/i18n/archive/6e3d4d26916fce1cf97f49a201459a2d066d144c.tar.gz",
8+
.hash = "12203988815fdb49289b66e766e6733728157c3f77508933af6d205aa6bcc3b4b595",
9+
},
10+
.phantom = .{
11+
.url = "https://github.com/PhantomUIx/core/archive/8d5ec14e9bd68f5c6d56f4425b894f6ac5660d4c.tar.gz",
12+
.hash = "122089bcabf151c4e64e4480f87d3aaa09863b486ccf112a17445319b4be5ec1d88c",
13+
},
14+
},
15+
}

src/example.zig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const std = @import("std");
2+
const phantom = @import("phantom");
3+
4+
pub const phantomOptions = struct {
5+
pub const modules = struct {
6+
pub const i18n = @import("phantom.i18n");
7+
};
8+
};
9+
10+
pub fn main() void {
11+
std.debug.print("{}\n", .{phantom.i18n});
12+
}

0 commit comments

Comments
 (0)