コード例 #1
0
def __BuildTargetLinkLibrariesForDirectExternalDependencies(log: Log, package: Package,
                                                            resolvedDirectExternalDependencies: Union[List[PackageExternalDependency], List[PackagePlatformExternalDependency]],
                                                            ignoreLibs: Optional[List[str]] = None) -> str:
    if ignoreLibs is None:
        ignoreLibs = []

    isExternalLibrary = package.Type == PackageType.ExternalLibrary

    deps = ""
    for entry in resolvedDirectExternalDependencies:
        libraryName = LibUtil.ToUnixLibName(entry.Name)
        if libraryName not in ignoreLibs:
            if entry.Type == ExternalDependencyType.StaticLib or (entry.Type == ExternalDependencyType.DLL and entry.Name.lower().endswith(".so")):
                location = entry.Location if entry.Location is not None and (entry.IsManaged or not isExternalLibrary) else ""
                libraryName = libraryName if len(location) <= 0 else entry.Name
                fullPathLinkDir = Util.ChangeToCMakeEnvVariables(IOUtil.Join(location, libraryName))
                if entry.DebugName != entry.Name:
                    deps += "\n  {0} optimized {1}".format(GetAccessTypeString(package, entry.Access, False), fullPathLinkDir)
                    libraryName = LibUtil.ToUnixLibName(entry.DebugName)
                    fullPathLinkDir = Util.ChangeToCMakeEnvVariables(IOUtil.Join(location, libraryName))
                    deps += "\n  {0} debug {1}".format(GetAccessTypeString(package, entry.Access, False), fullPathLinkDir)
                else:
                    deps += "\n  {0} {1}".format(GetAccessTypeString(package, entry.Access, False), fullPathLinkDir)
            if entry.Type == ExternalDependencyType.Find:
                linkName = "${%s_LIBRARY}" % (libraryName)
                deps += "\n  {0} {1}".format(GetAccessTypeString(package, entry.Access, False), linkName)
        else:
            log.LogPrintVerbose(2, "INFO: Force ignored '{0}'".format(libraryName))
    return deps
コード例 #2
0
def __TryTargetIncludeDirectoriesGetExternalDependencyString(config: Config, package: Package,
                                                             directExternalDeps: Union[PackageExternalDependency, PackagePlatformExternalDependency],
                                                             templatePackageTargetIncludeDirEntry: str,
                                                             templatePackageTargetIncludeDirVirtualEntry: str, pathType: int) -> Optional[str]:
    add = None # type: Optional[str]
    relativeCurrentIncDir = None # type: Optional[str]
    if directExternalDeps.Type != ExternalDependencyType.Find:
        currentIncDir = directExternalDeps.Include
        if currentIncDir is not None:
            if package.AbsolutePath is None:
                raise Exception("Invalid package")
            packageRootPath = config.ToPath(package.AbsolutePath)
            if currentIncDir.startswith(packageRootPath):
                relativeCurrentIncDir = currentIncDir[len(packageRootPath)+1:] if pathType == CMakePathType.LocalRelative else Util.ChangeToCMakeVariables(currentIncDir)
                add = "\n" + __GenerateDirEntryString(GetAccessTypeString(package, directExternalDeps.Access), relativeCurrentIncDir, templatePackageTargetIncludeDirEntry)
            else:
                currentTemplate = templatePackageTargetIncludeDirEntry
                relativeCurrentIncDir = config.TryToPath(currentIncDir)
                if relativeCurrentIncDir is None:
                    relativeCurrentIncDir = currentIncDir
                if pathType != CMakePathType.LocalRelative:
                    relativeCurrentIncDir = Util.ChangeToCMakeVariables(relativeCurrentIncDir)
                else:
                    relativeCurrentIncDir = Util.ChangeToCMakeEnvVariables(relativeCurrentIncDir)
                    currentTemplate = templatePackageTargetIncludeDirVirtualEntry

                add = "\n" + __GenerateDirEntryString(GetAccessTypeString(package, directExternalDeps.Access), relativeCurrentIncDir, currentTemplate)
    else:
        add = "\n  %s ${%s_INCLUDE_DIRS}" % (GetAccessTypeString(package, directExternalDeps.Access), directExternalDeps.Name)
    return add
コード例 #3
0
def BuildTargetLinkLibrariesForDirectDependencies(
        config: Config,
        package: Package,
        templatePackageDependencyTargetLinkLibraries: str,
        ignoreLibs: Optional[List[str]] = None) -> str:
    if ignoreLibs is None:
        ignoreLibs = []

    if package.ResolvedDirectDependencies is None:
        raise Exception("Invalid package")

    isExternalLibrary = package.Type == PackageType.ExternalLibrary

    deps = ""
    for entry1 in package.ResolvedDirectDependencies:
        if entry1.Package.Type != PackageType.ToolRecipe:
            deps += "\n  {0} {1}".format(
                GetAccessTypeString(package, entry1.Access, False),
                GetPackageName(entry1.Package))


#           deps += "\n  {0} {1}".format(GetAccessTypeString(package, entry1.Access), GetAliasPackageName(entry1.Package))

# FIX: handle debug libraries
    for entry2 in package.ResolvedDirectExternalDependencies:
        libraryName = LibUtil.ToUnixLibName(entry2.Name)
        if libraryName not in ignoreLibs:
            if entry2.Type == ExternalDependencyType.StaticLib:
                location = entry2.Location if entry2.Location and not isExternalLibrary else ""
                fullPathLinkDir = Util.ChangeToCMakeEnvVariables(
                    IOUtil.Join(location, libraryName))
                deps += "\n  {0} {1}".format(
                    GetAccessTypeString(package, entry2.Access, False),
                    fullPathLinkDir)
            if entry2.Type == ExternalDependencyType.Find:
                linkName = "${%s_LIBRARY}" % (libraryName)
                deps += "\n  {0} {1}".format(
                    GetAccessTypeString(package, entry2.Access, False),
                    linkName)
        else:
            config.LogPrintVerbose(
                2, "INFO: Force ignored '{0}'".format(libraryName))

    if len(deps) <= 0:
        return ""

    content = templatePackageDependencyTargetLinkLibraries
    content = content.replace("##PACKAGE_DIRECT_DEPENDENCIES##", deps)
    return content
コード例 #4
0
def BuildTargetIncludeDirectories(
        config: Config,
        package: Package,
        templatePackageTargetIncludeDirectories: str,
        templatePackageTargetIncludeDirEntry: str,
        pathType: int = CMakePathType.Relative) -> str:
    isExternalLibrary = package.Type == PackageType.ExternalLibrary
    publicIncludeDir = ""
    if package.AbsoluteIncludePath:
        pubIncPath = __GetPackageIncludePath(config, package,
                                             package.AbsoluteIncludePath,
                                             pathType)
        accessString = "PUBLIC" if not package.IsVirtual else "INTERFACE"
        publicIncludeDir = "\n" + __GenerateDirEntryString(
            accessString, pubIncPath, templatePackageTargetIncludeDirEntry)
    privateIncludeDir = ""
    if package.AbsoluteSourcePath:
        priIncPath = __GetPackageIncludePath(config, package,
                                             package.AbsoluteSourcePath,
                                             pathType)
        accessString = "PRIVATE" if not package.IsVirtual else "INTERFACE"
        privateIncludeDir = "\n" + __GenerateDirEntryString(
            accessString, priIncPath, templatePackageTargetIncludeDirEntry)

    for directExternalDeps in package.ResolvedDirectExternalDependencies:
        if directExternalDeps.Type != ExternalDependencyType.Find:
            currentIncDir = directExternalDeps.Include
            if currentIncDir is not None:
                if package.AbsolutePath is None:
                    raise Exception("Invalid package")
                packageRootPath = config.ToPath(package.AbsolutePath)
                if currentIncDir.startswith(packageRootPath):
                    relativeCurrentIncDir = currentIncDir[
                        len(packageRootPath) +
                        1:] if pathType == CMakePathType.LocalRelative else Util.ChangeToCMakeVariables(
                            currentIncDir)
                    add = "\n" + __GenerateDirEntryString(
                        GetAccessTypeString(package,
                                            directExternalDeps.Access),
                        relativeCurrentIncDir,
                        templatePackageTargetIncludeDirEntry)
                else:
                    relativeCurrentIncDir = config.ToPath(currentIncDir)
                    if relativeCurrentIncDir is None:
                        add = "\n  {0} {1}".format(
                            GetAccessTypeString(package,
                                                directExternalDeps.Access),
                            Util.ChangeToCMakeEnvVariables(currentIncDir))
                    else:
                        if pathType != CMakePathType.LocalRelative:
                            relativeCurrentIncDir = Util.ChangeToCMakeVariables(
                                relativeCurrentIncDir)
                        add = "\n" + __GenerateDirEntryString(
                            GetAccessTypeString(package,
                                                directExternalDeps.Access),
                            relativeCurrentIncDir,
                            templatePackageTargetIncludeDirEntry)
                if directExternalDeps.Access == AccessType.Public:
                    publicIncludeDir += add
                else:
                    privateIncludeDir += add
        else:
            add = "\n  %s ${%s_INCLUDE_DIRS}" % (GetAccessTypeString(
                package, directExternalDeps.Access), directExternalDeps.Name)
            if directExternalDeps.Access == AccessType.Public:
                publicIncludeDir += add
            else:
                privateIncludeDir += add

    if len(publicIncludeDir) <= 0 and len(privateIncludeDir) <= 0:
        return ""

    content = templatePackageTargetIncludeDirectories
    content = content.replace("##PACKAGE_PUBLIC_INCLUDE_DIRECTORIES##",
                              publicIncludeDir)
    content = content.replace("##PACKAGE_PRIVATE_INCLUDE_DIRECTORIES##",
                              privateIncludeDir)
    return content
コード例 #5
0
def GetSDKBasedPath(config: Config, path: str) -> str:
    return Util.ChangeToCMakeEnvVariables(config.ToPath(path))