Commits

Justin Miller committed 9c30f47 Draft

Added vimmake action that shares most code with gmake

Comments (0)

Files changed (2)

src/actions/make/_make.lua

 			premake.clean.file(prj, _MAKE.getmakefilename(prj, true))
 		end
 	}
+
+
+--
+-- Register the "vimmake" action
+--
+
+	newaction {
+		trigger         = "vimmake",
+		shortname       = "GNU Make (vim-friendly)",
+		description     = "Generate GNU makefiles for POSIX, MinGW, and Cygwin (vim-friendly: print directories)",
+
+		valid_kinds     = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" },
+
+		valid_languages = { "C", "C++", "C#" },
+
+		valid_tools     = {
+			cc     = { "gcc" },
+			dotnet = { "mono", "msnet", "pnet" },
+		},
+
+		onsolution = function(sln)
+			premake.generate(sln, _MAKE.getmakefilename(sln, false), premake.make_solution_vimfriendly)
+		end,
+
+		onproject = function(prj)
+			local makefile = _MAKE.getmakefilename(prj, true)
+			if premake.isdotnetproject(prj) then
+				premake.generate(prj, makefile, premake.make_csharp)
+			else
+				premake.generate(prj, makefile, premake.make_cpp)
+			end
+		end,
+
+		oncleansolution = function(sln)
+			premake.clean.file(sln, _MAKE.getmakefilename(sln, false))
+		end,
+
+		oncleanproject = function(prj)
+			premake.clean.file(prj, _MAKE.getmakefilename(prj, true))
+		end
+	}
+

src/actions/make/make_solution.lua

 -- Copyright (c) 2002-2009 Jason Perkins and the Premake project
 --
 
-	function premake.make_solution(sln)
+	function premake.make_solution_base(sln, print_dirs)
 		-- create a shortcut to the compiler interface
 		local cc = premake[_OPTIONS.cc]
 
 		-- build a list of supported target platforms that also includes a generic build
 		local platforms = premake.filterplatforms(sln, cc.platforms, "Native")
 
+		local print_dirs_flag = ""
+		if not print_dirs then
+			print_dirs_flag = "--no-print-directory"
+		end
+
 		-- write a header showing the build options
 		_p('# %s solution makefile autogenerated by Premake', premake.action.current().shortname)
 		_p('# Type "make help" for usage help')
 		for _, prj in ipairs(sln.projects) do
 			_p('%s: %s', _MAKE.esc(prj.name), table.concat(_MAKE.esc(table.extract(premake.getdependencies(prj), "name")), " "))
 			_p('\t@echo "==== Building %s ($(config)) ===="', prj.name)
-			_p('\t@${MAKE} --no-print-directory -C %s -f %s', _MAKE.esc(path.getrelative(sln.location, prj.location)), _MAKE.esc(_MAKE.getmakefilename(prj, true)))
+			_p('\t@${MAKE} %s -C %s -f %s', print_dirs_flag, _MAKE.esc(path.getrelative(sln.location, prj.location)), _MAKE.esc(_MAKE.getmakefilename(prj, true)))
 			_p('')
 		end
 
 		-- clean rules
 		_p('clean:')
 		for _ ,prj in ipairs(sln.projects) do
-			_p('\t@${MAKE} --no-print-directory -C %s -f %s clean', _MAKE.esc(path.getrelative(sln.location, prj.location)), _MAKE.esc(_MAKE.getmakefilename(prj, true)))
+			_p('\t@${MAKE} %s -C %s -f %s clean', print_dirs_flag, _MAKE.esc(path.getrelative(sln.location, prj.location)), _MAKE.esc(_MAKE.getmakefilename(prj, true)))
 		end
 		_p('')
 		
 		_p(1,'@echo "For more information, see http://industriousone.com/premake/quick-start"')
 		
 	end
+
+	function premake.make_solution(sln)
+		premake.make_solution_base(sln, false)
+	end
+
+	function premake.make_solution_vimfriendly(sln)
+		premake.make_solution_base(sln, true)
+	end