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 execute(self): """ See :py:func:`waflib.Context.Context.execute` """ self.init_dirs() Logs.info("[WAF] Executing 'configure'") self.cachedir = self.bldnode.make_node(Build.CACHE_DIR) self.cachedir.mkdir() path = os.path.join(self.bldnode.abspath(), WAF_CONFIG_LOG) self.logger = Logs.make_logger(path, 'cfg') app = getattr(Context.g_module, 'APPNAME', '') if app: ver = getattr(Context.g_module, 'VERSION', '') if ver: app = "%s (%s)" % (app, ver) now = time.ctime() pyver = sys.hexversion systype = sys.platform args = " ".join(sys.argv) wafver = Context.WAFVERSION abi = Context.ABI self.to_log(conf_template % vars()) if id(self.srcnode) == id(self.bldnode): Logs.warn('Setting top == out (remember to use "update_outputs")') elif id(self.path) != id(self.srcnode): if self.srcnode.is_child_of(self.path): Logs.warn( 'Are you certain that you do not want to set top="." ?') super(ConfigurationContext, self).execute() self.store() Context.top_dir = self.srcnode.abspath() Context.out_dir = self.bldnode.abspath() # import waf branch spec branch_spec_globals = Context.load_branch_spec(Context.top_dir) Context.lock_dir = Context.run_dir + os.sep + branch_spec_globals[ 'BINTEMP_FOLDER'] # this will write a configure lock so that subsequent builds will # consider the current path as the root directory (see prepare_impl). # to remove: use 'waf distclean' env = ConfigSet.ConfigSet() env['argv'] = sys.argv env['options'] = Options.options.__dict__ env.run_dir = Context.run_dir env.top_dir = Context.top_dir env.out_dir = Context.out_dir env.lock_dir = Context.lock_dir # Add lmbr_waf.bat or lmbr_waf for dependency tracking ############################################################################### waf_command = os.path.basename(sys.executable) if waf_command.lower() == 'python' or waf_command.lower( ) == 'python.exe': waf_executable = self.engine_node.make_node( './Tools/build/waf-1.7.13/lmbr_waf') else: waf_executable = self.path.make_node(waf_command) self.hash = hash((self.hash, waf_executable.read('rb'))) self.files.append(os.path.normpath(waf_executable.abspath())) # conf.hash & conf.files hold wscript files paths and hash # (used only by Configure.autoconfig) env['hash'] = self.hash env['files'] = self.files env['environ'] = dict(self.environ) env.store(Context.lock_dir + os.sep + Options.lockfile)
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 execute(self): """ See :py:func:`waflib.Context.Context.execute` """ self.init_dirs() Logs.info("[WAF] Executing 'configure'") self.cachedir = self.bldnode.make_node(Build.CACHE_DIR) self.cachedir.mkdir() path = os.path.join(self.bldnode.abspath(), WAF_CONFIG_LOG) self.logger = Logs.make_logger(path, "cfg") app = getattr(Context.g_module, "APPNAME", "") if app: ver = getattr(Context.g_module, "VERSION", "") if ver: app = "%s (%s)" % (app, ver) now = time.ctime() pyver = sys.hexversion systype = sys.platform args = " ".join(sys.argv) wafver = Context.WAFVERSION abi = Context.ABI self.to_log(conf_template % vars()) if id(self.srcnode) == id(self.bldnode): Logs.warn('Setting top == out (remember to use "update_outputs")') elif id(self.path) != id(self.srcnode): if self.srcnode.is_child_of(self.path): Logs.warn('Are you certain that you do not want to set top="." ?') super(ConfigurationContext, self).execute() self.store() Context.top_dir = self.srcnode.abspath() Context.out_dir = self.bldnode.abspath() # import waf branch spec branch_spec_globals = Context.load_branch_spec(Context.top_dir) Context.lock_dir = Context.run_dir + os.sep + branch_spec_globals["BINTEMP_FOLDER"] # this will write a configure lock so that subsequent builds will # consider the current path as the root directory (see prepare_impl). # to remove: use 'waf distclean' env = ConfigSet.ConfigSet() env["argv"] = sys.argv env["options"] = Options.options.__dict__ env.run_dir = Context.run_dir env.top_dir = Context.top_dir env.out_dir = Context.out_dir env.lock_dir = Context.lock_dir # Add cry_waf.exe for dependency tracking cry_waf_exe_node = self.path.make_node("cry_waf.exe") self.hash = hash((self.hash, cry_waf_exe_node.read("rb"))) self.files.append(os.path.normpath(cry_waf_exe_node.abspath())) # conf.hash & conf.files hold wscript files paths and hash # (used only by Configure.autoconfig) env["hash"] = self.hash env["files"] = self.files env["environ"] = dict(self.environ) env.store(Context.lock_dir + os.sep + Options.lockfile)