From cc353bb0c4cc045288997a99ecce469057ace145 Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 5 Sep 2024 16:48:09 +0200 Subject: [PATCH 1/2] Avoid a weird mkfs.cpm bug where it doesn't always create the directory. --- build/zip.py | 2 +- tools/build.py | 37 +++++++++++++++++++++---------- tools/fillfile.cc | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 12 deletions(-) create mode 100644 tools/fillfile.cc diff --git a/build/zip.py b/build/zip.py index d6da0ca8..e2b1bd13 100644 --- a/build/zip.py +++ b/build/zip.py @@ -22,7 +22,7 @@ def zip(self, name, flags="", items: TargetsMap = {}): for k, v in items.items(): cs += [ "cat %s | $(ZIP) -q %s {outs[0]} -" % (filenameof(v), flags), - "echo '@ -\\n@=%s\\n' | $(ZIPNOTE) -w {outs[0]}" % k, + "printf '@ -\\n@=%s\\n' | $(ZIPNOTE) -w {outs[0]}" % k, ] ins += [v] diff --git a/tools/build.py b/tools/build.py index 7f61e18a..73c52512 100644 --- a/tools/build.py +++ b/tools/build.py @@ -1,4 +1,11 @@ -from build.ab import Rule, Target, simplerule, filenameof, TargetsMap, filenamesof +from build.ab import ( + Rule, + Target, + simplerule, + filenameof, + TargetsMap, + filenamesof, +) from build.c import cxxprogram, cprogram cxxprogram(name="multilink", srcs=["./multilink.cc"], deps=["+libfmt"]) @@ -6,6 +13,7 @@ cxxprogram(name="shuffle", srcs=["./shuffle.cc"], deps=["+libfmt"]) cxxprogram(name="mkoricdsk", srcs=["./mkoricdsk.cc"], deps=["+libfmt"]) cxxprogram(name="mkcombifs", srcs=["./mkcombifs.cc"], deps=["+libfmt"]) +cxxprogram(name="fillfile", srcs=["./fillfile.cc"], deps=["+libfmt"]) cprogram(name="unixtocpm", srcs=["./unixtocpm.c"]) cprogram(name="mkdfs", srcs=["./mkdfs.c"]) cprogram(name="mkimd", srcs=["./mkimd.c"]) @@ -13,17 +21,18 @@ name="fontconvert", srcs=["./fontconvert.c", "./libbdf.c", "./libbdf.h"] ) + @Rule -def unixtocpm( - self, name, src:Target=None): +def unixtocpm(self, name, src: Target = None): simplerule( replaces=self, ins=[src], outs=[f"={name}.txt"], deps=["tools+unixtocpm"], - commands=[ - "{deps[0]} < {ins[0]} > {outs[0]}"], - label="UNIXTOCPM") + commands=["{deps[0]} < {ins[0]} > {outs[0]}"], + label="UNIXTOCPM", + ) + @Rule def multilink( @@ -65,6 +74,9 @@ def mkcpmfs( if template: cs += ["cp %s {outs[0]}" % filenameof(template)] else: + # Some versions of mkfs.cpm don't work right if the input file + # doesn't exist. + cs += ["{deps[1]} -f {outs[0]} -b 0xe5 -n 100000"] mkfs = "mkfs.cpm -f %s" % format if bootimage: mkfs += " -b %s" % filenameof(bootimage) @@ -89,11 +101,14 @@ def mkcpmfs( replaces=self, ins=ins, outs=[f"={name}.img"], - deps=["diskdefs"] + [bootimage] - if bootimage - else [] + [template] - if template - else [], + deps=( + ["diskdefs", "tools+fillfile"] + + ( + [bootimage] + if bootimage + else [] + [template] if template else [] + ) + ), commands=cs, label="MKCPMFS", ) diff --git a/tools/fillfile.cc b/tools/fillfile.cc new file mode 100644 index 00000000..151e5be2 --- /dev/null +++ b/tools/fillfile.cc @@ -0,0 +1,56 @@ +#include +#include +#include +#include + +static std::string filename; +static int byteCount; +static int byteValue; + +static void parseArgs(int argc, char* argv[]) +{ + for (;;) + { + switch (getopt(argc, argv, "f:n:b:")) + { + case -1: + return; + + case 'f': + filename = optarg; + break; + + case 'n': + byteCount = strtol(optarg, nullptr, 0); + break; + + case 'b': + byteValue = strtol(optarg, nullptr, 0); + break; + + default: + fmt::print(stderr, + "Usage: fillfile -f -n -b \n"); + exit(1); + } + } +} + +int main(int argc, char* argv[]) +{ + parseArgs(argc, argv); + + std::ofstream of(filename); + if (!of) + { + fmt::print(stderr, + "fillfile: cannot open output file: {}\n", strerror(errno)); + exit(1); + } + + for (int i=0; i Date: Thu, 5 Sep 2024 16:49:29 +0200 Subject: [PATCH 2/2] Update to use artifact@v3 in the CI script. --- .github/workflows/ccpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 8042168f..9e3d8ac0 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -30,7 +30,7 @@ jobs: run: make LLVM=$HOME/llvm-mos/bin -j`nproc` +all +mametest - name: Upload build artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: ${{ github.event.repository.name }}.${{ github.sha }} path: |