瀏覽代碼

Add infrastructure for simple C-based tools

master
JustAnotherArchivist 2 年之前
父節點
當前提交
11485d9404
共有 3 個文件被更改,包括 15 次插入0 次删除
  1. +1
    -0
      .gitignore
  2. +10
    -0
      .make-and-exec
  3. +4
    -0
      .make-and-exec-Makefile

+ 1
- 0
.gitignore 查看文件

@@ -0,0 +1 @@
.make-and-exec-binaries

+ 10
- 0
.make-and-exec 查看文件

@@ -0,0 +1,10 @@
#!/bin/bash
# Usage: create a file foo.c, make foo a symlink to this script
# When foo is executed, this script silently compiles foo.c into .make-and-exec-binaries/foo and execs that with the arguments provided.
# The compilation goes through make, so later invocations directly exec the binary with little delay.
# To customise the compilation, you can set a CFLAGS env var before running foo.
set -e
name="$(basename "$0")"
cd "$(dirname "$0")"
make --file .make-and-exec-Makefile --silent ".make-and-exec-binaries/${name}"
exec "./.make-and-exec-binaries/${name}" "$@"

+ 4
- 0
.make-and-exec-Makefile 查看文件

@@ -0,0 +1,4 @@
.make-and-exec-binaries/%: %.c .%-test
mkdir -p .make-and-exec-binaries
$(CC) -O3 -o $@ $< $(CFLAGS)
./.$(notdir $(@))-test

Loading…
取消
儲存