I'm keeping all my source files in a separate location to keep my trunk clean and organized. I simply point to this "SourceCode" location within my lua files but set my "location" to a completely separate "builds" directory. For the most part, this produces exactly the type of behavior I want and seems to be an elegant solution. Except...
When I run premake to generate project files, it's creating Link elements for each (Compile element) file that is included. As a result, an extraneous folder is created upon opening the solution file. That folder is never used again.
Ex excerpt of generated project file:
<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>
Upon opening the solution in VS2013, a "bin" and "obj" folder are created (as needed). But an extra "SourceCode" directory (and its children) is also created yet never used again. Is there a flag I can use to simply tell premake to NOT include Link blocks within the project files?
I am using premake5.
Here's how my directory structure is set up:
\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>
template solution file, '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"
template project file, '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"
}
template configuration file, '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"
I would then run the following command from command prompt in \trunk\premake:
premake5 --file=./solutions/solution-Template.lua vs2013
This results in a folder being created in my \trunk\builds\ directory and a folder for each project being created within that. This is exactly what I want (and keeps my trunk organized and clean). However, upon opening the solution file in VS2013, a folders for my SourceCode directories are automatically created along with bin and obj folders but they aren't used for anything at all. As far as I can tell, it's because of the Link elements being added to the project files.