Skip to content

Commit

Permalink
WIP: Vendor external
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraVoves committed Nov 20, 2024
1 parent d0d9913 commit 5470878
Show file tree
Hide file tree
Showing 52 changed files with 110 additions and 9,271 deletions.
1 change: 0 additions & 1 deletion .ci/init_zig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ ZIG_ARCH=$1
OPTIMIZE=$2

./zig/get_zig.sh ${ZIG_ARCH}

25 changes: 14 additions & 11 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Fetch zig submodule
run: git submodule update --init externals/shared

- name: Read .zig-version
id: zigversion
Expand Down Expand Up @@ -58,10 +59,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true


- name: Fetch zig submodule
run: git submodule update --init externals/shared

- name: Prepare
uses: awalsh128/cache-apt-pkgs-action@latest
with:
Expand Down Expand Up @@ -165,10 +166,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

# - name: Prepare
- name: Fetch zig submodule
run: git submodule update --init externals/shared

# - name: Prepare`
# run: |
# brew update
# brew install kcov
Expand Down Expand Up @@ -256,9 +258,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true


- name: Fetch zig submodule
run: git submodule update --init externals/shared

- name: Read .zig-version
id: zigversion
uses: juliangruber/read-file-action@v1
Expand Down
27 changes: 3 additions & 24 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
[submodule "externals/shared/lib/zig-gamedev"]
path = externals/shared/lib/zig-gamedev
url = https://github.com/OndraVoves/zig-gamedev.git
[submodule "externals/shared/tools/zls"]
path = externals/shared/tools/zls
url = https://github.com/zigtools/zls.git
[submodule "externals/shared/lib/SDL_GameControllerDB"]
path = externals/shared/lib/SDL_GameControllerDB
url = https://github.com/mdqinc/SDL_GameControllerDB.git
[submodule "zig"]
path = zig
url = https://github.com/cyberegoorg/cetech1-zig.git
[submodule "externals/shared/lib/zbgfx"]
path = externals/shared/lib/zbgfx
url = https://github.com/cyberegoorg/zbgfx.git
[submodule "externals/shared/lib/ziglang-set"]
path = externals/shared/lib/ziglang-set
url = https://github.com/deckarep/ziglang-set
[submodule "externals/shared/lib/zig-uuid"]
path = externals/shared/lib/zig-uuid
url = https://github.com/tensorush/zig-uuid.git
[submodule "externals/shared/lib/zf"]
path = externals/shared/lib/zf
url = https://github.com/OndraVoves/zf.git
[submodule "externals/shared"]
path = externals/shared
url = https://github.com/cyberegoorg/cetech1-externals-shared.git
4 changes: 2 additions & 2 deletions Writerside/snippets/getting-started/clone.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# GIT_LFS_SKIP_SMUDGE=1 disable loading all LFS objects
GIT_LFS_SKIP_SMUDGE=1 git clone https://github.com/cyberegoorg/cetech1.git

# This fetch submodules from `externals` and zig directory
git submodule update --init
# This fetch basic externals deps
git submodule update --init externals/shared

# This download zig binary from our website. Only need for your arch where you develop
./zig/get_zig.sh <ARCH>
Expand Down
4 changes: 2 additions & 2 deletions Writerside/topics/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ CETech provide ZLS as submodule, but you must build it.
<tabs>
<tab title="MacOS/Linux">
<code-block lang="bash">
zig/bin/ARCH/zig build zls
zig/bin/ARCH/zig build -Dwith_zls zls
</code-block>
</tab>
<tab title="Windows">
<code-block lang="bash">
zig/bin/ARCH/zig.exe build zls
zig/bin/ARCH/zig.exe build -Dwith_zls zls
</code-block>
</tab>
</tabs>
Expand Down
115 changes: 79 additions & 36 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ pub fn build(b: *std.Build) !void {
.externals_optimize = b.option(std.builtin.OptimizeMode, "externals_optimize", "Optimize for externals libs") orelse .ReleaseFast,

.enable_shaderc = b.option(bool, "with_shaderc", "build with shaderc support") orelse true,

.enable_zls = b.option(bool, "with_zls", "zls") orelse false,
};

const options_step = b.addOptions();
Expand Down Expand Up @@ -120,15 +122,6 @@ pub fn build(b: *std.Build) !void {
},
);

// ZPOOL
const zpool = b.dependency(
"zpool",
.{
.target = target,
.optimize = options.externals_optimize,
},
);

// ZFLECS
const zflecs = b.dependency(
"zflecs",
Expand All @@ -148,12 +141,6 @@ pub fn build(b: *std.Build) !void {
},
);

// ZLS
const zls = b.dependency("zls", .{
.target = target,
.optimize = .ReleaseFast,
});

// System sdk
// const system_sdk = b.dependency("system_sdk", .{});

Expand Down Expand Up @@ -235,18 +222,41 @@ pub fn build(b: *std.Build) !void {
"--include",
"src/embed/fonts/*",
});

const init_system_sdk = b.addSystemCommand(&.{
"git",
"-C",
"externals/shared",
"submodule",
"update",
"--init",
"repo/system_sdk",
});
const init_lfs_system_sdk = b.addSystemCommand(&.{
"git",
"-C",
"externals/shared/lib/zig-gamedev",
"externals/shared/repo/system_sdk",
"lfs",
"pull",
"--include",
"libs/system-sdk/**/*",
});
init_lfs_system_sdk.step.dependOn(&init_system_sdk.step);

const init_zls = b.addSystemCommand(&.{
"git",
"-C",
"externals/shared",
"submodule",
"update",
"--init",
"tools/zls",
});

init_step.dependOn(&init_lfs_writerside.step);
init_step.dependOn(&init_lfs_fonts.step);
init_step.dependOn(&init_lfs_system_sdk.step);
init_step.dependOn(&init_system_sdk.step);
init_step.dependOn(&init_zls.step);

//
// Gen vscode
Expand All @@ -259,9 +269,17 @@ pub fn build(b: *std.Build) !void {
//
// ZLS
//
const zls_step = b.step("zls", "Build bundled ZLS");
var zls_install = b.addInstallArtifact(zls.artifact("zls"), .{});
zls_step.dependOn(&zls_install.step);
if (options.enable_zls) {
const zls = b.dependency("zls", .{
.target = target,
.optimize = .ReleaseFast,
});

const zls_step = b.step("zls", "Build bundled ZLS");
var zls_install = b.addInstallArtifact(zls.artifact("zls"), .{});
zls_install.step.dependOn(&init_zls.step);
zls_step.dependOn(&zls_install.step);
}

//
// CETech1 core build
Expand Down Expand Up @@ -337,7 +355,35 @@ pub fn build(b: *std.Build) !void {

// Libs, moduels etc..
inline for (.{ exe, tests }) |e| {
@import("system_sdk").addLibraryPathsTo(e);
switch (target.result.os.tag) {
.windows => {
if (target.result.cpu.arch.isX86()) {
if (target.result.abi.isGnu() or target.result.abi.isMusl()) {
if (b.lazyDependency("system_sdk", .{})) |system_sdk| {
e.addLibraryPath(system_sdk.path("windows/lib/x86_64-windows-gnu"));
}
}
}
},
.macos => {
if (b.lazyDependency("system_sdk", .{})) |system_sdk| {
e.addLibraryPath(system_sdk.path("macos12/usr/lib"));
e.addFrameworkPath(system_sdk.path("macos12/System/Library/Frameworks"));
}
},
.linux => {
if (target.result.cpu.arch.isX86()) {
if (b.lazyDependency("system_sdk", .{})) |system_sdk| {
e.addLibraryPath(system_sdk.path("linux/lib/x86_64-linux-gnu"));
}
} else if (target.result.cpu.arch == .aarch64) {
if (b.lazyDependency("system_sdk", .{})) |system_sdk| {
e.addLibraryPath(system_sdk.path("linux/lib/aarch64-linux-gnu"));
}
}
},
else => {},
}

// Make exe depends on generated files.
e.step.dependOn(&generated_files.step);
Expand Down Expand Up @@ -367,7 +413,6 @@ pub fn build(b: *std.Build) !void {

e.root_module.addImport("ztracy", ztracy.module("root"));
e.root_module.addImport("zjobs", zjobs.module("root"));
e.root_module.addImport("zpool", zpool.module("root"));
e.root_module.addImport("zglfw", zglfw.module("root"));
e.root_module.addImport("zgui", zgui.module("root"));
e.root_module.addImport("zflecs", zflecs.module("root"));
Expand Down Expand Up @@ -426,26 +471,24 @@ const externals = .{
.{ .name = "zig", .file = "zig/LICENSE" },

// zig-gamedev
.{ .name = "zig-gamedev", .file = "externals/shared/lib/zig-gamedev/LICENSE" },
.{ .name = "zglfw", .file = "externals/shared/lib/zig-gamedev/libs/zglfw/LICENSE" },
.{ .name = "zpool", .file = "externals/shared/lib/zig-gamedev/libs/zpool/LICENSE" },
.{ .name = "zjobs", .file = "externals/shared/lib/zig-gamedev/libs/zjobs/LICENSE" },
.{ .name = "ztracy", .file = "externals/shared/lib/zig-gamedev/libs/ztracy/LICENSE" },
.{ .name = "zgui", .file = "externals/shared/lib/zig-gamedev/libs/zgui/LICENSE" },
.{ .name = "zflecs", .file = "externals/shared/lib/zig-gamedev/libs/zflecs/LICENSE" },
.{ .name = "zglfw", .file = "externals/shared/lib/zglfw/LICENSE" },
.{ .name = "zjobs", .file = "externals/shared/lib/zjobs/LICENSE" },
.{ .name = "ztracy", .file = "externals/shared/lib/ztracy/LICENSE" },
.{ .name = "zgui", .file = "externals/shared/lib/zgui/LICENSE" },
.{ .name = "zflecs", .file = "externals/shared/lib/zflecs/LICENSE" },

// ImGui
.{ .name = "imgui", .file = "externals/shared/lib/zig-gamedev/libs/zgui/libs/imgui/LICENSE.txt" },
.{ .name = "imgui_test_engine", .file = "externals/shared/lib/zig-gamedev/libs/zgui/libs/imgui_test_engine/LICENSE.txt" },
.{ .name = "implot", .file = "externals/shared/lib/zig-gamedev/libs/zgui/libs/implot/LICENSE" },
.{ .name = "imguizmo", .file = "externals/shared/lib/zig-gamedev/libs/zgui/libs/imguizmo/LICENSE" },
.{ .name = "imgui_node_editor", .file = "externals/shared/lib/zig-gamedev/libs/zgui/libs/node_editor/LICENSE" },
.{ .name = "imgui", .file = "externals/shared/lib/zgui/libs/imgui/LICENSE.txt" },
.{ .name = "imgui_test_engine", .file = "externals/shared/lib/zgui/libs/imgui_test_engine/LICENSE.txt" },
.{ .name = "implot", .file = "externals/shared/lib/zgui/libs/implot/LICENSE" },
.{ .name = "imguizmo", .file = "externals/shared/lib/zgui/libs/imguizmo/LICENSE" },
.{ .name = "imgui_node_editor", .file = "externals/shared/lib/zgui/libs/node_editor/LICENSE" },

// FLECS
.{ .name = "FLECS", .file = "externals/shared/lib/zig-gamedev/libs/zflecs/libs/flecs/LICENSE" },
.{ .name = "FLECS", .file = "externals/shared/lib/zflecs/libs/flecs/LICENSE" },

// GLFW
.{ .name = "glfw", .file = "externals/shared/lib/zig-gamedev/libs/zglfw/libs/glfw/LICENSE.md" },
.{ .name = "glfw", .file = "externals/shared/lib/zglfw/libs/glfw/LICENSE.md" },

// SDL_GameControllerDB
.{ .name = "SDL_GameControllerDB", .file = "externals/shared/lib/SDL_GameControllerDB/LICENSE" },
Expand Down
14 changes: 6 additions & 8 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@
.zbgfx = .{ .path = "externals/shared/lib/zbgfx" },

// zig-gamedev
.system_sdk = .{ .path = "externals/shared/lib/zig-gamedev/libs/system-sdk" },
.zglfw = .{ .path = "externals/shared/lib/zig-gamedev/libs/zglfw" },
.zpool = .{ .path = "externals/shared/lib/zig-gamedev/libs/zpool" },
.zjobs = .{ .path = "externals/shared/lib/zig-gamedev/libs/zjobs" },
.ztracy = .{ .path = "externals/shared/lib/zig-gamedev/libs/ztracy" },
.zgui = .{ .path = "externals/shared/lib/zig-gamedev/libs/zgui" },
.zflecs = .{ .path = "externals/shared/lib/zig-gamedev/libs/zflecs" },
//.znfde = .{ .path = "externals/shared/lib/zig-gamedev/libs/znfde" },
.system_sdk = .{ .path = "externals/shared/repo/system_sdk" },
.zjobs = .{ .path = "externals/shared/lib/zjobs" },
.zglfw = .{ .path = "externals/shared/lib/zglfw" },
.zflecs = .{ .path = "externals/shared/lib/zflecs" },
.ztracy = .{ .path = "externals/shared/lib/ztracy" },
.zgui = .{ .path = "externals/shared/lib/zgui" },
},
}
1 change: 1 addition & 0 deletions externals/shared
Submodule shared added at 380bdc
4 changes: 0 additions & 4 deletions externals/shared/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion externals/shared/README.md

This file was deleted.

1 change: 0 additions & 1 deletion externals/shared/lib/SDL_GameControllerDB
Submodule SDL_GameControllerDB deleted from 08715f
1 change: 0 additions & 1 deletion externals/shared/lib/zbgfx
Submodule zbgfx deleted from 53c38f
1 change: 0 additions & 1 deletion externals/shared/lib/zf
Submodule zf deleted from 256fe0
1 change: 0 additions & 1 deletion externals/shared/lib/zig-gamedev
Submodule zig-gamedev deleted from 14e625
1 change: 0 additions & 1 deletion externals/shared/lib/zig-uuid
Submodule zig-uuid deleted from 4e51b6
1 change: 0 additions & 1 deletion externals/shared/lib/ziglang-set
Submodule ziglang-set deleted from fc2aa4
11 changes: 0 additions & 11 deletions externals/shared/lib/znfde/README.md

This file was deleted.

Loading

0 comments on commit 5470878

Please sign in to comment.