I'm moving some Unity code into a VS2022 project to use a plugin. Since this code references many different Unity classes I need to link in the Unity's DLLs in my Unity install. This is all fine and dandy, but I wanted to generate the project with Premake5.
I've been searching around and while I can link specific DLLs in the folder by setting libdirs "my unity DLLs"
followed by a link "UnityEditor.dll"
it seems like link
might not support wildcards in the way files
does. Is there a way to instruct Premake5 to grab all the dlls without manually listing all of them (there are many) that I'm not aware of? I'd also be fine with a lua workaround to grab the file names from the folder as long as it's reasonably portable.
Here is my premake.lua for reference grabbing only the single UnityEditor.dll
local ROOT = "../"
local SOURCE = ROOT.."Source/"
local BUILD = ROOT.."Build/"
workspace "RELoad_CorePlugin"
configurations { "Debug", "Release" }
location (ROOT)
dotnetframework "net6.0"
project "RELoad_Core"
kind "SharedLib"
language "C#"
libdirs "C:/Program Files/Unity/2021.3.12f1/Editor/Data/Managed/UnityEngine/" -- hard coded for now
links "UnityEditor.dll"
targetdir (ROOT.."Output")
location (BUILD)
files (SOURCE.."Core/**.cs")
It seems you want os.matchfiles
local dll_pattern = "C:/Program Files/Unity/2021.3.12f1/Editor/Data/Managed/UnityEngine/*.dll"
local fullpath_dlls = os.matchfiles(dll_pattern)
local dlls = table.translate(fullpath_dlls, path.getname)
links(dlls)