@@ -38,23 +38,34 @@ def addOptions(parser, add_build_targets=True):
38
38
)
39
39
40
40
def execCommand (args , following_args ):
41
+ status = installAndBuild (args , following_args )
42
+ return status ['status' ]
43
+
44
+ def installAndBuild (args , following_args ):
45
+ ''' Perform the build command, but provide detailed error information.
46
+ Returns {status:0, build_status:0, generate_status:0, install_status:0} on success.
47
+ If status: is nonzero there was some sort of error. Other properties
48
+ are optional, and may not be set if that step was not attempted.
49
+ '''
50
+ build_status = generate_status = install_status = 0
51
+
41
52
if not hasattr (args , 'build_targets' ):
42
53
vars (args )['build_targets' ] = []
43
54
44
55
if 'test' in args .build_targets :
45
56
logging .error ('Cannot build "test". Use "yotta test" to run tests.' )
46
- return 1
57
+ return { 'status' : 1 }
47
58
48
59
cwd = os .getcwd ()
49
60
c = validate .currentDirectoryModule ()
50
61
if not c :
51
- return 1
62
+ return { 'status' : 1 }
52
63
53
64
target , errors = c .satisfyTarget (args .target )
54
65
if errors :
55
66
for error in errors :
56
67
logging .error (error )
57
- return 1
68
+ return { 'status' : 1 }
58
69
59
70
# run the install command before building, we need to add some options the
60
71
# install command expects to be present to do this:
@@ -77,7 +88,7 @@ def execCommand(args, following_args):
77
88
78
89
# install may exit non-zero for non-fatal errors (such as incompatible
79
90
# version specs), which it will display
80
- errcode = install .execCommand (args , [])
91
+ install_status = install .execCommand (args , [])
81
92
82
93
builddir = os .path .join (cwd , 'build' , target .getName ())
83
94
@@ -95,12 +106,12 @@ def execCommand(args, following_args):
95
106
missing += 1
96
107
if missing :
97
108
logging .error ('Missing dependencies prevent build. Use `yotta ls` to list them.' )
98
- return 1
109
+ return { 'status' : 1 , 'install_status' : install_status , 'missing_status' : missing }
99
110
100
111
generator = cmakegen .CMakeGen (builddir , target )
101
112
for error in generator .generateRecursive (c , all_components , builddir ):
102
113
logging .error (error )
103
- errcode = 1
114
+ generate_status = 1
104
115
105
116
if (not hasattr (args , 'generate_only' )) or (not args .generate_only ):
106
117
error = target .build (
@@ -109,7 +120,14 @@ def execCommand(args, following_args):
109
120
)
110
121
if error :
111
122
logging .error (error )
112
- errcode = 1
113
-
123
+ build_status = 1
124
+
125
+ return {
126
+ 'status' : build_status or generate_status or install_status ,
127
+ 'missing_status' : missing ,
128
+ 'build_status' : build_status ,
129
+ 'generate_status' : generate_status ,
130
+ 'install_status' : install_status
131
+ }
114
132
return errcode
115
133
0 commit comments