def start(cwd, version, wafdir): # simple example, the file main.c is hard-coded try: os.stat(cwd + os.sep + 'cbit') except: print('call from a folder containing a file named "cbit"') sys.exit(1) Logs.init_log() Context.waf_dir = wafdir Context.top_dir = Context.run_dir = cwd Context.out_dir = os.path.join(cwd, 'build') Context.g_module = imp.new_module('wscript') Context.g_module.root_path = os.path.join(cwd, 'cbit') Context.Context.recurse = recurse_rep # this is a fake module, which looks like a standard wscript file Context.g_module.options = options Context.g_module.configure = configure Context.g_module.build = build Options.OptionsContext().execute() do_config = 'configure' in sys.argv try: os.stat(cwd + os.sep + 'build') except: do_config = True if do_config: Context.create_context('configure').execute() if 'clean' in sys.argv: Context.create_context('clean').execute() if 'build' in sys.argv: Context.create_context('build').execute()
def start(cwd, version, wafdir): # simple example, the file main.c is hard-coded try: os.stat(cwd + os.sep + 'bbit') except: print('call from a folder containing a file named "bbit"') sys.exit(1) Logs.init_log() Context.waf_dir = wafdir Context.top_dir = Context.run_dir = cwd Context.out_dir = os.path.join(cwd, 'build') Context.g_module = imp.new_module('wscript') Context.g_module.root_path = os.path.join(cwd, 'bbit') Context.Context.recurse = \ lambda x, y: getattr(Context.g_module, x.cmd or x.fun, Utils.nada)(x) Context.g_module.configure = lambda ctx: ctx.load('g++') Context.g_module.build = lambda bld: bld.objects(source='main.c') Options.OptionsContext().execute() do_config = 'configure' in sys.argv try: os.stat(cwd + os.sep + 'build') except: do_config = True if do_config: Context.create_context('configure').execute() if 'clean' in sys.argv: Context.create_context('clean').execute() if 'build' in sys.argv: Context.create_context('build').execute()
def start(cwd, version, wafdir): # this is the entry point of our small build system # no script file here Logs.init_log() Context.waf_dir = wafdir Context.out_dir = Context.top_dir = Context.run_dir = cwd Context.g_module = imp.new_module('wscript') Context.g_module.root_path = cwd Context.Context.recurse = recurse_rep Context.g_module.configure = configure Context.g_module.build = build Context.g_module.options = options Context.g_module.top = Context.g_module.out = '.' Options.OptionsContext().execute() do_config = 'configure' in sys.argv try: os.stat(cwd + os.sep + 'c4che') except: do_config = True if do_config: Context.create_context('configure').execute() if 'clean' in sys.argv: Context.create_context('clean').execute() if 'build' in sys.argv: Context.create_context('build').execute()
def start(cwd, version, wafdir): print ("cwd: %s" % cwd) print ("version: %s" % version) print ("wafdir: %s" % wafdir) Logs.init_log() Context.waf_dir = wafdir Context.launch_dir = Context.out_dir = Context.top_dir = Context.run_dir = cwd Context.g_module = imp.new_module('wscript') Context.g_module.root_path = cwd Context.Context.recurse = recurse_rep Context.g_module.configure = configure Context.g_module.build = build Context.g_module.options = options Context.g_module.top = Context.g_module.out = '.' Options.OptionsContext().execute() do_config = 'configure' in sys.argv try: os.stat(cwd + os.sep + 'c4che') except: do_config = True if do_config: Scripting.run_command('configure') if 'clean' in sys.argv: Scripting.run_command('clean') if 'build' in sys.argv: Scripting.run_command('build')
def __init__(self, cmd_argv, options_context, pkg, run_node): super(BuildWafContext, self).__init__(cmd_argv, options_context, pkg, run_node) o, a = options_context.parser.parse_args(cmd_argv) if o.jobs: jobs = int(o.jobs) else: jobs = 1 if o.verbose: verbose = int(o.verbose) zones = ["runner"] else: verbose = 0 zones = [] if o.inplace: self.inplace = 1 else: self.inplace = 0 if o.progress_bar: self.progress_bar = True else: self.progress_bar = False Logs.verbose = verbose Logs.init_log() if zones is None: Logs.zones = [] else: Logs.zones = zones run_path = self.run_node.abspath() source_path = self.top_node.abspath() build_path = self.build_node.abspath() _init(run_path=run_path, source_path=source_path, build_path=build_path) waf_context = create_context("build") waf_context.restore() if not waf_context.all_envs: waf_context.load_envs() waf_context.jobs = jobs waf_context.timer = Utils.Timer() if self.progress_bar: waf_context.progress_bar = 1 waf_context.bento_context = self self.waf_context = waf_context def _default_extension_builder(extension): # FIXME: should be handled in the waf builder itself maybe ? target = extension.name.replace(".", os.sep) return self.waf_context(features='c cshlib pyext bento', source=extension.sources, target=target, name=extension.name) def _default_library_builder(library): # FIXME: should be handled in the waf builder itself maybe ? target = library.name.replace(".", os.sep) return self.waf_context(features='c cstlib pyext bento', source=library.sources, target=target, name=library.name) self.builder_registry.register_category("extensions", _default_extension_builder) self.builder_registry.register_category("compiled_libraries", _default_library_builder)
def start(cwd, version, wafdir): # this is the entry point of our small build system Logs.init_log() Context.waf_dir = wafdir Context.out_dir = Context.top_dir = Context.run_dir = cwd Context.g_module = Context.load_module(cwd + os.sep + 'wscript') Context.g_module.configure = configure Context.g_module.root_path = cwd Context.Context.recurse = recurse_rep Context.g_module.top = Context.g_module.out = '.' # no build directory # just parse the options and execute a build Options.OptionsContext().execute() conf = Context.create_context('configure') conf.options = Options.options conf.execute() bld = Context.create_context('build') bld.env = conf.env bld.options = Options.options bld.environ = os.environ bld.execute()
def parse_options(): """ Parse the command-line options and initialize the logging system. Called by :py:func:`waflib.Scripting.waf_entry_point` during the initialization. """ Context.create_context('options').execute() if not Options.commands: Options.commands = [default_cmd] Options.commands = [x for x in Options.commands if x != 'options'] # issue 1076 # process some internal Waf options Logs.verbose = Options.options.verbose Logs.init_log() if Options.options.zones: Logs.zones = Options.options.zones.split(',') if not Logs.verbose: Logs.verbose = 1 elif Logs.verbose > 0: Logs.zones = ['runner'] if Logs.verbose > 2: Logs.zones = ['*'] # Force console mode for SSH connections if getattr(Options.options, 'console_mode', None): if os.environ.get('SSH_CLIENT') != None or os.environ.get('SSH_TTY') != None: Logs.info("[INFO] - SSH Connection detected. Forcing 'console_mode'") Options.options.console_mode = str(True)
def _init(run_path, source_path, build_path): if not (os.path.isabs(run_path) and os.path.isabs(source_path) and os.path.isabs(build_path)): raise ValueError("All paths must be absolute !") tooldir = os.path.join(WAFDIR, "Tools") sys.path.insert(0, tooldir) cwd = os.getcwd() if __USE_NO_OUTPUT_LOGGING is True: _init_log_no_output() else: Logs.init_log() class FakeModule(object): pass Context.g_module = FakeModule Context.g_module.root_path = os.path.abspath(__file__) Context.g_module.top = source_path Context.g_module.out = build_path Context.top_dir = source_path Context.run_dir = run_path Context.out_dir = build_path Context.waf_dir = WAF_TOP Context.launch_dir = run_path
def start(cwd, version, wafdir): # this is the entry point of our small build system # no script file here Logs.init_log() Context.waf_dir = wafdir Context.out_dir = Context.top_dir = Context.run_dir = cwd Context.g_module = imp.new_module("wscript") Context.g_module.root_path = cwd Context.Context.recurse = recurse_rep Context.g_module.configure = configure Context.g_module.build = build Context.g_module.options = options Context.g_module.top = Context.g_module.out = "." Options.OptionsContext().execute() do_config = "configure" in sys.argv try: os.stat(cwd + os.sep + "c4che") except: do_config = True if do_config: Context.create_context("configure").execute() if "clean" in sys.argv: Context.create_context("clean").execute() if "build" in sys.argv: Context.create_context("build").execute()
def parse_options(): """ Parse the command-line options and initialize the logging system. Called by :py:func:`waflib.Scripting.waf_entry_point` during the initialization. """ Context.create_context('options').execute() if not Options.commands: Options.commands = [default_cmd] Options.commands = [x for x in Options.commands if x != 'options'] # issue 1076 # process some internal Waf options Logs.verbose = Options.options.verbose Logs.init_log() if Options.options.zones: Logs.zones = Options.options.zones.split(',') if not Logs.verbose: Logs.verbose = 1 elif Logs.verbose > 0: Logs.zones = ['runner'] if Logs.verbose > 2: Logs.zones = ['*'] # Force console mode for SSH connections if getattr(Options.options, 'console_mode', None): if os.environ.get('SSH_CLIENT') != None or os.environ.get( 'SSH_TTY') != None: Logs.info( "[INFO] - SSH Connection detected. Forcing 'console_mode'") Options.options.console_mode = str(True)
def parse_options(): """ Parse the command-line options and initialize the logging system. Called by :py:func:`waflib.Scripting.waf_entry_point` during the initialization. """ Context.create_context('options').execute() if not Options.commands: Options.commands = [default_cmd] Options.commands = [x for x in Options.commands if x != 'options'] # issue 1076 # process some internal Waf options Logs.verbose = Options.options.verbose Logs.init_log() if Options.options.zones: Logs.zones = Options.options.zones.split(',') if not Logs.verbose: Logs.verbose = 1 elif Logs.verbose > 0: Logs.zones = ['runner'] if Logs.verbose > 2: Logs.zones = ['*']
def parse_options(): Context.create_context('options').execute() if not Options.commands: Options.commands = [default_cmd] Logs.verbose = Options.options.verbose Logs.init_log() if Options.options.zones: Logs.zones = Options.options.zones.split(',') if not Logs.verbose: Logs.verbose = 1 elif Logs.verbose > 0: Logs.zones = ['runner'] if Logs.verbose > 2: Logs.zones = ['*']
def parse_options(): Context.create_context('options').execute() if not Options.commands: Options.commands=[default_cmd] Logs.verbose=Options.options.verbose Logs.init_log() if Options.options.zones: Logs.zones=Options.options.zones.split(',') if not Logs.verbose: Logs.verbose=1 elif Logs.verbose>0: Logs.zones=['runner'] if Logs.verbose>2: Logs.zones=['*']
def parse_options(): opt=Options.OptionsContext().execute() if not Options.commands: Options.commands=['build'] Logs.verbose=Options.options.verbose Logs.init_log() if Options.options.zones: Logs.zones=Options.options.zones.split(',') if not Logs.verbose: Logs.verbose=1 elif Logs.verbose>0: Logs.zones=['runner'] if Logs.verbose>2: Logs.zones=['*']
def initialise_waf(): if waf_initialised: return Logs.init_log() Context.waf_dir = wafdir Context.top_dir = Context.run_dir = xpdeintUserDataPath Context.out_dir = os.path.join(xpdeintUserDataPath, 'waf_configure') wscript_path = resource_filename(__name__, 'support/wscript') Context.g_module = Context.load_module(wscript_path) Context.g_module.root_path = wscript_path Context.g_module.out = Context.out_dir Context.g_module.configure = configure_wrapper(Context.g_module.configure) Context.Context.recurse = \ lambda x, y: getattr(Context.g_module, x.cmd or x.fun, Utils.nada)(x) Options.OptionsContext().execute()
def parse_options(): """parse the command-line options and initialize the logging system""" opt = Options.OptionsContext().execute() if not Options.commands: Options.commands = ['build'] # process some internal Waf options Logs.verbose = Options.options.verbose Logs.init_log() if Options.options.zones: Logs.zones = Options.options.zones.split(',') if not Logs.verbose: Logs.verbose = 1 elif Logs.verbose > 0: Logs.zones = ['runner'] if Logs.verbose > 2: Logs.zones = ['*']
def parse_options(): """ Parse the command-line options and initialize the logging system. Called by :py:func:`waflib.Scripting.waf_entry_point` during the initialization. """ Context.create_context('options').execute() if not Options.commands: raise Errors.WafError( "No command specified. Run 'lmbr_waf --help' to see the list of commands" ) Options.commands = [x for x in Options.commands if x != 'options'] # issue 1076 # process some internal Waf options Logs.verbose = Options.options.verbose Logs.sig_delta = _is_option_true(Options.options, 'generate_sig_debug_output') if Logs.sig_delta: Logs.info('Enabling capturing of task signature data', Logs.sig_delta) Logs.init_log() if Options.options.zones: Logs.zones = Options.options.zones.split(',') if not Logs.verbose: Logs.verbose = 1 elif Logs.verbose > 0: Logs.zones = ['runner'] if Logs.verbose > 2: Logs.zones = ['*'] # Force console mode for SSH connections if getattr(Options.options, 'console_mode', None): if os.environ.get('SSH_CLIENT') != None or os.environ.get( 'SSH_TTY') != None: Logs.info( "[INFO] - SSH Connection detected. Forcing 'console_mode'") Options.options.console_mode = str(True)
def test_BuildShaderPaks_NoShaderPaks_Error(tmpdir, fake_ctx, game, assets_type): Logs.init_log() def _mock_generate_shaders_pak(ctx, game, assets_platform, shader_type): return fake_ctx.shaders_node old_generate_shaders_pak = packaging.generate_shaders_pak packaging.generate_shaders_pak = _mock_generate_shaders_pak try: android.build_shaders(fake_ctx, game, assets_type, fake_ctx.layout_node, fake_ctx.assets_cache, generate_pak=False) assert False, "Error expected" except Errors.WafError: pass finally: packaging.generate_shaders_pak = old_generate_shaders_pak
def parse_options(): """ Parse the command-line options and initialize the logging system. Called by :py:func:`waflib.Scripting.waf_entry_point` during the initialization. """ opt = Options.OptionsContext().execute() if not Options.commands: Options.commands = ["build"] # process some internal Waf options Logs.verbose = Options.options.verbose Logs.init_log() if Options.options.zones: Logs.zones = Options.options.zones.split(",") if not Logs.verbose: Logs.verbose = 1 elif Logs.verbose > 0: Logs.zones = ["runner"] if Logs.verbose > 2: Logs.zones = ["*"]
def parse_options(): """ Parse the command-line options and initialize the logging system. Called by :py:func:`waflib.Scripting.waf_entry_point` during the initialization. """ Context.create_context('options').execute() if not Options.commands: Options.commands = [default_cmd] # process some internal Waf options Logs.verbose = Options.options.verbose Logs.init_log() if Options.options.zones: Logs.zones = Options.options.zones.split(',') if not Logs.verbose: Logs.verbose = 1 elif Logs.verbose > 0: Logs.zones = ['runner'] if Logs.verbose > 2: Logs.zones = ['*']
def parse_options(): """ Parse the command-line options and initialize the logging system. Called by :py:func:`waflib.Scripting.waf_entry_point` during the initialization. """ Context.create_context("options").execute() if not Options.commands: Options.commands = [default_cmd] Options.commands = [x for x in Options.commands if x != "options"] # issue 1076 # process some internal Waf options Logs.verbose = Options.options.verbose Logs.init_log() if Options.options.zones: Logs.zones = Options.options.zones.split(",") if not Logs.verbose: Logs.verbose = 1 elif Logs.verbose > 0: Logs.zones = ["runner"] if Logs.verbose > 2: Logs.zones = ["*"]
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(directory=None): import os import sys import traceback import zippy import waflib from waflib import Logs from waflib import Errors from waflib import Options from waflib import Context from waflib import Scripting from waflib import Configure from waflib import Build Logs.init_log() directory = os.path.abspath(directory or os.getcwd()) name = __package__.title() Context.WSCRIPT_FILE = 'zscript.py' Context.g_module = __import__(__name__) Context.g_module.root_path = __file__ Context.cache_modules[Context.g_module.root_path] = Context.g_module Context.launch_dir = directory Context.run_dir = directory Context.top_dir = directory Context.out_dir = directory + os.sep + out Context.waf_dir = os.path.abspath(os.path.dirname(waflib.__path__[0])) for key in ('update', 'dist', 'distclean', 'distcheck'): attr = getattr(Scripting, key) if attr.__name__ not in Context.g_module.__dict__: setattr(Context.g_module, attr.__name__, attr) if key not in Context.g_module.__dict__: setattr(Context.g_module, key, attr) def pre_recurse(self, node, _pre_recurse=Context.Context.pre_recurse): _pre_recurse(self, node) if node.abspath() == Context.g_module.root_path: self.path = self.root.find_dir(Context.run_dir) def recurse(self, dirs, **kwds): if Context.run_dir in dirs: dirs[dirs.index(Context.run_dir)] = os.path.dirname(__file__) _recurse(self, dirs, **kwds) _pre_recurse = Context.Context.pre_recurse _recurse = Context.Context.recurse Context.Context.pre_recurse = pre_recurse Context.Context.recurse = recurse try: os.chdir(Context.run_dir) except OSError: Logs.error('%s: The directory %r is unreadable' % (name, Context.run_dir)) return 1 try: Scripting.parse_options() Scripting.run_command('init') try: os.stat(Context.out_dir + os.sep + Build.CACHE_DIR) except Exception: if 'configure' not in Options.commands: Options.commands.insert(0, 'configure') while Options.commands: cmd_name = Options.commands.pop(0) ctx = Scripting.run_command(cmd_name) Logs.info('%r finished successfully (%s)' % ( cmd_name, str(ctx.log_timer), )) Scripting.run_command('shutdown') except Errors.WafError as e: if Logs.verbose > 1: Logs.pprint('RED', e.verbose_msg) Logs.error(e.msg) return 1 except SystemExit: raise except Exception as e: traceback.print_exc(file=sys.stdout) return 2 except KeyboardInterrupt: Logs.pprint('RED', 'Interrupted') return 68 return 0
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) # Store current directory before any chdir Context.waf_dir = wafdir Context.run_dir = Context.launch_dir = current_directory start_dir = current_directory no_climb = os.environ.get('NOCLIMB') if len(sys.argv) > 1: # os.path.join handles absolute paths # 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]) if os.path.basename(potential_wscript) == Context.WSCRIPT_FILE and os.path.isfile(potential_wscript): # need to explicitly normalize the path, as it may contain extra '/.' path = os.path.normpath(os.path.dirname(potential_wscript)) start_dir = os.path.abspath(path) no_climb = True sys.argv.pop(1) ctx = Context.create_context('options') (options, commands, env) = ctx.parse_cmd_args(allow_unknown=True) if options.top: start_dir = Context.run_dir = Context.top_dir = options.top no_climb = True if options.out: Context.out_dir = options.out # if 'configure' is in the commands, do not search any further if not no_climb: for k in no_climb_commands: for y in commands: if y.startswith(k): no_climb = True break # try to find a lock file (if the project was configured) # at the same time, store the first wscript file seen cur = start_dir while cur: 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: # check if the folder was not moved for x in (env.run_dir, env.top_dir, env.out_dir): if not x: continue 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 wscript = os.path.normpath(os.path.join(Context.run_dir, Context.WSCRIPT_FILE)) if not os.path.exists(wscript): if options.whelp: Logs.warn('These are the generic options (no wscript/project found)') ctx.parser.print_help() sys.exit(0) Logs.error('Waf: Run from a folder containing a %r file (or try -h for the generic options)', 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(wscript) 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 options.profile: 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' else: try: try: run_commands() except: if options.pdb: import pdb type, value, tb = sys.exc_info() traceback.print_exc() pdb.post_mortem(tb) else: raise 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) 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: if k in sys.argv: no_climb = True break cur = current_directory while cur: 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(Context.run_dir + os.sep + 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): """ 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) 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: if k in sys.argv: no_climb = True break # 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: 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: 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(Context.run_dir + os.sep + 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("import Scripting; Scripting.run_commands()", {}, {}, 'profi.txt') p = pstats.Stats('profi.txt') p.sort_stats('time').print_stats(25) """ 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 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) Context.waf_dir = wafdir Context.run_dir = Context.launch_dir = current_directory start_dir = current_directory no_climb = os.environ.get('NOCLIMB') if len(sys.argv) > 1: potential_wscript = os.path.join(current_directory, sys.argv[1]) if os.path.basename( potential_wscript) == Context.WSCRIPT_FILE and os.path.isfile( potential_wscript): path = os.path.normpath(os.path.dirname(potential_wscript)) start_dir = os.path.abspath(path) no_climb = True sys.argv.pop(1) ctx = Context.create_context('options') (options, commands, env) = ctx.parse_cmd_args(allow_unknown=True) if options.top: start_dir = Context.run_dir = Context.top_dir = options.top no_climb = True if options.out: Context.out_dir = options.out if not no_climb: for k in no_climb_commands: for y in commands: if y.startswith(k): no_climb = True break cur = start_dir while cur: 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 not x: continue 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 wscript = os.path.normpath( os.path.join(Context.run_dir, Context.WSCRIPT_FILE)) if not os.path.exists(wscript): if options.whelp: Logs.warn( 'These are the generic options (no wscript/project found)') ctx.parser.print_help() sys.exit(0) Logs.error( 'Waf: Run from a folder containing a %r file (or try -h for the generic options)', 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(wscript) 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 options.profile: 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: try: run_commands() except: if options.pdb: import pdb type, value, tb = sys.exc_info() traceback.print_exc() pdb.post_mortem(tb) else: raise 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) 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: if k in sys.argv: no_climb=True break cur=current_directory while cur: 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(Context.run_dir+os.sep+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): """ 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 """ def _wait_for_user_input(): """ Helper function to wait for a key press when needed (like on windows to prevent closing the windows """ try: if not Utils.unversioned_sys_platform() == 'win32': return # No need on non windows platforms if not _is_option_true(Options.options, 'ask_for_user_input'): return # Obey what the user wants if Options.options.execsolution: return # Dont ask for input in visual studio if _is_option_true(Options.options, 'internal_dont_check_recursive_execution'): return # Dont ask from within Incredibuild import msvcrt Logs.error('Please Press Any Key to Continue') msvcrt.getch() except: pass # Crashed to early to do something meaningful def _dump_call_stack(): """ Util function to dump a callstack, and if running from Visual Studio, to format the error to be clickable """ if getattr(Options.options, 'execsolution', None): exc_type, exc_value, exc_traceback = sys.exc_info() stackstace = traceback.format_tb(exc_traceback) sys.stdout.write('Traceback (most recent call last):\n') python_to_vs = re.compile(r'(.*?)"(.+?)", line ([0-9]+?),(.*)', re.M) # Align output vertically nAlignedPos = 0 for line in stackstace[:-1]: m = re.match(python_to_vs, line) if m: nNeededLenght = len('%s(%s):' % (m.group(2), m.group(3))) if nNeededLenght > nAlignedPos: nAlignedPos = nNeededLenght # output for line in stackstace[:-1]: m = re.match(python_to_vs, line) if m: nNeededSpaces = 1 + (nAlignedPos - len('%s(%s):' % (m.group(2), m.group(3)))) sys.stdout.write('%s(%s):%s%s\n' % (m.group(2), m.group(3), ' ' * nNeededSpaces, m.group(4))) else: sys.stdout.write(line) m = re.match(python_to_vs, stackstace[-1]) if m: sys.stdout.write( '%s(%s): error : %s %s\n' % (m.group(2), m.group(3), m.group(4), str(exc_value))) else: sys.stdout.write(line) else: traceback.print_exc(file=sys.stdout) Logs.init_log() if Context.WAFVERSION != version: Logs.error('Waf script %r and library %r do not match (directory %r)' % (version, Context.WAFVERSION, wafdir)) _wait_for_user_input() sys.exit(1) # import waf branch spec branch_spec_globals = Context.load_branch_spec(current_directory) if Utils.is_win32: # Make sure we always have the same path, regardless of used shell current_directory = current_directory[0].lower( ) + current_directory[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) 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: if k in sys.argv: no_climb = True break # try to find a lock file (if the project was configured) cur_lockfile = current_directory + os.sep + branch_spec_globals[ 'BINTEMP_FOLDER'] try: lst_lockfile = os.listdir(cur_lockfile) except OSError: pass else: if Options.lockfile in lst_lockfile: env = ConfigSet.ConfigSet() try: env.load(os.path.join(cur_lockfile, Options.lockfile)) ino = os.stat(cur_lockfile)[stat.ST_INO] Context.lock_dir = cur_lockfile except Exception: pass else: # check if the folder was not moved for x in [env.lock_dir]: if Utils.is_win32: if cur_lockfile == 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_lockfile) load = False if load: Context.run_dir = env.run_dir Context.top_dir = env.top_dir Context.out_dir = env.out_dir Context.lock_dir = env.lock_dir # store the first wscript file seen (if the project was not configured) if not Context.run_dir: cur = current_directory while cur: lst = os.listdir(cur) 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) _wait_for_user_input() sys.exit(1) try: os.chdir(Context.run_dir) except OSError: Logs.error('Waf: The folder %r is unreadable' % Context.run_dir) _wait_for_user_input() sys.exit(1) try: set_main_module(Context.run_dir + os.sep + Context.WSCRIPT_FILE) except Errors.WafError as e: Logs.pprint('RED', e.verbose_msg) Logs.error(str(e)) _wait_for_user_input() sys.exit(1) except Exception as e: Logs.error('Waf: The wscript in %r is unreadable' % Context.run_dir, e) _dump_call_stack() _wait_for_user_input() 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(25) # or 'cumulative' """ try: run_commands() except Errors.WafError as e: if Logs.verbose > 1: Logs.pprint('RED', e.verbose_msg) Logs.error(e.msg) _wait_for_user_input() sys.exit(1) except SystemExit: raise except Exception as e: _dump_call_stack() _wait_for_user_input() sys.exit(2) except KeyboardInterrupt: Logs.pprint('RED', 'Interrupted') _wait_for_user_input() 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,WAFVERSION,wafdir)) sys.exit(1) Context.waf_dir=wafdir Context.launch_dir=current_directory cur=current_directory while cur: lst=os.listdir(cur) if Options.lockfile in lst: env=ConfigSet.ConfigSet() try: env.load(os.path.join(cur,Options.lockfile)) except Exception: continue Context.run_dir=env.run_dir Context.top_dir=env.top_dir Context.out_dir=env.out_dir try: os.stat(Context.run_dir) except: Context.run_dir=cur 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 for k in no_climb_commands: if k in sys.argv: break else: continue 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') opt_obj=Options.OptionsContext() opt_obj.curdir=current_directory opt_obj.parse_args() sys.exit(0) elif'--version'in sys.argv: opt_obj=Options.OptionsContext() opt_obj.curdir=current_directory opt_obj.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(Context.run_dir+os.sep+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, WAFVERSION, wafdir)) sys.exit(1) Context.waf_dir = wafdir Context.launch_dir = current_directory cur = current_directory while cur: lst = os.listdir(cur) if Options.lockfile in lst: env = ConfigSet.ConfigSet() try: env.load(os.path.join(cur, Options.lockfile)) except Exception: pass else: Context.run_dir = env.run_dir Context.top_dir = env.top_dir Context.out_dir = env.out_dir try: os.stat(Context.run_dir) except: Context.run_dir = cur 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 for k in no_climb_commands: if k in sys.argv: break else: continue 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') opt_obj = Options.OptionsContext() opt_obj.curdir = current_directory opt_obj.parse_args() sys.exit(0) elif '--version' in sys.argv: opt_obj = Options.OptionsContext() opt_obj.curdir = current_directory opt_obj.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(Context.run_dir + os.sep + 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) Context.waf_dir = wafdir Context.run_dir = Context.launch_dir = current_directory start_dir = current_directory no_climb = os.environ.get('NOCLIMB') if len(sys.argv) > 1: potential_wscript = os.path.join(current_directory, sys.argv[1]) if os.path.basename( potential_wscript) == Context.WSCRIPT_FILE and os.path.isfile( potential_wscript): path = os.path.normpath(os.path.dirname(potential_wscript)) start_dir = os.path.abspath(path) no_climb = True sys.argv.pop(1) ctx = Context.create_context('options') (options, commands, env) = ctx.parse_cmd_args(allow_unknown=True) if options.top: start_dir = Context.run_dir = Context.top_dir = options.top no_climb = True if options.out: Context.out_dir = options.out if not no_climb: for k in no_climb_commands: for y in commands: if y.startswith(k): no_climb = True break cur = start_dir while cur: 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 not x: continue 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 options.whelp: Logs.warn( 'These are the generic options (no wscript/project found)') ctx.parser.print_help() sys.exit(0) Logs.error( 'Waf: Run from a folder containing a %r file (or try -h for the generic options)', 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): """ 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 """ def _wait_for_user_input(): """ Helper function to wait for a key press when needed (like on windows to prevent closing the windows """ try: if not Utils.unversioned_sys_platform() == 'win32': return # No need on non windows platforms if not _is_option_true(Options.options, 'ask_for_user_input'): return # Obey what the user wants if Options.options.execsolution: return # Dont ask for input in visual studio if _is_option_true(Options.options, 'internal_dont_check_recursive_execution'): return # Dont ask from within Incredibuild import msvcrt Logs.error('Please Press Any Key to Continue') msvcrt.getch() except: pass # Crashed to early to do something meaningful def _dump_call_stack(): """ Util function to dump a callstack, and if running from Visual Studio, to format the error to be clickable """ if getattr(Options.options, 'execsolution', None): exc_type, exc_value, exc_traceback = sys.exc_info() stackstace = traceback.format_tb(exc_traceback) sys.stdout.write('Traceback (most recent call last):\n') python_to_vs = re.compile(r'(.*?)"(.+?)", line ([0-9]+?),(.*)', re.M) # Align output vertically nAlignedPos = 0 for line in stackstace[:-1]: m = re.match(python_to_vs, line) if m: nNeededLenght = len('%s(%s):' % (m.group(2), m.group(3))) if nNeededLenght > nAlignedPos: nAlignedPos = nNeededLenght # output for line in stackstace[:-1]: m = re.match(python_to_vs, line) if m: nNeededSpaces = 1 + (nAlignedPos - len('%s(%s):' % (m.group(2), m.group(3)))) sys.stdout.write('%s(%s):%s%s\n' % (m.group(2), m.group(3), ' ' * nNeededSpaces, m.group(4))) else: sys.stdout.write(line) m = re.match(python_to_vs, stackstace[-1]) if m: sys.stdout.write('%s(%s): error : %s %s\n' % (m.group(2), m.group(3), m.group(4), str(exc_value))) else: sys.stdout.write(line) else: traceback.print_exc(file=sys.stdout) Logs.init_log() if Context.WAFVERSION != version: Logs.error('Waf script %r and library %r do not match (directory %r)' % (version, Context.WAFVERSION, wafdir)) _wait_for_user_input() sys.exit(1) # import waf branch spec branch_spec_globals = Context.load_branch_spec(current_directory) if Utils.is_win32: # Make sure we always have the same path, regardless of used shell current_directory = current_directory[0].lower() + current_directory[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) 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: if k in sys.argv: no_climb = True break # try to find a lock file (if the project was configured) cur_lockfile = current_directory + os.sep + branch_spec_globals['BINTEMP_FOLDER'] try: lst_lockfile = os.listdir(cur_lockfile) except OSError: pass else: if Options.lockfile in lst_lockfile: env = ConfigSet.ConfigSet() try: env.load(os.path.join(cur_lockfile, Options.lockfile)) ino = os.stat(cur_lockfile)[stat.ST_INO] Context.lock_dir = cur_lockfile except Exception: pass else: # check if the folder was not moved for x in [env.lock_dir]: if Utils.is_win32: if cur_lockfile == 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_lockfile) load = False if load: Context.run_dir = env.run_dir Context.top_dir = env.top_dir Context.out_dir = env.out_dir Context.lock_dir = env.lock_dir # store the first wscript file seen (if the project was not configured) if not Context.run_dir: cur = current_directory while cur: lst = os.listdir(cur) 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) _wait_for_user_input() sys.exit(1) try: os.chdir(Context.run_dir) except OSError: Logs.error('Waf: The folder %r is unreadable' % Context.run_dir) _wait_for_user_input() sys.exit(1) try: set_main_module(Context.run_dir + os.sep + Context.WSCRIPT_FILE) except Errors.WafError as e: Logs.pprint('RED', e.verbose_msg) Logs.error(str(e)) _wait_for_user_input() sys.exit(1) except Exception as e: Logs.error('Waf: The wscript in %r is unreadable' % Context.run_dir, e) _dump_call_stack() _wait_for_user_input() 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(25) # or 'cumulative' """ try: run_commands() except Errors.WafError as e: if Logs.verbose > 1: Logs.pprint('RED', e.verbose_msg) Logs.error(e.msg) _wait_for_user_input() sys.exit(1) except SystemExit: raise except Exception as e: _dump_call_stack() _wait_for_user_input() sys.exit(2) except KeyboardInterrupt: Logs.pprint('RED', 'Interrupted') _wait_for_user_input() sys.exit(68)
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, WAFVERSION, wafdir)) sys.exit(1) Context.waf_dir = wafdir Context.launch_dir = current_directory # 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: lst = os.listdir(cur) if Options.lockfile in lst: env = ConfigSet.ConfigSet() try: env.load(os.path.join(cur, Options.lockfile)) except Exception: pass else: Context.run_dir = env.run_dir Context.top_dir = env.top_dir Context.out_dir = env.out_dir # the directory of the wscript file was moved try: os.stat(Context.run_dir) except: Context.run_dir = cur 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 'configure' is in the commands, do not search any further for k in no_climb_commands: if k in sys.argv: break else: continue 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') opt_obj = Options.OptionsContext() opt_obj.curdir = current_directory opt_obj.parse_args() sys.exit(0) elif '--version' in sys.argv: opt_obj = Options.OptionsContext() opt_obj.curdir = current_directory opt_obj.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(Context.run_dir + os.sep + 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) parse_options() """ import cProfile, pstats cProfile.runctx("import Scripting; Scripting.run_commands()", {}, {}, 'profi.txt') p = pstats.Stats('profi.txt') p.sort_stats('time').print_stats(25) """ 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 Exception as e: traceback.print_exc(file=sys.stdout) sys.exit(2) except KeyboardInterrupt: Logs.pprint('RED', 'Interrupted') sys.exit(68)
def __init__(self, global_context, cmd_argv, options_context, pkg, run_node): super(BuildWafContext, self).__init__(global_context, cmd_argv, options_context, pkg, run_node) o, a = options_context.parser.parse_args(cmd_argv) if o.jobs: jobs = int(o.jobs) else: jobs = 1 if o.verbose: verbose = int(o.verbose) zones = ["runner"] else: verbose = 0 zones = [] if o.inplace: self.inplace = 1 else: self.inplace = 0 if o.progress_bar: self.progress_bar = True else: self.progress_bar = False Logs.verbose = verbose Logs.init_log() if zones is None: Logs.zones = [] else: Logs.zones = zones run_path = self.run_node.abspath() source_path = self.top_node.abspath() build_path = self.build_node.abspath() _init(run_path=run_path, source_path=source_path, build_path=build_path) create_context("options").parse_args([]) waf_context = create_context("build") waf_context.restore() if not waf_context.all_envs: waf_context.load_envs() waf_context.jobs = jobs waf_context.timer = Utils.Timer() if self.progress_bar: waf_context.progress_bar = 1 waf_context.bento_context = self self.waf_context = waf_context def _default_extension_builder(extension, **kw): if not "features" in kw: kw["features"] = "c cshlib pyext bento" if not "source" in kw: kw["source"] = extension.sources[:] if not "name" in kw: kw["name"] = extension.name return self.waf_context(**kw) def _default_library_builder(library, **kw): if not "features" in kw: kw["features"] = "c cstlib pyext bento" if not "source" in kw: kw["source"] = library.sources[:] if not "name" in kw: kw["name"] = library.name return self.waf_context(**kw) self.builder_registry.register_category("extensions", _default_extension_builder) self.builder_registry.register_category("compiled_libraries", _default_library_builder)
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): """ 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) 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 # 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: 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.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(25) # 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)