Skip to content

Commit b36de58

Browse files
committed
wip: no c import
1 parent 689ae93 commit b36de58

File tree

5 files changed

+17
-13
lines changed

5 files changed

+17
-13
lines changed

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
zig-cache/
2-
tetris
1+
.zig-cache/
2+
zig-out/

build.zig

+8-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ pub fn build(b: *std.Build) void {
55
const optimize = b.standardOptimizeOption(.{});
66
const use_llvm = b.option(bool, "use-llvm", "use the LLVM backend");
77

8+
const translate_c = b.addTranslateC(.{
9+
.root_source_file = b.path("src/c.h"),
10+
.target = target,
11+
.optimize = optimize,
12+
.link_libc = true,
13+
});
814
const exe = b.addExecutable(.{
915
.name = "tetris",
1016
.root_source_file = b.path("src/main.zig"),
@@ -13,10 +19,10 @@ pub fn build(b: *std.Build) void {
1319
.use_llvm = use_llvm,
1420
.use_lld = use_llvm,
1521
});
16-
17-
exe.linkLibC();
22+
exe.root_module.addImport("c", translate_c.createModule());
1823
exe.linkSystemLibrary("glfw");
1924
exe.linkSystemLibrary("epoxy");
25+
2026
b.installArtifact(exe);
2127

2228
const play = b.step("play", "Play the game");

src/c.h

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <stdio.h>
2+
#include <math.h>
3+
#include <time.h>
4+
#include <stdlib.h>
5+
#include <epoxy/gl.h>
6+
#include <GLFW/glfw3.h>

src/c.zig

-8
This file was deleted.

src/main.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const Tetris = @import("tetris.zig").Tetris;
88
const std = @import("std");
99
const assert = std.debug.assert;
1010
const bufPrint = std.fmt.bufPrint;
11-
const c = @import("c.zig");
11+
const c = @import("c");
1212
const debug_gl = @import("debug_gl.zig");
1313
const AllShaders = @import("all_shaders.zig").AllShaders;
1414
const StaticGeometry = @import("static_geometry.zig").StaticGeometry;

0 commit comments

Comments
 (0)