-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathbuild.py
executable file
·135 lines (110 loc) · 3.61 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#! /usr/bin/env python2
# -*- mode: python; coding: utf-8; -*-
#
# Top-level build script for Codezero
#
# Configures the Codezero environment, builds the kernel and userspace
# libraries, builds and packs all containers and builds the final loader
# image that contains all images.
#
import os, sys, shelve, shutil
from os.path import join
from scripts.config.projpaths import *
from scripts.config.configuration import *
from scripts.config.config_check import *
from scripts.qemu.qemu_cmdline import *
from scripts.conts import containers
from scripts.config.config_invoke import *
from scripts.kernel.check_kernel_limit import *
def build_system(opts, args):
if opts.print_config:
config = configuration_retrieve()
if config:
config.config_print()
else:
print '\nNo configuration to print...\n'
return None
# Configure
configure_system(opts, args)
# Are we asked to configure only
if opts.config_only:
return None
# Check for sanity of containers
sanity_check_conts()
# Build userspace libraries
os.chdir(USERLIBS_DIR)
print "\nBuilding userspace libraries..."
ret = os.system("scons" + " -j " + opts.jobs)
if(ret):
print "Building userspace libraries failed...\n"
sys.exit(1)
# Build containers
os.chdir(PROJROOT)
print "\nBuilding containers..."
containers.build_all_containers(opts)
# Build the kernel
print "\nBuilding the kernel..."
os.chdir(PROJROOT)
ret = os.system("scons" + " -j " + opts.jobs)
if(ret):
print "Building kernel failed...\n"
sys.exit(1)
# Check if kernel overlap with first container
if(check_kernel_container_overlap()):
print "Kernel overlaps with first continer."
print "Please shift the first container to some higher " + \
"address after the kernel and build again...\n"
sys.exit(1)
# Build the loader
os.chdir(PROJROOT)
print "\nBuilding the loader and packing..."
ret = os.system("scons -f " + join(LOADERDIR, 'SConstruct') + " -j " + opts.jobs)
if(ret):
print "Building loader failed...\n"
sys.exit(1)
# Build qemu-gdb-script
print "\nBuilding qemu-gdb-script..."
build_qemu_cmdline_script()
print "\nBuild complete..."
print "\nRun qemu with following command: ./tools/run-qemu-gdb\n"
renamed_cml = rename_config_cml(opts)
if(renamed_cml):
print 'CML configuration file saved as ' + renamed_cml + '\n'
return None
def clean_system(opts):
# Clean only if some config exists.
if not configuration_retrieve():
print '\nNo configuration exists, nothing to clean..\n'
return None
# Clean userspace libraries
os.chdir(USERLIBS_DIR)
print "\nCleaning userspace libraries..."
ret = os.system("scons -c")
# Clean containers
os.chdir(PROJROOT)
print "\nCleaning containers..."
containers.clean_all_containers()
# Clean the kernel
print "\nCleaning the kernel..."
os.chdir(PROJROOT)
ret = os.system("scons -c")
# Clean the loader
os.chdir(PROJROOT)
print "\nCleaning the loader..."
ret = os.system("scons -c -f " + join(LOADERDIR, 'SConstruct'))
# Remove qemu-gdb-script
print "\nRemoving qemu-gdb-script..."
clean_qemu_cmdline_script()
if opts.clean_all:
cml_files_cleanup()
print '\nCleaning Done...\n'
return None
def main():
opts, args = build_parse_options()
if opts.clean or opts.clean_all:
clean_system(opts)
else:
build_system(opts, args)
return None
if __name__ == "__main__":
main()