def DetermineMinSDKVersion(package: Package) -> AndroidSDKVersion: namesOnly = [entry.Name for entry in package.ResolvedAllUsedFeatures] if "Vulkan" in namesOnly: return AndroidSDKVersion(24) elif "OpenGLES3.1" in namesOnly: return AndroidSDKVersion(AndroidUtil.GetMinimumSDKVersion()) return AndroidSDKVersion(AndroidUtil.GetMinimumSDKVersion())
def __init__(self) -> None: super().__init__(PackageConfig.PlatformNameString.ANDROID) options = AndroidUtil.GetKnownABIList(True) self.VariantAndroidABI = GeneratorVariant( GEN_MAGIC_VARIANT_ANDROID_ABI, options, "##OPTIONS##", BuildVariantType.Static) self.OptionAndroidABI_all = AndroidUtil.GetKnownABIList(False) self.AddGeneratorVariant(self.VariantAndroidABI)
def TryGetCompilerShortIdFromGeneratorName( generatorName: str) -> Optional[str]: if generatorName == CMakeGeneratorName.UnixMakeFile: return "Make" elif generatorName == CMakeGeneratorName.VisualStudio2015_X64: return "VS2015_X64" elif generatorName == CMakeGeneratorName.VisualStudio2017_X64: return "VS2017_X64" elif generatorName == CMakeGeneratorName.VisualStudio2017_X64: return "VS2017_X64" elif generatorName == CMakeGeneratorName.Android: # For android we utilize a combination of the SDK and NDK version for the unique 'toolchain' name id = AndroidUtil.GetSDKNDKId() sdkVersion = AndroidUtil.GetMinimumSDKVersion() return "V{1}{0}".format(id, sdkVersion) return None
def GetCompilerShortIdFromGeneratorName(generatorName: str) -> str: if generatorName == CMakeGeneratorName.UnixMakeFile: return "Make" elif generatorName == CMakeGeneratorName.VisualStudio2015_X64: return "VS2015_X64" elif generatorName == CMakeGeneratorName.VisualStudio2017_X64: return "VS2017_X64" elif generatorName == CMakeGeneratorName.VisualStudio2019_X64: return "VS2019_X64" elif generatorName == CMakeGeneratorName.Android: # For android we utilize a combination of the SDK and NDK version for the unique 'toolchain' name theId = AndroidUtil.GetSDKNDKId() sdkVersion = AndroidUtil.GetSDKVersion() return "V{1}{0}".format(theId, sdkVersion) generatorName = generatorName.strip() generatorName = generatorName.replace(' ', '_') return generatorName
def __RunCMakeAndBuild(self, sourcePackage: Package, toolFinder: PackageToolFinder, recipeVariants: List[str], sourcePath: str, installPath: str, tempBuildPath: str, target: int, cmakeProjectName: str, configurationList: List[int], cmakeOptionList: List[str], allowSkip: bool) -> None: installedDependencyList = self.__BuildDependencyPathList( sourcePackage, sourcePackage.ResolvedExperimentalRecipeBuildOrder) if len(recipeVariants) <= 0: installedDependencies = self.__BuildDependencyPathString( installedDependencyList) if installedDependencies is not None and len( installedDependencies) > 0: cmakeOptionList = list(cmakeOptionList) cmakeOptionList.append(installedDependencies) self.Task.RunCMakeAndBuild(toolFinder, sourcePath, installPath, tempBuildPath, target, cmakeProjectName, configurationList, cmakeOptionList, allowSkip) return for variant in recipeVariants: self.BasicConfig.LogPrint("Recipe variant: {0}".format(variant)) self.BasicConfig.PushIndent() try: cmakeOptionListCopy = list(cmakeOptionList) if len(installedDependencyList) > 0: installedDependencyListCopy = [ IOUtil.Join(entry, variant) for entry in installedDependencyList ] installedDependencies = self.__BuildDependencyPathString( installedDependencyListCopy) cmakeOptionListCopy.append(installedDependencies) if self._IsAndroid: # FIX: Set this depending on package type optionList = [ "-DCMAKE_SYSTEM_VERSION={0}".format( AndroidUtil.GetMinimumSDKVersion()), "-DCMAKE_ANDROID_ARCH_ABI={0}".format(variant) ] cmakeOptionListCopy += optionList installPathCopy = IOUtil.Join(installPath, variant) tempBuildPathCopy = IOUtil.Join(tempBuildPath, variant) IOUtil.SafeMakeDirs(tempBuildPathCopy) self.Task.RunCMakeAndBuild(toolFinder, sourcePath, installPathCopy, tempBuildPathCopy, target, cmakeProjectName, configurationList, cmakeOptionListCopy, allowSkip) finally: self.BasicConfig.PopIndent()
def DeterminePlatformArguments(platformName: str) -> List[str]: res = [] # type: List[str] if platformName != PackageConfig.PlatformNameString.ANDROID: return res androidToolchain = "clang" androidStlType = "c++_shared" if not AndroidUtil.UseNDKCMakeToolchain(): # NDK before 19 res.append("-DCMAKE_SYSTEM_NAME=Android") res.append("-DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION={0}".format( androidToolchain)) res.append("-DCMAKE_ANDROID_STL_TYPE={0}".format(androidStlType)) else: # NDK from 19 res.append("-DCMAKE_TOOLCHAIN_FILE={0}".format( IOUtil.Join(AndroidUtil.GetNDKPath(), "build/cmake/android.toolchain.cmake"))) res.append("-DANDROID_STL={0}".format(androidStlType)) res.append("-DANDROID_TOOLCHAIN={0}".format(androidToolchain)) return res
def __GetDstFilenameModifier( self, config: Config, dstPath: str, package: Package, appPackageTemplateInfo: AndroidGeneratorUtil. AppPackageTemplateInfo, template: CMakeGeneratorUtil.CodeTemplateCMake, androidProjectCMakeDir: str, androidABIList: List[str], templateFileProcessor: TemplateFileProcessor, cmakePackageRootVariables: str) -> Callable[[str], str]: androidHome = AndroidUtil.GetSDKPath() androidNDK = AndroidUtil.GetNDKPath() androidNDKForProp = self.__ToPropPath(androidNDK) androidHomeForProp = self.__ToPropPath(androidHome) androidABIList = self.__patchABIList(config, package, androidABIList) self.__CheckABI(package, androidABIList) packageVariantGradleAndroidABIList = self.__CreateGradleAndroidABIList( androidABIList) packageName = CMakeGeneratorUtil.GetPackageName(package) cmakePackageExeLib = CMakeGeneratorUtil.GetAliasName(packageName) cmakePackageFindDirectExternalDependencies = CMakeGeneratorUtil.BuildFindDirectExternalDependencies( config, package, template.PackageDependencyFindPackage) cmakePackageDirectDependenciesAndSubDirectories = self.__BuildCMakeAddSubDirectoriesForDirectDependencies( config, package, template, androidProjectCMakeDir) addCMakeLibsList = self.__AddCMakeLibs(package) thirdPartyLibsList = [] # type: List[str] for entry in addCMakeLibsList: for staticLib in entry.StaticLibs: thirdPartyLibsList.append(staticLib.Name) thirdPartyAddLibs = "" for entry in addCMakeLibsList: for staticLib in entry.StaticLibs: content = template.AddImportedLibrary content = content.replace("##LIBRARY_NAME##", staticLib.Name) content = content.replace("##LIBRARY_TYPE##", "STATIC") content = content.replace("##LIBRARY_PATH##", staticLib.Path) thirdPartyAddLibs += "\n" + content # thirdPartyLibs is a space seperated list of third party lib names thirdPartyLibs = " ".join(thirdPartyLibsList) templateFileProcessor.Environment.Set("##CMAKE_THIRD_PARTY_LIBS##", thirdPartyLibs) templateFileProcessor.Environment.Set("##CMAKE_THIRD_PARTY_ADD_LIBS##", thirdPartyAddLibs) templateFileProcessor.Environment.Set( "##CMAKE_PACKAGE_DIRECT_DEPENDENCIES_ADD_SUBDIRECTORIES##", cmakePackageDirectDependenciesAndSubDirectories) templateFileProcessor.Environment.Set( "##CMAKE_PACKAGE_FIND_DIRECT_EXTERNAL_DEPENDENCIES##", cmakePackageFindDirectExternalDependencies) templateFileProcessor.Environment.Set("##CMAKE_PACKAGE_EXE_LIB##", cmakePackageExeLib) templateFileProcessor.Environment.Set( "##CMAKE_DEFINE_PACKAGE_ROOT_VARIABLES##", cmakePackageRootVariables) templateFileProcessor.Environment.Set("##ENV_ANDROID_HOME_FOR_PROP##", androidHomeForProp) templateFileProcessor.Environment.Set("##ENV_ANDROID_NDK_FOR_PROP##", androidNDKForProp) templateFileProcessor.Environment.Set( "##FSL_PACKAGE_GLES_VERSION##", appPackageTemplateInfo.MinGLESVersion) templateFileProcessor.Environment.Set( "##FSL_PACKAGE_MIN_ANDROID_SDK_VERSION##", appPackageTemplateInfo.MinSDKVersion.VersionString) templateFileProcessor.Environment.Set( "##FSL_PACKAGE_TARGET_ANDROID_SDK_VERSION##", appPackageTemplateInfo.TargetSDKVersion.VersionString) templateFileProcessor.Environment.Set( "##PACKAGE_APP_PLATFORM##", appPackageTemplateInfo.MinSDKVersion.AppPlatform) templateFileProcessor.Environment.Set( "##PACKAGE_VARIANT_ANDROID_ABIS##", packageVariantGradleAndroidABIList) templateFileProcessor.Environment.Set( "##PREFIXED_PROJECT_NAME##", appPackageTemplateInfo.PrefixedProjectName) templateFileProcessor.Environment.Set( "##PREFIXED_PROJECT_NAME_L##", appPackageTemplateInfo.PrefixedProjectName.lower()) return appPackageTemplateInfo.UpdateFileName
def GetTargetSDKVersion(package: Package) -> AndroidSDKVersion: return AndroidSDKVersion(AndroidUtil.GetTargetSDKVersion())