Build deps for iOS

This commit is contained in:
Wojtek Figat
2023-03-16 22:13:37 +01:00
parent 0ba261d338
commit c615ad18a8
26 changed files with 163 additions and 15 deletions

View File

@@ -55,9 +55,11 @@ public class Audio : EngineModule
options.CompileEnv.PreprocessorDefinitions.Add("AUDIO_API_PS5");
break;
case TargetPlatform.Mac:
case TargetPlatform.iOS:
useOpenAL = true;
break;
case TargetPlatform.iOS:
//useOpenAL = true; // TODO: fix linker error 'ld: framework not found AudioUnit' for OpenAL on iOS
break;
default: throw new InvalidPlatformException(options.Platform.Target);
}

4
Source/Platforms/iOS/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
!Binaries/
!bin/
!*.*
*.DS_Store

Binary file not shown.

BIN
Source/Platforms/iOS/Binaries/ThirdParty/ARM64/libPhysXCommon_static_64.a (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Source/Platforms/iOS/Binaries/ThirdParty/ARM64/libPhysXPvdSDK_static_64.a (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Source/Platforms/iOS/Binaries/ThirdParty/ARM64/libPhysX_static_64.a (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
Source/Platforms/iOS/Binaries/ThirdParty/ARM64/libfreetype.a (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
Source/Platforms/iOS/Binaries/ThirdParty/ARM64/libogg.a (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
Source/Platforms/iOS/Binaries/ThirdParty/ARM64/libopenal.a (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
Source/Platforms/iOS/Binaries/ThirdParty/ARM64/libvorbis.a (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
Source/Platforms/iOS/Binaries/ThirdParty/ARM64/libvorbisenc.a (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
Source/Platforms/iOS/Binaries/ThirdParty/ARM64/libvorbisfile.a (Stored with Git LFS) vendored Normal file

Binary file not shown.

View File

@@ -60,6 +60,7 @@ public class PhysX : DepsModule
case TargetPlatform.XboxScarlett:
case TargetPlatform.Mac:
case TargetPlatform.Android:
case TargetPlatform.iOS:
switch (options.Architecture)
{
case TargetArchitecture.x86:

View File

@@ -38,6 +38,7 @@ namespace Flax.Deps.Dependencies
return new[]
{
TargetPlatform.Mac,
TargetPlatform.iOS,
};
default: return new TargetPlatform[0];
}
@@ -48,7 +49,7 @@ namespace Flax.Deps.Dependencies
public override void Build(BuildOptions options)
{
var root = options.IntermediateFolder;
var version = "1.19.1";
var version = "1.23.0";
var dstIncludePath = Path.Combine(options.ThirdPartyFolder, "OpenAL");
foreach (var platform in options.Platforms)
@@ -182,6 +183,35 @@ namespace Flax.Deps.Dependencies
}
break;
}
case TargetPlatform.iOS:
{
var binariesToCopy = new[]
{
"libopenal.a",
};
var config = "-DALSOFT_REQUIRE_COREAUDIO=ON -DALSOFT_EMBED_HRTF_DATA=YES";
// Get the source
var packagePath = Path.Combine(root, "package.zip");
if (!File.Exists(packagePath))
{
Downloader.DownloadFileFromUrlToPath("https://openal-soft.org/openal-releases/openal-soft-" + version + ".tar.bz2", packagePath);
Utilities.Run("tar", "xjf " + packagePath.Replace('\\', '/'), null, root, Utilities.RunOptions.None);
}
// Use separate build directory
root = Path.Combine(root, "openal-soft-" + version);
var buildDir = Path.Combine(root, "build");
// Build for iOS
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_SYSTEM_NAME=iOS -DALSOFT_OSX_FRAMEWORK=ON -DLIBTYPE=STATIC -DCMAKE_BUILD_TYPE=Release " + config);
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.None);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
foreach (var file in binariesToCopy)
Utilities.FileCopy(Path.Combine(buildDir, file), Path.Combine(depsFolder, file));
break;
}
}
}
}

View File

@@ -45,6 +45,7 @@ namespace Flax.Deps.Dependencies
return new[]
{
TargetPlatform.Mac,
TargetPlatform.iOS,
};
default: return new TargetPlatform[0];
}
@@ -99,7 +100,10 @@ namespace Flax.Deps.Dependencies
case TargetPlatform.Mac:
ConfigureCmakeSwitch(cmakeParams, "CMAKE_OSX_DEPLOYMENT_TARGET", Configuration.MacOSXMinVer);
break;
// TODO: support CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET switch for iOS
case TargetPlatform.iOS:
ConfigureCmakeSwitch(cmakeParams, "CMAKE_OSX_DEPLOYMENT_TARGET", Configuration.iOSMinVer);
ConfigureCmakeSwitch(cmakeParams, "CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET", Configuration.iOSMinVer);
break;
}
// Save preset
@@ -202,7 +206,11 @@ namespace Flax.Deps.Dependencies
binariesPrefix = "lib";
envVars.Add("MACOSX_DEPLOYMENT_TARGET", Configuration.MacOSXMinVer);
break;
// TODO: set IPHONEOS_DEPLOYMENT_TARGET env var for iOS
case TargetPlatform.iOS:
binariesSubDir = "ios.arm_64";
binariesPrefix = "lib";
envVars.Add("IPHONEOS_DEPLOYMENT_TARGET", Configuration.iOSMinVer);
break;
default: throw new InvalidPlatformException(targetPlatform);
}
@@ -410,6 +418,11 @@ namespace Flax.Deps.Dependencies
Build(options, "mac-arm64", platform, TargetArchitecture.ARM64);
break;
}
case TargetPlatform.iOS:
{
Build(options, "ios64", platform, TargetArchitecture.ARM64);
break;
}
}
}

View File

@@ -43,6 +43,7 @@ namespace Flax.Deps.Dependencies
return new[]
{
TargetPlatform.Mac,
TargetPlatform.iOS,
};
default: return new TargetPlatform[0];
}
@@ -77,6 +78,7 @@ namespace Flax.Deps.Dependencies
archive.ExtractToDirectory(root);
root = newRoot;
}
var buildDir = Path.Combine(root, "build");
var configurationMsvc = "Release Static";
var binariesToCopyMsvc = new[]
@@ -128,7 +130,6 @@ namespace Flax.Deps.Dependencies
{ "CC", "clang-7" },
{ "CC_FOR_BUILD", "clang-7" }
};
var buildDir = Path.Combine(root, "build");
// Fix scripts
Utilities.Run("sed", "-i -e \'s/\r$//\' autogen.sh", null, root, Utilities.RunOptions.ThrowExceptionOnError, envVars);
@@ -216,8 +217,6 @@ namespace Flax.Deps.Dependencies
}
case TargetPlatform.Android:
{
var buildDir = Path.Combine(root, "build");
// Disable using libpng even if it's found on the system
var cmakeFile = Path.Combine(root, "CMakeLists.txt");
File.WriteAllText(cmakeFile,
@@ -238,7 +237,6 @@ namespace Flax.Deps.Dependencies
case TargetPlatform.Switch:
{
// Build for Switch
var buildDir = Path.Combine(root, "build");
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_BUILD_TYPE=Release");
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.None);
@@ -249,7 +247,6 @@ namespace Flax.Deps.Dependencies
case TargetPlatform.Mac:
{
// Build for Mac
var buildDir = Path.Combine(root, "build");
foreach (var architecture in new []{ TargetArchitecture.x64, TargetArchitecture.ARM64 })
{
SetupDirectory(buildDir, true);
@@ -260,6 +257,22 @@ namespace Flax.Deps.Dependencies
}
break;
}
case TargetPlatform.iOS:
{
// Fix archive creation issue due to missing ar tool
Utilities.ReplaceInFile(Path.Combine(root, "builds/cmake/iOS.cmake"), "set(CMAKE_SYSTEM_NAME Darwin)", "set(CMAKE_SYSTEM_NAME Darwin)\nset(CMAKE_AR ar CACHE FILEPATH \"\" FORCE)");
// Fix freetype toolchain rejecting min iPhone version
Utilities.ReplaceInFile(Path.Combine(root, "builds/cmake/iOS.cmake"), "set(CMAKE_OSX_DEPLOYMENT_TARGET \"\"", "set(CMAKE_OSX_DEPLOYMENT_TARGET \"${CMAKE_OSX_DEPLOYMENT_TARGET}\"");
// Build for iOS
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DIOS_PLATFORM=OS -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_BUILD_TYPE=Release -DFT_WITH_BZIP2=OFF -DFT_WITH_ZLIB=OFF -DFT_WITH_PNG=OFF");
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.None);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
break;
}
}
}

View File

@@ -42,6 +42,7 @@ namespace Flax.Deps.Dependencies
return new[]
{
TargetPlatform.Mac,
TargetPlatform.iOS,
};
default: return new TargetPlatform[0];
}
@@ -81,6 +82,7 @@ namespace Flax.Deps.Dependencies
vcxprojContents = vcxprojContents.Replace("<RuntimeLibrary>MultiThreaded</RuntimeLibrary>", "<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>");
vcxprojContents = vcxprojContents.Replace("<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>", "<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>");
vcxprojContents = vcxprojContents.Replace("<WholeProgramOptimization>true</WholeProgramOptimization>", "<WholeProgramOptimization>false</WholeProgramOptimization>");
var buildDir = Path.Combine(root, "build");
foreach (var platform in options.Platforms)
{
@@ -119,7 +121,6 @@ namespace Flax.Deps.Dependencies
{ "CC", "clang-7" },
{ "CC_FOR_BUILD", "clang-7" }
};
var buildDir = Path.Combine(root, "build");
Utilities.Run(Path.Combine(root, "autogen.sh"), null, null, root, Utilities.RunOptions.Default, envVars);
@@ -192,8 +193,6 @@ namespace Flax.Deps.Dependencies
}
case TargetPlatform.Android:
{
var buildDir = Path.Combine(root, "build");
// Build for Android
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_BUILD_TYPE=Release");
@@ -208,7 +207,6 @@ namespace Flax.Deps.Dependencies
Utilities.DirectoryCopy(Path.Combine(options.PlatformsFolder, "Switch", "Data", "ogg"), root, true, true);
// Build for Switch
var buildDir = Path.Combine(root, "build");
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_BUILD_TYPE=Release");
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.None);
@@ -218,8 +216,6 @@ namespace Flax.Deps.Dependencies
}
case TargetPlatform.Mac:
{
var buildDir = Path.Combine(root, "build");
// Build for Mac
foreach (var architecture in new []{ TargetArchitecture.x64, TargetArchitecture.ARM64 })
{
@@ -231,6 +227,15 @@ namespace Flax.Deps.Dependencies
}
break;
}
case TargetPlatform.iOS:
{
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_BUILD_TYPE=Release");
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.None);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
Utilities.FileCopy(Path.Combine(buildDir, libraryFileName), Path.Combine(depsFolder, libraryFileName));
break;
}
}
}

View File

@@ -43,6 +43,7 @@ namespace Flax.Deps.Dependencies
return new[]
{
TargetPlatform.Mac,
TargetPlatform.iOS,
};
default: return new TargetPlatform[0];
}
@@ -389,6 +390,29 @@ namespace Flax.Deps.Dependencies
}
break;
}
case TargetPlatform.iOS:
{
var oggRoot = Path.Combine(root, "ogg");
var oggBuildDir = Path.Combine(oggRoot, "build");
var buildDir = Path.Combine(root, "build");
// Get the source
CloneGitRepoFast(root, "https://github.com/xiph/vorbis.git");
CloneGitRepo(oggRoot, "https://github.com/xiph/ogg.git");
GitCheckout(oggRoot, "master", "4380566a44b8d5e85ad511c9c17eb04197863ec5");
// Build for Mac
SetupDirectory(oggBuildDir, true);
RunCmake(oggBuildDir, platform, TargetArchitecture.ARM64, ".. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=\"../install\"");
Utilities.Run("cmake", "--build . --target install", null, oggBuildDir, Utilities.RunOptions.None);
SetupDirectory(buildDir, true);
RunCmake(buildDir, platform, TargetArchitecture.ARM64, string.Format(".. -DCMAKE_BUILD_TYPE=Release -DOGG_INCLUDE_DIR=\"{0}/install/include\" -DOGG_LIBRARY=\"{0}/install/lib\"", oggRoot));
Utilities.Run("cmake", "--build .", null, buildDir, Utilities.RunOptions.None);
var depsFolder = GetThirdPartyFolder(options, platform, TargetArchitecture.ARM64);
foreach (var file in binariesToCopyUnix)
Utilities.FileCopy(Path.Combine(buildDir, file.SrcFolder, file.Filename), Path.Combine(depsFolder, file.Filename));
break;
}
}
}

View File

@@ -288,6 +288,12 @@ namespace Flax.Deps
cmdLine = string.Format("CMakeLists.txt -DCMAKE_OSX_DEPLOYMENT_TARGET=\"{0}\" -DCMAKE_OSX_ARCHITECTURES={1}", Configuration.MacOSXMinVer, arch);
break;
}
case TargetPlatform.iOS:
{
var arch = GetAppleArchName(architecture);
cmdLine = string.Format("CMakeLists.txt -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_DEPLOYMENT_TARGET=\"{0}\" -DCMAKE_OSX_ARCHITECTURES={1}", Configuration.iOSMinVer, arch);
break;
}
default: throw new InvalidPlatformException(platform);
}

View File

@@ -251,6 +251,7 @@ namespace Flax.Build.Platforms
args.Add("-dynamiclib");
}
}
SetupLinkFilesArgs(graph, options, args, outputFilePath);
// Input libraries
var libraryPaths = new HashSet<string>();

View File

@@ -43,12 +43,16 @@ namespace Flax.Build.Platforms
// TODO: move this to the specific module configs (eg. Platform.Build.cs)
options.LinkEnv.InputLibraries.Add("z");
options.LinkEnv.InputLibraries.Add("bz2");
options.LinkEnv.InputLibraries.Add("Foundation.framework");
options.LinkEnv.InputLibraries.Add("CoreFoundation.framework");
options.LinkEnv.InputLibraries.Add("CoreGraphics.framework");
options.LinkEnv.InputLibraries.Add("SystemConfiguration.framework");
options.LinkEnv.InputLibraries.Add("IOKit.framework");
options.LinkEnv.InputLibraries.Add("UIKit.framework");
options.LinkEnv.InputLibraries.Add("QuartzCore.framework");
//options.LinkEnv.InputLibraries.Add("QuartzCore.framework");
//options.LinkEnv.InputLibraries.Add("AudioToolbox.framework");
//options.LinkEnv.InputLibraries.Add("AudioUnit.framework");
}
protected override void AddArgsCommon(BuildOptions options, List<string> args)