soc/integration/builder: add use_symlinks parameter and desactivate symlinks by default
On windows machines, console need to be run as Administrator to create symlinks which is bit painful.
This commit is contained in:
parent
1cec0f8086
commit
352cb91688
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import struct
|
import struct
|
||||||
|
import shutil
|
||||||
|
|
||||||
from litex.soc.integration import cpu_interface, soc_sdram, sdram_init
|
from litex.soc.integration import cpu_interface, soc_sdram, sdram_init
|
||||||
|
|
||||||
|
@ -29,7 +30,8 @@ class Builder:
|
||||||
def __init__(self, soc, output_dir=None,
|
def __init__(self, soc, output_dir=None,
|
||||||
compile_software=True, compile_gateware=True,
|
compile_software=True, compile_gateware=True,
|
||||||
gateware_toolchain_path=None,
|
gateware_toolchain_path=None,
|
||||||
csr_csv=None):
|
csr_csv=None,
|
||||||
|
use_symlinks=False):
|
||||||
self.soc = soc
|
self.soc = soc
|
||||||
if output_dir is None:
|
if output_dir is None:
|
||||||
output_dir = "soc_{}_{}".format(
|
output_dir = "soc_{}_{}".format(
|
||||||
|
@ -42,6 +44,7 @@ class Builder:
|
||||||
self.compile_gateware = compile_gateware
|
self.compile_gateware = compile_gateware
|
||||||
self.gateware_toolchain_path = gateware_toolchain_path
|
self.gateware_toolchain_path = gateware_toolchain_path
|
||||||
self.csr_csv = csr_csv
|
self.csr_csv = csr_csv
|
||||||
|
self.use_symlinks = use_symlinks
|
||||||
|
|
||||||
self.software_packages = []
|
self.software_packages = []
|
||||||
for name in soc_software_packages:
|
for name in soc_software_packages:
|
||||||
|
@ -93,9 +96,10 @@ class Builder:
|
||||||
with open(self.csr_csv, "w") as f:
|
with open(self.csr_csv, "w") as f:
|
||||||
f.write(cpu_interface.get_csr_csv(csr_regions))
|
f.write(cpu_interface.get_csr_csv(csr_regions))
|
||||||
|
|
||||||
def _generate_software(self):
|
def _prepare_software(self):
|
||||||
for name, src_dir in self.software_packages:
|
for name, src_dir in self.software_packages:
|
||||||
dst_dir = os.path.join(self.output_dir, "software", name)
|
dst_dir = os.path.join(self.output_dir, "software", name)
|
||||||
|
if self.use_symlinks:
|
||||||
os.makedirs(dst_dir, exist_ok=True)
|
os.makedirs(dst_dir, exist_ok=True)
|
||||||
src = os.path.join(src_dir, "Makefile")
|
src = os.path.join(src_dir, "Makefile")
|
||||||
dst = os.path.join(dst_dir, "Makefile")
|
dst = os.path.join(dst_dir, "Makefile")
|
||||||
|
@ -104,6 +108,14 @@ class Builder:
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
os.symlink(src, dst)
|
os.symlink(src, dst)
|
||||||
|
else:
|
||||||
|
if os.path.exists(dst_dir):
|
||||||
|
shutil.rmtree(dst_dir)
|
||||||
|
shutil.copytree(src_dir, dst_dir)
|
||||||
|
|
||||||
|
def _generate_software(self):
|
||||||
|
for name, src_dir in self.software_packages:
|
||||||
|
dst_dir = os.path.join(self.output_dir, "software", name)
|
||||||
if self.compile_software:
|
if self.compile_software:
|
||||||
subprocess.check_call(["make", "-C", dst_dir])
|
subprocess.check_call(["make", "-C", dst_dir])
|
||||||
|
|
||||||
|
@ -127,6 +139,7 @@ class Builder:
|
||||||
raise ValueError("Software must be compiled in order to "
|
raise ValueError("Software must be compiled in order to "
|
||||||
"intitialize integrated ROM")
|
"intitialize integrated ROM")
|
||||||
|
|
||||||
|
self._prepare_software()
|
||||||
self._generate_includes()
|
self._generate_includes()
|
||||||
self._generate_software()
|
self._generate_software()
|
||||||
self._initialize_rom()
|
self._initialize_rom()
|
||||||
|
|
Loading…
Reference in New Issue