def prepare_env(self,env): if not env.PREFIX: if Options.options.prefix or Utils.is_win32: env.PREFIX=Utils.sane_path(Options.options.prefix) else: env.PREFIX='' if not env.BINDIR: if Options.options.bindir: env.BINDIR=Utils.sane_path(Options.options.bindir) else: env.BINDIR=Utils.subst_vars('${PREFIX}/bin',env) if not env.LIBDIR: if Options.options.libdir: env.LIBDIR=Utils.sane_path(Options.options.libdir) else: env.LIBDIR=Utils.subst_vars('${PREFIX}/lib%s'%Utils.lib64(),env)
def prepare_env(self,env): if not env.PREFIX: if Options.options.prefix or Utils.is_win32: env.PREFIX=Utils.sane_path(Options.options.prefix) else: env.PREFIX='' if not env.BINDIR: if Options.options.bindir: env.BINDIR=Utils.sane_path(Options.options.bindir) else: env.BINDIR=Utils.subst_vars('${PREFIX}/bin',env) if not env.LIBDIR: if Options.options.libdir: env.LIBDIR=Utils.sane_path(Options.options.libdir) else: env.LIBDIR=Utils.subst_vars('${PREFIX}/lib%s'%Utils.lib64(),env)
def prepare_env(self, env): """ Insert *PREFIX*, *BINDIR* and *LIBDIR* values into ``env`` :type env: :py:class:`waflib.ConfigSet.ConfigSet` :param env: a ConfigSet, usually ``conf.env`` """ if not env.PREFIX: if Options.options.prefix or Utils.is_win32: env.PREFIX = Utils.sane_path(Options.options.prefix) else: env.PREFIX = '' if not env.BINDIR: if Options.options.bindir: env.BINDIR = Utils.sane_path(Options.options.bindir) else: env.BINDIR = Utils.subst_vars('${PREFIX}/bin', env) if not env.LIBDIR: if Options.options.libdir: env.LIBDIR = Utils.sane_path(Options.options.libdir) else: env.LIBDIR = Utils.subst_vars('${PREFIX}/lib%s' % Utils.lib64(), env)
def prepare_env(self, env): """ Insert *PREFIX*, *BINDIR* and *LIBDIR* values into ``env`` :type env: :py:class:`waflib.ConfigSet.ConfigSet` :param env: a ConfigSet, usually ``conf.env`` """ if not env.PREFIX: if Options.options.prefix or Utils.is_win32: env.PREFIX = Utils.sane_path(Options.options.prefix) else: env.PREFIX = '' if not env.BINDIR: if Options.options.bindir: env.BINDIR = Utils.sane_path(Options.options.bindir) else: env.BINDIR = Utils.subst_vars('${PREFIX}/bin', env) if not env.LIBDIR: if Options.options.libdir: env.LIBDIR = Utils.sane_path(Options.options.libdir) else: env.LIBDIR = Utils.subst_vars('${PREFIX}/lib%s' % Utils.lib64(), env)
def parse_args(self,_args=None): global options,commands,envvars (options,leftover_args)=self.parser.parse_args(args=_args) for arg in leftover_args: if'='in arg: envvars.append(arg) else: commands.append(arg) if options.destdir: options.destdir=Utils.sane_path(options.destdir) if options.verbose>=1: self.load('errcheck') colors={'yes':2,'auto':1,'no':0}[options.colors] Logs.enable_colors(colors)
def parse_args(self,_args=None): global options,commands,envvars (options,leftover_args)=self.parser.parse_args(args=_args) for arg in leftover_args: if'='in arg: envvars.append(arg) else: commands.append(arg) if options.destdir: options.destdir=Utils.sane_path(options.destdir) if options.verbose>=1: self.load('errcheck') colors={'yes':2,'auto':1,'no':0}[options.colors] Logs.enable_colors(colors)
def parse_args(self, _args=None): global options, commands, envvars (options, leftover_args) = self.parser.parse_args(args=_args) for arg in leftover_args: if "=" in arg: envvars.append(arg) else: commands.append(arg) if options.destdir: options.destdir = Utils.sane_path(options.destdir) if options.verbose >= 1: self.load("errcheck") colors = {"yes": 2, "auto": 1, "no": 0}[options.colors] Logs.enable_colors(colors)
def parse_args(self, _args=None): """ Parse arguments from a list (not bound to the command-line). :param _args: arguments :type _args: list of strings """ global options, commands, envvars (options, leftover_args) = self.parser.parse_args(args=_args) for arg in leftover_args: if '=' in arg: envvars.append(arg) else: commands.append(arg) if options.destdir: options.destdir = Utils.sane_path(options.destdir) if options.verbose >= 1: self.load('errcheck') colors = {'yes' : 2, 'auto' : 1, 'no' : 0}[options.colors] Logs.enable_colors(colors)
def parse_args(self, _args=None): """ Parses arguments from a list which is not necessarily the command-line. :param _args: arguments :type _args: list of strings """ global options, commands, envvars (options, leftover_args) = self.parser.parse_args(args=_args) for arg in leftover_args: if '=' in arg: envvars.append(arg) else: commands.append(arg) if options.destdir: options.destdir = Utils.sane_path(options.destdir) if options.verbose >= 1: self.load('errcheck') colors = {'yes': 2, 'auto': 1, 'no': 0}[options.colors] Logs.enable_colors(colors)
def parse_args(self, _args=None): """ Parses arguments from a list which is not necesarily the command-line. :param _args: arguments :type _args: list of strings """ global options, commands, envvars (options, leftover_args) = self.parser.parse_args(args=_args) for arg in leftover_args: if "=" in arg: envvars.append(arg) else: commands.append(arg) if options.destdir: options.destdir = Utils.sane_path(options.destdir) if options.verbose >= 1: self.load("errcheck") colors = {"yes": 2, "auto": 1, "no": 0}[options.colors] Logs.enable_colors(colors)
def waf_entry_point(current_directory, version, wafdir): """ This is the main entry point, all Waf execution starts here. :param current_directory: absolute path representing the current directory :type current_directory: string :param version: version number :type version: string :param wafdir: absolute path representing the directory of the waf library :type wafdir: string """ Logs.init_log() if Context.WAFVERSION != version: Logs.error('Waf script %r and library %r do not match (directory %r)' % (version, Context.WAFVERSION, wafdir)) sys.exit(1) if '--version' in sys.argv: Context.run_dir = current_directory ctx = Context.create_context('options') ctx.curdir = current_directory ctx.parse_args() sys.exit(0) if len(sys.argv) > 1: # os.path.join handles absolute paths in sys.argv[1] accordingly (it discards the previous ones) # if sys.argv[1] is not an absolute path, then it is relative to the current working directory potential_wscript = os.path.join(current_directory, sys.argv[1]) # maybe check if the file is executable # perhaps extract 'wscript' as a constant if os.path.basename(potential_wscript) == 'wscript' and os.path.isfile(potential_wscript): # need to explicitly normalize the path, as it may contain extra '/.' # TODO abspath? current_directory = os.path.normpath(os.path.dirname(potential_wscript)) sys.argv.pop(1) Context.waf_dir = wafdir Context.launch_dir = current_directory # if 'configure' is in the commands, do not search any further no_climb = os.environ.get('NOCLIMB', None) if not no_climb: for k in no_climb_commands: for y in sys.argv: if y.startswith(k): no_climb = True break # if --top is provided assume the build started in the top directory for i, x in enumerate(sys.argv): # WARNING: this modifies sys.argv if x.startswith('--top='): Context.run_dir = Context.top_dir = Utils.sane_path(x[6:]) sys.argv[i] = '--top=' + Context.run_dir if x.startswith('--out='): Context.out_dir = Utils.sane_path(x[6:]) sys.argv[i] = '--out=' + Context.out_dir # try to find a lock file (if the project was configured) # at the same time, store the first wscript file seen cur = current_directory while cur and not Context.top_dir: lst = os.listdir(cur) if Options.lockfile in lst: env = ConfigSet.ConfigSet() try: env.load(os.path.join(cur, Options.lockfile)) ino = os.stat(cur)[stat.ST_INO] except Exception: pass else: # check if the folder was not moved for x in (env.run_dir, env.top_dir, env.out_dir): if Utils.is_win32: if cur == x: load = True break else: # if the filesystem features symlinks, compare the inode numbers try: ino2 = os.stat(x)[stat.ST_INO] except OSError: pass else: if ino == ino2: load = True break else: Logs.warn('invalid lock file in %s' % cur) load = False if load: Context.run_dir = env.run_dir Context.top_dir = env.top_dir Context.out_dir = env.out_dir break if not Context.run_dir: if Context.WSCRIPT_FILE in lst: Context.run_dir = cur next = os.path.dirname(cur) if next == cur: break cur = next if no_climb: break if not Context.run_dir: if '-h' in sys.argv or '--help' in sys.argv: Logs.warn('No wscript file found: the help message may be incomplete') Context.run_dir = current_directory ctx = Context.create_context('options') ctx.curdir = current_directory ctx.parse_args() sys.exit(0) Logs.error('Waf: Run from a directory containing a file named %r' % Context.WSCRIPT_FILE) sys.exit(1) try: os.chdir(Context.run_dir) except OSError: Logs.error('Waf: The folder %r is unreadable' % Context.run_dir) sys.exit(1) try: set_main_module(os.path.normpath(os.path.join(Context.run_dir, Context.WSCRIPT_FILE))) except Errors.WafError as e: Logs.pprint('RED', e.verbose_msg) Logs.error(str(e)) sys.exit(1) except Exception as e: Logs.error('Waf: The wscript in %r is unreadable' % Context.run_dir, e) traceback.print_exc(file=sys.stdout) sys.exit(2) """ import cProfile, pstats cProfile.runctx("from waflib import Scripting; Scripting.run_commands()", {}, {}, 'profi.txt') p = pstats.Stats('profi.txt') p.sort_stats('time').print_stats(75) # or 'cumulative' """ try: run_commands() except Errors.WafError as e: if Logs.verbose > 1: Logs.pprint('RED', e.verbose_msg) Logs.error(e.msg) sys.exit(1) except SystemExit: raise except Exception as e: traceback.print_exc(file=sys.stdout) sys.exit(2) except KeyboardInterrupt: Logs.pprint('RED', 'Interrupted') sys.exit(68)
def waf_entry_point(current_directory, version, wafdir): Logs.init_log() if Context.WAFVERSION != version: Logs.error('Waf script %r and library %r do not match (directory %r)', version, Context.WAFVERSION, wafdir) sys.exit(1) if '--version' in sys.argv: Context.run_dir = current_directory ctx = Context.create_context('options') ctx.curdir = current_directory ctx.parse_args() sys.exit(0) if len(sys.argv) > 1: potential_wscript = os.path.join(current_directory, sys.argv[1]) if os.path.basename(potential_wscript) == 'wscript' and os.path.isfile( potential_wscript): current_directory = os.path.normpath( os.path.dirname(potential_wscript)) sys.argv.pop(1) Context.waf_dir = wafdir Context.launch_dir = current_directory no_climb = os.environ.get('NOCLIMB') if not no_climb: for k in no_climb_commands: for y in sys.argv: if y.startswith(k): no_climb = True break for i, x in enumerate(sys.argv): if x.startswith('--top='): Context.run_dir = Context.top_dir = Utils.sane_path(x[6:]) sys.argv[i] = '--top=' + Context.run_dir if x.startswith('--out='): Context.out_dir = Utils.sane_path(x[6:]) sys.argv[i] = '--out=' + Context.out_dir cur = current_directory while cur and not Context.top_dir: try: lst = os.listdir(cur) except OSError: lst = [] Logs.error('Directory %r is unreadable!', cur) if Options.lockfile in lst: env = ConfigSet.ConfigSet() try: env.load(os.path.join(cur, Options.lockfile)) ino = os.stat(cur)[stat.ST_INO] except EnvironmentError: pass else: for x in (env.run_dir, env.top_dir, env.out_dir): if Utils.is_win32: if cur == x: load = True break else: try: ino2 = os.stat(x)[stat.ST_INO] except OSError: pass else: if ino == ino2: load = True break else: Logs.warn('invalid lock file in %s', cur) load = False if load: Context.run_dir = env.run_dir Context.top_dir = env.top_dir Context.out_dir = env.out_dir break if not Context.run_dir: if Context.WSCRIPT_FILE in lst: Context.run_dir = cur next = os.path.dirname(cur) if next == cur: break cur = next if no_climb: break if not Context.run_dir: if '-h' in sys.argv or '--help' in sys.argv: Logs.warn( 'No wscript file found: the help message may be incomplete') Context.run_dir = current_directory ctx = Context.create_context('options') ctx.curdir = current_directory ctx.parse_args() sys.exit(0) Logs.error('Waf: Run from a directory containing a file named %r', Context.WSCRIPT_FILE) sys.exit(1) try: os.chdir(Context.run_dir) except OSError: Logs.error('Waf: The folder %r is unreadable', Context.run_dir) sys.exit(1) try: set_main_module( os.path.normpath( os.path.join(Context.run_dir, Context.WSCRIPT_FILE))) except Errors.WafError, e: Logs.pprint('RED', e.verbose_msg) Logs.error(str(e)) sys.exit(1)
def waf_entry_point(current_directory,version,wafdir): Logs.init_log() if Context.WAFVERSION!=version: Logs.error('Waf script %r and library %r do not match (directory %r)',version,Context.WAFVERSION,wafdir) sys.exit(1) if'--version'in sys.argv: Context.run_dir=current_directory ctx=Context.create_context('options') ctx.curdir=current_directory ctx.parse_args() sys.exit(0) if len(sys.argv)>1: potential_wscript=os.path.join(current_directory,sys.argv[1]) if os.path.basename(potential_wscript)=='wscript'and os.path.isfile(potential_wscript): current_directory=os.path.normpath(os.path.dirname(potential_wscript)) sys.argv.pop(1) Context.waf_dir=wafdir Context.launch_dir=current_directory no_climb=os.environ.get('NOCLIMB') if not no_climb: for k in no_climb_commands: for y in sys.argv: if y.startswith(k): no_climb=True break for i,x in enumerate(sys.argv): if x.startswith('--top='): Context.run_dir=Context.top_dir=Utils.sane_path(x[6:]) sys.argv[i]='--top='+Context.run_dir if x.startswith('--out='): Context.out_dir=Utils.sane_path(x[6:]) sys.argv[i]='--out='+Context.out_dir cur=current_directory while cur and not Context.top_dir: try: lst=os.listdir(cur) except OSError: lst=[] Logs.error('Directory %r is unreadable!',cur) if Options.lockfile in lst: env=ConfigSet.ConfigSet() try: env.load(os.path.join(cur,Options.lockfile)) ino=os.stat(cur)[stat.ST_INO] except EnvironmentError: pass else: for x in(env.run_dir,env.top_dir,env.out_dir): if Utils.is_win32: if cur==x: load=True break else: try: ino2=os.stat(x)[stat.ST_INO] except OSError: pass else: if ino==ino2: load=True break else: Logs.warn('invalid lock file in %s',cur) load=False if load: Context.run_dir=env.run_dir Context.top_dir=env.top_dir Context.out_dir=env.out_dir break if not Context.run_dir: if Context.WSCRIPT_FILE in lst: Context.run_dir=cur next=os.path.dirname(cur) if next==cur: break cur=next if no_climb: break if not Context.run_dir: if'-h'in sys.argv or'--help'in sys.argv: Logs.warn('No wscript file found: the help message may be incomplete') Context.run_dir=current_directory ctx=Context.create_context('options') ctx.curdir=current_directory ctx.parse_args() sys.exit(0) Logs.error('Waf: Run from a directory containing a file named %r',Context.WSCRIPT_FILE) sys.exit(1) try: os.chdir(Context.run_dir) except OSError: Logs.error('Waf: The folder %r is unreadable',Context.run_dir) sys.exit(1) try: set_main_module(os.path.normpath(os.path.join(Context.run_dir,Context.WSCRIPT_FILE))) except Errors.WafError as e: Logs.pprint('RED',e.verbose_msg) Logs.error(str(e)) sys.exit(1) except Exception as e: Logs.error('Waf: The wscript in %r is unreadable',Context.run_dir) traceback.print_exc(file=sys.stdout) sys.exit(2) if'--profile'in sys.argv: import cProfile,pstats cProfile.runctx('from waflib import Scripting; Scripting.run_commands()',{},{},'profi.txt') p=pstats.Stats('profi.txt') p.sort_stats('time').print_stats(75) else: try: run_commands() except Errors.WafError as e: if Logs.verbose>1: Logs.pprint('RED',e.verbose_msg) Logs.error(e.msg) sys.exit(1) except SystemExit: raise except Exception as e: traceback.print_exc(file=sys.stdout) sys.exit(2) except KeyboardInterrupt: Logs.pprint('RED','Interrupted') sys.exit(68)
def waf_entry_point(current_directory,version,wafdir): Logs.init_log() if Context.WAFVERSION!=version: Logs.error('Waf script %r and library %r do not match (directory %r)'%(version,Context.WAFVERSION,wafdir)) sys.exit(1) if'--version'in sys.argv: Context.run_dir=current_directory ctx=Context.create_context('options') ctx.curdir=current_directory ctx.parse_args() sys.exit(0) if len(sys.argv)>1: potential_wscript=os.path.join(current_directory,sys.argv[1]) if os.path.basename(potential_wscript)=='wscript'and os.path.isfile(potential_wscript): current_directory=os.path.normpath(os.path.dirname(potential_wscript)) sys.argv.pop(1) Context.waf_dir=wafdir Context.launch_dir=current_directory no_climb=os.environ.get('NOCLIMB',None) if not no_climb: for k in no_climb_commands: for y in sys.argv: if y.startswith(k): no_climb=True break for i,x in enumerate(sys.argv): if x.startswith('--top='): Context.run_dir=Context.top_dir=Utils.sane_path(x[6:]) sys.argv[i]='--top='+Context.run_dir if x.startswith('--out='): Context.out_dir=Utils.sane_path(x[6:]) sys.argv[i]='--out='+Context.out_dir cur=current_directory while cur and not Context.top_dir: lst=os.listdir(cur) if Options.lockfile in lst: env=ConfigSet.ConfigSet() try: env.load(os.path.join(cur,Options.lockfile)) ino=os.stat(cur)[stat.ST_INO] except Exception: pass else: for x in(env.run_dir,env.top_dir,env.out_dir): if Utils.is_win32: if cur==x: load=True break else: try: ino2=os.stat(x)[stat.ST_INO] except OSError: pass else: if ino==ino2: load=True break else: Logs.warn('invalid lock file in %s'%cur) load=False if load: Context.run_dir=env.run_dir Context.top_dir=env.top_dir Context.out_dir=env.out_dir break if not Context.run_dir: if Context.WSCRIPT_FILE in lst: Context.run_dir=cur next=os.path.dirname(cur) if next==cur: break cur=next if no_climb: break if not Context.run_dir: if'-h'in sys.argv or'--help'in sys.argv: Logs.warn('No wscript file found: the help message may be incomplete') Context.run_dir=current_directory ctx=Context.create_context('options') ctx.curdir=current_directory ctx.parse_args() sys.exit(0) Logs.error('Waf: Run from a directory containing a file named %r'%Context.WSCRIPT_FILE) sys.exit(1) try: os.chdir(Context.run_dir) except OSError: Logs.error('Waf: The folder %r is unreadable'%Context.run_dir) sys.exit(1) try: set_main_module(os.path.normpath(os.path.join(Context.run_dir,Context.WSCRIPT_FILE))) except Errors.WafError ,e: Logs.pprint('RED',e.verbose_msg) Logs.error(str(e)) sys.exit(1)