def __init__(self, cc=None, x64=False, ver0=None): self.x64 = x64 patch_os_env(self.externals) self.c_environ = os.environ.copy() if cc is None: # prefer compiler used to build host. Python2 only if ver0 is None: ver0 = _get_vcver0() msvc_compiler_environ, self.vsver = find_msvc_env(x64, ver0=ver0) Platform.__init__(self, 'cl.exe') if msvc_compiler_environ: self.c_environ.update(msvc_compiler_environ) if x64: self.externals_branch = 'win34_%d' % self.vsver else: self.externals_branch = 'win32_%d' % self.vsver else: self.cc = cc # detect version of current compiler try: returncode, stdout, stderr = _run_subprocess(self.cc, [], env=self.c_environ) except EnvironmentError: log.msg('Could not run %s using PATH=\n%s' %(self.cc, '\n'.join(self.c_environ['PATH'].split(';')))) raise r = re.search(r'Microsoft.+C/C\+\+.+\s([0-9]+)\.([0-9]+).*', stderr) if r is not None: self.version = int(''.join(r.groups())) / 10 - 60 else: # Probably not a msvc compiler... self.version = 0 # Try to find a masm assembler returncode, stdout, stderr = _run_subprocess('ml.exe', [], env=self.c_environ) r = re.search('Macro Assembler', stderr) if r is None and os.path.exists('c:/masm32/bin/ml.exe'): masm32 = 'c:/masm32/bin/ml.exe' masm64 = 'c:/masm64/bin/ml64.exe' else: masm32 = 'ml.exe' masm64 = 'ml64.exe' if x64: self.masm = masm64 else: self.masm = masm32 # Install debug options only when interpreter is in debug mode if sys.executable.lower().endswith('_d.exe'): self.cflags = ['/MDd', '/Z7', '/Od'] # Increase stack size, for the linker and the stack check code. stack_size = 8 << 20 # 8 Mb self.link_flags = self.link_flags + ('/STACK:%d' % stack_size,) # The following symbol is used in c/src/stack.h self.cflags.append('/DMAX_STACK_SIZE=%d' % (stack_size - 1024))
def __init__(self, cc=None, x64=False): self.x64 = x64 if cc is None: msvc_compiler_environ = find_msvc_env(x64) Platform.__init__(self, 'cl.exe') if msvc_compiler_environ: self.c_environ = os.environ.copy() self.c_environ.update(msvc_compiler_environ) else: self.cc = cc # detect version of current compiler returncode, stdout, stderr = _run_subprocess(self.cc, '', env=self.c_environ) r = re.search(r'Microsoft.+C/C\+\+.+\s([0-9]+)\.([0-9]+).*', stderr) if r is not None: self.version = int(''.join(r.groups())) / 10 - 60 else: # Probably not a msvc compiler... self.version = 0 # Try to find a masm assembler returncode, stdout, stderr = _run_subprocess('ml.exe', '', env=self.c_environ) r = re.search('Macro Assembler', stderr) if r is None and os.path.exists('c:/masm32/bin/ml.exe'): masm32 = 'c:/masm32/bin/ml.exe' masm64 = 'c:/masm64/bin/ml64.exe' else: masm32 = 'ml.exe' masm64 = 'ml64.exe' if x64: self.masm = masm64 else: self.masm = masm32 # Install debug options only when interpreter is in debug mode if sys.executable.lower().endswith('_d.exe'): self.cflags = ['/MDd', '/Z7', '/Od'] # Increase stack size, for the linker and the stack check code. stack_size = 8 << 20 # 8 Mb self.link_flags.append('/STACK:%d' % stack_size) # The following symbol is used in c/src/stack.h self.cflags.append('/DMAX_STACK_SIZE=%d' % (stack_size - 1024))
def _pkg_config(self, lib, opt, default, check_result_dir=False): try: pkg_config = os.environ.get('PKG_CONFIG', 'pkg-config') ret, out, err = _run_subprocess(pkg_config, [lib, opt]) except OSError as e: err = str(e) ret = 1 if ret: result = default else: # strip compiler flags result = [entry[2:] for entry in out.split()] # if not result: pass # if pkg-config explicitly returned nothing, then # we assume it means no options are needed elif check_result_dir: # check that at least one of the results is a valid dir for check in result: if os.path.isdir(check): break else: if ret: msg = ("running 'pkg-config %s %s' failed:\n%s\n" "and the default %r is not a valid directory" % ( lib, opt, err.rstrip(), default)) else: msg = ("'pkg-config %s %s' returned no valid directory:\n" "%s\n%s" % (lib, opt, out.rstrip(), err.rstrip())) raise ValueError(msg) return result
def execute_makefile(self, path_to_makefile, extra_opts=[]): if isinstance(path_to_makefile, GnuMakefile): path = path_to_makefile.makefile_dir else: path = path_to_makefile log.execute("make %s in %s" % (" ".join(extra_opts), path)) returncode, stdout, stderr = _run_subprocess(self.make_cmd, ["-C", str(path)] + extra_opts) self._handle_error(returncode, stdout, stderr, path.join("make"))
def __init__(self, cc=None, x64=False): self.x64 = x64 msvc_compiler_environ = find_msvc_env(x64) Platform.__init__(self, 'cl.exe') if msvc_compiler_environ: self.c_environ = os.environ.copy() self.c_environ.update(msvc_compiler_environ) # XXX passing an environment to subprocess is not enough. Why? os.environ.update(msvc_compiler_environ) # detect version of current compiler returncode, stdout, stderr = _run_subprocess(self.cc, '', env=self.c_environ) r = re.search(r'Microsoft.+C/C\+\+.+\s([0-9]+)\.([0-9]+).*', stderr) if r is not None: self.version = int(''.join(r.groups())) / 10 - 60 else: # Probably not a msvc compiler... self.version = 0 # Try to find a masm assembler returncode, stdout, stderr = _run_subprocess('ml.exe', '', env=self.c_environ) r = re.search('Macro Assembler', stderr) if r is None and os.path.exists('c:/masm32/bin/ml.exe'): masm32 = 'c:/masm32/bin/ml.exe' masm64 = 'c:/masm64/bin/ml64.exe' else: masm32 = 'ml.exe' masm64 = 'ml64.exe' if x64: self.masm = masm64 else: self.masm = masm32 # Install debug options only when interpreter is in debug mode if sys.executable.lower().endswith('_d.exe'): self.cflags = ['/MDd', '/Z7', '/Od'] self.link_flags = ['/debug'] # Increase stack size, for the linker and the stack check code. stack_size = 8 << 20 # 8 Mb self.link_flags.append('/STACK:%d' % stack_size) # The following symbol is used in c/src/stack.h self.cflags.append('/DMAX_STACK_SIZE=%d' % (stack_size - 1024))
def execute_makefile(self, path_to_makefile, extra_opts=[]): if isinstance(path_to_makefile, GnuMakefile): path = path_to_makefile.makefile_dir else: path = path_to_makefile log.execute('make %s in %s' % (" ".join(extra_opts), path)) returncode, stdout, stderr = _run_subprocess( self.make_cmd, ['-C', str(path)] + extra_opts) self._handle_error(returncode, stdout, stderr, path.join('make'))
def _pkg_config(self, lib, opt, default): try: ret, out, err = _run_subprocess("pkg-config", [lib, opt]) except OSError: ret = 1 if ret: return default # strip compiler flags return [entry[2:] for entry in out.split()]
def execute_makefile(self, path_to_makefile, extra_opts=[]): if isinstance(path_to_makefile, GnuMakefile): path = path_to_makefile.makefile_dir else: path = path_to_makefile log.execute('make %s in %s' % (" ".join(extra_opts), path)) env = os.environ.copy() returncode, stdout, stderr = _run_subprocess( self.make_cmd, ['-C', str(path)] + extra_opts, env=env) self._handle_error(returncode, stdout, stderr, path.join('make'))
def __init__(self, cc=None, x64=False): self.x64 = x64 msvc_compiler_environ = find_msvc_env(x64) Platform.__init__(self, "cl.exe") if msvc_compiler_environ: self.c_environ = os.environ.copy() self.c_environ.update(msvc_compiler_environ) # detect version of current compiler returncode, stdout, stderr = _run_subprocess(self.cc, "", env=self.c_environ) r = re.search(r"Microsoft.+C/C\+\+.+\s([0-9]+)\.([0-9]+).*", stderr) if r is not None: self.version = int("".join(r.groups())) / 10 - 60 else: # Probably not a msvc compiler... self.version = 0 # Try to find a masm assembler returncode, stdout, stderr = _run_subprocess("ml.exe", "", env=self.c_environ) r = re.search("Macro Assembler", stderr) if r is None and os.path.exists("c:/masm32/bin/ml.exe"): masm32 = "c:/masm32/bin/ml.exe" masm64 = "c:/masm64/bin/ml64.exe" else: masm32 = "ml.exe" masm64 = "ml64.exe" if x64: self.masm = masm64 else: self.masm = masm32 # Install debug options only when interpreter is in debug mode if sys.executable.lower().endswith("_d.exe"): self.cflags = ["/MDd", "/Z7", "/Od"] self.link_flags = ["/debug"] # Increase stack size, for the linker and the stack check code. stack_size = 8 << 20 # 8 Mb self.link_flags.append("/STACK:%d" % stack_size) # The following symbol is used in c/src/stack.h self.cflags.append("/DMAX_STACK_SIZE=%d" % (stack_size - 1024))
def __init__(self, cc=None, x64=False, ver0=None): self.x64 = x64 patch_os_env(self.externals) self.c_environ = os.environ.copy() if cc is None: msvc_compiler_environ, self.vsver = find_msvc_env(x64, ver0=ver0) Platform.__init__(self, 'cl.exe') if msvc_compiler_environ: self.c_environ.update(msvc_compiler_environ) self.version = "MSVC %s" % str(self.vsver) if self.vsver > 90: tag = '14x' else: tag = '%d' % self.vsver if x64: self.externals_branch = 'win64_%s' % tag else: self.externals_branch = 'win32_%s' % tag else: self.cc = cc # Try to find a masm assembler # Dilemma: raise now or later if masm is not found. Postponing the # exception means we can use a fake compiler for testing on linux # but may mean cryptic error messages and wasted build time. try: returncode, stdout, stderr = _run_subprocess( 'ml.exe' if not x64 else 'ml64.exe', [], env=self.c_environ) r = re.search('Macro Assembler', stderr) except (EnvironmentError, OSError): r = None masm32 = "'Could not find ml.exe'" masm64 = "'Could not find ml.exe'" if r is None and os.path.exists('c:/masm32/bin/ml.exe'): masm32 = 'c:/masm32/bin/ml.exe' masm64 = 'c:/masm64/bin/ml64.exe' elif r: masm32 = 'ml.exe' masm64 = 'ml64.exe' if x64: self.masm = masm64 else: self.masm = masm32 # Install debug options only when interpreter is in debug mode if sys.executable.lower().endswith('_d.exe'): self.cflags = ['/MDd', '/Z7', '/Od'] # Increase stack size, for the linker and the stack check code. stack_size = 8 << 20 # 8 Mb self.link_flags = self.link_flags + ('/STACK:%d' % stack_size,) # The following symbol is used in c/src/stack.h self.cflags.append('/DMAX_STACK_SIZE=%d' % (stack_size - 1024))
def execute_makefile(self, path_to_makefile, extra_opts=[]): if isinstance(path_to_makefile, NMakefile): path = path_to_makefile.makefile_dir else: path = path_to_makefile log.execute("make %s in %s" % (" ".join(extra_opts), path)) oldcwd = path.chdir() try: returncode, stdout, stderr = _run_subprocess( "nmake", ["/nologo", "/f", str(path.join("Makefile"))] + extra_opts, env=self.c_environ ) finally: oldcwd.chdir() self._handle_error(returncode, stdout, stderr, path.join("make"))
def execute_makefile(self, path_to_makefile, extra_opts=[]): if isinstance(path_to_makefile, NMakefile): path = path_to_makefile.makefile_dir else: path = path_to_makefile log.execute('make %s in %s' % (" ".join(extra_opts), path)) oldcwd = path.chdir() try: returncode, stdout, stderr = _run_subprocess( 'nmake', ['/nologo', '/f', str(path.join('Makefile'))] + extra_opts) finally: oldcwd.chdir() self._handle_error(returncode, stdout, stderr, path.join('make'))
def execute_makefile(self, path_to_makefile, extra_opts=[]): if isinstance(path_to_makefile, NMakefile): path = path_to_makefile.makefile_dir else: path = path_to_makefile log.execute('%s %s in %s' % (self.make, " ".join(extra_opts), path)) oldcwd = path.chdir() try: returncode, stdout, stderr = _run_subprocess( self.make, ['/nologo', '/f', str(path.join('Makefile'))] + extra_opts, env=self.c_environ) finally: oldcwd.chdir() self._handle_error(returncode, stdout, stderr, path.join('make'))
def __init__(self, cc=None, x64=False, ver0=None): self.x64 = x64 patch_os_env(self.externals) self.c_environ = os.environ.copy() if cc is None: msvc_compiler_environ, self.vsver = find_msvc_env(x64, ver0=ver0) Platform.__init__(self, 'cl.exe') if msvc_compiler_environ: self.c_environ.update(msvc_compiler_environ) self.version = "MSVC %s" % str(self.vsver) if self.vsver > 90: tag = '14x' else: tag = '%d' % self.vsver if x64: self.externals_branch = 'win64_%s' % tag else: self.externals_branch = 'win32_%s' % tag else: self.cc = cc # Try to find a masm assembler returncode, stdout, stderr = _run_subprocess( 'ml.exe' if not x64 else 'ml64.exe', [], env=self.c_environ) r = re.search('Macro Assembler', stderr) if r is None and os.path.exists('c:/masm32/bin/ml.exe'): masm32 = 'c:/masm32/bin/ml.exe' masm64 = 'c:/masm64/bin/ml64.exe' else: masm32 = 'ml.exe' masm64 = 'ml64.exe' if x64: self.masm = masm64 else: self.masm = masm32 # Install debug options only when interpreter is in debug mode if sys.executable.lower().endswith('_d.exe'): self.cflags = ['/MDd', '/Z7', '/Od'] # Increase stack size, for the linker and the stack check code. stack_size = 8 << 20 # 8 Mb self.link_flags = self.link_flags + ('/STACK:%d' % stack_size, ) # The following symbol is used in c/src/stack.h self.cflags.append('/DMAX_STACK_SIZE=%d' % (stack_size - 1024))
def _pkg_config(self, lib, opt, default, check_result_dir=False): try: ret, out, err = _run_subprocess("pkg-config", [lib, opt]) except OSError, e: err = str(e) ret = 1
def _pkg_config(self, lib, opt, default, check_result_dir=False): try: ret, out, err = _run_subprocess("pkg-config", [lib, opt]) except OSError, e: err = str(e) ret = 1