1
0
Fork 0
mirror of https://git.sr.ht/~kivikakk/niar synced 2024-12-22 23:12:23 +00:00

cxxrtl: CXXRTL cc doesn't depend on our headers.

This commit is contained in:
Asherah Connor 2024-06-27 18:43:27 +03:00
parent 46ac1c24e9
commit c757d4f606

View file

@ -130,10 +130,11 @@ def main(np: Project, args):
cr.run() cr.run()
with logtime(logging.DEBUG, "compilation"): with logtime(logging.DEBUG, "compilation"):
cc_o_paths = {cxxrtl_cc_path: np.path.build(f"{np.name}.o")} cc_odep_paths = {cxxrtl_cc_path: (np.path.build(f"{np.name}.o"), [])}
depfs = list(np.path("cxxrtl").glob("**/*.h"))
for path in np.path("cxxrtl").glob("**/*.cc"): for path in np.path("cxxrtl").glob("**/*.cc"):
# XXX: we make no effort to distinguish cxxrtl/a.cc and cxxrtl/dir/a.cc. # XXX: we make no effort to distinguish cxxrtl/a.cc and cxxrtl/dir/a.cc.
cc_o_paths[path] = np.path.build(f"{path.stem}.o") cc_odep_paths[path] = (np.path.build(f"{path.stem}.o"), depfs)
cxxflags = CXXFLAGS + [ cxxflags = CXXFLAGS + [
f"-DCLOCK_HZ={int(platform.default_clk_frequency)}", f"-DCLOCK_HZ={int(platform.default_clk_frequency)}",
@ -146,9 +147,7 @@ def main(np: Project, args):
"-DCXXRTL_INCLUDE_VCD_CAPI_IMPL", "-DCXXRTL_INCLUDE_VCD_CAPI_IMPL",
] ]
depfs = list(np.path("cxxrtl").glob("**/*.h")) for cc_path, (o_path, dep_paths) in cc_odep_paths.items():
for cc_path, o_path in cc_o_paths.items():
cmd = [ cmd = [
"c++", "c++",
*cxxflags, *cxxflags,
@ -161,7 +160,7 @@ def main(np: Project, args):
] ]
if platform.uses_zig: if platform.uses_zig:
cmd = ["zig"] + cmd cmd = ["zig"] + cmd
cr.add_process(cmd, infs=[cc_path] + depfs, outf=o_path) cr.add_process(cmd, infs=[cc_path] + dep_paths, outf=o_path)
with open(np.path.build("compile_commands.json"), "w") as f: with open(np.path.build("compile_commands.json"), "w") as f:
json.dump( json.dump(
@ -176,6 +175,7 @@ def main(np: Project, args):
cr.run() cr.run()
exe_o_path = np.path.build("cxxrtl") exe_o_path = np.path.build("cxxrtl")
cc_o_paths = [o_path for (o_path, _) in cc_odep_paths.values()]
if platform.uses_zig: if platform.uses_zig:
cmd = [ cmd = [
"zig", "zig",
@ -184,13 +184,13 @@ def main(np: Project, args):
f"-Dyosys_data_dir={yosys.data_dir()}", f"-Dyosys_data_dir={yosys.data_dir()}",
] + [ ] + [
# Zig really wants relative paths. # Zig really wants relative paths.
f"-Dcxxrtl_o_path=../{p.relative_to(np.path())}" for p in cc_o_paths.values() f"-Dcxxrtl_o_path=../{p.relative_to(np.path())}" for p in cc_o_paths
] ]
if args.optimize.opt_app: if args.optimize.opt_app:
cmd += ["-Doptimize=ReleaseFast"] cmd += ["-Doptimize=ReleaseFast"]
outf = "cxxrtl/zig-out/bin/cxxrtl" outf = "cxxrtl/zig-out/bin/cxxrtl"
cr.add_process(cmd, cr.add_process(cmd,
infs=cc_o_paths.values() + np.path("cxxrtl").glob("**/*.zig"), infs=cc_o_paths + np.path("cxxrtl").glob("**/*.zig"),
outf=outf, outf=outf,
chdir="cxxrtl") chdir="cxxrtl")
cr.run() cr.run()
@ -199,12 +199,12 @@ def main(np: Project, args):
cmd = [ cmd = [
"c++", "c++",
*cxxflags, *cxxflags,
*cc_o_paths.values(), *cc_o_paths,
"-o", "-o",
exe_o_path, exe_o_path,
] ]
cr.add_process(cmd, cr.add_process(cmd,
infs=cc_o_paths.values(), infs=cc_o_paths,
outf=exe_o_path) outf=exe_o_path)
cr.run() cr.run()