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 f22704a
Show file tree
Hide file tree
Showing 2,171 changed files with 1,597,725 additions and 81 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 zig

- 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 zig

- 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 zig

# - 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 zig

- name: Read .zig-version
id: zigversion
uses: juliangruber/read-file-action@v1
Expand Down
52 changes: 35 additions & 17 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,24 +1,42 @@
[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
[submodule "externals/shared/repo/SDL_GameControllerDB"]
path = externals/shared/repo/SDL_GameControllerDB
url = https://github.com/cyberegoorg/SDL_GameControllerDB.git
[submodule "externals/shared/repo/ziglang-set"]
path = externals/shared/repo/ziglang-set
url = https://github.com/cyberegoorg/ziglang-set.git
[submodule "externals/shared/repo/zig-uuid"]
path = externals/shared/repo/zig-uuid
url = https://github.com/cyberegoorg/zig-uuid.git
[submodule "externals/shared/repo/zf"]
path = externals/shared/repo/zf
url = https://github.com/cyberegoorg/zf.git
[submodule "externals/shared/repo/zbgfx"]
path = externals/shared/repo/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/repo/zjobs"]
path = externals/shared/repo/zjobs
url = https://github.com/cyberegoorg/zjobs.git
[submodule "externals/shared/repo/zflecs"]
path = externals/shared/repo/zflecs
url = https://github.com/cyberegoorg/zflecs.git
[submodule "externals/shared/repo/zglfw"]
path = externals/shared/repo/zglfw
url = https://github.com/cyberegoorg/zglfw.git
[submodule "externals/shared/repo/system_sdk"]
path = externals/shared/repo/system_sdk
url = https://github.com/cyberegoorg/system_sdk.git
[submodule "externals/shared/repo/ztracy"]
path = externals/shared/repo/ztracy
url = https://github.com/cyberegoorg/ztracy.git
[submodule "externals/shared/repo/zgui"]
path = externals/shared/repo/zgui
url = https://github.com/cyberegoorg/zgui.git
[submodule "externals/shared/repo/zmath"]
path = externals/shared/repo/zmath
url = https://github.com/OndraVoves/zmath.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 zig submodules
git submodule update --init zig

# 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
109 changes: 73 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,28 @@ pub fn build(b: *std.Build) !void {
"--include",
"src/embed/fonts/*",
});

const init_system_sdk = b.addSystemCommand(&.{
"git",
"submodule",
"update",
"--init",
"externals/shared/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);

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);

//
// Gen vscode
Expand All @@ -259,9 +256,24 @@ 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");
const init_zls = b.addSystemCommand(&.{
"git",
"submodule",
"update",
"--init",
"externals/shared/tools/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 +349,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 +407,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 +465,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: 0 additions & 1 deletion externals/shared/lib/SDL_GameControllerDB
Submodule SDL_GameControllerDB deleted from 08715f
17 changes: 17 additions & 0 deletions externals/shared/lib/SDL_GameControllerDB/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Copyright (C) 1997-2022 Sam Lantinga <[email protected]>

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Loading

0 comments on commit f22704a

Please sign in to comment.