Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienos.com/blob/main/om/site/build.om # aienos.com Source of www.aienos.com, served from my own hardware Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienos.com / om / site / build.om` 212 lines ยท 3326 bytes Raw Blame History 1 note Native build conductor: ./build-tool MODULE_MANIFEST OUTPUT_BINARY 2 note Run from the repository root. The pinned omc is the sole compiler dependency. 3 note Manifest is newline-separated relative .om source paths. One OM-2 directive is prepended. 4 note Compilation writes only the requested new output; a failed compile removes that incomplete file. 5 global bline uchar 4096 6 global blen ulong 1 7 global bout uchar 4096 8 global boutn ulong 1 9 global bargs uchar 4096 10 global bbuf uchar 65536 11 global bstat uchar 4 12 text bcomp "om/site/omc" 13 text bunit "build/site-unit.om" 14 text bdir "build" 15 text bmode "om2\n" 16 text bfail "SITE-BUILD refused input or failed I/O\n" 17 text bok "SITE-BUILD compiled\n" 18 19 fn build_fail to void 20 n = write 2 bfail 0 len bfail 21 exit 80 22 end 23 24 fn build_write fd int n ulong to void 25 p = ulong 0 26 while lt p n bound 65536 27 k = write fd bbuf p sub n p 28 if le k 0 29 build_fail 30 end 31 p = add p ulong k 32 end 33 end 34 35 fn build_source fd int to void 36 n = get blen 0 37 if eq n 0 38 build_fail 39 end 40 if eq get bline 0 47 41 build_fail 42 end 43 for i ulong n 44 c = get bline i 45 if or eq c 0 eq c 92 46 build_fail 47 end 48 if eq c 46 49 if lt add i 1 n 50 if eq get bline add i 1 46 51 build_fail 52 end 53 end 54 end 55 end 56 src = fopen bline 0 n 0 0 57 if lt src 0 58 build_fail 59 end 60 more = true 61 while more bound 65536 62 k = read int src bbuf 0 len bbuf 63 if lt k 0 64 build_fail 65 end 66 if eq k 0 67 more = false 68 else 69 build_write fd ulong k 70 end 71 end 72 rc = fclose int src 73 if ne rc 0 74 build_fail 75 end 76 put bbuf 0 10 77 build_write fd 1 78 put blen 0 0 79 end 80 81 fn build_manifest fd int mf int to void 82 one = new uchar 1 0 83 more = true 84 while more bound 65536 85 k = read mf one 0 1 86 if lt k 0 87 build_fail 88 end 89 if eq k 0 90 if ne get blen 0 0 91 build_fail 92 end 93 more = false 94 else 95 c = get one 0 96 if eq c 10 97 build_source fd 98 else 99 n = get blen 0 100 if ge n len bline 101 build_fail 102 end 103 put bline n c 104 put blen 0 add n 1 105 end 106 end 107 end 108 end 109 110 fn build_child infd int outfd int to void 111 rc = dupfd infd 0 0 112 if lt rc 0 113 build_fail 114 end 115 rc = dupfd outfd 1 0 116 if lt rc 0 117 build_fail 118 end 119 put bargs 0 1 120 put bargs 1 0 121 put bargs 2 uchar len bcomp 122 put bargs 3 0 123 for i ulong len bcomp 124 put bargs add i 4 get bcomp i 125 end 126 rc = execprog bargs 0 add len bcomp 4 127 build_fail 128 end 129 130 fn build_compile to int 131 inf = fopen bunit 0 len bunit 0 0 132 if lt inf 0 133 build_fail 134 end 135 outf = fopen bout 0 get boutn 0 193 493 136 if lt outf 0 137 build_fail 138 end 139 pid = fork 140 if lt pid 0 141 build_fail 142 end 143 if eq pid 0 144 build_child int inf int outf 145 end 146 rc = fclose int inf 147 if ne rc 0 148 build_fail 149 end 150 rc = fclose int outf 151 if ne rc 0 152 build_fail 153 end 154 rc = waitpid int pid bstat 0 len bstat 0 155 if ne rc pid 156 build_fail 157 end 158 status = or uint get bstat 0 shl uint get bstat 1 8 159 if ne status 0 160 rc = unlink bout 0 get boutn 0 161 if ne rc 0 162 build_fail 163 end 164 ret 81 165 end 166 n = write 1 bok 0 len bok 167 if ne n long len bok 168 build_fail 169 end 170 ret 0 171 end 172 173 fn main to int 174 if ne argcnt 3 175 build_fail 176 end 177 n = argread 1 bline 0 len bline 178 if le n 0 179 build_fail 180 end 181 mf = fopen bline 0 ulong n 0 0 182 if lt mf 0 183 build_fail 184 end 185 n = argread 2 bout 0 len bout 186 if le n 0 187 build_fail 188 end 189 put boutn 0 ulong n 190 rc = makedir bdir 0 len bdir 493 191 if and ne rc 0 ne rc -17 192 build_fail 193 end 194 unit = fopen bunit 0 len bunit 577 420 195 if lt unit 0 196 build_fail 197 end 198 n = write int unit bmode 0 len bmode 199 if ne n long len bmode 200 build_fail 201 end 202 build_manifest int unit int mf 203 rc = fclose int mf 204 if ne rc 0 205 build_fail 206 end 207 rc = fclose int unit 208 if ne rc 0 209 build_fail 210 end 211 ret build_compile 212 end