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
|
#!/usr/bin/python
import sys
sys.path.append('/usr/share/oe')
from oe import *
import oe
import os
def usage(errorlevel=0, txt=''):
global tasks
if txt:
print
print txt
print "Usage: oebuild [options]... [task] [oefile]"
# print "Run TASK on OEFILE or standard input if OEFILE is -."
print "Run task on oefile. Default task is 'build'."
print "Default .oe file is the first .oe file found in the"
print "current directory, if one exists."
print "Example: oebuild build content/glibc-2.3.1.oe"
print ""
print " %s\t\t%s" % ("-v, --version", "output version information and exit")
sys.exit(0)
__version__ = 1.0
def version():
print "OpenEmbedded Build Infrastructure Core version %s" % oe.__version__
print "OEBuild version %s" % __version__
import getopt
try:
(opts, args) = getopt.getopt(sys.argv[1:], 'vh', [ 'version', 'help' ])
except getopt.GetoptError:
usage(1)
def get_oefiles():
"""Get default oefiles"""
dirs = os.listdir(os.getcwd())
oefiles = []
for f in dirs:
(root, ext) = os.path.splitext(f)
if ext == ".oe":
oefiles.append(os.path.abspath(os.path.join(os.getcwd(),f)))
return oefiles
def get_oefile():
"""Get default oefile"""
oefiles = get_oefiles()
if len(oefiles):
return oefiles[0]
else:
return None
def get_cmd():
"""Get default command"""
return "build"
def load_oefile(oefile, cfgdata):
oepath = data.getVar('OEPATH', cfg)
topdir = data.getVar('TOPDIR', cfg)
if not topdir:
topdir = os.path.abspath(os.getcwd())
# set topdir to here
data.setVar('TOPDIR', topdir, cfg)
oefile = os.path.abspath(oefile)
oefile_loc = os.path.abspath(os.path.dirname(oefile))
# expand tmpdir to include this topdir
data.setVar('TMPDIR', data.getVar('TMPDIR', cfg, 1) or "", cfg)
# add topdir to oepath
oepath += ":%s" % topdir
# set topdir to location of .oe file
topdir = oefile_loc
#data.setVar('TOPDIR', topdir, cfg)
# add that topdir to oepath
oepath += ":%s" % topdir
# go there
os.chdir(topdir)
data.setVar('OEPATH', oepath, cfg)
from copy import copy
oe = copy(cfgdata)
try:
oe = parse.handle(oefile, oe) # read .oe data
return oe
except IOError, OSError:
return None
# handle opts
optsonly = [ opt for (opt,val) in opts]
if '--version' in optsonly or '-v' in optsonly:
version()
sys.exit(0)
if '--help' in optsonly or '-h' in optsonly:
usage(1)
# variable initialization
oefile = None
cmd = None
oedata = None
cfg = data.init()
graph = digraph()
try:
cfg = parse.handle("conf/oe.conf", cfg) # Read configuration
except IOError:
(type, value, traceback) = sys.exc_info()
fatal("Unable to open oe.conf: %s" % value)
if len(args) == 0:
# user didnt specify command or .oe
# see if we can find a .oe file in the current dir
oefile = get_oefile()
cmd = get_cmd()
elif len(args) == 1:
# one of two cases:
# 1) oebuild COMMAND
# 2) oebuild OEFILE
# First, see if this is a valid task.
oedata = load_oefile(args[0], cfg)
if not oedata:
# If so, assume its a command.
# If its a command, but we cant get a .oe file
# in the current dir, usage()
cmd = args[0]
else:
# If not, assume a .oe file.
oefile = args[0]
if not cmd:
cmd = get_cmd()
if not oefile:
oefile = get_oefile()
elif len(args) == 2:
# user specified both
cmd = args[0]
oefile = args[1]
else:
# invalid
usage(1)
if not cmd:
usage(1)
if not oefile:
usage(1)
if not oedata:
oedata = load_oefile(oefile, cfg)
if not oedata:
fatal("Unable to open %s" % oefile)
for var in oedata.keys():
if data.getVarFlag(var, 'handler', oedata):
event.register(data.getVar(var, oedata))
continue
if not data.getVarFlag(var, 'task', oedata):
continue
deps = data.getVarFlag(var, 'deps', oedata) or []
postdeps = data.getVarFlag(var, 'postdeps', oedata) or []
build.add_task(var, var, deps)
for p in postdeps:
d = build.get_task_data()
pcontent = data.getVar(p, d) or p
pdeps = data.getVarFlag(pcontent, 'deps', oedata) or []
pdeps.append(var)
data.setVarFlag(pcontent, 'deps', pdeps, oedata)
build.add_task(p, pcontent, pdeps)
try:
build.exec_task('do_%s' % cmd, oedata)
except build.FuncFailed:
fatal("task stack execution failed")
except build.EventException:
(type, value, traceback) = sys.exc_info()
e = value.event
fatal("%s event exception, aborting" % event.getName(e))
|