Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit ea0d339

Browse files
committed
seperate jsb assemblies from assemblies of project with asmdef
1 parent 77a2d4b commit ea0d339

15 files changed

Lines changed: 311 additions & 182 deletions

Assets/jsb/Source/Binding/Editor/BindingCallback/InMemoryCompilationBindingCallback.cs

Lines changed: 115 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,119 @@ public class InMemoryCompilationBindingCallback : IBindingCallback, ICodeGenCall
1717
private List<Assembly> _generatedAssemblies = new List<Assembly>();
1818
private string _compilerOptions;
1919

20+
public static List<string> GetDefinedSymbols()
21+
{
22+
var defines = new List<string>();
23+
24+
#if UNITY_EDITOR // #define directive to call Unity Editor scripts from your game code.
25+
defines.Add("UNITY_EDITOR");
26+
#endif
27+
#if UNITY_EDITOR_WIN // #define directive for Editor code on Windows.
28+
defines.Add("UNITY_EDITOR_WIN");
29+
#endif
30+
#if UNITY_EDITOR_OSX // #define directive for Editor code on Mac OS X.
31+
defines.Add("UNITY_EDITOR_OSX");
32+
#endif
33+
#if UNITY_EDITOR_LINUX // #define directive for Editor code on Linux.
34+
defines.Add("UNITY_EDITOR_LINUX");
35+
#endif
36+
#if UNITY_STANDALONE_OSX // #define directive to compile or execute code specifically for Mac OS X (including Universal, PPC and Intel architectures).
37+
defines.Add("UNITY_STANDALONE_OSX");
38+
#endif
39+
#if UNITY_STANDALONE_WIN // #define directive for compiling/executing code specifically for Windows standalone applications.
40+
defines.Add("UNITY_STANDALONE_WIN");
41+
#endif
42+
#if UNITY_STANDALONE_LINUX // #define directive for compiling/executing code specifically for Linux standalone applications.
43+
defines.Add("UNITY_STANDALONE_LINUX");
44+
#endif
45+
#if UNITY_STANDALONE // #define directive for compiling/executing code for any standalone platform (Mac OS X, Windows or Linux).
46+
defines.Add("UNITY_STANDALONE");
47+
#endif
48+
#if UNITY_WII // #define directive for compiling/executing code for the Wii console.
49+
defines.Add("UNITY_WII");
50+
#endif
51+
#if UNITY_IOS // #define directive for compiling/executing code for the iOS platform.
52+
defines.Add("UNITY_IOS");
53+
#endif
54+
#if UNITY_IPHONE // Deprecated. Use UNITY_IOS instead.
55+
defines.Add("UNITY_IPHONE");
56+
#endif
57+
#if UNITY_ANDROID // #define directive for the Android platform.
58+
defines.Add("UNITY_ANDROID");
59+
#endif
60+
#if UNITY_PS4 // #define directive for running PlayStation 4 code.
61+
defines.Add("UNITY_PS4");
62+
#endif
63+
#if UNITY_XBOXONE // #define directive for executing Xbox One code.
64+
defines.Add("UNITY_XBOXONE");
65+
#endif
66+
#if UNITY_LUMIN // #define directive for the Magic Leap OS platform. You can also use PLATFORM_LUMIN.
67+
defines.Add("UNITY_LUMIN");
68+
#endif
69+
#if UNITY_TIZEN // #define directive for the Tizen platform.
70+
defines.Add("UNITY_TIZEN");
71+
#endif
72+
#if UNITY_TVOS // #define directive for the Apple TV platform.
73+
defines.Add("UNITY_TVOS");
74+
#endif
75+
#if UNITY_WSA // #define directive for Universal Windows Platform
76+
defines.Add("UNITY_WSA");
77+
#endif
78+
#if UNITY_WSA_10_0 // #define directive for Universal Windows Platform. Additionally WINDOWS_UWP is defined when compiling C# files against .NET Core.
79+
defines.Add("UNITY_WSA_10_0");
80+
#endif
81+
#if UNITY_WINRT // Same as UNITY_WSA.
82+
defines.Add("UNITY_WINRT");
83+
#endif
84+
#if UNITY_WINRT_10_0 // Equivalent to UNITY_WSA_10_0
85+
defines.Add("UNITY_WINRT_10_0");
86+
#endif
87+
#if UNITY_WEBGL // #define directive for WebGL
88+
defines.Add("UNITY_WEBGL");
89+
#endif
90+
#if UNITY_FACEBOOK // #define directive for the Facebook platform (WebGL or Windows standalone).
91+
defines.Add("UNITY_FACEBOOK");
92+
#endif
93+
#if UNITY_ANALYTICS // #define directive for calling Unity Analytics
94+
defines.Add("UNITY_ANALYTICS");
95+
#endif
96+
#if UNITY_ASSERTIONS // #define directive for assertions control process.
97+
defines.Add("UNITY_ASSERTIONS");
98+
#endif
99+
#if UNITY_64 // #define directive for 64-bit platforms.
100+
defines.Add("UNITY_64");
101+
#endif
102+
#if UNITY_SERVER
103+
defines.Add("UNITY_SERVER");
104+
#endif
105+
return defines;
106+
}
107+
108+
#if !JSB_UNITYLESS && UNITY_EDITOR
109+
public static UnityEditor.BuildTargetGroup GetBuildTargetGroup()
110+
{
111+
var buildTarget = UnityEditor.EditorUserBuildSettings.activeBuildTarget;
112+
switch (buildTarget)
113+
{
114+
case UnityEditor.BuildTarget.Android: return UnityEditor.BuildTargetGroup.Android;
115+
case UnityEditor.BuildTarget.iOS: return UnityEditor.BuildTargetGroup.iOS;
116+
case UnityEditor.BuildTarget.WSAPlayer: return UnityEditor.BuildTargetGroup.WSA;
117+
#if !UNITY_2019_2_OR_NEWER
118+
case UnityEditor.BuildTarget.StandaloneLinux:
119+
case UnityEditor.BuildTarget.StandaloneLinuxUniversal:
120+
#endif
121+
case UnityEditor.BuildTarget.StandaloneLinux64:
122+
case UnityEditor.BuildTarget.StandaloneOSX:
123+
case UnityEditor.BuildTarget.StandaloneWindows:
124+
case UnityEditor.BuildTarget.StandaloneWindows64: return UnityEditor.BuildTargetGroup.Standalone;
125+
case UnityEditor.BuildTarget.Switch: return UnityEditor.BuildTargetGroup.Switch;
126+
case UnityEditor.BuildTarget.PS4: return UnityEditor.BuildTargetGroup.PS4;
127+
case UnityEditor.BuildTarget.XboxOne: return UnityEditor.BuildTargetGroup.XboxOne;
128+
}
129+
throw new NotImplementedException();
130+
}
131+
#endif
132+
20133
public InMemoryCompilationBindingCallback(ScriptRuntime runtime)
21134
{
22135
_runtime = runtime;
@@ -26,13 +139,13 @@ public InMemoryCompilationBindingCallback(ScriptRuntime runtime)
26139
var compilerOptions = "-unsafe";
27140

28141
#if !JSB_UNITYLESS
29-
symbolList.AddRange(Unity.UnityHelper.GetDefinedSymbols());
142+
symbolList.AddRange(GetDefinedSymbols());
30143
#endif
31144

32145
defines += string.Join(";", symbolList);
33146

34147
#if !JSB_UNITYLESS && UNITY_EDITOR
35-
var customDefinedSymbols = UnityEditor.PlayerSettings.GetScriptingDefineSymbolsForGroup(Unity.UnityHelper.GetBuildTargetGroup());
148+
var customDefinedSymbols = UnityEditor.PlayerSettings.GetScriptingDefineSymbolsForGroup(GetBuildTargetGroup());
36149
if (!string.IsNullOrEmpty(customDefinedSymbols))
37150
{
38151
defines += ";" + customDefinedSymbols;
Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
1-
using System;
2-
using System.IO;
3-
using System.Collections.Generic;
4-
using System.Reflection;
5-
6-
namespace QuickJS.Binding
7-
{
8-
public interface IBindingUtils
9-
{
10-
string ReplacePathVars(string value);
11-
12-
bool IsExplicitEditorType(Type type);
13-
}
14-
15-
public class DefaultBindingUtils : IBindingUtils
16-
{
17-
public string ReplacePathVars(string value)
18-
{
19-
#if JSB_UNITYLESS
20-
value = value.Replace("${platform}", "unityless");
21-
return value;
22-
#else
23-
return Unity.UnityHelper.ReplacePathVars(value);
24-
#endif
25-
}
26-
27-
public bool IsExplicitEditorType(Type type)
28-
{
29-
#if JSB_UNITYLESS
30-
return false;
31-
#else
32-
return Unity.UnityHelper.IsExplicitEditorType(type);
33-
#endif
34-
}
35-
}
1+
using System;
2+
using System.IO;
3+
using System.Collections.Generic;
4+
using System.Reflection;
5+
6+
namespace QuickJS.Binding
7+
{
8+
public interface IBindingUtils
9+
{
10+
string ReplacePathVars(string value);
11+
12+
bool IsExplicitEditorType(Type type);
13+
}
14+
15+
public class DefaultBindingUtils : IBindingUtils
16+
{
17+
public string ReplacePathVars(string value)
18+
{
19+
value = value.Replace("${platform}", "unityless");
20+
return value;
21+
}
22+
23+
public bool IsExplicitEditorType(Type type)
24+
{
25+
return false;
26+
}
27+
}
3628
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "jsb.editor.binding",
3+
"references": [
4+
"GUID:118b4ca3a1852354bac065cf952c1e85"
5+
],
6+
"includePlatforms": [
7+
"Editor"
8+
],
9+
"excludePlatforms": [],
10+
"allowUnsafeCode": true,
11+
"overrideReferences": false,
12+
"precompiledReferences": [],
13+
"autoReferenced": true,
14+
"defineConstraints": [],
15+
"versionDefines": [],
16+
"noEngineReferences": false
17+
}

Assets/jsb/Source/Binding/Editor/jsb.editor.binding.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/jsb/Source/Unity/Editor/PrefsEditor.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,14 @@ protected override void OnEnable()
449449
{
450450
base.OnEnable();
451451

452+
var args = new BindingManager.Args()
453+
{
454+
utils = new UnityBindingUtils(),
455+
};
456+
452457
_prefs = UnityHelper.LoadPrefs(out _filePath);
453458
_selectedBindingMethod = Array.IndexOf(_bindingMethodValues, _prefs.preferredBindingMethod);
454-
_bindingManager = new BindingManager(_prefs, new BindingManager.Args());
459+
_bindingManager = new BindingManager(_prefs, args);
455460
_bindingManager.Collect();
456461
_bindingManager.Generate(TypeBindingFlags.None);
457462
_bindingManager.Report();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.IO;
3+
using System.Collections.Generic;
4+
using System.Reflection;
5+
6+
namespace QuickJS.Unity
7+
{
8+
public class UnityBindingUtils : Binding.IBindingUtils
9+
{
10+
public string ReplacePathVars(string value)
11+
{
12+
return Unity.UnityHelper.ReplacePathVars(value);
13+
}
14+
15+
public bool IsExplicitEditorType(Type type)
16+
{
17+
return Unity.UnityHelper.IsExplicitEditorType(type);
18+
}
19+
}
20+
}

Assets/jsb/Source/Unity/Editor/UnityBindingUtils.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)