def create_build_system(working_dir, buildsys_type=None, package=None, opts=None, write_build_scripts=False, verbose=False, build_args=[], child_build_args=[]): """Return a new build system that can build the source in working_dir.""" from rez.plugin_managers import plugin_manager if buildsys_type: cls = plugin_manager.get_plugin_class('build_system', buildsys_type) clss = [cls] else: clss = get_valid_build_systems(working_dir) if clss: # deal with leftover tempfiles from child buildsys in working dir child_clss = set(x.child_build_system() for x in clss) clss = set(clss) - child_clss if len(clss) > 1: s = ', '.join(x.name() for x in clss) raise BuildSystemError(("Source could be built with one of: %s; " "Please specify a build system") % s) else: cls = iter(clss).next() return cls(working_dir, opts=opts, package=package, write_build_scripts=write_build_scripts, verbose=verbose, build_args=build_args, child_build_args=child_build_args) else: raise BuildSystemError("No build system is associated with the path %s" % working_dir)
def create_build_system(working_dir, buildsys_type=None, package=None, opts=None, write_build_scripts=False, verbose=False, build_args=[], child_build_args=[]): """Return a new build system that can build the source in working_dir.""" from rez.plugin_managers import plugin_manager # detect build system if necessary if not buildsys_type: clss = get_valid_build_systems(working_dir, package=package) if not clss: raise BuildSystemError( "No build system is associated with the path %s" % working_dir) if len(clss) != 1: s = ', '.join(x.name() for x in clss) raise BuildSystemError(("Source could be built with one of: %s; " "Please specify a build system") % s) buildsys_type = next(iter(clss)).name() # create instance of build system cls_ = plugin_manager.get_plugin_class('build_system', buildsys_type) return cls_(working_dir, opts=opts, package=package, write_build_scripts=write_build_scripts, verbose=verbose, build_args=build_args, child_build_args=child_build_args)
def __init__(self, working_dir, opts=None, write_build_scripts=False, verbose=False, build_args=[], child_build_args=[]): """Create a build system instance. Args: working_dir: Directory to build source from. opts: argparse.Namespace object which may contain constructor params, as set by our bind_cli() classmethod. write_build_scripts: If True, create build scripts rather than perform the full build. The user can then run these scripts to place themselves into a build environment and invoke the build system directly. build_args: Extra cli build arguments. child_build_args: Extra cli args for child build system, ignored if there is no child build system. """ self.working_dir = working_dir if not self.is_valid_root(working_dir): raise BuildSystemError("Not a valid %s working directory: %s" % (self.name(), working_dir)) self.package = get_developer_package(working_dir) self.write_build_scripts = write_build_scripts self.build_args = build_args self.child_build_args = child_build_args self.verbose = verbose
def create_build_system(working_dir, buildsys_type=None, package=None, opts=None, write_build_scripts=False, verbose=False, build_args=[], child_build_args=[]): """Return a new build system that can build the source in working_dir.""" from rez.plugin_managers import plugin_manager # detect build system if necessary if not buildsys_type: clss = get_valid_build_systems(working_dir, package=package) if not clss: # Special case - bez. This is an old deprecated build system, # which expects a rezbuild.py file. Include info in error showing # how to port to a custom build command. # if os.path.exists(os.path.join(working_dir, "rezbuild.py")): msg = ( "No build system is associated with the path %s.\n" "\n" "There is a rezbuild.py file present, suggesting you were " "using the deprecated bez build system. You need to use a " "custom build command instead. You can port your existing " "rezbuild.py like so:\n" "\n" "Add this line to package.py:\n" "\n" " build_command = 'python {root}/rezbuild.py {install}'\n" "\n" "Add these lines to rezbuild.py:\n" "\n" " if __name__ == '__main__':\n" " import os, sys\n" " build(\n" " source_path=os.environ['REZ_BUILD_SOURCE_PATH'],\n" " build_path=os.environ['REZ_BUILD_PATH'],\n" " install_path=os.environ['REZ_BUILD_INSTALL_PATH'],\n" " targets=sys.argv[1:]\n" " )") raise BuildSystemError(msg % working_dir) raise BuildSystemError( "No build system is associated with the path %s" % working_dir) if len(clss) != 1: s = ', '.join(x.name() for x in clss) raise BuildSystemError(("Source could be built with one of: %s; " "Please specify a build system") % s) buildsys_type = next(iter(clss)).name() # create instance of build system cls_ = plugin_manager.get_plugin_class('build_system', buildsys_type) return cls_(working_dir, opts=opts, package=package, write_build_scripts=write_build_scripts, verbose=verbose, build_args=build_args, child_build_args=child_build_args)