v3: gstack-code-gen 生成
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from runners.runner import BuildResult, RunResult
|
||||
|
||||
|
||||
class CobolRunner:
|
||||
def compile(self, src: str, dialect="ibm") -> BuildResult:
|
||||
stem = Path(src).stem
|
||||
out = str(Path(src).parent / stem)
|
||||
p = subprocess.run(["cobc", "-x", f"-std={dialect}-strict", "-o", out, src],
|
||||
capture_output=True, text=True, timeout=30)
|
||||
return BuildResult(success=p.returncode == 0, artifact_path=out, log=p.stdout + p.stderr)
|
||||
|
||||
def run(self, binary: str, input_path: str, output_path: str) -> RunResult:
|
||||
with open(input_path, "rb") as f:
|
||||
data = f.read()
|
||||
p = subprocess.run([binary], input=data, capture_output=True, timeout=30)
|
||||
Path(output_path).write_bytes(p.stdout)
|
||||
return RunResult(success=p.returncode == 0)
|
||||
Reference in New Issue
Block a user