From 5764df44f291d7769366e7495baaa6fd1cf1e794 Mon Sep 17 00:00:00 2001 From: Thibaut Monseigne <thibaut.monseigne@inria.fr> Date: Wed, 23 Jun 2021 14:55:24 +0200 Subject: [PATCH] :bug: Quick Fix for Build with new Unity Editor --- Editor/BuildHooks.cs | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/Editor/BuildHooks.cs b/Editor/BuildHooks.cs index 8819fa3..6bec07c 100644 --- a/Editor/BuildHooks.cs +++ b/Editor/BuildHooks.cs @@ -9,6 +9,9 @@ public class BuildHooks { private const string LIB_LSL_NAME = "liblsl"; private const string PLUGIN_DIR = "Plugins"; + private const string X86_FOLDER = "x86"; + private const string X64_FOLDER = "x86_64"; + private const string IOS_FOLDER = "iOS"; /// <summary> Called after the build. See also <see cref="PostProcessBuildAttribute"/>. </summary> /// <param name="target"> The build target. </param> @@ -26,16 +29,16 @@ public class BuildHooks switch (target) { case BuildTarget.StandaloneWindows: - RenameLibFile(pluginDir, LSLEditorIntegration.LIB32_NAME, LSLEditorIntegration.LIB64_NAME, LSLEditorIntegration.DLL_ENDING); + RenameLibFile(pluginDir, X86_FOLDER, LSLEditorIntegration.LIB32_NAME, LSLEditorIntegration.LIB64_NAME, LSLEditorIntegration.DLL_ENDING); break; case BuildTarget.StandaloneWindows64: - RenameLibFile(pluginDir, LSLEditorIntegration.LIB64_NAME, LSLEditorIntegration.LIB32_NAME, LSLEditorIntegration.DLL_ENDING); + RenameLibFile(pluginDir, X64_FOLDER, LSLEditorIntegration.LIB64_NAME, LSLEditorIntegration.LIB32_NAME, LSLEditorIntegration.DLL_ENDING); break; case BuildTarget.StandaloneLinux64: - RenameLibFile(pluginDir, LSLEditorIntegration.LIB64_NAME, LSLEditorIntegration.LIB32_NAME, LSLEditorIntegration.SO_ENDING); + RenameLibFile(pluginDir, X64_FOLDER, LSLEditorIntegration.LIB64_NAME, LSLEditorIntegration.LIB32_NAME, LSLEditorIntegration.SO_ENDING); break; case BuildTarget.StandaloneOSX: - RenameLibFile(pluginDir, LSLEditorIntegration.LIB64_NAME, LSLEditorIntegration.LIB32_NAME, LSLEditorIntegration.BUNDLE_ENDING); + RenameLibFile(pluginDir, IOS_FOLDER, LSLEditorIntegration.LIB64_NAME, LSLEditorIntegration.LIB32_NAME, LSLEditorIntegration.BUNDLE_ENDING); break; } } @@ -46,16 +49,18 @@ public class BuildHooks /// <param name="srcName"> Name of the source file. </param> /// <param name="oldName"> Name of the old. </param> /// <param name="extension"> The extension. </param> - private static void RenameLibFile(string pluginDir, string srcName, string oldName, string extension) + private static void RenameLibFile(string pluginDir, string subDir, string srcName, string oldName, string extension) { - var oldFile = Path.Combine(pluginDir, oldName + extension); - Debug.Log("[LSL BUILD Hook] Delete obsolete file: " + oldFile); - File.Delete(oldFile); + var oldDir = Path.Combine(pluginDir, subDir); + var oldFile = Path.Combine(oldDir, oldName + extension); + Debug.Log("[LSL BUILD Hook] Delete obsolete file: " + oldFile); + File.Delete(oldFile); - var srcFile = Path.Combine(pluginDir, srcName + extension); - var dstFile = Path.Combine(pluginDir, LIB_LSL_NAME + extension); - Debug.Log($"[LSL BUILD Hook] Renaming: {srcFile} to {dstFile}"); - File.Move(srcFile, dstFile); - } + + var srcFile = Path.Combine(oldDir, srcName + extension); + var dstFile = Path.Combine(pluginDir, LIB_LSL_NAME + extension); + Debug.Log($"[LSL BUILD Hook] Renaming: {srcFile} to {dstFile}"); + File.Move(srcFile, dstFile); } } +} -- GitLab