Skip to content

Commit fe2cb56

Browse files
committed
Initial commit
0 parents  commit fe2cb56

File tree

16 files changed

+504
-0
lines changed

16 files changed

+504
-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
10+
11+
ls -Rhan zig-out/

.github/workflows/test.yaml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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+
x86-64-linux:
37+
needs: ["validation"]
38+
name: x86-64 Linux
39+
runs-on: linux-latest
40+
timeout-minutes: 20
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
with:
45+
submodules: true
46+
47+
- name: Prepare
48+
uses: awalsh128/cache-apt-pkgs-action@latest
49+
with:
50+
packages: libdbus-1-dev
51+
version: 1.0
52+
53+
- name: Read .zig-version
54+
id: zigversion
55+
uses: juliangruber/read-file-action@v1
56+
with:
57+
path: ./.zigversion
58+
- name: Install Zig
59+
uses: mlugg/setup-zig@v1
60+
with:
61+
version: ${{ steps.zigversion.outputs.content }}
62+
63+
- name: Build
64+
run: .ci/build.sh
65+
66+
x86-64-macos:
67+
needs: ["validation"]
68+
name: x86-64 Macos
69+
runs-on: macos-latest
70+
timeout-minutes: 20
71+
steps:
72+
- name: Checkout
73+
uses: actions/checkout@v4
74+
with:
75+
submodules: true
76+
77+
- name: Read .zig-version
78+
id: zigversion
79+
uses: juliangruber/read-file-action@v1
80+
with:
81+
path: ./.zigversion
82+
- name: Install Zig
83+
uses: mlugg/setup-zig@v1
84+
with:
85+
version: ${{ steps.zigversion.outputs.content }}
86+
87+
- name: Build
88+
run: .ci/build.sh
89+
90+
x86-64-windows:
91+
needs: ["validation"]
92+
name: x86-64 Windows
93+
runs-on: windows-latest
94+
timeout-minutes: 20
95+
steps:
96+
- name: Checkout
97+
uses: actions/checkout@v4
98+
with:
99+
submodules: true
100+
101+
- name: Read .zig-version
102+
id: zigversion
103+
uses: juliangruber/read-file-action@v1
104+
with:
105+
path: ./.zigversion
106+
- name: Install Zig
107+
uses: mlugg/setup-zig@v1
108+
with:
109+
version: ${{ steps.zigversion.outputs.content }}
110+
111+
- name: Build
112+
shell: bash
113+
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: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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. Have fun

build.zig

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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+
32+
const options_step = b.addOptions();
33+
options_step.addOption(std.SemanticVersion, "version", version);
34+
35+
// add build args
36+
inline for (std.meta.fields(@TypeOf(options))) |field| {
37+
options_step.addOption(field.type, field.name, @field(options, field.name));
38+
}
39+
const options_module = options_step.createModule();
40+
_ = options_module; // autofix
41+
42+
//
43+
// Extrnals
44+
//
45+
46+
// Cetech1
47+
const cetech1 = b.dependency(
48+
"cetech1",
49+
.{
50+
.target = target,
51+
52+
.optimize = optimize,
53+
// .optimize = options.externals_optimize,
54+
55+
//.static_modules = options.static_modules,
56+
.dynamic_modules = options.dynamic_modules,
57+
},
58+
);
59+
60+
//
61+
// TOOLS
62+
//
63+
64+
const generate_vscode_tool = b.addExecutable(.{
65+
.name = "generate_vscode",
66+
.root_source_file = b.path("tools/generate_vscode.zig"),
67+
.target = target,
68+
});
69+
generate_vscode_tool.root_module.addAnonymousImport("generate_vscode", .{
70+
.root_source_file = b.path("externals/cetech1/src/tools/generate_vscode.zig"),
71+
});
72+
73+
//
74+
// Init repository step
75+
//
76+
const init_step = b.step("init", "init repository");
77+
cetech1_build.initStep(b, init_step, "externals/cetech1/");
78+
79+
//
80+
// Gen vscode
81+
//
82+
const vscode_step = b.step("vscode", "init/update vscode configs");
83+
const gen_vscode = b.addRunArtifact(generate_vscode_tool);
84+
gen_vscode.addDirectoryArg(b.path(".vscode/"));
85+
vscode_step.dependOn(&gen_vscode.step);
86+
87+
b.installArtifact(cetech1.artifact("shaderc"));
88+
89+
if (options.dynamic_modules) {
90+
b.installArtifact(cetech1.artifact("cetech1"));
91+
92+
var buff: [256:0]u8 = undefined;
93+
for (enabled_cetech_modules) |m| {
94+
const artifact_name = try std.fmt.bufPrintZ(&buff, "ct_{s}", .{m});
95+
const art = cetech1.artifact(artifact_name);
96+
const step = b.addInstallArtifact(art, .{});
97+
b.default_step.dependOn(&step.step);
98+
}
99+
100+
for (modules) |m| {
101+
const artifact_name = try std.fmt.bufPrintZ(&buff, "ct_{s}", .{m});
102+
const art = b.dependency(m, .{
103+
.target = target,
104+
.optimize = optimize,
105+
}).artifact(artifact_name);
106+
107+
const step = b.addInstallArtifact(art, .{});
108+
b.default_step.dependOn(&step.step);
109+
}
110+
}
111+
}
112+
113+
fn ensureZigVersion() !void {
114+
var installed_ver = builtin.zig_version;
115+
installed_ver.build = null;
116+
117+
if (installed_ver.order(min_zig_version) == .lt) {
118+
std.log.err("\n" ++
119+
\\---------------------------------------------------------------------------
120+
\\
121+
\\Installed Zig compiler version is too old.
122+
\\
123+
\\Min. required version: {any}
124+
\\Installed version: {any}
125+
\\
126+
\\Please install newer version and try again.
127+
\\zig/get_zig.sh <ARCH>
128+
\\
129+
\\---------------------------------------------------------------------------
130+
\\
131+
, .{ min_zig_version, installed_ver });
132+
return error.ZigIsTooOld;
133+
}
134+
}

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)