883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
27 lines
1.3 KiB
Python
27 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""A header edit must change the compiled behavior; unchanged builds do no work."""
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
|
|
from codec_build_cache import Cache
|
|
|
|
with tempfile.TemporaryDirectory(prefix='gateway-compiler-') as temporary:
|
|
root=Path(temporary);header=root/'value.h';source=root/'main.cpp';obj=root/'main.o';exe=root/'example'
|
|
source.write_text('#include "value.h"\nint main(){return VALUE;}\n')
|
|
header.write_text('#define VALUE 1\n')
|
|
flags=['clang++','-std=c++20']
|
|
def build():
|
|
cache=Cache('clang++');cache.compile(flags,source,obj)
|
|
linked=cache.link([*flags,str(obj),'-o',str(exe.with_suffix('.new'))],[obj],exe)
|
|
return cache.compiled,linked
|
|
assert build()==(1,True) and subprocess.run([str(exe)]).returncode==1
|
|
assert build()==(0,False)
|
|
header.write_text('#define VALUE 2\n')
|
|
assert build()==(1,True) and subprocess.run([str(exe)]).returncode==2
|
|
assert build()==(0,False)
|
|
obj.write_bytes(b'corrupted object')
|
|
assert build()[0]==1 and subprocess.run([str(exe)]).returncode==2
|
|
print('Compiler dependency changes and corrupted outputs invalidate cache; unchanged builds skip compilation/linking.')
|