Skip to content

Commit

Permalink
Build CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
branc116 committed Dec 31, 2024
1 parent 4be0e10 commit e9a2126
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 116 deletions.
62 changes: 16 additions & 46 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,17 @@ jobs:
os: [ {name: ubuntu-20.04, lto: NO}, {name: ubuntu-22.04, lto: YES}, {name: ubuntu-24.04, lto: YES} ]
steps:
- uses: actions/[email protected]
- run: |
- run: | # libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libxext-dev libxfixes-dev gcc mingw-w64 clang
- run: make -j8 PLATFORM=LINUX CONFIG=DEBUG GUI=IMGUI COMPILER=GCC -B
- run: make -j8 PLATFORM=LINUX CONFIG=DEBUG GUI=RAYLIB COMPILER=GCC -B
- run: make -j8 PLATFORM=LINUX CONFIG=DEBUG GUI=HEADLESS COMPILER=GCC -B
- run: make -j8 PLATFORM=LINUX CONFIG=RELEASE GUI=IMGUI COMPILER=GCC LTO=${{matrix.os.lto}} -B
- run: make -j8 PLATFORM=LINUX CONFIG=RELEASE GUI=RAYLIB COMPILER=GCC LTO=${{matrix.os.lto}} -B
- run: make -j8 PLATFORM=LINUX CONFIG=RELEASE GUI=HEADLESS COMPILER=GCC LTO=${{matrix.os.lto}} -B
- run: make -j8 PLATFORM=LINUX CONFIG=DEBUG GUI=IMGUI COMPILER=CLANG -B
- run: make -j8 PLATFORM=LINUX CONFIG=DEBUG GUI=RAYLIB COMPILER=CLANG -B
- run: make -j8 PLATFORM=LINUX CONFIG=DEBUG GUI=HEADLESS COMPILER=CLANG -B
- run: make -j8 PLATFORM=LINUX CONFIG=RELEASE GUI=IMGUI COMPILER=CLANG LTO=${{matrix.os.lto}} -B
- run: make -j8 PLATFORM=LINUX CONFIG=RELEASE GUI=RAYLIB COMPILER=CLANG LTO=${{matrix.os.lto}} -B
- run: make -j8 PLATFORM=LINUX CONFIG=RELEASE GUI=HEADLESS COMPILER=CLANG LTO=${{matrix.os.lto}} -B
- run: make -j8 PLATFORM=WINDOWS CONFIG=RELEASE GUI=IMGUI -B
- run: make -j8 PLATFORM=WINDOWS CONFIG=RELEASE GUI=RAYLIB -B
- run: make -j8 PLATFORM=WINDOWS CONFIG=RELEASE GUI=HEADLESS -B
sudo apt-get install -y --no-install-recommends gcc mingw-w64 clang
- run: make -j8 PLATFORM=LINUX CONFIG=DEBUG COMPILER=GCC -B
- run: make -j8 PLATFORM=LINUX CONFIG=RELEASE COMPILER=GCC LTO=${{matrix.os.lto}} -B
- run: make -j8 PLATFORM=LINUX CONFIG=DEBUG COMPILER=CLANG -B
- run: make -j8 PLATFORM=LINUX CONFIG=RELEASE COMPILER=CLANG LTO=${{matrix.os.lto}} -B
- run: make -j8 PLATFORM=WINDOWS CONFIG=RELEASE -B
- run: |
./bin/brplot_imgui_linux_debug_gcc --unittest
./bin/brplot_raylib_linux_debug_gcc --unittest
./bin/brplot_headless_linux_debug_gcc --unittest
./bin/brplot_imgui_linux_debug_clang --unittest
./bin/brplot_raylib_linux_debug_clang --unittest
./bin/brplot_headless_linux_debug_clang --unittest
./bin/brplot_linux_debug_wx_gcc --unittest
./bin/brplot_linux_debug_wx_clang --unittest
- run: |
git clone https://github.com/emscripten-core/emsdk.git
Expand All @@ -54,32 +40,16 @@ jobs:
source ./emsdk_env.sh
cd ..
- run: make -j8 EMSCRIPTEN=/home/runner/work/brplot/brplot/emsdk/upstream/emscripten/ PLATFORM=WEB CONFIG=RELEASE GUI=IMGUI -B

- run: make -j8 EMSCRIPTEN=/home/runner/work/brplot/brplot/emsdk/upstream/emscripten/ PLATFORM=WEB CONFIG=RELEASE GUI=RAYLIB -B

- run: |
make -j8 EMSCRIPTEN=/home/runner/work/brplot/brplot/emsdk/upstream/emscripten/ PLATFORM=WEB CONFIG=RELEASE GUI=HEADLESS -B
make -j8 EMSCRIPTEN=/home/runner/work/brplot/brplot/emsdk/upstream/emscripten/ PLATFORM=WEB CONFIG=RELEASE -B
- run: |
make -j8 PLATFORM=WINDOWS CONFIG=RELEASE GUI=HEADLESS
make -j8 PLATFORM=WINDOWS CONFIG=RELEASE GUI=RAYLIB
make -j8 PLATFORM=WINDOWS CONFIG=RELEASE GUI=IMGUI
make -j8 EMSCRIPTEN=/home/runner/work/brplot/brplot/emsdk/upstream/emscripten/ PLATFORM=WEB CONFIG=RELEASE GUI=HEADLESS
make -j8 EMSCRIPTEN=/home/runner/work/brplot/brplot/emsdk/upstream/emscripten/ PLATFORM=WEB CONFIG=RELEASE GUI=RAYLIB
make -j8 EMSCRIPTEN=/home/runner/work/brplot/brplot/emsdk/upstream/emscripten/ PLATFORM=WEB CONFIG=RELEASE GUI=IMGUI
make -j8 PLATFORM=LINUX CONFIG=RELEASE GUI=HEADLESS COMPILER=GCC LTO=${{matrix.os.lto}}
make -j8 PLATFORM=LINUX CONFIG=RELEASE GUI=RAYLIB COMPILER=GCC LTO=${{matrix.os.lto}}
make -j8 PLATFORM=LINUX CONFIG=RELEASE GUI=IMGUI COMPILER=GCC LTO=${{matrix.os.lto}}
make -j8 PLATFORM=LINUX CONFIG=DEBUG GUI=HEADLESS COMPILER=GCC
make -j8 PLATFORM=LINUX CONFIG=DEBUG GUI=RAYLIB COMPILER=GCC
make -j8 PLATFORM=LINUX CONFIG=DEBUG GUI=IMGUI COMPILER=GCC
make -j8 PLATFORM=LINUX CONFIG=RELEASE GUI=HEADLESS COMPILER=CLANG LTO=${{matrix.os.lto}}
make -j8 PLATFORM=LINUX CONFIG=RELEASE GUI=RAYLIB COMPILER=CLANG LTO=${{matrix.os.lto}}
make -j8 PLATFORM=LINUX CONFIG=RELEASE GUI=IMGUI COMPILER=CLANG LTO=${{matrix.os.lto}}
make -j8 PLATFORM=LINUX CONFIG=DEBUG GUI=HEADLESS COMPILER=CLANG
make -j8 PLATFORM=LINUX CONFIG=DEBUG GUI=RAYLIB COMPILER=CLANG
make -j8 PLATFORM=LINUX CONFIG=DEBUG GUI=IMGUI COMPILER=CLANG
make -j8 PLATFORM=WINDOWS CONFIG=RELEASE
make -j8 EMSCRIPTEN=/home/runner/work/brplot/brplot/emsdk/upstream/emscripten/ PLATFORM=WEB CONFIG=RELEASE
make -j8 PLATFORM=LINUX CONFIG=RELEASE COMPILER=GCC LTO=${{matrix.os.lto}}
make -j8 PLATFORM=LINUX CONFIG=DEBUG COMPILER=GCC
make -j8 PLATFORM=LINUX CONFIG=RELEASE COMPILER=CLANG LTO=${{matrix.os.lto}}
make -j8 PLATFORM=LINUX CONFIG=DEBUG COMPILER=CLANG
- run: |
cat /dev/random | time bin/brplot_headless_linux_debug_gcc
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
strategy:
matrix:
os: [ macos-12, macos-13, macos-14 ]
gui: [ raylib, imgui, headless ]
steps:
- uses: actions/[email protected]
- uses: goto-bus-stop/[email protected]
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ endif
OBJS= $(patsubst %.c, $(PREFIX_BUILD)/%.o, $(SOURCE))
MAKE_INCLUDES= $(patsubst %.o, %.d, $(OBJS))
NOBS+= $(patsubst %.o, %.nob.dir, $(OBJS))
NOBS+= bin/.nob.dir
NOBS+= bin/.nob.dir .generated/.nob.dir


LD= $(CC)
Expand Down Expand Up @@ -228,6 +228,7 @@ src/shaders.c: $(SHADERS_HEADER)

.PHONY: clean
clean:
test -d .generated && rm .generated -rdf || echo "done"
test -d build && rm build -rdf || echo "done"
test -d bin && rm bin -rdf || echo "done"
test -d www && rm www -rdf || echo "done"
Expand Down
87 changes: 19 additions & 68 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,98 +6,49 @@ var is_release = true;
pub fn generate_fonts(b: *std.Build) !*std.Build.Step.Run {
const full = std.builtin.OptimizeMode.ReleaseSafe;
const native_target = b.resolveTargetQuery(.{});
const native_rl = try build_raylib(b, native_target, full);
var generateFont = b.addExecutable(.{
.name = "generate_shaders",
.target = native_target,
.optimize = full,
});
generateFont.addCSourceFile(.{ .file = b.path("./tools/font_bake.c") });
generateFont.linkLibrary(native_rl);
generateFont.linkLibC();
var ret = b.addRunArtifact(generateFont);
ret.addArg("./content/PlayfairDisplayRegular-ywLOY.ttf");
ret.addArg("./content/font.ttf");
ret.addArg(".generated/default_font.h");
return ret;
}

pub fn generate_shaders(b: *std.Build) !*std.Build.Step.Run {
const full = std.builtin.OptimizeMode.ReleaseSafe;
const native_target = b.resolveTargetQuery(.{});
const native_rl = try build_raylib(b, native_target, full);
var shaderGen = b.addExecutable(.{
.name = "generate_shaders",
.target = native_target,
.optimize = full,
});
shaderGen.addCSourceFile(.{ .file = b.path("./tools/shaders_bake.c") });
shaderGen.addCSourceFile(.{ .file = b.path("./src/str.c") });
shaderGen.addIncludePath(b.path("./external/raylib-5.0/src"));
shaderGen.addIncludePath(b.path("./src"));
shaderGen.addIncludePath(b.path("."));
shaderGen.linkLibC();
shaderGen.linkLibrary(native_rl);
var ret = b.addRunArtifact(shaderGen);
ret.addArg("WINDOWS");
ret.addArg(".generated/shaders.h");
return ret;
}

pub fn build_raylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) !*std.Build.Step.Compile {
const raylib = b.addStaticLibrary(.{
.name = b.fmt("raylib_{s}_{s}", .{ @tagName(target.result.os.tag), @tagName(optimize) }),
.target = target,
.optimize = optimize,
pub fn pack_icons(b: *std.Build) !*std.Build.Step.Run {
const full = std.builtin.OptimizeMode.ReleaseSafe;
const native_target = b.resolveTargetQuery(.{});
var shaderGen = b.addExecutable(.{
.name = "pack_icons",
.target = native_target,
.optimize = full,
});

const raylibSources = .{
"./external/raylib-5.0/src/rmodels.c",
"./external/raylib-5.0/src/rshapes.c",
"./external/raylib-5.0/src/rtext.c",
"./external/raylib-5.0/src/rtextures.c",
"./external/raylib-5.0/src/utils.c",
"./external/raylib-5.0/src/rcore.c",
};
inline for (raylibSources) |source| {
raylib.addCSourceFile(.{ .file = b.path(source) });
}

switch (target.result.os.tag) {
.windows => {
raylib.addCSourceFile(.{ .file = b.path("./external/raylib-5.0/src/rglfw.c") });
raylib.linkSystemLibrary("winmm");
raylib.linkSystemLibrary("gdi32");
raylib.linkSystemLibrary("opengl32");
raylib.defineCMacro("PLATFORM_DESKTOP", null);
},
.linux, .freebsd => {
raylib.linkSystemLibrary("glfw");
raylib.defineCMacro("PLATFORM_DESKTOP", null);
},
.macos => {
var raylib_flags_arr: std.ArrayListUnmanaged([]const u8) = .{};
raylib_flags_arr.clearRetainingCapacity();
try raylib_flags_arr.append(b.allocator, "-ObjC");
raylib.addCSourceFile(.{
.file = b.path("./external/raylib-5.0/src/rglfw.c"),
.flags = raylib_flags_arr.items,
});
raylib_flags_arr.deinit(b.allocator);
raylib.linkFramework("Foundation");
raylib.linkFramework("CoreServices");
raylib.linkFramework("CoreGraphics");
raylib.linkFramework("AppKit");
raylib.linkFramework("IOKit");
raylib.defineCMacro("PLATFORM_DESKTOP", null);
},
else => {
unreachable();
},
}
raylib.linkLibC();
raylib.addIncludePath(b.path("."));
raylib.addIncludePath(b.path("./external/glfw/include"));
return raylib;
shaderGen.addCSourceFile(.{ .file = b.path("./tools/pack_icons.c") });
shaderGen.addIncludePath(b.path("."));
shaderGen.linkLibC();
return b.addRunArtifact(shaderGen);
}

pub fn build_brplot(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, is_headless: bool) !*std.Build.Step.Compile {
Expand Down Expand Up @@ -132,28 +83,28 @@ pub fn build_brplot(b: *std.Build, target: std.Build.ResolvedTarget, optimize: s
"./src/smol_mesh.c",
"./src/str.c",
"./src/text_renderer.c",
"./src/theme.c",
} });
exe.addIncludePath(b.path("."));
exe.addIncludePath(b.path("./src"));
exe.addIncludePath(b.path("./external/Tracy"));
exe.linkLibC();
exe.defineCMacro("PLATFORM_DESKTOP", "1");

if (is_release) {
exe.defineCMacro("RELEASE", "1");
exe.defineCMacro("_GNU_SOURCE", null);
if (false == is_release) {
exe.defineCMacro("BR_DEBUG", "1");
} else {
exe.step.dependOn(&(try generate_shaders(b)).step);
}

switch (is_headless) {
false => {
exe.defineCMacro("RAYLIB", null);
},
false => {},
true => {
exe.defineCMacro("NUMBER_OF_STEPS", "100");
exe.defineCMacro("HEADLESS", null);
},
}

exe.step.dependOn(&(try pack_icons(b)).step);
exe.step.dependOn(&(try generate_fonts(b)).step);
return exe;
}
Expand Down

0 comments on commit e9a2126

Please sign in to comment.