我将所有源文件保存在一个单独的位置,以保持我的后备箱清洁和井井有条。我只是在我的 lua 文件中指向这个“源代码”位置,但将我的“位置”设置为一个完全独立的“构建”目录。在大多数情况下,这会产生我想要的行为类型,并且似乎是一个优雅的解决方案。除了...
当我运行 premake 生成项目文件时,它会为包含的每个(编译元素)文件创建链接元素。因此,在打开解决方案文件时会创建一个无关文件夹。该文件夹不再使用。
生成的项目文件的摘录:
<ItemGroup>
<Compile Include="..\..\SourceCode\FileUtilities\FileUtilities.cs">
<Link>SourceCode\FileUtilities\FileUtilities.cs</Link>
</Compile>
<Compile Include="..\..\SourceCode\FileUtilities\FileWriter.cs">
<Link>SourceCode\FileUtilities\FileWriter.cs</Link>
</Compile>
</ItemGroup>
在 VS2013 中打开解决方案后,会创建一个“bin”和“obj”文件夹(根据需要)。但是还创建了一个额外的“SourceCode”目录(及其子目录),但从未再次使用过。是否有一个标志我可以用来简单地告诉 premake 不要在项目文件中包含链接块?
我正在使用premake5。
这是我的目录结构的设置方式:
\trunk\builds
\trunk\SourceCode\<Contains separate folders for each projects source code>
\trunk\premake\solutions\<contains premake solution files>
\trunk\premake\projects\<contains premake project files>
\trunk\premake\configurations\<contains premake configuration files>
模板解决方案文件,“solution-Template.lua”:
solutionName = "Template"
solution(solutionName)
location("../../builds/" .. solutionName)
--Include a configuration file to define all your build settings
include "../configurations/configurations-Template.lua"
--List all the projects contained in your solution.
--Note: The first project will be the default StartUp project
include "../projects/project-Template.lua"
include "../projects/project-AnotherProject.lua"
模板项目文件,“project-Template.lua”:
projectName = "Template"
buildLocation = projectName
if solutionName ~= nil then
buildLocation = solutionName .. "/" .. projectName
end
project(projectName)
location("../../builds/" .. buildLocation)
--kind is the output type of the project.
--https://github.com/premake/premake-core/wiki/kind
kind "SharedLib"
--language is the programming language the project is written in
--https://github.com/premake/premake-core/wiki/language
language "C#"
targetdir("../../builds/" .. buildLocation .. "/bin/%{cfg.buildcfg}")
--List all the files used in the project using relative paths
--The wild card "*" works (e.g. *.cs). "**" checks all child folders
files
{
"../../SourceCode/Template/File1.cs",
"../../SourceCode/Template/File2.cs",
"../../SourceCode/Template/Etc.cs"
}
--List all the libraries/references that your project uses, including
--other projects
links
{
"System",
"Template"
}
模板配置文件,'configurations-Template.lua':
configurations { "Debug", "Release" }
--Define the platform configuration names. These can be named anything.
--Visual Studio will default to the first value upon opening the solution.
--Note: Be careful, 'Win32' is a predefined name and will be replaced with 'x86' even if
--you set the architecture to "x64".
platforms { "Win64", "Win32" }
--Set all the filters needed to produce the desired build/platform configuration results.
--https://github.com/premake/premake-core/wiki/Configurations_And_Platforms
filter "configurations:Debug"
defines { "DEBUG" }
flags { "Symbols" }
filter "configurations:Release"
defines { "NDEBUG" }
optimize "On"
filter { "platforms:Win32" }
system "Windows"
architecture "x86"
filter { "platforms:Win64" }
system "Windows"
architecture "x64"
然后,我将在 \trunk\premake 的命令提示符下运行以下命令:
premake5 --file=./solutions/solution-Template.lua vs2013
这会导致在我的 \trunk\builds\ 目录中创建一个文件夹,并在其中为每个项目创建一个文件夹。这正是我想要的(并保持我的行李箱井井有条)。但是,在 VS2013 中打开解决方案文件时,会自动创建我的 SourceCode 目录的文件夹以及 bin 和 obj 文件夹,但它们根本不用于任何事情。据我所知,这是因为 Link 元素被添加到项目文件中。