Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] add linux prebuilt library #15

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
**/prebuilt/**/share
**/prebuilt/**/cmake
build/**/build
UserSettings
Library
Logs
obj
Temp
out
8 changes: 8 additions & 0 deletions Assets/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

158 changes: 158 additions & 0 deletions Assets/Editor/BuildScript.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#if UNITY_EDITOR
using System.IO;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;


public static class BuildScript
{
public static string[] GetBuildSceneList()
{
var scenes = new List<string>();
foreach (var scene in EditorBuildSettings.scenes)
{
if (scene.enabled)
{
scenes.Add(scene.path);
}
}
return scenes.ToArray();
}

[MenuItem("Build/android")]
public static void Android()
{
var scenes = GetBuildSceneList();
PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.Mono2x);
PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARMv7;
EditorUserBuildSettings.buildAppBundle = false;

build(new BuildPlayerOptions()
{
scenes = scenes,
locationPathName = "out/android/build.apk",
target = BuildTarget.Android,
options = BuildOptions.Development,
});
}

public static void AndroidIL2CPP()
{
var scenes = GetBuildSceneList();
PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP);
PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64;
EditorUserBuildSettings.buildAppBundle = false;

build(new BuildPlayerOptions()
{
scenes = scenes,
locationPathName = "out/android_il2cpp/build.apk",
target = BuildTarget.Android,
options = BuildOptions.Development,
});
}

public static void AndroidIL2CPPStore()
{
var scenes = GetBuildSceneList();
PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP);
PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64 | AndroidArchitecture.ARMv7;
EditorUserBuildSettings.buildAppBundle = true;

build(new BuildPlayerOptions()
{
scenes = scenes,
locationPathName = "out/android_il2cpp/build.aab",
target = BuildTarget.Android,
options = BuildOptions.None,
});
}

[MenuItem("Build/ios")]
public static void iOS()
{
var scenes = GetBuildSceneList();
build(new BuildPlayerOptions()
{
scenes = scenes,
locationPathName = "out/ios",
target = BuildTarget.iOS,
options = BuildOptions.Development | BuildOptions.AllowDebugging,
});
}

[MenuItem("Build/macos")]
public static void MacOS()
{
var scenes = GetBuildSceneList();
build(new BuildPlayerOptions()
{
scenes = scenes,
locationPathName = "out/macos/curl-unity.app",
target = BuildTarget.StandaloneOSX,
options = BuildOptions.Development | BuildOptions.AllowDebugging,
});
}

[MenuItem("Build/linux")]
public static void Linux()
{
var scenes = GetBuildSceneList();
build(new BuildPlayerOptions()
{
scenes = scenes,
locationPathName = "out/linux/curl-unity.x86_64",
target = BuildTarget.StandaloneLinux64,
options = BuildOptions.Development | BuildOptions.AllowDebugging,
});
}

[MenuItem("Build/windows")]
public static void Windows()
{
var scenes = GetBuildSceneList();
build(new BuildPlayerOptions()
{
scenes = scenes,
locationPathName = "out/windows/curl-unity",
target = BuildTarget.StandaloneWindows64,
options = BuildOptions.Development | BuildOptions.AllowDebugging,
});
}


[MenuItem("Build/sync")]
public static void Sync()
{
Packages.Rider.Editor.RiderScriptEditor.SyncSolution();
maybeExit(0);
}

private static void build(BuildPlayerOptions options)
{
var report = BuildPipeline.BuildPlayer(options);
if (report.summary.result == BuildResult.Succeeded)
{
UnityEngine.Debug.Log($"Build ({options.target}) succeeded.");
maybeExit(0);
}
else
{
UnityEngine.Debug.LogError($"Build for [{options.target}]: {report.summary.result}...");
maybeExit(1);
}
}

private static void maybeExit(int exitcode)
{
Debug.Log($"maybeExit isBatchMode={Application.isBatchMode}, exitcode={exitcode}");
if (Application.isBatchMode)
{
EditorApplication.Exit(exitcode);
}
}
}
#endif
11 changes: 11 additions & 0 deletions Assets/Editor/BuildScript.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions Assets/Editor/XCodePostProcessSDK.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Callbacks;
#endif

using System.IO;
using System.Collections.Generic;
using System;

#if UNITY_IOS
#if UNITY_2019_3_OR_NEWER
using UnityEditor.iOS.Xcode;
using UnityEditor.iOS.Xcode.Extensions;
#else
using UnityEditor.iOS.Xcode.Custom;
using UnityEditor.iOS.Xcode.Custom.Extensions;
#endif
#endif

using System.Text.RegularExpressions;

public static class XCodePostProcessSDK
{
#if UNITY_EDITOR && UNITY_IOS
[PostProcessBuildAttribute(1)]
public static void OnPostProcessBuild(BuildTarget buildTarget, string pathToBuiltProject)
{
if (buildTarget != BuildTarget.iOS)
{
return;
}

var projectPath = pathToBuiltProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject pbxProject = new PBXProject();
pbxProject.ReadFromFile(projectPath);

string targetGuid = "";

#if UNITY_2019_3_OR_NEWER
targetGuid = pbxProject.GetUnityFrameworkTargetGuid();
#else
targetGuid = pbxProject.TargetGuidByName("Unity-iPhone");
#endif

AddLibToProject(pbxProject, targetGuid, "libz.tbd");
pbxProject.WriteToFile(projectPath);
}

static void AddLibToProject(PBXProject inst, string targetGuid, string lib)
{
string fileGuid = inst.AddFile("/usr/lib/" + lib, "Frameworks/" + lib, PBXSourceTree.Sdk);
inst.AddFileToBuild(targetGuid, fileGuid);
}
#endif
}
11 changes: 11 additions & 0 deletions Assets/Editor/XCodePostProcessSDK.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading