homebrew-omega
aien-dev/homebrew-omega
Brought by drakestapleton
homebrew-omega / Formula / omc.rb
| 1 | # omc, the Omega compiler, born from the 408-byte hand-written seed of aien-dev/omega-mv. |
| 2 | # The build runs omega-mv's seed/omega-from-seed.sh (seed0 -> hex1 -> asm2 -> om4 -> omc -> omc -> omc) |
| 3 | # using only sh, printf, cat, stat, sed, sha256sum and cmp, then refuses any omc whose sha256 is not |
| 4 | # the pinned one. AArch64 (arm64) Linux only: omc runs on and emits code for that platform alone. |
| 5 | class Omc < Formula |
| 6 | desc "Omega compiler, born from a 408-byte hand-written seed" |
| 7 | homepage "https://github.com/aien-dev/omega-mv" |
| 8 | url "https://github.com/aien-dev/omega-mv/archive/e5b32567a7aff3ce594e3254a622a846a6cd190b.tar.gz" |
| 9 | version "0.0.0+git.e5b32567" |
| 10 | sha256 "c621b6cefe728d67a1a253a9d8991495406460d365dd91ea356451eb2254a95c" |
| 11 | license "Apache-2.0" |
| 12 | |
| 13 | depends_on arch: :arm64 |
| 14 | depends_on :linux |
| 15 | |
| 16 | OMC_SHA256 = "2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f".freeze |
| 17 | |
| 18 | def install |
| 19 | system "sh", "seed/omega-from-seed.sh" |
| 20 | got = Digest::SHA256.file("seed/out/omc").hexdigest |
| 21 | odie "omc sha256 #{got} is not the pinned #{OMC_SHA256}" if got != OMC_SHA256 |
| 22 | bin.install "seed/out/omc" |
| 23 | end |
| 24 | |
| 25 | test do |
| 26 | (testpath/"hello.om").write <<~OM |
| 27 | note hello: sum 1..10 and print "omega 55" through write |
| 28 | global out uchar 16 |
| 29 | fn main to int |
| 30 | s = ulong 0 |
| 31 | for i ulong 11 |
| 32 | s = add s i |
| 33 | end |
| 34 | put out 0 111 |
| 35 | put out 1 109 |
| 36 | put out 2 101 |
| 37 | put out 3 103 |
| 38 | put out 4 97 |
| 39 | put out 5 32 |
| 40 | put out 6 uchar add div s 10 48 |
| 41 | put out 7 uchar add rem s 10 48 |
| 42 | put out 8 10 |
| 43 | w = write 1 out 0 9 |
| 44 | ret 0 |
| 45 | end |
| 46 | OM |
| 47 | system "sh", "-c", "#{bin}/omc < hello.om > hello" |
| 48 | chmod 0755, testpath/"hello" |
| 49 | assert_equal "omega 55\n", shell_output("./hello") |
| 50 | assert_equal OMC_SHA256, Digest::SHA256.file(bin/"omc").hexdigest |
| 51 | end |
| 52 | end |