diff --git a/Editor/BuildHooks.cs b/Editor/BuildHooks.cs index 8819fa3e1262b177f26c96cfae899317e2e48587..6bec07c00e9d995a3209be171979e0eeaf548011 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); } } +}