def msbuild(args, **options): system = platform.uname().system if system.startswith("MSYS_NT") or system.startswith("MINGW"): isMSYS = True elif system == "Windows": isMSYS = False else: raise ParseError("Unsupported system for $(msbuild,...): " + system) try: vswargs = (os.path.join( os.environ["ProgramFiles(x86)"], "Microsoft Visual Studio/Installer/vswhere.exe"), '-find', 'MSBuild\**\Bin\MSBuild.exe', '-latest', '-products', '*', '-requires', 'Microsoft.Component.MSBuild') path = subprocess.check_output(vswargs, universal_newlines=True).strip() if isMSYS: path = subprocess.check_output(["cygpath", "-u", "-p", path], universal_newlines=True).strip() path = subprocess.check_output(["dirname", path], universal_newlines=True).strip() else: pass return path except (OSError, subprocess.SubprocessError) as e: raise ParseError("$(msbuild) failed: " + str(e))
def vsvars2019(args, **options): if len(args) < 2: raise ParseError( "$(vsvars2019,VAR,ARCH,...) expects at least two arguments") system = platform.uname().system if system.startswith("MSYS_NT"): isMSYS = True elif system == "Windows": isMSYS = False else: raise ParseError("Unsupported system for $(vsvars2019,...): " + system) try: varname = args[0] vsvars_args = args[1:] vswargs = (os.path.join( os.environ["ProgramFiles(x86)"], "Microsoft Visual Studio/Installer/vswhere.exe"), '-property', 'installationPath', '-version', '[16.0,17.0)', '-products', '*', '-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64') tag = tuple(vsvars_args) if tag not in cache: r = subprocess.check_output(vswargs, universal_newlines=True).strip() vsvarsall = os.path.join(r, "VC/Auxiliary/Build/vcvarsall.bat") r = subprocess.check_output([vsvarsall] + vsvars_args + ['&&', 'set'], universal_newlines=True) env = {} for l in r.splitlines(): k, sep, v = l.strip().partition("=") k = k.upper() if k == 'PATH' and isMSYS: # convert to POSIX path to be mergeable v = subprocess.check_output( ["cygpath", "-u", "-p", v], universal_newlines=True).strip() env[k] = v cache[tag] = env return cache[tag][varname] except (OSError, subprocess.SubprocessError) as e: raise ParseError("$(vsvars2019) failed: " + str(e))
def hostAutoconf(args, **options): machine = hostArch(None) system = platform.uname().system if system == 'Linux': return machine + "-linux-gnu" elif system.startswith("MSYS_NT"): return machine + "-pc-msys" elif system == "Windows": return machine + "-pc-win32" else: raise ParseError("Unsupported system: " + system)
def override(args, env, recipe, **options): if len(args) != 2: raise ParseError("override expects two arguments") if args[0] in env: o = env[args[0]] o = [i.split(":") for i in o.split(",")] o = {k: v for (k, v) in o} return o.get(recipe.getPackageName(), args[1]) else: return args[1]
def hostArch(args, **options): m = os.uname().machine if m == "x86_64": return m elif m.startswith("i"): return "i386" elif m.startswith("aarch64"): return "arm64" elif m.startswith("arm"): return "arm" else: raise ParseError("Unsupported host machine: " + m)
def genAutoconf(args, **options): if len(args) != 1: raise ParseError("$(gen-autoconf,vendor) expects one argument") machine, _, system = hostAutoconf(None).partition("-") return machine + '-' + args[0] + '-' + system
def genAutoconf(args, **options): if len(args) != 1: raise ParseError("$(gen-autoconf,vendor) expects one argument") u = os.uname() return u.machine + '-' + args[0] + '-linux-gnu'
def hostAutoconf(args, **options): u = os.uname() if u.sysname != 'Linux': raise ParseError("Unsupported system: " + u.sysname) return u.machine + "-linux-gnu"