Repository navigation
Expand file tree
/
Copy pathcheck_script_cpp_abi.py
More file actions
65 lines (57 loc) · 2.84 KB
/
Copy pathcheck_script_cpp_abi.py
File metadata and controls
65 lines (57 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
"""Compile/link the generated source-host ABI against frozen v18 and live v19."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
import re
from cpp_abi_pairing import PairingError, enforce_receipt_mode, execute_frozen_pair
def verify_source_shape(include: Path) -> None:
engine = (include / "pineforge" / "engine.hpp").read_text()
host = (include / "pineforge" / "source" / "pine_strategy_host.hpp").read_text()
if "class PineStrategyHost : public NativeStrategyHost" not in host:
raise PairingError("source host is not native-bound")
if re.search(r"(?<!~)\bBacktestEngine\s*\(\s*\)\s*;", engine):
raise PairingError("legacy default execution-owner constructor remains")
if "NativeConsumerBindTag" not in engine:
raise PairingError("explicit native construction tag is missing")
if (include / "pineforge" / "source" / "pine_pending_intent.hpp").exists():
raise PairingError("retired source order header remains installed")
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--compiler", required=True)
parser.add_argument("--library", type=Path, required=True)
parser.add_argument("--include", type=Path, required=True)
parser.add_argument("--generated-include", type=Path, required=True)
parser.add_argument("--v18-frozen-receipt", type=Path, required=True)
parser.add_argument("--extra-flag", action="append", default=[])
parser.add_argument("--receipt", type=Path, required=True)
receipt_mode = parser.add_mutually_exclusive_group()
receipt_mode.add_argument("--skip-if-receipt-missing", action="store_true")
receipt_mode.add_argument("--require-receipts", action="store_true")
args = parser.parse_args()
try:
mode = enforce_receipt_mode(
(args.v18_frozen_receipt,), skip=args.skip_if_receipt_missing,
require=args.require_receipts, label="script C++ ABI")
if mode is not None:
return mode
verify_source_shape(args.include)
result = execute_frozen_pair(
compiler=args.compiler,
extra_flags=args.extra_flag,
current_library=args.library,
current_include=args.include,
generated_include=args.generated_include,
frozen_receipt=args.v18_frozen_receipt,
kind="script",
artifact_directory=args.receipt.parent,
)
except PairingError as error:
raise SystemExit("script C++ ABI: " + str(error))
args.receipt.parent.mkdir(parents=True, exist_ok=True)
args.receipt.write_text(json.dumps(result, indent=2, sort_keys=True) + "\n")
print("script C++ ABI: source-host v18/v19 acceptance and bidirectional rejection pairs passed")
return 0
if __name__ == "__main__":
raise SystemExit(main())