def preprocess_tasks(self): """ For apple targets, the xcode project is required to be generated before any of the packaging tasks can be executed """ # Generating the xcode project should only be done on macOS and if we actually have something to package (len(group) > 0) group = self.get_group(self.group_name) if len(group) > 0 and self.is_option_true( 'run_xcode_for_packaging') and self.is_apple_platform( self.platform): Logs.debug('package: checking for xcode project... ') platform = self.platform if 'darwin' in platform: platform = 'mac' # Check if the Xcode solution exists. We need it to perform bundle # stuff (processing Info.plist and icon assets...) project_name_and_location = '/{}/{}.xcodeproj'.format( getattr(self.options, platform + '_project_folder', None), getattr(self.options, platform + '_project_name', None)) if not os.path.exists(self.path.abspath() + project_name_and_location): Logs.debug( 'package: running xcode_{} command to generate the project {}' .format(platform, self.path.abspath() + project_name_and_location)) run_command('xcode_' + platform)
def gdist(ctx): # Make sure the build has already been run. run_command('build') # First, run the dist command to create the initial zip archive. dist = run_command('dist') # Add web files to the ZIP file. This was copied and modified from # waflib.Scripting.Dist.archive. with zipfile.ZipFile(dist.get_arch_name(), 'a', compression=zipfile.ZIP_DEFLATED) as zip: # Get a list of the web files. base_path = dist.base_path.find_node(os.path.join('_build', 'html')) generated_files = base_path.ant_glob('**') # Add them to the archive. for x in generated_files: archive_name = dist.get_base_name() + '/' + x.path_from(base_path) zip.write(x.abspath(), archive_name, zipfile.ZIP_DEFLATED) # Copy the result to the web. shutil.copy(dist.get_arch_name(), 'E:\\Dropbox\\Public\\Microprocessors_book')
def execute(self): """ Wraps :py:func:`waflib.Context.Context.execute` on the context class """ if not Configure.autoconfig: return execute_method(self) # Disable autoconfig so waf's version doesn't run (and don't end up on loop of bad configure) Configure.autoconfig = False if self.variant == '': raise Errors.WafError('The project is badly configured: run "waf configure" again!') env = ConfigSet.ConfigSet() do_config = False try: p = os.path.join(Context.out_dir, Build.CACHE_DIR, self.variant + Build.CACHE_SUFFIX) env.load(p) except EnvironmentError: raise Errors.WafError('The project is not configured for board {0}: run "waf configure --board {0} [...]" first!'.format(self.variant)) lock_env = ConfigSet.ConfigSet() try: lock_env.load(os.path.join(Context.top_dir, Options.lockfile)) except EnvironmentError: Logs.warn('Configuring the project') do_config = True else: if lock_env.run_dir != Context.run_dir: do_config = True else: h = 0 for f in env.CONFIGURE_FILES: try: h = Utils.h_list((h, Utils.readf(f, 'rb'))) except EnvironmentError: do_config = True break else: do_config = h != env.CONFIGURE_HASH if do_config: cmd = lock_env.config_cmd or 'configure' tmp = Options.options.__dict__ if env.OPTIONS and sorted(env.OPTIONS.keys()) == sorted(tmp.keys()): Options.options.__dict__ = env.OPTIONS else: raise Errors.WafError('The project configure options have changed: run "waf configure" again!') try: run_command(cmd) finally: Options.options.__dict__ = tmp run_command(self.cmd) else: return execute_method(self)
def run_all(kind): from waflib.Scripting import run_command for cmd in cmds[kind]: run_command(cmd)
def execute(self): """ Extended Context.execute to perform packaging on games and tools. For an executable package to be processed by this context the wscript file must implement the package_[platform] function (i.e. package_darwin_x64), which can call the package_game or package_tool methods on this context. Those functions will create the necessary package_task objects that will be executed after all directories have been recursed through. The package_game/tool functions accept keyword arguments that define how the package_task should packge executable, resources, and assets that are needed. For more information about valid keyword arguments look at the package_task.__init__ method. """ # On windows when waf is run with incredibuild we get called multiple times # but only need to be executed once. The check for the class variable is # here to make sure we run once per package command (either specified on # the command line or when it is auto added). If multiple package commands # are executed on the command line they will get run and this check does # not interfere with that. if getattr(self.__class__, 'is_running', False): return else: self.__class__.is_running = True # When the package_* functions are called they will set the group to # packaging then back to build. This way we can filter out the package # tasks and only execute them and not the build task_generators that will # be added as we recurse through the directories self.add_group('build') self.add_group('packaging') self.set_group('build') self.project = self.get_bootstrap_game() self.restore() if not self.all_envs: self.load_envs() # The package command may be executed before SetupAssistant is executed to # configure the project, which is valid. If that is the case an exception # will be thrown by lumberyard.py to indicate this. Catch the exception and # return so that builds can complete correctly. try: self.recurse([self.run_dir]) except: Logs.info( "Could not run the package command as the build has not been run yet." ) return # display the time elapsed in the progress bar self.timer = Utils.Timer() group = self.get_group('packaging') # Generating the xcode project should only be done on macOS and if we actually have something to package (len(group) > 0) if len(group) > 0 and self.is_option_true( 'run_xcode_for_packaging') and self.platform in [ 'darwin_x64', 'ios', 'appletv' ]: Logs.debug("package: checking for xcode project... ") platform = self.platform if 'darwin' in platform: platform = "mac" # Check if the Xcode solution exists. We need it to perform bundle # stuff (processing Info.plist and icon assets...) project_name_and_location = "/{}/{}.xcodeproj".format( getattr(self.options, platform + "_project_folder", None), getattr(self.options, platform + "_project_name", None)) if not os.path.exists(self.path.abspath() + project_name_and_location): Logs.debug( "package: running xcode_{} command to generate the project {}". format(platform, self.path.abspath() + project_name_and_location)) run_command('xcode_' + platform) for task_generator in group: try: rs = task_generator.runnable_status scan = task_generator.scan run = task_generator.run except AttributeError: pass else: scan() run()
def run_all(kind, key_func=lambda v: 0): from waflib.Scripting import run_command for cmd in sorted(cmds[kind], key=key_func, reverse=True): run_command(cmd)