Exemple #1
0
class ConfigMeson():
    def __init__(self, platformData):
        self.storeTemp = StoreTemp(".vgazer/meson")
        self.crossFileName = self.storeTemp.GetDirectoryFilePath("cross-file")
        self.storeTemp.ResolveDirectory()
        self.platformData = platformData

    def GetCrossFileName(self):
        return self.crossFileName

    def GenerateCrossFile(self):
        print("VGAZER: Generating Meson cross-build definition file...")
        ar = GetAr(self.platformData["target"])
        cc = GetCc(self.platformData["target"])
        cxx = GetCxx(self.platformData["target"])
        pkgConfig = GetPkgConfig(self.platformData["target"])
        strip = GetStrip(self.platformData["target"])
        llvmConfig = GetLlvmConfig(self.platformData["target"])
        genericOs = Platform.GetGenericOs(self.platformData["target"].GetOs())
        if self.platformData["target"].GetArch() in [
                "i386", "i486", "i586", "i686"
        ]:
            mesonCpuFamily = "x86"
            mesonCpu = self.platformData["target"].GetArch()
        elif self.platformData["target"].GetArch() == "x86_64":
            mesonCpuFamily = "x86_64"
            mesonCpu = "x86_64"
        else:
            raise UnknownTargetArch("Unknown target architecture: " +
                                    self.platformData["target"].GetArch())

        self.storeTemp.DirectoryWriteTextFile(
            "cross-file", "[binaries]\n"
            "c = '{cc}'\n"
            "cpp = '{cxx}'\n"
            "ar = '{ar}'\n"
            "strip = '{strip}'\n"
            "pkgconfig = '{pkgConfig}'\n"
            "llvm-config = '{llvmConfig}'\n"
            "\n"
            "[host_machine]\n"
            "system = '{genericOs}'\n"
            "cpu_family = '{mesonCpuFamily}'\n"
            "cpu = '{mesonCpu}'\n"
            "endian = 'little'".format(ar=ar,
                                       cc=cc,
                                       cxx=cxx,
                                       pkgConfig=pkgConfig,
                                       llvmConfig=llvmConfig,
                                       strip=strip,
                                       genericOs=genericOs,
                                       mesonCpuFamily=mesonCpuFamily,
                                       mesonCpu=mesonCpu))
Exemple #2
0
class ConfigCmake():
    def __init__(self, platformData):
        self.storeTemp = StoreTemp(".vgazer/cmake")
        self.crossFileName = self.storeTemp.GetDirectoryFilePath(
            "toolchain.cmake")
        self.storeTemp.ResolveDirectory()
        self.platformData = platformData

    def GetCrossFileName(self):
        return self.crossFileName

    def GenerateCrossFile(self):
        print("VGAZER: Generating CMake toolchain file...")
        cmakeOs = Platform.GetGenericOs(
            self.platformData["target"].GetOs()).capitalize()
        prefix = GetInstallPrefix(self.platformData)
        targetTriplet = GetTriplet(self.platformData["target"])

        cc = GetCc(self.platformData["target"])
        cxx = GetCxx(self.platformData["target"])

        if self.platformData["target"].PlatformsEqual(
                self.platformData["host"]):
            findMode = "BOTH"
        else:
            findMode = "ONLY"

        self.storeTemp.DirectoryWriteTextFile(
            "toolchain.cmake", "set(CMAKE_SYSTEM_NAME {cmakeOs})\n"
            "set(CMAKE_SYSTEM_PROCESSOR {cpu})\n"
            "set(CMAKE_C_COMPILER {cc})\n"
            "set(CMAKE_CXX_COMPILER {cxx})\n"
            "set(CMAKE_FIND_ROOT_PATH {prefix})\n"
            "SET("
            "ENV{{PKG_CONFIG_LIBDIR}} "
            "${{CMAKE_FIND_ROOT_PATH}}/lib/pkgconfig/:"
            "/usr/lib/{triplet}/pkgconfig"
            ")\n"
            "SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\n"
            "SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY {findMode})\n"
            "SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE {findMode})".format(
                cmakeOs=cmakeOs,
                cpu=self.platformData["target"].GetArch(),
                cc=cc,
                cxx=cxx,
                prefix=prefix,
                triplet=targetTriplet,
                findMode=findMode))