Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Perkins <starkos@industriousone.com>2014-04-24 18:53:28 +0400
committerJason Perkins <starkos@industriousone.com>2014-04-24 18:53:28 +0400
commit9fe99f784ec5481f89668c42aa535dff74aa664b (patch)
treef93363698bc2a105a347af4a44428f9eca2ba734
parentb27d1accb89968833ee089e6544030829ca74ec0 (diff)
parent2776b538edf96ffbfe73abbe09270af3cf091483 (diff)
Merged in dcourtois/premake-stable/issue_60 (pull request #44)
added post and pre build events support for C# projects
-rw-r--r--src/actions/vstudio/vs2005_csproj.lua20
-rw-r--r--tests/actions/vstudio/cs2005/buildevents.lua53
-rw-r--r--tests/premake4.lua1
3 files changed, 74 insertions, 0 deletions
diff --git a/src/actions/vstudio/vs2005_csproj.lua b/src/actions/vstudio/vs2005_csproj.lua
index c8542c9..6b6238c 100644
--- a/src/actions/vstudio/vs2005_csproj.lua
+++ b/src/actions/vstudio/vs2005_csproj.lua
@@ -207,6 +207,23 @@
end
end
+--
+-- Write the build events groups.
+--
+
+ function cs2005.buildevents(cfg)
+ if #cfg.prebuildcommands > 0 then
+ _p(' <PropertyGroup>')
+ _p(' <PreBuildEvent>%s</PreBuildEvent>', premake.esc(table.implode(cfg.prebuildcommands, "", "", "\r\n")))
+ _p(' </PropertyGroup>')
+ end
+ if #cfg.postbuildcommands > 0 then
+ _p(' <PropertyGroup>')
+ _p(' <PostBuildEvent>%s</PostBuildEvent>', premake.esc(table.implode(cfg.postbuildcommands, "", "", "\r\n")))
+ _p(' </PropertyGroup>')
+ end
+ end
+
--
-- The main function: write the project file.
@@ -265,6 +282,9 @@
local msbuild = iif(_ACTION < "vs2012", "Bin", "Tools")
_p(' <Import Project="$(MSBuild%sPath)\\Microsoft.CSharp.targets" />', msbuild)
+ -- build events
+ cs2005.buildevents(prj)
+
_p(' <!-- To modify your build process, add your task inside one of the targets below and uncomment it.')
_p(' Other similar extension points exist, see Microsoft.Common.targets.')
_p(' <Target Name="BeforeBuild">')
diff --git a/tests/actions/vstudio/cs2005/buildevents.lua b/tests/actions/vstudio/cs2005/buildevents.lua
new file mode 100644
index 0000000..213de1b
--- /dev/null
+++ b/tests/actions/vstudio/cs2005/buildevents.lua
@@ -0,0 +1,53 @@
+--
+-- tests/actions/vstudio/cs2005/buildevents.lua
+-- Validate the build events in Visual Studio 2005+ .csproj
+-- Copyright (c) 2009-2014 Jason Perkins and the Premake project
+--
+
+ T.vstudio_cs2005_buildevents = { }
+ local suite = T.vstudio_cs2005_buildevents
+ local cs2005 = premake.vstudio.cs2005
+
+--
+-- Setup
+--
+
+ local sln, prj
+
+ function suite.setup()
+ sln = test.createsolution()
+ end
+
+ local function prepare()
+ premake.bake.buildconfigs()
+ prj = premake.solution.getproject(sln, 1)
+ cs2005.buildevents(prj)
+ end
+
+--
+-- Prebuild events
+--
+
+ function suite.prebuildEvents()
+ prebuildcommands { "pre" }
+ prepare()
+ test.capture [[
+ <PropertyGroup>
+ <PreBuildEvent>pre</PreBuildEvent>
+ </PropertyGroup>
+ ]]
+ end
+
+--
+-- Postbuild events
+--
+
+ function suite.postbuildEvents()
+ postbuildcommands { "post" }
+ prepare()
+ test.capture [[
+ <PropertyGroup>
+ <PostBuildEvent>post</PostBuildEvent>
+ </PropertyGroup>
+ ]]
+ end
diff --git a/tests/premake4.lua b/tests/premake4.lua
index b0ebde9..6c149e3 100644
--- a/tests/premake4.lua
+++ b/tests/premake4.lua
@@ -86,6 +86,7 @@
dofile("actions/vstudio/cs2005/projectelement.lua")
dofile("actions/vstudio/cs2005/projectsettings.lua")
dofile("actions/vstudio/cs2005/propertygroup.lua")
+ dofile("actions/vstudio/cs2005/buildevents.lua")
-- Visual Studio 2005-2010 solutions
dofile("actions/vstudio/sln2005/dependencies.lua")