mirror of
https://github.com/drasko/codezero.git
synced 2026-04-06 12:09:05 +02:00
Got the buildsystem to build multiple linux instances.
modified: config/configuration.py modified: config/projpaths.py modified: configure.py modified: scripts/linux/build_linux.py modified: scripts/linux/build_rootfs.py
This commit is contained in:
@@ -104,8 +104,33 @@ class configuration:
|
|||||||
# Make sure elements in order for indexed accessing
|
# Make sure elements in order for indexed accessing
|
||||||
self.containers.sort()
|
self.containers.sort()
|
||||||
|
|
||||||
|
def configuration_save(config):
|
||||||
|
if not os.path.exists(CONFIG_SHELVE_DIR):
|
||||||
|
os.mkdir(CONFIG_SHELVE_DIR)
|
||||||
|
|
||||||
|
config_shelve = shelve.open(CONFIG_SHELVE)
|
||||||
|
config_shelve["configuration"] = config
|
||||||
|
|
||||||
|
# Save containers explicitly
|
||||||
|
for i, c in zip(range(len(config.containers)), config.containers):
|
||||||
|
config_shelve["container" + str(i)] = c
|
||||||
|
|
||||||
|
# config_shelve["arch"] = configuration.arch
|
||||||
|
# config_shelve["subarch"] = configuration.subarch
|
||||||
|
# config_shelve["platform"] = configuration.platform
|
||||||
|
# config_shelve["all_symbols"] = configuration.all
|
||||||
|
config_shelve.close()
|
||||||
|
|
||||||
|
|
||||||
def configuration_retrieve():
|
def configuration_retrieve():
|
||||||
# Get configuration information
|
# Get configuration information
|
||||||
config_shelve = shelve.open(CONFIG_SHELVE)
|
config_shelve = shelve.open(CONFIG_SHELVE)
|
||||||
configuration = config_shelve["configuration"]
|
config = config_shelve["configuration"]
|
||||||
return configuration
|
|
||||||
|
# Retrieve and append containers explicitly
|
||||||
|
for i in range(int(config.ncontainers)):
|
||||||
|
config.containers.append(config_shelve["container" + str(i)])
|
||||||
|
|
||||||
|
config.containers.sort()
|
||||||
|
|
||||||
|
return config
|
||||||
|
|||||||
@@ -23,3 +23,9 @@ LINUXDIR = join(PROJROOT, 'conts/linux')
|
|||||||
LINUX_KERNELDIR = join(LINUXDIR, 'linux-2.6.28.10')
|
LINUX_KERNELDIR = join(LINUXDIR, 'linux-2.6.28.10')
|
||||||
LINUX_ROOTFSDIR = join(LINUXDIR, 'rootfs')
|
LINUX_ROOTFSDIR = join(LINUXDIR, 'rootfs')
|
||||||
|
|
||||||
|
projpaths = { \
|
||||||
|
'LINUX_ROOTFSDIR' : LINUX_ROOTFSDIR, \
|
||||||
|
'LINUX_KERNELDIR' : LINUX_KERNELDIR, \
|
||||||
|
'LINUXDIR' : LINUXDIR, \
|
||||||
|
'BUILDDIR' : BUILDDIR, \
|
||||||
|
}
|
||||||
|
|||||||
19
configure.py
19
configure.py
@@ -34,18 +34,6 @@ def cml2_configure(cml2_config_file):
|
|||||||
os.mkdir("build/l4")
|
os.mkdir("build/l4")
|
||||||
shutil.copy(CML2_CONFIG_H, CONFIG_H)
|
shutil.copy(CML2_CONFIG_H, CONFIG_H)
|
||||||
|
|
||||||
def save_configuration(configuration):
|
|
||||||
if not os.path.exists(CONFIG_SHELVE_DIR):
|
|
||||||
os.mkdir(CONFIG_SHELVE_DIR)
|
|
||||||
|
|
||||||
config_shelve = shelve.open(CONFIG_SHELVE)
|
|
||||||
config_shelve["configuration"] = configuration
|
|
||||||
config_shelve["arch"] = configuration.arch
|
|
||||||
config_shelve["subarch"] = configuration.subarch
|
|
||||||
config_shelve["platform"] = configuration.platform
|
|
||||||
config_shelve["all_symbols"] = configuration.all
|
|
||||||
config_shelve.close()
|
|
||||||
|
|
||||||
def configure_kernel(cml_file):
|
def configure_kernel(cml_file):
|
||||||
config = configuration()
|
config = configuration()
|
||||||
|
|
||||||
@@ -55,7 +43,12 @@ def configure_kernel(cml_file):
|
|||||||
cml2_configure(cml_file)
|
cml2_configure(cml_file)
|
||||||
cml2_header_to_symbols(CML2_CONFIG_H, config)
|
cml2_header_to_symbols(CML2_CONFIG_H, config)
|
||||||
cml2_update_config_h(CONFIG_H, config)
|
cml2_update_config_h(CONFIG_H, config)
|
||||||
save_configuration(config)
|
configuration_save(config)
|
||||||
|
# config2 = configuration_retrieve()
|
||||||
|
# print "containers: " + config2.ncontainers
|
||||||
|
# for c in config2.containers:
|
||||||
|
# print c.type
|
||||||
|
# print c.id
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
configure_kernel(join(CML2_CONFIG_SRCDIR, "arm.cml"))
|
configure_kernel(join(CML2_CONFIG_SRCDIR, "arm.cml"))
|
||||||
|
|||||||
@@ -18,36 +18,52 @@ from config.configuration import *
|
|||||||
|
|
||||||
LINUX_KERNEL_BUILDDIR = join(BUILDDIR, os.path.relpath(LINUX_KERNELDIR, PROJROOT))
|
LINUX_KERNEL_BUILDDIR = join(BUILDDIR, os.path.relpath(LINUX_KERNELDIR, PROJROOT))
|
||||||
|
|
||||||
|
# Create linux kernel build directory path as:
|
||||||
|
# conts/linux -> build/cont[0-9]/linux
|
||||||
|
def source_to_builddir(srcdir, id):
|
||||||
|
cont_builddir = \
|
||||||
|
os.path.relpath(srcdir, \
|
||||||
|
PROJROOT).replace("conts", \
|
||||||
|
"cont" + str(id))
|
||||||
|
return join(BUILDDIR, cont_builddir)
|
||||||
|
|
||||||
class LinuxBuilder:
|
class LinuxBuilder:
|
||||||
@staticmethod
|
LINUX_KERNEL_BUILDDIR = None
|
||||||
def build_linux(container):
|
LINUX_KERNELDIR = None
|
||||||
|
|
||||||
|
def __init__(self, pathdict, container):
|
||||||
|
self.LINUX_KERNELDIR = pathdict["LINUX_KERNELDIR"]
|
||||||
|
|
||||||
|
# Calculate linux kernel build directory
|
||||||
|
self.LINUX_KERNEL_BUILDDIR = \
|
||||||
|
source_to_builddir(LINUX_KERNELDIR, container.id)
|
||||||
|
|
||||||
|
def build_linux(self):
|
||||||
print '\nBuilding the linux kernel...'
|
print '\nBuilding the linux kernel...'
|
||||||
|
os.chdir(self.LINUX_KERNELDIR)
|
||||||
# Create linux kernel build directory path
|
if not os.path.exists(self.LINUX_KERNEL_BUILDDIR):
|
||||||
cont_builddir = join(BUILDDIR, "cont" + str(container.id))
|
os.makedirs(self.LINUX_KERNEL_BUILDDIR)
|
||||||
LINUX_KERNEL_BUILDDIR = join(cont_builddir, \
|
os.system("make defconfig ARCH=arm O=" + self.LINUX_KERNEL_BUILDDIR)
|
||||||
os.path.relpath(LINUX_KERNELDIR, \
|
|
||||||
PROJROOT))
|
|
||||||
|
|
||||||
os.chdir(LINUX_KERNELDIR)
|
|
||||||
if not os.path.exists(LINUX_KERNEL_BUILDDIR):
|
|
||||||
os.makedirs(LINUX_KERNEL_BUILDDIR)
|
|
||||||
os.system("make defconfig ARCH=arm O=" + LINUX_KERNEL_BUILDDIR)
|
|
||||||
os.system("make ARCH=arm " + \
|
os.system("make ARCH=arm " + \
|
||||||
"CROSS_COMPILE=arm-none-linux-gnueabi- O=" + \
|
"CROSS_COMPILE=arm-none-linux-gnueabi- O=" + \
|
||||||
LINUX_KERNEL_BUILDDIR)
|
self.LINUX_KERNEL_BUILDDIR)
|
||||||
|
print 'Done...'
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
if os.path.exists(LINUX_KERNEL_BUILDDIR):
|
print 'Cleaning linux kernel build...'
|
||||||
shutil.rmtree(LINUX_KERNEL_BUILDDIR)
|
if os.path.exists(self.LINUX_KERNEL_BUILDDIR):
|
||||||
|
shutil.rmtree(self.LINUX_KERNEL_BUILDDIR)
|
||||||
|
print 'Done...'
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
# This is only a default test case
|
||||||
container = Container()
|
container = Container()
|
||||||
container.id = 0
|
container.id = 0
|
||||||
|
linux_builder = LinuxBuilder(projpaths, container)
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
LinuxBuilder.build_linux(container)
|
linux_builder.build_linux()
|
||||||
elif "clean" == sys.argv[1]:
|
elif "clean" == sys.argv[1]:
|
||||||
LinuxBuilder.clean()
|
linux_builder.clean()
|
||||||
else:
|
else:
|
||||||
print " Usage: %s [clean]" % (sys.argv[0])
|
print " Usage: %s [clean]" % (sys.argv[0])
|
||||||
|
|||||||
@@ -15,34 +15,62 @@ sys.path.append(os.path.abspath(PROJRELROOT))
|
|||||||
from config.projpaths import *
|
from config.projpaths import *
|
||||||
from config.configuration import *
|
from config.configuration import *
|
||||||
|
|
||||||
LINUX_ROOTFS_BUILDDIR = join(BUILDDIR, os.path.relpath(LINUX_ROOTFSDIR, PROJROOT))
|
|
||||||
|
|
||||||
rootfs_lds_in = join(LINUX_ROOTFSDIR, "rootfs.lds.in")
|
# Create linux kernel build directory path as:
|
||||||
rootfs_lds_out = join(LINUX_ROOTFS_BUILDDIR, "rootfs.lds")
|
# conts/linux -> build/cont[0-9]/linux
|
||||||
rootfs_elf_out = join(LINUX_ROOTFS_BUILDDIR, "rootfs.elf")
|
def source_to_builddir(srcdir, id):
|
||||||
|
cont_builddir = \
|
||||||
|
os.path.relpath(srcdir, \
|
||||||
|
PROJROOT).replace("conts", \
|
||||||
|
"cont" + str(id))
|
||||||
|
return join(BUILDDIR, cont_builddir)
|
||||||
|
|
||||||
class BuildRootfs:
|
class RootfsBuilder:
|
||||||
@staticmethod
|
LINUX_ROOTFS_BUILDDIR = None
|
||||||
def build_rootfs():
|
LINUX_ROOTFSDIR = None
|
||||||
|
rootfs_lds_in = None
|
||||||
|
rootfs_lds_out = None
|
||||||
|
rootfs_elf_out = None
|
||||||
|
|
||||||
|
def __init__(self, pathdict, container):
|
||||||
|
self.LINUX_ROOTFSDIR = pathdict["LINUX_ROOTFSDIR"]
|
||||||
|
|
||||||
|
# Determine build directory
|
||||||
|
self.LINUX_ROOTFS_BUILDDIR = \
|
||||||
|
source_to_builddir(self.LINUX_ROOTFSDIR, container.id)
|
||||||
|
|
||||||
|
def build_rootfs(self):
|
||||||
print 'Building the root filesystem...'
|
print 'Building the root filesystem...'
|
||||||
|
# IO files from this build
|
||||||
|
rootfs_lds_in = join(self.LINUX_ROOTFSDIR, "rootfs.lds.in")
|
||||||
|
rootfs_lds_out = join(self.LINUX_ROOTFS_BUILDDIR, "rootfs.lds")
|
||||||
|
rootfs_elf_out = join(self.LINUX_ROOTFS_BUILDDIR, "rootfs.elf")
|
||||||
|
|
||||||
os.chdir(LINUX_ROOTFSDIR)
|
os.chdir(LINUX_ROOTFSDIR)
|
||||||
config_symbols = configuration_retrieve()
|
if not os.path.exists(self.LINUX_ROOTFS_BUILDDIR):
|
||||||
if not os.path.exists(LINUX_ROOTFS_BUILDDIR):
|
os.makedirs(self.LINUX_ROOTFS_BUILDDIR)
|
||||||
os.makedirs(LINUX_ROOTFS_BUILDDIR)
|
|
||||||
os.system("arm-none-linux-gnueabi-cpp -P " + \
|
os.system("arm-none-linux-gnueabi-cpp -P " + \
|
||||||
"%s > %s" % (rootfs_lds_in, rootfs_lds_out))
|
"%s > %s" % (rootfs_lds_in, rootfs_lds_out))
|
||||||
os.system("arm-none-linux-gnueabi-gcc " + \
|
os.system("arm-none-linux-gnueabi-gcc " + \
|
||||||
"-nostdlib -o %s -T%s rootfs.S" % (rootfs_elf_out, rootfs_lds_out))
|
"-nostdlib -o %s -T%s rootfs.S" % (rootfs_elf_out, rootfs_lds_out))
|
||||||
|
print "Done..."
|
||||||
|
return rootfs_lds_out
|
||||||
|
|
||||||
@staticmethod
|
def clean(self):
|
||||||
def clean():
|
print 'Cleaning the built root filesystem...'
|
||||||
if os.path.exists(LINUX_ROOTFS_BUILDDIR):
|
if os.path.exists(self.LINUX_ROOTFS_BUILDDIR):
|
||||||
shutil.rmtree(LINUX_ROOTFS_BUILDDIR)
|
shutil.rmtree(self.LINUX_ROOTFS_BUILDDIR)
|
||||||
|
print 'Done...'
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
# This is only a default test case
|
||||||
|
container = Container()
|
||||||
|
container.id = 0
|
||||||
|
rootfs_builder = RootfsBuilder(projpaths, container)
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
BuildRootfs.build_rootfs()
|
rootfs_builder.build_rootfs()
|
||||||
elif "clean" == sys.argv[1]:
|
elif "clean" == sys.argv[1]:
|
||||||
BuildRootfs.clean()
|
rootfs_builder.clean()
|
||||||
else:
|
else:
|
||||||
print " Usage: %s [clean]" % (sys.argv[0])
|
print " Usage: %s [clean]" % (sys.argv[0])
|
||||||
|
|||||||
Reference in New Issue
Block a user