Skip to content

Commit ffaa3ec

Browse files
committed
Initial commit
0 parents  commit ffaa3ec

File tree

16 files changed

+517
-0
lines changed

16 files changed

+517
-0
lines changed

.ci/build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -x
4+
set -e
5+
6+
git -C externals/cetech1/ submodule update --init
7+
8+
zig build init
9+
zig build -Dwith_tracy=false
10+
11+
ls -Rhan zig-out/

.github/workflows/test.yaml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Test
2+
3+
permissions:
4+
checks: write
5+
6+
on:
7+
pull_request:
8+
push:
9+
10+
concurrency:
11+
group: ${{ github.head_ref || github.run_id }}-${{ github.actor }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
validation:
16+
name: Validation
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 1
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Read .zig-version
24+
id: zigversion
25+
uses: juliangruber/read-file-action@v1
26+
with:
27+
path: ./.zigversion
28+
- name: Install Zig
29+
uses: mlugg/setup-zig@v1
30+
with:
31+
version: ${{ steps.zigversion.outputs.content }}
32+
33+
- name: Lint
34+
run: zig fmt --check . --exclude externals/
35+
36+
# TODO: Fix me
37+
# x86-64-linux:
38+
# needs: ["validation"]
39+
# name: x86-64 Linux
40+
# runs-on: linux-latest
41+
# timeout-minutes: 20
42+
# steps:
43+
# - name: Checkout
44+
# uses: actions/checkout@v4
45+
# with:
46+
# submodules: true
47+
48+
# - name: Prepare
49+
# uses: awalsh128/cache-apt-pkgs-action@latest
50+
# with:
51+
# packages: libdbus-1-dev
52+
# version: 1.0
53+
54+
# - name: Read .zig-version
55+
# id: zigversion
56+
# uses: juliangruber/read-file-action@v1
57+
# with:
58+
# path: ./.zigversion
59+
# - name: Install Zig
60+
# uses: mlugg/setup-zig@v1
61+
# with:
62+
# version: ${{ steps.zigversion.outputs.content }}
63+
64+
# - name: Build
65+
# run: .ci/build.sh
66+
67+
# x86-64-macos:
68+
# needs: ["validation"]
69+
# name: x86-64 Macos
70+
# runs-on: macos-latest
71+
# timeout-minutes: 20
72+
# steps:
73+
# - name: Checkout
74+
# uses: actions/checkout@v4
75+
# with:
76+
# submodules: true
77+
78+
# - name: Read .zig-version
79+
# id: zigversion
80+
# uses: juliangruber/read-file-action@v1
81+
# with:
82+
# path: ./.zigversion
83+
# - name: Install Zig
84+
# uses: mlugg/setup-zig@v1
85+
# with:
86+
# version: ${{ steps.zigversion.outputs.content }}
87+
88+
# - name: Build
89+
# run: .ci/build.sh
90+
91+
# x86-64-windows:
92+
# needs: ["validation"]
93+
# name: x86-64 Windows
94+
# runs-on: windows-latest
95+
# timeout-minutes: 20
96+
# steps:
97+
# - name: Checkout
98+
# uses: actions/checkout@v4
99+
# with:
100+
# submodules: true
101+
102+
# - name: Read .zig-version
103+
# id: zigversion
104+
# uses: juliangruber/read-file-action@v1
105+
# with:
106+
# path: ./.zigversion
107+
# - name: Install Zig
108+
# uses: mlugg/setup-zig@v1
109+
# with:
110+
# version: ${{ steps.zigversion.outputs.content }}
111+
112+
# - name: Build
113+
# shell: bash
114+
# run: .ci/build.sh

.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Build
2+
/build
3+
4+
# ZIG
5+
*zig-cache
6+
*zig-out
7+
8+
# VSCode
9+
10+
# MacOS
11+
*.DS_Store
12+
.DS_Store
13+
*.dylib
14+
15+
# Xcode
16+
*.pbxuser
17+
*.mode1v3
18+
*.mode2v3
19+
*.perspectivev3
20+
*.xcuserstate
21+
project.xcworkspace/
22+
xcuserdata/
23+
24+
kcov-output/
25+
26+
imgui.ini
27+
28+
_static.zig
29+
30+
# VSCode
31+
.vscode/launch.json
32+
.vscode/settings.json
33+
34+
# temp folder for tests
35+
/fixtures/tmp
36+
37+
# folder for generated tmp data, cache and debug purpose files
38+
.ct_temp
39+

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "externals/cetech1"]
2+
path = externals/cetech1
3+
url = https://github.com/cyberegoorg/cetech1.git

.version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0-a1

.vscode/extensions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"ziglang.vscode-zig", // ZIG support.
4+
"vadimcn.vscode-lldb", // Debugging support.
5+
"Gruntfuggly.todo-tree", // Todo viewer.
6+
"kdheepak.d2-markdown-preview" // D2 preview
7+
]
8+
}

.zigversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2024.10.0-mach

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# CETech1 minimal
2+
3+
> [!IMPORTANT]
4+
> Work in progressssssssssssss
5+
6+
## Getting started
7+
8+
1. Create repository from this template.
9+
10+
2. [Get ZIG/ZLS](https://cyberegoorg.github.io/cetech1/getting-started.html#get-zig-zls)
11+
12+
3. Init
13+
14+
```sh
15+
git -C externals/cetech1/ submodule update --init
16+
zig build init
17+
```
18+
19+
4. Build
20+
21+
```sh
22+
zig build
23+
```
24+
25+
5. Create CETech1 project in `content` dir
26+
27+
```sh
28+
zig-out/bin/cetech1 --asset-root content/
29+
```
30+
31+
6. Add `content` dir with project to git
32+
33+
```sh
34+
git add content/
35+
```
36+
37+
7. Have fun

build.zig

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
const std = @import("std");
2+
const builtin = @import("builtin");
3+
4+
const min_zig_version = std.SemanticVersion.parse("0.14.0-dev.1911") catch @panic("Where is .zigversion?");
5+
const version = std.SemanticVersion.parse(@embedFile(".version")) catch @panic("Where is .version?");
6+
7+
const cetech1_build = @import("cetech1");
8+
9+
const enabled_cetech_modules = cetech1_build.core_modules ++ cetech1_build.editor_modules;
10+
11+
pub const modules = [_][]const u8{
12+
// Minimal
13+
"minimal",
14+
};
15+
16+
pub fn build(b: *std.Build) !void {
17+
try ensureZigVersion();
18+
19+
const target = b.standardTargetOptions(.{});
20+
const optimize = b.standardOptimizeOption(.{});
21+
22+
//
23+
// OPTIONS
24+
//
25+
26+
const options = .{
27+
.externals_optimize = b.option(std.builtin.OptimizeMode, "externals_optimize", "Optimize for externals libs") orelse .ReleaseFast,
28+
.dynamic_modules = b.option(bool, "dynamic_modules", "build all modules in dynamic mode.") orelse true,
29+
//.static_modules = b.option(bool, "static_modules", "build all modules in static mode.") orelse false,
30+
31+
// Tracy options
32+
.enable_tracy = b.option(bool, "with_tracy", "build with tracy.") orelse true,
33+
.tracy_on_demand = b.option(bool, "tracy_on_demand", "build tracy with TRACY_ON_DEMAND") orelse true,
34+
};
35+
36+
const options_step = b.addOptions();
37+
options_step.addOption(std.SemanticVersion, "version", version);
38+
39+
// add build args
40+
inline for (std.meta.fields(@TypeOf(options))) |field| {
41+
options_step.addOption(field.type, field.name, @field(options, field.name));
42+
}
43+
const options_module = options_step.createModule();
44+
_ = options_module; // autofix
45+
46+
//
47+
// Extrnals
48+
//
49+
50+
// Cetech1
51+
const cetech1 = b.dependency(
52+
"cetech1",
53+
.{
54+
.target = target,
55+
.optimize = optimize,
56+
// .optimize = options.externals_optimize,
57+
58+
.with_tracy = options.enable_tracy,
59+
.tracy_on_demand = options.tracy_on_demand,
60+
61+
//.static_modules = options.static_modules,
62+
.dynamic_modules = options.dynamic_modules,
63+
},
64+
);
65+
66+
//
67+
// TOOLS
68+
//
69+
70+
const generate_vscode_tool = b.addExecutable(.{
71+
.name = "generate_vscode",
72+
.root_source_file = b.path("tools/generate_vscode.zig"),
73+
.target = target,
74+
});
75+
generate_vscode_tool.root_module.addAnonymousImport("generate_vscode", .{
76+
.root_source_file = b.path("externals/cetech1/src/tools/generate_vscode.zig"),
77+
});
78+
79+
//
80+
// Init repository step
81+
//
82+
const init_step = b.step("init", "init repository");
83+
cetech1_build.initStep(b, init_step, "externals/cetech1/");
84+
85+
//
86+
// Gen vscode
87+
//
88+
const vscode_step = b.step("vscode", "init/update vscode configs");
89+
const gen_vscode = b.addRunArtifact(generate_vscode_tool);
90+
gen_vscode.addDirectoryArg(b.path(".vscode/"));
91+
vscode_step.dependOn(&gen_vscode.step);
92+
93+
b.installArtifact(cetech1.artifact("shaderc"));
94+
95+
if (options.dynamic_modules) {
96+
b.installArtifact(cetech1.artifact("cetech1"));
97+
98+
var buff: [256:0]u8 = undefined;
99+
for (enabled_cetech_modules) |m| {
100+
const artifact_name = try std.fmt.bufPrintZ(&buff, "ct_{s}", .{m});
101+
const art = cetech1.artifact(artifact_name);
102+
const step = b.addInstallArtifact(art, .{});
103+
b.default_step.dependOn(&step.step);
104+
}
105+
106+
for (modules) |m| {
107+
const artifact_name = try std.fmt.bufPrintZ(&buff, "ct_{s}", .{m});
108+
const art = b.dependency(m, .{
109+
.target = target,
110+
.optimize = optimize,
111+
}).artifact(artifact_name);
112+
113+
const step = b.addInstallArtifact(art, .{});
114+
b.default_step.dependOn(&step.step);
115+
}
116+
}
117+
}
118+
119+
fn ensureZigVersion() !void {
120+
var installed_ver = builtin.zig_version;
121+
installed_ver.build = null;
122+
123+
if (installed_ver.order(min_zig_version) == .lt) {
124+
std.log.err("\n" ++
125+
\\---------------------------------------------------------------------------
126+
\\
127+
\\Installed Zig compiler version is too old.
128+
\\
129+
\\Min. required version: {any}
130+
\\Installed version: {any}
131+
\\
132+
\\Please install newer version and try again.
133+
\\zig/get_zig.sh <ARCH>
134+
\\
135+
\\---------------------------------------------------------------------------
136+
\\
137+
, .{ min_zig_version, installed_ver });
138+
return error.ZigIsTooOld;
139+
}
140+
}

build.zig.zon

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.{
2+
.name = "cetech1-minimal",
3+
.version = "0.1.0",
4+
.paths = .{
5+
"build.zig",
6+
"build.zig.zon",
7+
"README.md",
8+
},
9+
.dependencies = .{
10+
.cetech1 = .{ .path = "externals/cetech1" },
11+
12+
//
13+
// Modules
14+
//
15+
.minimal = .{ .path = "modules/minimal" },
16+
},
17+
}

0 commit comments

Comments
 (0)