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/hop/blob/main/Linux/build.om # hop Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key. Brought by drakestapleton Sign in to star 1 stars 1 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `hop / Linux / build.om` 608 lines ยท 11212 bytes Raw Blame History 1 om2 2 note Linux build driver. Compiler inputs, concatenation and subprocesses are owned by Omega. 3 note Bootstrap this file with OMEGA_MV/seed/out/omc; run it from Hop's source root. 4 text hb_usage "Usage: linux-build OMEGA_MV [install]\n" 5 text hb_error "Hop Linux build failed. The failing tool's diagnostic is above.\n" 6 text hb_done "Built build/linux/hop and its matching helper.\n" 7 text hb_root "/seed/out/omc" 8 text hb_ngsrc "build/linux/ngbuild.om" 9 text hb_ngboot "build/linux/ngbuild" 10 text hb_ng "build/linux/ng" 11 text hb_units "seed/ng/ng.units" 12 text hb_sha "/seed/ng/sha256.om" 13 text hb_builder "/seed/ng/ngbuild.om" 14 text hb_ngunits "/seed/ng/ng.units" 15 text hb_s1 "Linux/window.om" 16 text hb_s2 "Linux/apps.om" 17 text hb_s3 "Linux/core.om" 18 text hb_s4 "Linux/main.om" 19 text hb_s5 "Linux/chat.om" 20 text hb_s6 "Linux/files.om" 21 text hb_join "build/linux/hop.om" 22 text hb_hop "build/linux/hop" 23 text hb_core "Omega/hopcore.om" 24 text hb_front "@ng front-ir\n" 25 text hb_opt "@ng opt\n" 26 text hb_a64 "@ng a64\n" 27 text hb_ci "build/linux/core-input.om" 28 text hb_ir "build/linux/core.ir" 29 text hb_oi "build/linux/opt-input" 30 text hb_or "build/linux/core.opt.ir" 31 text hb_ai "build/linux/elf-input" 32 text hb_co "build/linux/hopcore" 33 text hb_build "build" 34 text hb_dir "build/linux" 35 text hb_empty "" 36 text hb_slash "/" 37 text hb_gio "/usr/bin/gio" 38 text hb_env "/usr/bin/env" 39 text hb_curl "/usr/bin/curl" 40 text hb_version "version" 41 text hb_vflag "--version" 42 text hb_glog "build/linux/dependency-gio.txt" 43 text hb_elog "build/linux/dependency-env.txt" 44 text hb_clog "build/linux/dependency-curl.txt" 45 text hb_isrc "Linux/install.om" 46 text hb_ibin "build/linux/install" 47 text hb_iarg "install" 48 text hb_dd "--" 49 text hb_git "/usr/bin/git" 50 text hb_status "status" 51 text hb_porcelain "--porcelain=v1" 52 text hb_all "--untracked-files=all" 53 text hb_statuslog "build/linux/SOURCE_STATUS" 54 text hb_headlog "build/linux/SOURCE_HEAD" 55 text hb_revparse "rev-parse" 56 text hb_head "HEAD" 57 text hb_privatekey "HOP_API_KEY=" 58 text hb_record "build/linux/BUILD_RECORD" 59 text hb_recordtmp "build/linux/BUILD_RECORD.pending" 60 text hb_magic "HOPBUILD1\n" 61 text hb_compilerhead "/source-commit" 62 text hb_sum "/usr/bin/sha256sum" 63 text hb_sumlog "build/linux/build-hash.txt" 64 text hb_sumversion "build/linux/dependency-sha256sum.txt" 65 text hb_newline "\n" 66 global hb_tree uchar 4096 67 global hb_tn ulong 1 68 global hb_cwd uchar 4096 69 global hb_cn ulong 1 70 global hb_tool uchar 4096 71 global hb_tl ulong 1 72 global hb_out uchar 4096 73 global hb_on ulong 1 74 global hb_src uchar 4096 75 global hb_sn ulong 1 76 global hb_pkt uchar 65536 77 global hb_pn ulong 1 78 global hb_ac ulong 1 79 global hb_input uchar 4096 80 global hb_in ulong 1 81 global hb_cd ulong 1 82 global hb_doins ulong 1 83 global hb_initial uchar 128 84 global hb_initialn ulong 1 85 86 fn hb_fail to void 87 k = write 2 hb_error 0 len hb_error 88 exit 1 89 end 90 91 fn hb_path dest int suffix view uchar * to void 92 n = get hb_tn 0 93 if gt add n len suffix 4096 94 hb_fail 95 end 96 for i ulong n 97 if eq dest 0 98 put hb_tool i get hb_tree i 99 else 100 put hb_src i get hb_tree i 101 end 102 end 103 for i ulong len suffix 104 if eq dest 0 105 put hb_tool add n i get suffix i 106 else 107 put hb_src add n i get suffix i 108 end 109 end 110 if eq dest 0 111 put hb_tl 0 add n len suffix 112 else 113 put hb_sn 0 add n len suffix 114 end 115 end 116 117 fn hb_arg a view uchar * to void 118 p = get hb_pn 0 119 if gt add add p 2 len a len hb_pkt 120 hb_fail 121 end 122 put hb_pkt p uchar and len a 255 123 put hb_pkt add p 1 uchar shr len a 8 124 p = add p 2 125 for i ulong len a 126 put hb_pkt add p i get a i 127 end 128 put hb_pn 0 add p len a 129 put hb_ac 0 add get hb_ac 0 1 130 end 131 132 fn hb_absarg a view uchar * to void 133 b = new uchar 4096 0 134 n = get hb_cn 0 135 if gt add add n 1 len a len b 136 hb_fail 137 end 138 for i ulong n 139 put b i get hb_cwd i 140 end 141 put b n 47 142 for i ulong len a 143 put b add add n 1 i get a i 144 end 145 hb_arg part b 0 add add n 1 len a 146 end 147 148 fn hb_reset to void 149 put hb_pn 0 2 150 put hb_ac 0 0 151 put hb_cd 0 0 152 put hb_in 0 0 153 put hb_on 0 0 154 end 155 156 fn hb_addtool to void 157 b = new uchar 4096 0 158 n = get hb_tl 0 159 for i ulong n 160 put b i get hb_tool i 161 end 162 hb_arg part b 0 n 163 end 164 165 fn hb_redirect path view uchar * input bool to void 166 if input 167 for i ulong len path 168 put hb_input i get path i 169 end 170 put hb_in 0 len path 171 else 172 for i ulong len path 173 put hb_out i get path i 174 end 175 put hb_on 0 len path 176 end 177 end 178 179 fn hb_run to void 180 st = new uchar 4 0 181 put hb_pkt 0 uchar and get hb_ac 0 255 182 put hb_pkt 1 uchar shr get hb_ac 0 8 183 pid = fork 184 if eq pid 0 185 if gt get hb_in 0 0 186 fd = fopen hb_input 0 get hb_in 0 0 0 187 if lt fd 0 188 exit 126 189 end 190 k = dupfd int fd 0 0 191 if lt k 0 192 exit 126 193 end 194 end 195 if gt get hb_on 0 0 196 fd = fopen hb_out 0 get hb_on 0 577 420 197 if lt fd 0 198 exit 126 199 end 200 k = dupfd int fd 1 0 201 if lt k 0 202 exit 126 203 end 204 end 205 if ne get hb_cd 0 0 206 k = chdir hb_tree 0 get hb_tn 0 207 if ne k 0 208 exit 126 209 end 210 end 211 k = execprog hb_pkt 0 get hb_pn 0 212 exit 127 213 end 214 if lt pid 0 215 hb_fail 216 end 217 k = waitpid int pid st 0 4 0 218 if ne k pid 219 hb_fail 220 end 221 if ne get st 0 0 222 hb_fail 223 end 224 if ne get st 1 0 225 hb_fail 226 end 227 end 228 229 fn hb_copy fd int path view uchar * to void 230 buf = new uchar 65536 0 231 src = fopen path 0 len path 0 0 232 if lt src 0 233 k = write 2 path 0 len path 234 hb_fail 235 end 236 while true bound `9223372036854775807` 237 n = read int src buf 0 len buf 238 if lt n 0 239 hb_fail 240 end 241 if eq n 0 242 break 243 end 244 p = ulong 0 245 while lt p ulong n bound 65536 246 k = write fd buf p sub ulong n p 247 if le k 0 248 hb_fail 249 end 250 p = add p ulong k 251 end 252 end 253 k = fclose int src 254 end 255 256 fn hb_sourcecopy fd int to void 257 b = new uchar 4096 0 258 n = get hb_sn 0 259 for i ulong n 260 put b i get hb_src i 261 end 262 hb_copy fd part b 0 n 263 end 264 265 fn hb_chmod path view uchar * to void 266 fd = fopen path 0 len path 0 0 267 if lt fd 0 268 hb_fail 269 end 270 k = fchmod int fd 493 271 if ne k 0 272 hb_fail 273 end 274 k = fclose int fd 275 end 276 277 fn hb_compile input view uchar * output view uchar * to void 278 hb_reset 279 hb_path 0 hb_root 280 hb_addtool 281 hb_redirect input true 282 hb_redirect output false 283 hb_run 284 hb_chmod output 285 end 286 287 fn hb_stage prefix view uchar * input view uchar * feed view uchar * to void 288 fd = fopen feed 0 len feed 577 420 289 if lt fd 0 290 hb_fail 291 end 292 k = write int fd prefix 0 len prefix 293 if ne k long len prefix 294 hb_fail 295 end 296 hb_copy int fd input 297 k = fclose int fd 298 end 299 300 fn hb_ngrun feed view uchar * output view uchar * to void 301 hb_reset 302 hb_absarg hb_ng 303 hb_redirect feed true 304 hb_redirect output false 305 hb_run 306 end 307 308 fn hb_dependency tool view uchar * arg view uchar * output view uchar * to void 309 hb_reset 310 hb_arg tool 311 hb_arg arg 312 hb_redirect output false 313 hb_run 314 end 315 316 fn hb_session to void 317 e = new uchar 131072 0 318 hb_arg hb_env 319 hb_arg hb_dd 320 for i ulong ulong envcnt bound `9223372036854775807` 321 n = envread i e 0 len e 322 if lt n 0 323 hb_fail 324 end 325 privatev = ge ulong n len hb_privatekey 326 if privatev 327 for j ulong len hb_privatekey 328 if ne get e j get hb_privatekey j 329 privatev = false 330 break 331 end 332 end 333 end 334 if not privatev 335 hb_arg part e 0 ulong n 336 end 337 end 338 end 339 340 fn hb_provenance to void 341 statusv = new uchar 1 0 342 hb_reset 343 hb_arg hb_git 344 hb_arg hb_status 345 hb_arg hb_porcelain 346 hb_arg hb_all 347 hb_redirect hb_statuslog false 348 hb_run 349 fd = fopen hb_statuslog 0 len hb_statuslog 0 0 350 if lt fd 0 351 hb_fail 352 end 353 n = read int fd statusv 0 1 354 k = fclose int fd 355 if lt n 0 356 hb_fail 357 end 358 if ne n 0 359 note Development builds are useful but must never acquire an installable source stamp. 360 fd = fopen hb_headlog 0 len hb_headlog 577 420 361 if lt fd 0 362 hb_fail 363 end 364 k = fclose int fd 365 ret 366 end 367 hb_reset 368 hb_arg hb_git 369 hb_arg hb_revparse 370 hb_arg hb_head 371 hb_redirect hb_headlog false 372 hb_run 373 end 374 375 fn hb_hash fd int path view uchar * to void 376 hb_reset 377 hb_arg hb_sum 378 hb_redirect path true 379 hb_redirect hb_sumlog false 380 hb_run 381 b = new uchar 66 0 382 src = fopen hb_sumlog 0 len hb_sumlog 0 0 383 if lt src 0 384 hb_fail 385 end 386 n = read int src b 0 len b 387 k = fclose int src 388 if ne n 66 389 hb_fail 390 end 391 for i ulong 64 392 c = get b i 393 digit = and ge c 48 le c 57 394 letter = and ge c 97 le c 102 395 if not or digit letter 396 hb_fail 397 end 398 end 399 k = write fd b 0 64 400 if ne k 64 401 hb_fail 402 end 403 k = write fd hb_newline 0 1 404 if ne k 1 405 hb_fail 406 end 407 end 408 409 fn hb_recordbuild to void 410 b = new uchar 1 0 411 src = fopen hb_headlog 0 len hb_headlog 0 0 412 if lt src 0 413 hb_fail 414 end 415 n = read int src b 0 1 416 k = fclose int src 417 if eq n 0 418 ret 419 end 420 if lt n 0 421 hb_fail 422 end 423 fd = fopen hb_recordtmp 0 len hb_recordtmp 577 420 424 if lt fd 0 425 hb_fail 426 end 427 k = write int fd hb_magic 0 len hb_magic 428 if ne k long len hb_magic 429 hb_fail 430 end 431 hb_copy int fd hb_headlog 432 hb_path 1 hb_compilerhead 433 hb_sourcecopy int fd 434 hb_path 1 hb_root 435 p = new uchar 4096 0 436 for i ulong get hb_sn 0 437 put p i get hb_src i 438 end 439 hb_hash int fd part p 0 get hb_sn 0 440 hb_hash int fd hb_hop 441 hb_hash int fd hb_co 442 k = fsync int fd 443 if ne k 0 444 hb_fail 445 end 446 k = fclose int fd 447 if ne k 0 448 hb_fail 449 end 450 hb_reset 451 hb_arg hb_recordtmp 452 hb_arg hb_record 453 put hb_pkt 0 2 454 put hb_pkt 1 0 455 k = renames hb_pkt 0 get hb_pn 0 0 456 if ne k 0 457 hb_fail 458 end 459 end 460 461 fn hb_checksource first bool to void 462 b = new uchar 128 0 463 src = fopen hb_headlog 0 len hb_headlog 0 0 464 if lt src 0 465 hb_fail 466 end 467 n = read int src b 0 len b 468 k = fclose int src 469 if or lt n 0 ge n long len b 470 hb_fail 471 end 472 if first 473 put hb_initialn 0 ulong n 474 for i ulong ulong n 475 put hb_initial i get b i 476 end 477 else 478 stable = eq ulong n get hb_initialn 0 479 if stable 480 for i ulong ulong n 481 if ne get hb_initial i get b i 482 stable = false 483 end 484 end 485 end 486 if not stable 487 note A source change during compilation cannot acquire a successful proof. 488 fd = fopen hb_headlog 0 len hb_headlog 577 420 489 if lt fd 0 490 hb_fail 491 end 492 k = fclose int fd 493 end 494 end 495 end 496 497 fn main to int 498 b = new uchar 4096 0 499 if and ne argcnt 2 ne argcnt 3 500 k = write 2 hb_usage 0 len hb_usage 501 ret 2 502 end 503 n = argread 1 b 0 len b 504 if or le n 0 ge n long len b 505 hb_fail 506 end 507 if ne get b 0 47 508 hb_fail 509 end 510 for i ulong ulong n 511 put hb_tree i get b i 512 end 513 put hb_tn 0 ulong n 514 if eq argcnt 3 515 n = argread 2 b 0 len b 516 if ne n long len hb_iarg 517 k = write 2 hb_usage 0 len hb_usage 518 ret 2 519 end 520 for i ulong len hb_iarg 521 if ne get b i get hb_iarg i 522 k = write 2 hb_usage 0 len hb_usage 523 ret 2 524 end 525 end 526 put hb_doins 0 1 527 end 528 n = cwd b 0 len b 529 if le n 0 530 hb_fail 531 end 532 put hb_cn 0 sub ulong n 1 533 for i ulong get hb_cn 0 534 put hb_cwd i get b i 535 end 536 k = makedir hb_build 0 len hb_build 493 537 if and lt k 0 ne k -17 538 hb_fail 539 end 540 k = makedir hb_dir 0 len hb_dir 493 541 if and lt k 0 ne k -17 542 hb_fail 543 end 544 note Invalidate the previous proof before any executable can be overwritten. 545 fd = fopen hb_record 0 len hb_record 577 420 546 if lt fd 0 547 hb_fail 548 end 549 k = fclose int fd 550 hb_provenance 551 hb_checksource true 552 fd = fopen hb_ngsrc 0 len hb_ngsrc 577 420 553 if lt fd 0 554 hb_fail 555 end 556 hb_path 1 hb_sha 557 hb_sourcecopy int fd 558 hb_path 1 hb_builder 559 hb_sourcecopy int fd 560 k = fclose int fd 561 hb_compile hb_ngsrc hb_ngboot 562 hb_reset 563 hb_absarg hb_ngboot 564 hb_arg hb_build 565 hb_path 0 hb_root 566 hb_addtool 567 hb_arg hb_units 568 hb_absarg hb_ng 569 put hb_cd 0 1 570 hb_run 571 hb_chmod hb_ng 572 hb_stage hb_front hb_core hb_ci 573 hb_ngrun hb_ci hb_ir 574 hb_stage hb_opt hb_ir hb_oi 575 hb_ngrun hb_oi hb_or 576 hb_stage hb_a64 hb_or hb_ai 577 hb_ngrun hb_ai hb_co 578 hb_chmod hb_co 579 fd = fopen hb_join 0 len hb_join 577 420 580 if lt fd 0 581 hb_fail 582 end 583 hb_copy int fd hb_s1 584 hb_copy int fd hb_s2 585 hb_copy int fd hb_s3 586 hb_copy int fd hb_s5 587 hb_copy int fd hb_s6 588 hb_copy int fd hb_s4 589 k = fclose int fd 590 hb_compile hb_join hb_hop 591 hb_compile hb_isrc hb_ibin 592 hb_dependency hb_gio hb_version hb_glog 593 hb_dependency hb_env hb_vflag hb_elog 594 hb_dependency hb_curl hb_vflag hb_clog 595 hb_dependency hb_sum hb_vflag hb_sumversion 596 hb_provenance 597 hb_checksource false 598 hb_recordbuild 599 k = write 1 hb_done 0 len hb_done 600 if ne get hb_doins 0 0 601 hb_reset 602 hb_session 603 hb_absarg hb_ibin 604 hb_absarg hb_empty 605 hb_run 606 end 607 ret 0 608 end