def __init__(self, sourcePath, buildPath, originalCwd, options, args): super(ContextManager, self).__init__(sourcePath, buildPath, originalCwd, options, args) self.contextStack_.append(None) # This is a hack... if we ever do cross-compiling or something, we'll have # to change this. self.host_platform = util.Platform() self.target_platform = util.Platform()
def __init__(self, sourcePath, buildPath): self.sourcePath = sourcePath self.buildPath = buildPath self.host_platform = util.Platform() self.target_platform = util.Platform() self.options = OptionParser("usage: %prog [options]") self.options.add_option( "-g", "--gen", type="string", dest="generator", default="ambuild2", help="Build system generator to use. See --list-gen") self.options.add_option( "--list-gen", action="store_true", dest="list_gen", default=False, help="List available build system generators, then exit.") self.options.add_option( "--make-scripts", action="store_true", dest="make_scripts", default=False, help= "Generate extra command-line files for building (build.py, Makefile)." ) self.options.add_option("--no-color", action="store_true", dest="no_color", default=False, help="Disable color output in the terminal.") self.options.add_option( "--symbol-files", action="store_true", dest="symbol_files", default=False, help= "Split debugging symbols from binaries into separate symbol files." ) # Generator specific options. self.options.add_option("--vs-version", type="string", dest="vs_version", default="10", help=SUPPRESS_HELP) self.options.add_option("--vs-split", action='store_true', dest="vs_split", default=False, help=SUPPRESS_HELP)
def DetectCxxCompiler(env, var): if var in env: trys = [env[var]] else: if util.Platform() in CompilerSearch[var]: trys = CompilerSearch[var][util.Platform()] else: trys = CompilerSearch[var]['default'] for i in trys: cc = TryVerifyCompiler(env, var, i) if cc: return cc raise Exception('Unable to find a suitable ' + var + ' compiler')
def __init__(self, sourcePath, buildPath, originalCwd, options, args): self.sourcePath = sourcePath self.buildPath = os.path.normpath(buildPath) self.originalCwd = originalCwd self.options = options self.args = args self.contextStack_ = [None] self.configure_failed = False # This is a hack... if we ever do cross-compiling or something, we'll have # to change this. self.host_platform = util.Platform() self.target_platform = util.Platform()
def DetectCxxCompiler(env, var): if var in env: trys = [env[var]] else: if util.Platform() in CompilerSearch[var]: trys = CompilerSearch[var][util.Platform()] else: trys = CompilerSearch[var]['default'] for i in trys: result = FindCompiler(env, var, i) if result is not None: return result raise Exception('Unable to find a suitable ' + var + ' compiler')
def detect(self): if 'CC' in os.environ or 'CXX' in os.environ: return self.detect_from_env() if util.Platform() == 'windows': compiler = self.detect_msvc() if compiler: return compiler return self.find_default_compiler()
def DetectCxxCompiler(env, var): if var in env: trys = [env[var]] else: if util.Platform() in CompilerSearch[var]: trys = CompilerSearch[var][util.Platform()] else: trys = CompilerSearch[var]['default'] for i in trys: cc = TryVerifyCompiler(env, var, i) if cc: return cc # Try for Emscripten. This only works with an env override. if 'emcc' in env.get(var, ''): cc = DetectEmscripten(env, var) if cc: return cc # Fail. raise Exception('Unable to find a suitable ' + var + ' compiler')
def find_default_compiler(self): candidates = [] if util.Platform() == 'windows': candidates.append(kMsvcTuple) candidates.extend([kClangTuple, kGccTuple, kIntelTuple]) for cc_cmd, cxx_cmd, cc_family in candidates: cc = self.find_compiler(os.environ, 'CC', cc_cmd, cc_family) if cc is None: continue cxx = self.find_compiler(os.environ, 'CXX', cxx_cmd, cc_family) if cxx is not None: return self.create_cli(cc, cxx) raise CompilerNotFoundException('Unable to find a suitable C/C++ compiler')
def find_compiler(self, env, mode, cmd, cc_family=None): families = [] if "EMSDK" in env and cmd[:2] == 'em': families.append('emscripten') if cc_family is not None: families.append(cc_family) else: # On Windows, check for MSVC compatibility before checking GCC. if util.Platform() == 'windows': families.append('msvc') families.append('gcc') for family in families: compiler, e = self.run_compiler(env, mode, cmd, family) if compiler is not None: return compiler if isinstance(e, CompilerNotFoundException): # No reason to keep trying the same command. break return None
def make_objdir_name(p): return 'obj-' + util.Platform() + '-' + p.target_arch
def default_build_folder(prep): return 'obj-' + util.Platform() + '-' + platform.machine()
# # AMBuild is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with AMBuild. If not, see <http://www.gnu.org/licenses/>. from ambuild2 import util class System(object): def __init__(self, platform, arch, subarch = ''): super(System, self).__init__() self.platform_ = platform self.arch_ = arch self.subarch_ = subarch @property def platform(self): return self.platform_ @property def arch(self): return self.arch_ @property def subarch(self): return self.subarch_ System.Host = System(util.Platform(), util.Architecture, util.SubArch)
if util.IsWindows() or util.IsCygwin(): # Cygwin doesn't support SCM_RIGHTS (which, I guess, is actually unused) # but more importantly posix_spawn(), so we just cheat and use WinAPI # directly, ignoring the sketchy Unix layer. from . import windows as ipc_impl elif util.IsLinux(): from . import linux as ipc_impl elif util.IsBSD(): from . import bsd as ipc_impl else: import select if hasattr(select, 'poll'): from . import generic_poll as ipc_impl else: raise Exception('Unknown platform: ' + util.Platform()) ProcessManager = ipc_impl.ProcessManager MessagePump = ipc_impl.MessagePump if util.IsWindows() or util.IsCygwin(): from .windows import NamedPipe as Channel else: from .posix_proc import SocketChannel as Channel class ChildWrapperListener(process.MessageListener): def __init__(self, mp, channel): super(ChildWrapperListener, self).__init__() self.mp = mp self.channel = channel
super(System, self).__init__() self.platform_ = platform self.arch_ = arch self.subarch_ = subarch self.abi_ = abi @property def platform(self): return self.platform_ @property def arch(self): return self.arch_ @property def subarch(self): return self.subarch_ @property def abi(self): return self.abi_ @property def triple(self): suffix = '' if self.abi: suffix += '-' + self.abi return '{}-{}{}{}'.format(self.platform, self.arch, self.subarch, suffix) System.Host = System(util.Platform(), util.Architecture, util.SubArch, util.DetectHostAbi())