soc/integration/builder: Allow linking in external software packages.
This commit is contained in:
parent
6b8a35a2f8
commit
61636f1248
|
@ -46,9 +46,6 @@ soc_software_packages = [
|
|||
"libliteeth",
|
||||
"liblitesdcard",
|
||||
"liblitesata",
|
||||
|
||||
# BIOS.
|
||||
"bios"
|
||||
]
|
||||
|
||||
# Builder ------------------------------------------------------------------------------------------
|
||||
|
@ -105,16 +102,25 @@ class Builder:
|
|||
# Documentation
|
||||
self.generate_doc = generate_doc
|
||||
|
||||
# List software packages.
|
||||
# List software packages and libraries.
|
||||
self.software_packages = []
|
||||
self.software_libraries = []
|
||||
|
||||
for name in soc_software_packages:
|
||||
self.add_software_package(name)
|
||||
|
||||
if name == "libbase":
|
||||
name += "-nofloat"
|
||||
self.add_software_library(name)
|
||||
|
||||
def add_software_package(self, name, src_dir=None):
|
||||
if src_dir is None:
|
||||
src_dir = os.path.join(soc_directory, "software", name)
|
||||
self.software_packages.append((name, src_dir))
|
||||
|
||||
def add_software_library(self, name):
|
||||
self.software_libraries.append(name)
|
||||
|
||||
def _generate_includes(self):
|
||||
# Generate Include/Generated directories.
|
||||
_create_dir(self.include_dir)
|
||||
|
@ -123,12 +129,18 @@ class Builder:
|
|||
# Generate BIOS files when the SoC uses it.
|
||||
with_bios = self.soc.cpu_type not in [None, "zynq7000"]
|
||||
if with_bios:
|
||||
self.add_software_package("bios")
|
||||
|
||||
# Generate Variables to variables.mak.
|
||||
variables_contents = []
|
||||
def define(k, v):
|
||||
variables_contents.append("{}={}".format(k, _makefile_escape(v)))
|
||||
|
||||
# Define packages and libraries.
|
||||
define("PACKAGES", " ".join(name for name, src_dir in self.software_packages))
|
||||
define("PACKAGE_DIRS", " ".join(src_dir for name, src_dir in self.software_packages))
|
||||
define("LIBS", " ".join(self.software_libraries))
|
||||
|
||||
# Define the CPU variables.
|
||||
for k, v in export.get_cpu_mak(self.soc.cpu, self.compile_software):
|
||||
define(k, v)
|
||||
|
|
|
@ -54,28 +54,17 @@ endif
|
|||
|
||||
bios.elf: $(BIOS_DIRECTORY)/linker.ld $(OBJECTS)
|
||||
|
||||
vpath %.a $(PACKAGES:%=../%)
|
||||
|
||||
%.elf: ../libbase/crt0.o \
|
||||
../libcompiler_rt/libcompiler_rt.a \
|
||||
../libbase/libbase-nofloat.a \
|
||||
../liblitedram/liblitedram.a \
|
||||
../libliteeth/libliteeth.a \
|
||||
../liblitespi/liblitespi.a \
|
||||
../libfatfs/libfatfs.a \
|
||||
../liblitesdcard/liblitesdcard.a \
|
||||
../liblitesata/liblitesata.a
|
||||
%.elf: ../libbase/crt0.o $(LIBS:%=%.a)
|
||||
$(CC) $(LDFLAGS) -T $(BIOS_DIRECTORY)/linker.ld -N -o $@ \
|
||||
../libbase/crt0.o \
|
||||
$(OBJECTS) \
|
||||
-L../libcompiler_rt \
|
||||
-L../libbase \
|
||||
-L../liblitedram \
|
||||
-L../libliteeth \
|
||||
-L../liblitespi \
|
||||
-L../libfatfs \
|
||||
-L../liblitesdcard \
|
||||
-L../liblitesata \
|
||||
-llitedram -lliteeth -llitespi -lfatfs -llitesdcard -llitesata -lbase-nofloat -lcompiler_rt
|
||||
$(PACKAGES:%=-L../%) \
|
||||
-Wl,--whole-archive \
|
||||
-Wl,--gc-sections \
|
||||
$(LIBS:lib%=-l%) \
|
||||
|
||||
|
||||
ifneq ($(OS),Windows_NT)
|
||||
chmod -x $@
|
||||
|
|
Loading…
Reference in New Issue