Skip to content

Commit

Permalink
wip: no c import
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Jul 16, 2024
1 parent 689ae93 commit b36de58
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
zig-cache/
tetris
.zig-cache/
zig-out/
10 changes: 8 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const use_llvm = b.option(bool, "use-llvm", "use the LLVM backend");

const translate_c = b.addTranslateC(.{
.root_source_file = b.path("src/c.h"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
const exe = b.addExecutable(.{
.name = "tetris",
.root_source_file = b.path("src/main.zig"),
Expand All @@ -13,10 +19,10 @@ pub fn build(b: *std.Build) void {
.use_llvm = use_llvm,
.use_lld = use_llvm,
});

exe.linkLibC();
exe.root_module.addImport("c", translate_c.createModule());
exe.linkSystemLibrary("glfw");
exe.linkSystemLibrary("epoxy");

b.installArtifact(exe);

const play = b.step("play", "Play the game");
Expand Down
6 changes: 6 additions & 0 deletions src/c.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <epoxy/gl.h>
#include <GLFW/glfw3.h>
8 changes: 0 additions & 8 deletions src/c.zig

This file was deleted.

2 changes: 1 addition & 1 deletion src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Tetris = @import("tetris.zig").Tetris;
const std = @import("std");
const assert = std.debug.assert;
const bufPrint = std.fmt.bufPrint;
const c = @import("c.zig");
const c = @import("c");
const debug_gl = @import("debug_gl.zig");
const AllShaders = @import("all_shaders.zig").AllShaders;
const StaticGeometry = @import("static_geometry.zig").StaticGeometry;
Expand Down

0 comments on commit b36de58

Please sign in to comment.