| OLD | NEW |
| 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Implementation of the 'build' chromite command.""" | 5 """Implementation of the 'build' chromite command.""" |
| 6 | 6 |
| 7 # Python imports | 7 # Python imports |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 clean_first: Delete any old board config first. | 57 clean_first: Delete any old board config first. |
| 58 """ | 58 """ |
| 59 # Skip this whole command if things already exist. | 59 # Skip this whole command if things already exist. |
| 60 board_dir = utils.GetBoardDir(build_config) | 60 board_dir = utils.GetBoardDir(build_config) |
| 61 if (not clean_first) and os.path.isdir(board_dir): | 61 if (not clean_first) and os.path.isdir(board_dir): |
| 62 cros_env.GetOperation().Info('%s already exists, skipping setup_board.' % | 62 cros_env.GetOperation().Info('%s already exists, skipping setup_board.' % |
| 63 board_dir) | 63 board_dir) |
| 64 return | 64 return |
| 65 | 65 |
| 66 # Put together command. | 66 # Put together command. |
| 67 cmd_list = [ | 67 arg_list = [ |
| 68 '--board="%s"' % build_config.get('DEFAULT', 'target'), | 68 '--board="%s"' % build_config.get('DEFAULT', 'target'), |
| 69 build_config.get('BUILD', 'setup_board_flags'), | 69 build_config.get('BUILD', 'setup_board_flags'), |
| 70 ] | 70 ] |
| 71 if clean_first: | 71 if clean_first: |
| 72 arg_list.insert(0, '--force') | 72 arg_list.insert(0, '--force') |
| 73 | 73 |
| 74 cros_env.RunScript('SETTING UP THE BOARD', './setup_board', arg_list) | 74 cros_env.RunScript('SETTING UP THE BOARD', './setup_board', arg_list) |
| 75 | 75 |
| 76 | 76 |
| 77 def _DoBuildPackages(cros_env, build_config): | 77 def _DoBuildPackages(cros_env, build_config): |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 loaded_config: If True, we've already loaded the config. | 149 loaded_config: If True, we've already loaded the config. |
| 150 build_config: None when called normally, but contains the SafeConfigParser | 150 build_config: None when called normally, but contains the SafeConfigParser |
| 151 for the build config if we call ourselves with _DoEnterChroot(). Note | 151 for the build config if we call ourselves with _DoEnterChroot(). Note |
| 152 that even when called through _DoEnterChroot(), could still be None | 152 that even when called through _DoEnterChroot(), could still be None |
| 153 if user chose 'HOST' as the target. | 153 if user chose 'HOST' as the target. |
| 154 """ | 154 """ |
| 155 # Parse options for command... | 155 # Parse options for command... |
| 156 usage_str = ('usage: %%prog [chromite_options] %s [options] [target]' % | 156 usage_str = ('usage: %%prog [chromite_options] %s [options] [target]' % |
| 157 raw_argv[0]) | 157 raw_argv[0]) |
| 158 parser = optparse.OptionParser(usage=usage_str) | 158 parser = optparse.OptionParser(usage=usage_str) |
| 159 # This option won't work until a later CL plumbs in optparse | 159 parser.add_option('--clean', default=False, action='store_true', |
| 160 #parser.add_option('--clean', default=False, action='store_true', | 160 help='Clean before building.') |
| 161 #help='Clean before building.') | |
| 162 (options, argv) = parser.parse_args(raw_argv[1:]) | 161 (options, argv) = parser.parse_args(raw_argv[1:]) |
| 163 options.clean = False | |
| 164 | 162 |
| 165 # Load the build config if needed... | 163 # Load the build config if needed... |
| 166 if not loaded_config: | 164 if not loaded_config: |
| 167 argv, build_config = utils.GetBuildConfigFromArgs(argv) | 165 argv, build_config = utils.GetBuildConfigFromArgs(argv) |
| 168 if argv: | 166 if argv: |
| 169 cros_lib.Die('Unknown arguments: %s' % ' '.join(argv)) | 167 cros_lib.Die('Unknown arguments: %s' % ' '.join(argv)) |
| 170 | 168 |
| 171 if not cros_lib.IsInsideChroot(): | 169 if not cros_lib.IsInsideChroot(): |
| 172 # Note: we only want to clean the chroot if they do --clean and have the | 170 # Note: we only want to clean the chroot if they do --clean and have the |
| 173 # host target. If they do --clean and have a board target, it means | 171 # host target. If they do --clean and have a board target, it means |
| 174 # that they just want to clean the board... | 172 # that they just want to clean the board... |
| 175 want_clean_chroot = options.clean and build_config is None | 173 want_clean_chroot = options.clean and build_config is None |
| 176 | 174 |
| 177 _DoMakeChroot(self.cros_env, chroot_config, want_clean_chroot) | 175 _DoMakeChroot(self.cros_env, chroot_config, want_clean_chroot) |
| 178 | 176 |
| 179 if build_config is not None: | 177 if build_config is not None: |
| 180 self._oper.Info('ENTERING THE CHROOT') | 178 self._oper.Info('ENTERING THE CHROOT') |
| 181 utils.EnterChroot(chroot_config, (self, 'Run'), raw_argv, | 179 utils.EnterChroot(chroot_config, (self, 'Run'), raw_argv, |
| 182 build_config=build_config, loaded_config=True) | 180 build_config=build_config, loaded_config=True) |
| 183 | 181 |
| 184 self._oper.Info('Done building.') | 182 self._oper.Info('Done building.') |
| 185 else: | 183 else: |
| 186 if build_config is None: | 184 if build_config is None: |
| 187 cros_lib.Die("You can't build the host chroot from within the chroot.") | 185 cros_lib.Die("You can't build the host chroot from within the chroot.") |
| 188 | 186 |
| 189 _DoSetupBoard(self.cros_env, build_config, options.clean) | 187 _DoSetupBoard(self.cros_env, build_config, options.clean) |
| 190 _DoBuildPackages(self.cros_env, build_config) | 188 _DoBuildPackages(self.cros_env, build_config) |
| 191 _DoBuildImage(self.cros_env, build_config) | 189 _DoBuildImage(self.cros_env, build_config) |
| 192 _DoImagePostProcessing(self.cros_env, build_config) | 190 _DoImagePostProcessing(self.cros_env, build_config) |
| OLD | NEW |