Import dlls (#3105)

* install apple plugin

* start setting up bluetooth prefs

* basic test connection

* build the plugins from the webhook
This commit is contained in:
2023-12-12 18:08:56 -08:00
committed by GitHub
parent 19014f3ffd
commit ec4802a29f
20 changed files with 2791 additions and 79 deletions
+1
View File
@@ -3,6 +3,7 @@ opensource_noEdits/
*.a
*.lib
*.dSYM/
*.bundle/
.DS_Store
xcuserdata/
.codelite/
+34 -8
View File
@@ -2,20 +2,24 @@
# bazel-toolchain
#
bazel_dep(name = "toolchains_llvm", version = "0.10.3")
bazel_dep(
name = "toolchains_llvm",
version = "0.10.3",
)
# To directly use a commit from GitHub, replace commit with the commit you want.
# Otherwise, omit this block.
git_override(
module_name = "toolchains_llvm",
commit = "0a9feb723796f6eb9e9947ccffa629964ec4680f",
remote = "https://github.com/grailbio/bazel-toolchain",
commit = "0a9feb723796f6eb9e9947ccffa629964ec4680f",
module_name = "toolchains_llvm",
remote = "https://github.com/grailbio/bazel-toolchain",
)
# Configure and register the toolchain.
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(
llvm_version = "15.0.7",
llvm_version = "15.0.7",
)
use_repo(llvm, "llvm_toolchain")
@@ -29,8 +33,13 @@ register_toolchains("@llvm_toolchain//:all")
scala_version = "2.13.12"
bazel_dep(name = "rules_jvm_external", version = "5.3")
bazel_dep(
name = "rules_jvm_external",
version = "5.3",
)
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
artifacts = [
"org.scala-lang:scala-library:%s" % scala_version,
@@ -47,10 +56,27 @@ maven.install(
"com.amazonaws:aws-lambda-java-events:3.11.0",
"javax.xml.bind:jaxb-api:2.3.1",
],
lock_file = "//:maven_install.json",#
fail_if_repin_required = True,
lock_file = "//:maven_install.json", #
repositories = [
"https://repo1.maven.org/maven2",
],
)
use_repo(maven, "maven", "unpinned_maven")
use_repo(maven, "maven", "unpinned_maven")
#
# rules_apple
#
bazel_dep(
name = "rules_apple",
repo_name = "build_bazel_rules_apple",
version = "3.1.1",
)
bazel_dep(
name = "rules_swift",
repo_name = "build_bazel_rules_swift",
version = "1.13.0",
)
+11 -32
View File
@@ -129,38 +129,17 @@ cc_library(
)
#
# rules-apple
# Plugins for the native code for interacting with GoDice
#
unity_godice_commit = "334179084199b565544f3f56a1248beb1785b3e9"
unity_godice_sha = "bc13c13b45c4312d2d00134ab31181c41eeeaf14dce8bb872f780d0aaf62868e"
http_archive(
name = "build_bazel_rules_apple",
sha256 = "90e3b5e8ff942be134e64a83499974203ea64797fd620eddeb71b3a8e1bff681",
url = "https://github.com/bazelbuild/rules_apple/releases/download/1.1.2/rules_apple.1.1.2.tar.gz",
name = "net_eagle0_unity_godice",
sha256 = unity_godice_sha,
strip_prefix = "godice-framework-%s" % unity_godice_commit,
urls = [
"https://github.com/nolen777/godice-framework/archive/%s.zip" % unity_godice_commit,
],
)
load(
"@build_bazel_rules_apple//apple:repositories.bzl",
"apple_rules_dependencies",
)
apple_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
)
swift_rules_dependencies()
load(
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)
swift_rules_extra_dependencies()
load(
"@build_bazel_apple_support//lib:repositories.bzl",
"apple_support_dependencies",
)
apple_support_dependencies()
+3
View File
@@ -27,6 +27,9 @@ mkdir -p /tmp/scriptlock
/bin/echo "build protos"
./scripts/build_protos.sh
/bin/echo "build plugins"
./scripts/build_plugins.sh
/bin/echo "build Windows"
./ci/webhook/build_windows.sh
/bin/echo "Running smart upload script for Windows client"
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
set -euxo pipefail
/bin/echo "build plugins"
/bin/echo "building darwin bundle"
bazel build --noincompatible_enable_cc_toolchain_resolution @net_eagle0_unity_godice//darwin/framework:DarwinGodiceBundle
/usr/bin/unzip -o bazel-bin/external/net_eagle0_unity_godice/darwin/framework/DarwinGodiceBundle.zip -d src/main/csharp/net/eagle0/clients/unity/eagle0/Assets/Plugins/
/bin/echo "building windows dll"
bazel build @net_eagle0_unity_godice//windows:dll_zip
/usr/bin/unzip -o bazel-bin/external/net_eagle0_unity_godice/windows/dll_zip.zip -d src/main/csharp/net/eagle0/clients/unity/eagle0/Assets/Plugins/
@@ -101,6 +101,7 @@
<Compile Include="Assets/Eagle/Table Rows/CustomUnitRowController.cs" />
<Compile Include="Assets/Modern UI Pack/Scripts/Modal Window/ModalWindowManagerEditor.cs" />
<Compile Include="Assets/GUI Pro Kit Fantasy RPG/Scripts/CtrPanel.cs" />
<Compile Include="Assets/Bluetooth/NativeDiceInterfaceImports.cs" />
<Compile Include="Assets/Eagle/Notifications/ARNNotifications/AllianceRejectedNotificationGenerator.cs" />
<Compile Include="Assets/Eagle/Notifications/ARNNotifications/InvitationAcceptedDetailsNotificationGenerator.cs" />
<Compile Include="Assets/Eagle/CommandSelectors/HandleRiotGiveCommandSelector.cs" />
@@ -174,6 +175,7 @@
<Compile Include="Assets/Eagle/CommandSelectors/DefendCommandSelector.cs" />
<Compile Include="Assets/Eagle/Notifications/WeatherForcedSuppliesBackNotificationGenerator.cs" />
<Compile Include="Assets/Eagle/HeroesAndBattalionsPanelController.cs" />
<Compile Include="Assets/Bluetooth/DiceInterface.cs" />
<Compile Include="Assets/ButtonColors.cs" />
<Compile Include="Assets/common/GUIUtils/ErrorPanel.cs" />
<Compile Include="Assets/Modern UI Pack/Scripts/Button/ButtonManagerWithIcon.cs" />
@@ -231,6 +233,7 @@
<Compile Include="Assets/Modern UI Pack/Scripts/Window/WindowManager.cs" />
<Compile Include="Assets/Modern UI Pack/Scripts/UI Manager/UIManagerSliderEditor.cs" />
<Compile Include="Assets/Eagle/CommandSelectors/IssueOrdersCommandSelector.cs" />
<Compile Include="Assets/Bluetooth/IDiceInterfaceImports.cs" />
<Compile Include="Assets/Shardok/Grid.cs" />
<Compile Include="Assets/Eagle/CommandSelectors/ArmTroopsCommandSelector.cs" />
<Compile Include="Assets/Eagle/Notifications/ARNNotifications/TruceAcceptedDetailsNotificationGenerator.cs" />
@@ -265,6 +268,7 @@
<Compile Include="Assets/Eagle/Table Rows/UnitSelectorHeroRowController.cs" />
<Compile Include="Assets/Eagle/Notifications/Notification.cs" />
<Compile Include="Assets/Eagle/Notifications/ARNNotifications/QuestFailedDetailsNotificationGenerator.cs" />
<Compile Include="Assets/Bluetooth/DicePanelController.cs" />
<Compile Include="Assets/Modern UI Pack/Scripts/Button/ButtonManagerBasicWithIconEditor.cs" />
<Compile Include="Assets/Eagle/EagleGameController.cs" />
<Compile Include="Assets/Modern UI Pack/Scripts/UI Manager/UIManagerProgressBarLoop.cs" />
@@ -692,6 +696,7 @@
<Folder Include="Assets/Packages/Grpc.Core.Api.2.45.0/lib" />
<Folder Include="Assets/GUI Pro Kit Fantasy RPG/Sprites/20_Rate" />
<Folder Include="Assets/4000_Fantasy_Icons/Skills" />
<Folder Include="Assets/Bluetooth" />
<Folder Include="Assets/GUI Pro Kit Fantasy RPG/Sprites/00_PictoIcons_32x32" />
<Folder Include="Assets/Medieval Combat Sounds/Footsteps/Foley Armor Heavy" />
<Folder Include="Assets/Modern UI Pack/Resources/Button/Basic - Outline Gradient" />
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6ddb90d3140384d50a98a19e72539b62
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,95 @@
#if UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
#define USE_SWIFT_INTERFACE
#elif UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN || ENABLE_WINMD_SUPPORT
#define USE_WINDOWS_INTERFACE
#else
#endif
using System.Collections.Generic;
using UnityEngine;
using UnityGoDiceInterface;
public class DiceInterface : MonoBehaviour {
IDiceInterfaceImports diceInterfaceImports = new NativeDiceInterfaceImports();
private static byte[] rollVector(List<byte> rawData) {
if (rawData.Count < 1) {
Debug.Log("rollVector: no data");
return null;
}
byte firstByte = rawData[0];
if (firstByte != 83) {
Debug.Log("rollVector: first byte is not 83");
return null;
}
if (rawData.Count != 4) {
Debug.Log("rollVector: data length is not 4");
return null;
}
return new byte[] { rawData[1], rawData[2], rawData[3] };
}
private static void DelegateMessageReceived(string name, List<byte> byteList) {
if (_singleton != null) {
if (byteList.Count == 0) {
if (_singleton.connectionCallback != null) {
_singleton.connectionCallback(name);
return;
}
} else {
byte firstByte = byteList[0];
switch (firstByte) {
case 82:
// Roll started
break;
case 66:
// Battery level
break;
case 67:
// Color (fetched)
break;
case 83: {
var roll = rollVector(byteList);
if (roll != null && _singleton.rollCallback != null) {
_singleton.rollCallback(name, roll[0], roll[1], roll[2]);
}
break;
}
case 70:
case 84:
case 77: {
byteList.RemoveAt(0);
var roll = rollVector(byteList);
if (roll != null && _singleton.rollCallback != null) {
_singleton.rollCallback(name, roll[0], roll[1], roll[2]);
}
break;
}
default: Debug.Log("Not yet handled"); break;
}
}
}
}
private static DiceInterface _singleton = null;
public delegate void ConnectionCallback(string name);
public delegate void RollCallback(string name, byte x, byte y, byte z);
public ConnectionCallback connectionCallback = null;
public RollCallback rollCallback = null;
public void StartListening() {
diceInterfaceImports.StartListening();
diceInterfaceImports.SetCallback(DelegateMessageReceived);
}
public void StopListening() { diceInterfaceImports.StopListening(); }
// Start is called before the first frame update
void Start() { _singleton = this; }
// Update is called once per frame
void Update() {}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d2c2bcddb22554e0abbf1bd31c4876fa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,67 @@
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using TMPro;
using UnityEngine;
public class DicePanelController : MonoBehaviour {
public TMP_Text mainText;
private DiceInterface diceInterface;
struct DiceRoll {
public string name;
public byte x;
public byte y;
public byte z;
}
private List<DiceRoll> _diceRolls = new List<DiceRoll>();
private List<string> _connections = new List<string>();
// Start is called before the first frame update
void Start() {
diceInterface = GetComponent<DiceInterface>();
mainText.text = "Hello, World!\n";
diceInterface.rollCallback = ReceiveRollCallback;
diceInterface.connectionCallback = ConnectionCallback;
diceInterface.StartListening();
}
void OnDestroy() { diceInterface.StopListening(); }
void ReceiveRollCallback(string name, byte x, byte y, byte z) {
lock (_diceRolls) { _diceRolls.Add(new DiceRoll { name = name, x = x, y = y, z = z }); }
}
void ConnectionCallback(string name) {
lock (_connections) { _connections.Add(name); }
}
public void DismissButtonClicked() {
GetComponentInParent<Canvas>().gameObject.SetActive(false);
}
// Update is called once per frame
void Update() {
List<string> toProcessConnections = new List<string>();
lock (_connections) {
if (_connections.Count > 0) {
(_connections, toProcessConnections) = (toProcessConnections, _connections);
}
}
foreach (string name in toProcessConnections) { mainText.text += $"{name} connected\n"; }
List<DiceRoll> toProcessRolls = new List<DiceRoll>();
lock (_diceRolls) {
if (_diceRolls.Count > 0) {
(_diceRolls, toProcessRolls) = (toProcessRolls, _diceRolls);
}
}
foreach (DiceRoll dr in toProcessRolls) {
mainText.text += $"{dr.name} rolled {dr.x} {dr.y} {dr.z}\n";
}
if (Input.GetButtonUp("Cancel")) { Application.Quit(); }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e694fb18ea1df4034b392352bf3aa04a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
using System.Collections.Generic;
namespace UnityGoDiceInterface {
public interface IDiceInterfaceImports {
delegate void DelegateMessage(string name, List<byte> bytes);
protected static DelegateMessage Delegate;
public void StartListening();
public void StopListening();
public void SetCallback(IDiceInterfaceImports.DelegateMessage delegateMessage) {
Delegate = delegateMessage;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 883bf622d61244e079aa51acadeb756e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,51 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using AOT;
using UnityEngine;
namespace UnityGoDiceInterface {
public class NativeDiceInterfaceImports : IDiceInterfaceImports {
#if UNITY_IOS
private const string BundleName = "__Internal";
#elif UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
private const string BundleName = "DarwinGodiceBundle";
#elif UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
private const string BundleName = "BleWinrtDll.dll";
#endif
private delegate void MonoDelegateMessage(string name, UInt32 byteCount, IntPtr bytePtr);
[DllImport(dllName: BundleName, EntryPoint = "godice_start_listening")]
private static extern void _NativeBridgeStartListening();
[DllImport(dllName: BundleName, EntryPoint = "godice_stop_listening")]
private static extern void _NativeBridgeStopListening();
[DllImport(dllName: BundleName, EntryPoint = "godice_set_callback")]
private static extern void _NativeBridgeSetCallback(
MonoDelegateMessage monoDelegateMessage);
private static List<byte> BytesFromRawPointer(UInt32 byteCount, IntPtr bytes) {
byte[] array = new byte[byteCount];
Marshal.Copy(bytes, array, 0, (int)byteCount);
return new List<byte>(array);
}
[MonoPInvokeCallback(typeof(MonoDelegateMessage))]
private static void
MonoDelegateMessageReceived(string name, UInt32 byteCount, IntPtr bytePtr) {
if (IDiceInterfaceImports.Delegate != null) {
IDiceInterfaceImports.Delegate(name, BytesFromRawPointer(byteCount, bytePtr));
}
}
public void StartListening() {
_NativeBridgeSetCallback(MonoDelegateMessageReceived);
_NativeBridgeStartListening();
}
public void StopListening() { _NativeBridgeStopListening(); }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4b908afeab4ea4af08693f4466ad48f4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: 81a7aed2387984bd8a5fef92babb6718
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: bc05c87fa086c4418bdd690561cc6373
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
DefaultValueInitialized: true
- first:
Standalone: OSXUniversal
second:
enabled: 1
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
@@ -11,10 +11,15 @@ public class SettingsPanelController : MonoBehaviour {
public Slider soundEffectsSlider;
public Slider musicSlider;
public Toggle useGoDiceToggle;
public Button testGoDice;
public Canvas goDiceCanvas;
private bool _active = false;
private readonly string _soundEffectsVolumeKey = "soundEffectsVolume";
private readonly string _musicVolumeKey = "musicVolume";
private readonly string _useGoDiceKey = "useGoDice";
void Start() {
_active = false;
@@ -26,6 +31,7 @@ public class SettingsPanelController : MonoBehaviour {
soundEffectsSlider.value = soundEffectsSource.volume;
musicSlider.value = musicSource.volume;
useGoDiceToggle.isOn = PlayerPrefs.GetInt(_useGoDiceKey, 0) == 1;
}
// Update is called once per frame
@@ -61,6 +67,13 @@ public class SettingsPanelController : MonoBehaviour {
PlayerPrefs.SetFloat(_musicVolumeKey, val);
}
public void OnUseGoDiceToggleChange(bool val) {
PlayerPrefs.SetInt(_useGoDiceKey, val ? 1 : 0);
testGoDice.interactable = val;
}
public void OnTestGoDiceClick() { goDiceCanvas.gameObject.SetActive(true); }
private void HandleQuit() {
ConnectionKiller.ShutdownAll();
#if UNITY_EDITOR