-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSConstruct
More file actions
182 lines (161 loc) · 5.84 KB
/
SConstruct
File metadata and controls
182 lines (161 loc) · 5.84 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import sys
import os
import fnmatch
# No point in runnnig multiple jobs in SCons, lets pass this on to make
NUM_JOBS = GetOption('num_jobs')
# TODO: For some reason this does not work. For now this file has a
# strictly linear dependency chain so it is not a big deal?
SetOption('num_jobs', 1)
bw_scons_path = os.environ.get('BWSCONSTOOLS_PATH')
if bw_scons_path:
env = Environment(
ENV=os.environ,
tools=['birdwing_install'],
toolpath=[bw_scons_path]
)
else:
env = Environment(ENV=os.environ)
#TODO: Use mw_scons_tools rather than copy/pasting this
# This is a special glob made by NicholasBishop
def mb_recursive_file_glob(env, root, pattern, exclude = None):
"""Recursively search in 'root' for files matching 'pattern'
Returns a list of matches of type SCons.Node.FS.File.
If exclude is not None, it should be a glob pattern or list of
glob patterns. Any results matching a glob in exclude will be
excluded from the returned list."""
def excluded(filename, exclude):
if exclude:
if isinstance(exclude, str):
exclude = [exclude]
for pattern in exclude:
if fnmatch.fnmatch(filename, pattern):
return True
return False
matches = []
if root.startswith('#'):
raise Exception('Directories starting with "#" not supported yet')
project_root = env.Dir('#').abspath
for parent, dirnames, filenames in os.walk(os.path.join(
project_root, root)):
for filename in fnmatch.filter(filenames, pattern):
if not excluded(filename, exclude):
p = os.path.join(parent, filename)
rp = os.path.relpath(p, project_root)
matches.append(env.File(rp))
return matches
env.AddMethod(mb_recursive_file_glob, 'MBRecursiveFileGlob')
linuxDir = os.path.abspath(str(Dir('#')))
baseDir = os.path.abspath(os.path.join(linuxDir, os.pardir))
subenv = os.environ.copy()
# U-boot uses the angstrom toolchain
if bw_scons_path:
toolchain_repo_path = os.path.join(baseDir, os.pardir, 'toolchain')
else:
toolchain_repo_path = os.path.join(baseDir, 'Birdwing-Cross-Compile-Tools')
angstrom = os.path.join(toolchain_repo_path, 'angstrom', 'arm')
tool_prefix = 'arm-angstrom-linux-gnueabi'
env.PrependENVPath('PATH', os.path.join(angstrom, 'bin'))
# I hope we don't actually need this, since it breaks builds on most systems
#env.PrependENVPath('CPATH', os.path.join(angstrom, tool_prefix, 'usr', 'include'))
env['ENV']['LIBTOOL_SYSROOT_PATH'] = os.path.join(angstrom, tool_prefix)
env['ENV']['PKG_CONFIG_SYSROOT_DIR'] = os.path.join(angstrom, tool_prefix)
env['ENV']['PKG_CONFIG_PATH'] = os.path.join(angstrom, tool_prefix, 'usr', 'lib', 'pkgconfig')
env['ENV']['CONFIG_SITE'] = os.path.join(angstrom, 'site-config')
# Yes, this is a scons script to call make
def make_cmd(*args):
makebaseCmd = ['make',
'ARCH=arm',
'CROSS_COMPILE=%s-' % (tool_prefix),
]
makeCmd = makebaseCmd + list(args)
return ' '.join(makeCmd)
config_sources = [
'arch/arm/configs/mb_manhattan_defconfig'
]
config_targets = [
'.config',
'scripts/basic/.fixdep.cmd',
'scripts/basic/fixdep',
'scripts/kconfig/.conf.cmd',
'scripts/kconfig/.conf.o.cmd',
'scripts/kconfig/.zconf.tab.o.cmd',
'scripts/kconfig/conf',
'scripts/kconfig/conf.o',
'scripts/kconfig/zconf.hash.c',
'scripts/kconfig/zconf.lex.c',
'scripts/kconfig/zconf.tab.c',
'scripts/kconfig/zconf.tab.o',
]
config = env.Command(config_targets, config_sources, make_cmd('mb_manhattan_defconfig'))
gen_sources = [
'arch/arm/boot/compressed/ashldi3.S',
'arch/arm/boot/compressed/lib1funcs.S',
'arch/arm/kernel/asm-offsets.s',
'drivers/tty/vt/consolemap_deftbl.c',
'drivers/tty/vt/defkeymap.c',
'kernel/bounds.s',
'kernel/config_data.h',
'kernel/timeconst.h',
'lib/crc32table.h',
'scripts/dtc/dtc-lexer.lex.c',
'scripts/dtc/dtc-parser.tab.c',
'scripts/dtc/dtc-parser.tab.h',
'scripts/genksyms/keywords.hash.c',
'scripts/genksyms/lex.lex.c',
'scripts/genksyms/parse.tab.c',
'scripts/genksyms/parse.tab.h',
'scripts/mod/elfconfig.h',
]
gen_sources.extend(env.MBRecursiveFileGlob('drivers/video/logo', '*.c', 'logo.c'))
build_sources = [
config,
]
build_targets = [
'arch/arm/boot/uImage',
]
main_args = ['uImage', 'modules', 'DO_STARTUP_BLINK=true']
if NUM_JOBS > 1: main_args.append('-j%s' % NUM_JOBS)
build = env.Command(build_targets, build_sources, make_cmd(*main_args))
AlwaysBuild(build) # Let make determine what needs to be built
clean_targets = [
'.missing-syscalls.d',
'.version',
'Module.symvers',
'System.map',
'arch/arm/boot/Image',
'arch/arm/boot/compressed/piggy.gzip',
'arch/arm/boot/compressed/vmlinux',
'arch/arm/boot/compressed/vmlinux.lds',
'arch/arm/boot/zImage',
'arch/arm/kernel/vmlinux.lds',
'arch/arm/lib/lib.a',
'include/config/',
'include/generated/',
'kernel/config_data.gz',
'lib/gen_crc32table',
'lib/lib.a',
'scripts/bin2c',
'scripts/conmakehash',
'scripts/dtc/dtc',
'scripts/genksyms/genksyms',
'scripts/kallsyms',
'scripts/mod/mk_elfconfig',
'scripts/mod/modpost',
'scripts/pnmtologo',
'scripts/sortextable',
'usr/.initramfs_data.cpio.d',
'usr/gen_init_cpio',
'usr/initramfs_data.cpio',
'vmlinux',
]
clean_targets.extend(gen_sources)
clean_targets.extend(env.Glob('.tmp_*'))
clean_targets.extend(env.MBRecursiveFileGlob('.', '*.o'))
clean_targets.extend(env.MBRecursiveFileGlob('.', '.*.cmd'))
env.Clean(build, clean_targets)
if bw_scons_path:
mod_target = env.BWPath('/lib/modules')
mod_args = ('INSTALL_MOD_PATH=' + env.BWPath('/'), 'modules_install')
mod_cmd = env.Command(mod_target, build, make_cmd(*mod_args))
env.AlwaysBuild(mod_cmd)
env.Alias('install', mod_cmd)