build/builder: Simplify/Review #1190.
- Only do copy in Builder. - Use relative path for copied files (will be useful to create self-contained gateware archive).
This commit is contained in:
parent
3dcc6180f3
commit
bfad61cd2a
|
@ -9,7 +9,6 @@
|
|||
import sys
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
|
||||
from migen.fhdl.structure import Signal, Cat
|
||||
from migen.genlib.record import Record
|
||||
|
@ -313,7 +312,6 @@ class GenericPlatform:
|
|||
self.sources = []
|
||||
self.verilog_include_paths = []
|
||||
self.output_dir = None
|
||||
self.gateware_dir = None
|
||||
self.finalized = False
|
||||
self.use_default_clk = False
|
||||
|
||||
|
@ -375,20 +373,13 @@ class GenericPlatform:
|
|||
language = tools.language_by_filename(filename)
|
||||
if library is None:
|
||||
library = "work"
|
||||
for f, *r in self.sources:
|
||||
for f, *_ in self.sources:
|
||||
if f == filename:
|
||||
return
|
||||
# If the gateware_dir is already defined, we can copy the file
|
||||
if self.gateware_dir:
|
||||
dst = filename
|
||||
if copy:
|
||||
dst = os.path.join(self.gateware_dir, os.path.basename(s[0]))
|
||||
shutil.copyfile(filename, dst)
|
||||
self.sources.append((dst, language, library))
|
||||
# If it's too early and the gateware_dir is not known and if it's
|
||||
# necessary, the file will be copied by the Builder class
|
||||
if copy:
|
||||
self.sources.append((filename, language, library, True))
|
||||
else:
|
||||
self.sources.append((filename, language, library, copy))
|
||||
self.sources.append((filename, language, library))
|
||||
|
||||
def add_sources(self, path, *filenames, language=None, library=None, copy=False):
|
||||
for f in filenames:
|
||||
|
|
|
@ -278,8 +278,7 @@ class Builder:
|
|||
|
||||
def build(self, **kwargs):
|
||||
# Pass Output Directory to Platform.
|
||||
self.soc.platform.output_dir = self.output_dir
|
||||
self.soc.platform.gateware_dir = self.gateware_dir
|
||||
self.soc.platform.output_dir = self.output_dir
|
||||
|
||||
# Check if BIOS is used and add software package if so.
|
||||
with_bios = self.soc.cpu_type is not None
|
||||
|
@ -289,15 +288,12 @@ class Builder:
|
|||
# Create Gateware directory.
|
||||
_create_dir(self.gateware_dir)
|
||||
|
||||
# If asked, copy files to the gateware directory and change the source file location.
|
||||
# Drop the 'copy' element from the tupple.
|
||||
# 'copy' may or may not be present in the tupple.
|
||||
for i, (f, language, library, *r) in enumerate(self.soc.platform.sources):
|
||||
dst = f
|
||||
if r[0] is True:
|
||||
dst = os.path.join(self.gateware_dir, os.path.basename(f))
|
||||
shutil.copyfile(f, dst)
|
||||
self.soc.platform.sources[i] = (dst, language, library)
|
||||
# Copy Sources to Gateware directory (Optional).
|
||||
for i, (f, language, library, *copy) in enumerate(self.soc.platform.sources):
|
||||
if len(copy) and copy[0]:
|
||||
shutil.copy(f, self.gateware_dir)
|
||||
f = os.path.basename(f)
|
||||
self.soc.platform.sources[i] = (f, language, library)
|
||||
|
||||
# Create Software directory.
|
||||
# First check if software needs a full re-build and remove software dir if so.
|
||||
|
|
Loading…
Reference in New Issue