Skip to content

Commit

Permalink
Replace main.c with main.zig
Browse files Browse the repository at this point in the history
  • Loading branch information
tiehuis committed Jul 19, 2017
1 parent e24d314 commit 1bbee32
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 37 deletions.
26 changes: 1 addition & 25 deletions build.zig
@@ -1,31 +1,7 @@
const Builder = @import("std").build.Builder;

pub fn build(b: &Builder) {
const exe = b.addCExecutable("main");
b.addCIncludePath(".");
exe.addCompileFlags([][]const u8 {
"-std=c99",
"-nostdlib",
});

const source_files = [][]const u8 {
"main.c",
};

for (source_files) |source| {
exe.addSourceFile(source);
}

const zig_source_files = [][]const u8 {
"compute.zig",
"compute_helper.zig",
"display.zig",
};

for (zig_source_files) |source| {
const object = b.addObject(source, source);
exe.addObject(object);
}
const exe = b.addExecutable("main", "main.zig");

exe.setOutputPath("./main");
b.default_step.dependOn(&exe.step);
Expand Down
1 change: 0 additions & 1 deletion compute.h

This file was deleted.

4 changes: 2 additions & 2 deletions compute.zig
@@ -1,5 +1,5 @@
pub use @import("compute_helper.zig");
use @import("compute_helper.zig");

export fn compute(a: u8) -> u8 {
pub fn compute(a: u8) -> u8 {
compute_helper(a) + 5
}
1 change: 0 additions & 1 deletion display.h

This file was deleted.

2 changes: 1 addition & 1 deletion display.zig
@@ -1,7 +1,7 @@
const std = @import("std");
const printf = std.io.stdout.printf;

export fn display_char(c: u8)
pub fn display_char(c: u8)
{
%%printf("{c}\n", c);
}
7 changes: 0 additions & 7 deletions main.c

This file was deleted.

6 changes: 6 additions & 0 deletions main.zig
@@ -0,0 +1,6 @@
use @import("display.zig");
use @import("compute.zig");

pub fn main() -> %void {
display_char(compute('A'));
}

0 comments on commit 1bbee32

Please sign in to comment.