|
393 | 393 | os.chdir(here[0]) |
394 | 394 |
|
395 | 395 |
|
| 396 | +def xchg_1vs2(matchobj): |
| 397 | + if matchobj.group(2) == '1': |
| 398 | + return matchobj.group(1) + '2' |
| 399 | + else: |
| 400 | + return matchobj.group(1) + '1' |
| 401 | + |
| 402 | + |
| 403 | +print("generating blst.zig...") or sys.stdout.flush() |
| 404 | +with open("blst.zig", "w") as fd: |
| 405 | + print("//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", file=fd) |
| 406 | + print("// DO NOT EDIT THIS FILE!!!", file=fd) |
| 407 | + print("// The file is auto-generated by " + here[-1], file=fd) |
| 408 | + print("//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", file=fd) |
| 409 | + print(top_zig, file=fd) |
| 410 | + print(p1_zig, file=fd) |
| 411 | + print(re.sub(r'((?<!f)[pgPG\*])([12])', xchg_1vs2, p1_zig), file=fd) |
| 412 | + |
| 413 | + |
396 | 414 | def newer(*files): |
397 | 415 | assert len(files) > 1 |
398 | 416 | rh = files[-1] |
@@ -426,31 +444,17 @@ def newer(*files): |
426 | 444 | print("pub const {} = {};".format(key, val), file=fd) |
427 | 445 | del pubs |
428 | 446 |
|
429 | | - |
430 | | -def xchg_1vs2(matchobj): |
431 | | - if matchobj.group(2) == '1': |
432 | | - return matchobj.group(1) + '2' |
433 | | - else: |
434 | | - return matchobj.group(1) + '1' |
435 | | - |
436 | | - |
437 | | -print("generating blst.zig...") or sys.stdout.flush() |
438 | | -with open("blst.zig", "w") as fd: |
439 | | - print("//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", file=fd) |
440 | | - print("// DO NOT EDIT THIS FILE!!!", file=fd) |
441 | | - print("// The file is auto-generated by " + here[-1], file=fd) |
442 | | - print("//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", file=fd) |
443 | | - print(top_zig, file=fd) |
444 | | - print(p1_zig, file=fd) |
445 | | - print(re.sub(r'((?<!f)[pgPG\*])([12])', xchg_1vs2, p1_zig), file=fd) |
446 | | - |
447 | 447 | version = "0.3.16" |
448 | 448 |
|
449 | 449 | os.chdir("../..") |
450 | | -with open("build.zig.zon", "r") as fd: |
451 | | - m = re.search(r'\.version = "([^"]+)"', fd.read()) |
452 | | - if m.group(1) == version: |
453 | | - sys.exit(0) |
| 450 | +try: |
| 451 | + with open("build.zig.zon", "r") as fd: |
| 452 | + m = re.search(r'\.version = "([^"]+)"', fd.read()) |
| 453 | + if m and m.group(1) == version: |
| 454 | + sys.exit(0) |
| 455 | +except OSError as e: |
| 456 | + if e.errno != 2: # not "no such file or directory" |
| 457 | + raise e |
454 | 458 |
|
455 | 459 | print("generating build.zig.zon...") or sys.stdout.flush() |
456 | 460 | zon = """.{ |
|
0 commit comments