build/sim/verilator: compile sim just before running and not when building.

This commit is contained in:
Florent Kermarrec 2018-12-21 09:57:52 +01:00
parent 291843ee76
commit 2deffd8c8a
1 changed files with 5 additions and 3 deletions

View File

@ -117,7 +117,7 @@ def _generate_sim_config(config):
tools.write_to_file("sim_config.js", content)
def _build_sim(platform, build_name, sources, threads, coverage, verbose):
def _build_sim(build_name, sources, threads, coverage):
makefile = os.path.join(core_directory, 'Makefile')
cc_srcs = []
for filename, language, library in sources:
@ -134,6 +134,8 @@ mkdir -p modules && cp obj_dir/*.so modules
build_script_file = "build_" + build_name + ".sh"
tools.write_to_file(build_script_file, build_script_contents, force_unix=True)
def _compile_sim(build_name, verbose):
build_script_file = "build_" + build_name + ".sh"
p = subprocess.Popen(["bash", build_script_file], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output, _ = p.communicate()
output = output.decode('utf-8')
@ -146,7 +148,6 @@ mkdir -p modules && cp obj_dir/*.so modules
if verbose:
print(output)
def _run_sim(build_name, as_root=False):
run_script_contents = "sudo " if as_root else ""
run_script_contents += "obj_dir/Vdut"
@ -198,10 +199,11 @@ class SimVerilatorToolchain:
_generate_sim_config(sim_config)
# build
_build_sim(platform, build_name, platform.sources, threads, coverage, verbose)
_build_sim(build_name, platform.sources, threads, coverage)
# run
if run:
_compile_sim(build_name, verbose)
_run_sim(build_name, as_root=sim_config.has_module("ethernet"))
os.chdir("../../")