def gather_product_data( cmd_args, architectures, configurations, absolute_buildfile_path, selected_product_names, global_params, executor, context_list ): prepend_dependency_values = True operate_on_dependencies = True process_configs_enabled = True rootcd = None # load the buildfile buildfile = BuildFile.find_or_create( build_file_path=absolute_buildfile_path, architectures=architectures, configurations=configurations ) # fetch a list of potential products to operate on all_products = buildfile.get_products( args=cmd_args, host_platform=HostPlatform, target_platform=TargetPlatform.instance, global_params=global_params ) # need to filter products here products = buildfile.filter_products( selected_product_names, all_products ) for product in products: # ignore targets unsupported by this driver if not TargetPlatform.instance.product_supported( product, Driver.instance, Driver.name ): continue BuildCache.add_product(buildfile.abs_buildfile_path, product) # create the product context context = ProductContext.find_or_create(buildfile=buildfile, product=product) # determine if we need to process config files if process_configs_enabled: process_config_files(context) # whitelist the product root so we don't remove it. FileManager.instance.whitelist(context.abs_root) # fetch architectures and configurations for this product architectures, configurations = buildfile.get_layout_params(product) dependencies = [] prebuild_commands = {} postbuild_commands = [] dependency_contexts = [] if not Environment.get().use_cache: BuildCache.add_product( buildfile.abs_buildfile_path, product ) # fetch all direct dependencies for this product # these are returned as Dependency instances dependencies = product.get_dependencies( context, architectures, configurations ) if operate_on_dependencies and dependencies: for dependency in dependencies: # create a buildfile instance dep_buildfile = BuildFile.find_or_create( build_file_path=dependency.abs_file, parent=buildfile, architectures=architectures, configurations=configurations, ) # create a temp parser and parse the dependency's args # if any exist parser = argparse.ArgumentParser() dep_buildfile.load_arguments(parser=parser) dep_args = parser.parse_args(dependency.arguments) # fetch ALL products for this dependency all_products = dep_buildfile.get_products( args=dep_args, host_platform=HostPlatform, target_platform=TargetPlatform.instance, global_params=global_params ) # filter out only the ones we're interested in using the # dependency instance as a mask ("products") filtered_products = dep_buildfile.filter_products( dependency.products, all_products ) for p in filtered_products: BuildCache.add_product( dep_buildfile.abs_buildfile_path, p ) # NOTE: This is a temporary ProductContext # So it does NOT go through the normal find_or_create # mechanism. dep_context = ProductContext( buildfile=dep_buildfile, product=p, parent=context ) # # populate context with layout params for architecture in architectures: for configuration in configurations: layout_params = LayoutParams( TargetPlatform.instance, dep_context, architecture, configuration ) layout_params.populate() dep_context.add_layout(layout_params) dependency_contexts.append(dep_context) # for each context, add layout params for # arch/config permutations # run command on dependencies for dep_context in dependency_contexts: if not Environment.get().use_cache: BuildCache.add_dependency( buildfile.abs_buildfile_path, product.name, dep_context.buildfile.abs_buildfile_path, dep_context.product.name ) if dep_context.product.output == ProductType.None: continue # run this command on the dependency (recursively) if cmd_args.recurse_dependencies: # for dependencies within the same file, we need to # ensure correct build orders. # # Re-use the base level context_list if this dependency # is in the same buildfile as the current one. # # Due to the recursive nature, dependencies will be # prepended in the context list to their dependents. dep_context_list = [] if buildfile.abs_buildfile_path == dep_context.buildfile.abs_buildfile_path: dep_context_list = context_list # recursive call... gather_product_data( cmd_args, architectures, configurations, dep_context.buildfile.abs_buildfile_path, [dep_context.product.name], global_params, executor, dep_context_list ) for architecture in architectures: if architecture not in prebuild_commands: prebuild_commands[architecture] = {} for configuration in configurations: if configuration not in prebuild_commands[architecture]: prebuild_commands[architecture][configuration] = [] prebuild_commands[architecture][configuration] += \ Driver.instance.prebuild_commands_for_dependency( architecture, configuration, TargetPlatform.instance, context, dep_context ) # maintain a unique ordered set of ProductContexts. if context not in context_list: context_list.append(context) for architecture in architectures: for configuration in configurations: # fetch the layout from the product params = LayoutParams( TargetPlatform.instance, context, architecture, configuration ) # populate params params.populate( global_params=global_params, dependencies=dependency_contexts ) prebuild_command_list = [] if architecture in prebuild_commands and configuration in prebuild_commands[architecture]: prebuild_command_list = prebuild_commands[architecture][configuration] params.prebuild_commands = \ prebuild_command_list + params.prebuild_commands params.postbuild_commands = \ postbuild_commands + params.postbuild_commands # process these through the target platform output_params = \ TargetPlatform.instance.process_params_for_driver( params, Driver.instance, Driver.instance.__class__.__name__.lower() ) # create the abs_project_root FileManager.instance.makedirs(output_params.abs_project_root) # add these params to the context layout context.add_layout(output_params) product_data = BuildCache.get_product_data(buildfile.abs_buildfile_path, context.product.name) if (not product_data.touched) and product._requires_action: product_data.touched = True product_data.built = False BuildCache.queue_product(buildfile.abs_buildfile_path, product)
def handle_list(args): logging.info( "System info for %s, %s" % (pegasus.__name__, pegasus.__version__) ) logging.info("") logging.info("-- (%i) Architectures --" % (len(Architecture.enum_keys))) for key in Architecture.enum_keys: logging.info("\t%s" % key) logging.info("") logging.info("-- (%i) Languages --" % (len(Language.enum_keys))) for key in Language.enum_keys: logging.info("\t%s" % key) logging.info("") logging.info( "-- (%i) Host Platforms --" % (len(HostPlatform.__subclasses__())) ) for d in HostPlatform.__subclasses__(): logging.info("\t%s" % d.__name__) logging.info("") logging.info( "-- (%i) Target Platforms --" % (len(TargetPlatform.__subclasses__())) ) for d in TargetPlatform.__subclasses__(): logging.info("\t%s" % d.__name__) logging.info("") logging.info("-- (%i) Compilers --" % (len(Compiler.__subclasses__()))) for d in Compiler.__subclasses__(): logging.info("\t%s" % d.__name__) logging.info("") logging.info("-- (%i) Drivers --" % (len(Core.driver_classes))) for d in Core.driver_classes: logging.info("\t%s" % d.__name__) logging.info("") buildfile = BuildFile(args.build_file) # need to mockup a parser here: parser = argparse.ArgumentParser() buildfile.execute("arguments", parser) args = parser.parse_args("") global_params = Attributes() products = buildfile.get_products( args=args, host_platform=HostPlatform, target_platform=TargetPlatform.instance, global_params=global_params ) if not products or type(products[0]) is not Product: raise Exception( "BuildFile returned an invalid value for products()!" ) logging.info( "Listing products for build file '%s' and platform '%s'" % \ (buildfile.abs_buildfile_path, HostPlatform.get()) ) logging.info("") logging.info("-- (%i) Products --" % len(products)) for p in products: logging.info("\t\"%s\": %s" % (p.name, p.output))