Makefileはバイバイ、build.zigはハロー
このコミットが含まれているのは:
コミット
2091aeb9dd
|
@ -1,3 +1,2 @@
|
|||
*.o
|
||||
*.tar.gz
|
||||
/bin
|
||||
/zig-out
|
||||
/zig-cache
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[submodule "libtoki"]
|
||||
path = libtoki
|
||||
url = https://gitler.moe/suwako/libtoki
|
34
Makefile
34
Makefile
|
@ -1,34 +0,0 @@
|
|||
NAME=coreutils
|
||||
VERSION := $(shell cat version.zig | grep "const version" | awk '{print $$4}' | sed "s/\"//g" | sed "s/;//")
|
||||
PREFIX=/usr
|
||||
MANPREFIX=${PREFIX}/share/man
|
||||
PROG=basename cat cp dirname echo false groups ls mkdir pwd rm touch true wc whoami
|
||||
CC=zig build-exe
|
||||
RELEASE=ReleaseSmall
|
||||
|
||||
all: ${PROG}
|
||||
|
||||
%: %.zig
|
||||
mkdir -p bin
|
||||
${CC} $< -O ${RELEASE} --name $@
|
||||
mv $@ bin
|
||||
mv $@.o bin
|
||||
|
||||
loc-install: all
|
||||
mkdir -p ~/.local/bin
|
||||
for prog in ${PROG}; do \
|
||||
cp bin/$$prog ~/.local/bin; \
|
||||
chmod +x ~/.local/bin/$$prog; \
|
||||
done
|
||||
|
||||
sys-install: all
|
||||
mkdir -p ${PREFIX}/bin
|
||||
for prog in ${PROG}; do \
|
||||
cp bin/$$prog ${PREFIX}/bin; \
|
||||
chmod +x ${PREFIX}/bin/$$prog; \
|
||||
done
|
||||
|
||||
clean:
|
||||
rm -rf bin/${PROG}
|
||||
|
||||
.PHONY: all loc-install sys-install clean
|
|
@ -0,0 +1,58 @@
|
|||
const std = @import("std");
|
||||
const toki = @import("libtoki");
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
// ライブラリ
|
||||
const lib_toki = b.dependency("toki", .{ .target = target, .optimize = optimize });
|
||||
|
||||
// バイナリ
|
||||
const bin_basename = b.addExecutable(.{ .name = "basename", .root_source_file = .{ .path = "src/basename.zig" }, .target = target, .optimize = optimize });
|
||||
b.installArtifact(bin_basename);
|
||||
|
||||
const bin_cat = b.addExecutable(.{ .name = "cat", .root_source_file = .{ .path = "src/cat.zig" }, .target = target, .optimize = optimize });
|
||||
b.installArtifact(bin_cat);
|
||||
|
||||
const bin_cp = b.addExecutable(.{ .name = "cp", .root_source_file = .{ .path = "src/cp.zig" }, .target = target, .optimize = optimize });
|
||||
b.installArtifact(bin_cp);
|
||||
|
||||
const bin_dirname = b.addExecutable(.{ .name = "dirname", .root_source_file = .{ .path = "src/dirname.zig" }, .target = target, .optimize = optimize });
|
||||
b.installArtifact(bin_dirname);
|
||||
|
||||
const bin_echo = b.addExecutable(.{ .name = "echo", .root_source_file = .{ .path = "src/echo.zig" }, .target = target, .optimize = optimize });
|
||||
b.installArtifact(bin_echo);
|
||||
|
||||
const bin_false = b.addExecutable(.{ .name = "false", .root_source_file = .{ .path = "src/false.zig" }, .target = target, .optimize = optimize });
|
||||
b.installArtifact(bin_false);
|
||||
|
||||
const bin_groups = b.addExecutable(.{ .name = "groups", .root_source_file = .{ .path = "src/groups.zig" }, .target = target, .optimize = optimize });
|
||||
b.installArtifact(bin_groups);
|
||||
|
||||
const bin_ls = b.addExecutable(.{ .name = "ls", .root_source_file = .{ .path = "src/ls.zig" }, .target = target, .optimize = optimize });
|
||||
bin_ls.addModule("toki", lib_toki.module("toki"));
|
||||
bin_ls.linkLibrary(lib_toki.artifact("toki"));
|
||||
b.installArtifact(bin_ls);
|
||||
|
||||
const bin_mkdir = b.addExecutable(.{ .name = "mkdir", .root_source_file = .{ .path = "src/mkdir.zig" }, .target = target, .optimize = optimize });
|
||||
b.installArtifact(bin_mkdir);
|
||||
|
||||
const bin_pwd = b.addExecutable(.{ .name = "pwd", .root_source_file = .{ .path = "src/pwd.zig" }, .target = target, .optimize = optimize });
|
||||
b.installArtifact(bin_pwd);
|
||||
|
||||
const bin_rm = b.addExecutable(.{ .name = "rm", .root_source_file = .{ .path = "src/rm.zig" }, .target = target, .optimize = optimize });
|
||||
b.installArtifact(bin_rm);
|
||||
|
||||
const bin_touch = b.addExecutable(.{ .name = "touch", .root_source_file = .{ .path = "src/touch.zig" }, .target = target, .optimize = optimize });
|
||||
b.installArtifact(bin_touch);
|
||||
|
||||
const bin_true = b.addExecutable(.{ .name = "true", .root_source_file = .{ .path = "src/true.zig" }, .target = target, .optimize = optimize });
|
||||
b.installArtifact(bin_true);
|
||||
|
||||
const bin_wc = b.addExecutable(.{ .name = "wc", .root_source_file = .{ .path = "src/wc.zig" }, .target = target, .optimize = optimize });
|
||||
b.installArtifact(bin_wc);
|
||||
|
||||
const bin_whoami = b.addExecutable(.{ .name = "whoami", .root_source_file = .{ .path = "src/whoami.zig" }, .target = target, .optimize = optimize });
|
||||
b.installArtifact(bin_whoami);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
.{
|
||||
.name = "coreutils",
|
||||
.version = "0.0.1",
|
||||
.dependencies = .{
|
||||
.toki = .{
|
||||
.url = "https://gitler.moe/suwako/libtoki/archive/libtoki-1.0.0.tar.gz",
|
||||
.hash = "1220e9fede6780ed0670d20142363be9f6deb412a9df2ddbec1713c563c6b924fa7b",
|
||||
},
|
||||
}
|
||||
}
|
1
libtoki
1
libtoki
|
@ -1 +0,0 @@
|
|||
Subproject commit 9cec39129a5fcfaa2840fab0f63d85cecdcff11e
|
|
@ -1,5 +1,5 @@
|
|||
const std = @import("std");
|
||||
const toki = @import("libtoki/src/main.zig");
|
||||
const toki = @import("toki");
|
||||
const fs = std.fs;
|
||||
const io = std.io;
|
||||
|
読み込み中…
新しいイシューから参照