From 94374e496bdf0e5184589a1bd8fc96ca13a550e2 Mon Sep 17 00:00:00 2001 From: rhuvendiek Date: Mon, 29 Jun 2015 13:56:15 +0200 Subject: [PATCH 1/2] Write entries to compile idl files with MIDL into vcxproj-files. --- src/actions/vstudio/vs2010_vcxproj.lua | 34 +++++++++++++++++++++++++- src/base/path.lua | 8 ++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua index a1816ef8..cb7d6cd4 100644 --- a/src/actions/vstudio/vs2010_vcxproj.lua +++ b/src/actions/vstudio/vs2010_vcxproj.lua @@ -583,7 +583,8 @@ "none", "resourceCompile", "customBuild", - "customRule" + "customRule", + "midlCompile" } m.elements.files = function(prj, groups) @@ -779,6 +780,35 @@ end end + function m.midlCompileFiles(prj, groups) + local files = groups.MidlCompile or {} + if #files > 0 then + p.push('') + for i, file in ipairs(files) do + local contents = p.capture(function () + p.push() + for cfg in project.eachconfig(prj) do + local condition = m.condition(cfg) + local filecfg = fileconfig.getconfig(file, cfg) + if cfg.system == premake.WINDOWS then + m.excludedFromBuild(cfg, filecfg) + end + end + p.pop() + end) + + if #contents > 0 then + p.push('', path.translate(file.relpath)) + p.outln(contents) + p.pop('') + else + p.x('', path.translate(file.relpath)) + end + end + p.pop('') + end + end + function m.categorize(prj, file) -- If any configuration for this file uses a custom build step, @@ -803,6 +833,8 @@ return "ClInclude" elseif path.isresourcefile(file.name) then return "ResourceCompile" + elseif path.isidlfile(file.name) then + return "MidlCompile" else return "None" end diff --git a/src/base/path.lua b/src/base/path.lua index 585428ab..9edad764 100644 --- a/src/base/path.lua +++ b/src/base/path.lua @@ -197,6 +197,14 @@ return path.hasextension(fname, ".rc") end +-- +-- Returns true if the filename represents a Windows idl file. +-- + + function path.isidlfile(fname) + return path.hasextension(fname, ".idl") + end + -- -- Takes a path which is relative to one location and makes it relative From 2014046021d7de75735fa267f09fd13455bba8d8 Mon Sep 17 00:00:00 2001 From: rhuvendiek Date: Wed, 1 Jul 2015 16:52:53 +0200 Subject: [PATCH 2/2] Add unit test for MIDL generator. --- tests/actions/vstudio/vc2010/test_files.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/actions/vstudio/vc2010/test_files.lua b/tests/actions/vstudio/vc2010/test_files.lua index 2ec49108..875eb91e 100755 --- a/tests/actions/vstudio/vc2010/test_files.lua +++ b/tests/actions/vstudio/vc2010/test_files.lua @@ -68,6 +68,16 @@ ]] end + function suite.midlCompile_onIDLFile() + files { "idl/interfaces.idl" } + prepare() + test.capture [[ + + + + ]] + end + function suite.none_onTxtFile() files { "docs/hello.txt" } prepare()