Lines Matching full:self
58 def __call__(self, parser, namespace, values, option_string=None): argument
59 setattr(namespace, self.dest, values or 'always')
63 def __init__(self): argument
64 super(Build, self).__init__(
71 self.source_dir = None
74 self.build_dir = None
77 self.created_build_dir = False
80 self.run_cmake = False
87 self.cmake_cache = None
90 def do_add_parser(self, parser_adder): argument
92 self.name,
93 help=self.help,
95 description=self.description,
106 self.add_force_arg(parser)
134 def do_run(self, args, remainder): argument
135 self.args = args # Avoid having to pass them around
136 self.config_board = config_get('board', None)
140 source_dir = self.args.source_dir
141 self._parse_remainder(remainder)
143 if self.args.test_item:
144 self._parse_test_item()
146 if self.args.source_dir:
148 source_dir, self.args.source_dir))
149 self.args.source_dir = source_dir
150 log.dbg('source_dir: {} cmake_opts: {}'.format(self.args.source_dir,
151 self.args.cmake_opts),
153 self._sanity_precheck()
154 self._setup_build_dir()
166 self.auto_pristine = (pristine == 'auto')
169 self.auto_pristine),
171 if is_zephyr_build(self.build_dir):
173 self._run_pristine()
174 self.run_cmake = True
176 self._update_cache()
177 if (self.args.cmake or self.args.cmake_opts or
178 self.args.cmake_only):
179 self.run_cmake = True
181 self.run_cmake = True
182 self.source_dir = self._find_source_dir()
183 self._sanity_check()
185 board, origin = self._find_board()
186 self._run_cmake(board, origin, self.args.cmake_opts)
190 self._sanity_check()
191 self._update_cache()
193 self._run_build(args.target)
195 def _find_board(self): argument
197 if self.cmake_cache:
198 board, origin = (self.cmake_cache.get('CACHED_BOARD'),
206 if self.args.board:
207 board, origin = self.args.board, 'command line'
210 elif self.config_board is not None:
211 board, origin = self.config_board, 'configfile'
214 def _parse_remainder(self, remainder): argument
215 self.args.source_dir = None
216 self.args.cmake_opts = None
221 self.args.source_dir = remainder[0]
228 self.args.cmake_opts = remainder
232 def _parse_test_item(self): argument
234 yf = os.path.join(self.args.source_dir, yp)
245 item = tests.get(self.args.test_item)
258 if self.args.cmake_opts:
259 self.args.cmake_opts.extend(args)
261 self.args.cmake_opts = args
263 def _sanity_precheck(self): argument
264 app = self.args.source_dir
266 self.check_force(
269 self.check_force(
273 def _update_cache(self): argument
275 self.cmake_cache = CMakeCache.from_build_dir(self.build_dir)
279 def _setup_build_dir(self): argument
284 board, _ = self._find_board()
285 source_dir = self._find_source_dir()
287 build_dir = find_build_dir(self.args.build_dir, board=board,
299 self.created_build_dir = True
300 self.run_cmake = True
302 self.build_dir = build_dir
304 def _find_source_dir(self): argument
309 if self.args.source_dir:
310 source_dir = self.args.source_dir
311 elif self.cmake_cache:
312 source_dir = self.cmake_cache.get('CMAKE_HOME_DIRECTORY')
316 log.die('build directory', self.build_dir,
323 def _sanity_check_source_dir(self): argument
324 if self.source_dir == self.build_dir:
328 format(self.source_dir, self.build_dir))
330 srcrel = os.path.relpath(self.source_dir)
331 self.check_force(
332 not is_zephyr_build(self.source_dir),
336 self.check_force(
337 'CMakeLists.txt' in os.listdir(self.source_dir),
344 def _sanity_check(self): argument
348 self._sanity_check_source_dir()
350 if not self.cmake_cache:
353 if "CMAKE_PROJECT_NAME" not in self.cmake_cache:
357 self.run_cmake = True
359 cached_app = self.cmake_cache.get('APPLICATION_SOURCE_DIR')
362 source_abs = (os.path.abspath(self.args.source_dir)
363 if self.args.source_dir else None)
366 log.dbg('pristine:', self.auto_pristine, level=log.VERBOSE_EXTREME)
373 self.check_force(
374 not apps_mismatched or self.auto_pristine,
378 format(self.build_dir, cached_abs, source_abs))
381 self.run_cmake = True # If they insist, we need to re-run cmake.
385 cached_board = self.cmake_cache.get('CACHED_BOARD')
387 # If apps_mismatched and self.auto_pristine are true, we will
390 self.check_force((cached_board and
391 not (apps_mismatched and self.auto_pristine))
392 or self.args.board or self.config_board or
400 boards_mismatched = (self.args.board and cached_board and
401 self.args.board != cached_board)
402 self.check_force(
403 not boards_mismatched or self.auto_pristine,
407 format(self.build_dir, cached_board, self.args.board))
409 if self.auto_pristine and (apps_mismatched or boards_mismatched):
410 self._run_pristine()
411 self.cmake_cache = None
413 self.run_cmake = True
420 self.source_dir = self._find_source_dir()
421 self._sanity_check_source_dir()
423 def _run_cmake(self, board, origin, cmake_opts): argument
431 if not self.run_cmake:
440 if self.args.cmake_opts:
441 cmake_opts.extend(self.args.cmake_opts)
454 '-B{}'.format(self.build_dir),
455 '-S{}'.format(self.source_dir),
460 run_cmake(final_cmake_args, dry_run=self.args.dry_run)
462 def _run_pristine(self): argument
463 _banner('making build dir {} pristine'.format(self.build_dir))
464 if not is_zephyr_build(self.build_dir):
468 cache = CMakeCache.from_build_dir(self.build_dir)
476 run_cmake(cmake_args, cwd=self.build_dir, dry_run=self.args.dry_run)
478 def _run_build(self, target): argument
481 elif self.run_cmake:
484 if self.args.build_opt:
486 extra_args.extend(self.args.build_opt)
487 if self.args.verbose:
488 self._append_verbose_args(extra_args,
489 not bool(self.args.build_opt))
490 run_build(self.build_dir, extra_args=extra_args,
491 dry_run=self.args.dry_run)
493 def _append_verbose_args(self, extra_args, add_dashes): argument
497 self._update_cache()
498 if not self.cmake_cache:
500 generator = self.cmake_cache.get('CMAKE_GENERATOR')