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

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstarkos <none@none>2009-08-12 18:56:54 +0400
committerstarkos <none@none>2009-08-12 18:56:54 +0400
commitb1ee77fef3a6b720ee5f27deb321f44fcd04a0bc (patch)
treeea5f412149ca6a19be43df5b17201117178b340a
parent2ad5055a63688d99585be7bce4f7d2f10e89335a (diff)
Refactored clean action to use new callbacks
-rw-r--r--samples/project/CppConsoleApp/premake4.lua3
-rw-r--r--samples/project/premake4.lua8
-rw-r--r--src/actions/clean/_clean.lua124
-rw-r--r--src/actions/vstudio/_vstudio.lua24
4 files changed, 54 insertions, 105 deletions
diff --git a/samples/project/CppConsoleApp/premake4.lua b/samples/project/CppConsoleApp/premake4.lua
index 7781ed9..e1d684a 100644
--- a/samples/project/CppConsoleApp/premake4.lua
+++ b/samples/project/CppConsoleApp/premake4.lua
@@ -12,9 +12,6 @@ project "CppConsoleApp"
libdirs { "../lib" }
links { "CppSharedLib" }
- pchheader "stdafx.h"
- pchsource "stdafx.cpp"
-
configuration "Debug"
targetdir "../bin/debug (x64)"
links { "CppStaticLib" }
diff --git a/samples/project/premake4.lua b/samples/project/premake4.lua
index e543803..7ce87bd 100644
--- a/samples/project/premake4.lua
+++ b/samples/project/premake4.lua
@@ -28,14 +28,6 @@ solution "PremakeTestbox"
--- add to the built-in clean action
-
- if _ACTION == "clean" then
- os.rmdir("bin")
- end
-
-
-
-- add a new install action
newaction {
diff --git a/src/actions/clean/_clean.lua b/src/actions/clean/_clean.lua
index c5eec7b..0772055 100644
--- a/src/actions/clean/_clean.lua
+++ b/src/actions/clean/_clean.lua
@@ -8,8 +8,8 @@
--
--- Clean a solution or project specific file. Uses information in the project
--- object to build the target filename.
+-- Clean a solution or project specific directory. Uses information in the
+-- project object to build the target path.
--
-- @param obj
-- A solution or project object.
@@ -18,9 +18,9 @@
-- a description of the format.
--
- function premake.clean.file(obj, pattern)
+ function premake.clean.directory(obj, pattern)
local fname = premake.project.getfilename(obj, pattern)
- os.remove(fname)
+ os.rmdir(fname)
end
@@ -41,21 +41,6 @@
end
-
---
--- Remove files created by an object's templates.
---
-
- local function cleantemplatefiles(this, templates)
- if (templates) then
- for _,tmpl in ipairs(templates) do
- local fname = premake.getoutputname(this, tmpl[1])
- os.remove(fname)
- end
- end
- end
-
-
--
-- Register the "clean" action.
--
@@ -64,77 +49,56 @@
trigger = "clean",
description = "Remove all binaries and generated files",
- execute = function()
- local solutions = { }
- local projects = { }
- local targets = { }
-
- local cwd = os.getcwd()
- local function rebase(parent, dir)
- return path.getabsolute(path.rebase(dir, parent.location, cwd))
+ onsolution = function(sln)
+ for action in premake.action.each() do
+ if action.oncleansolution then
+ action.oncleansolution(sln)
+ end
end
-
- -- Walk the tree. Build a list of object names to pass to the cleaners,
- -- and delete any toolset agnostic files along the way.
- for _,sln in ipairs(_SOLUTIONS) do
- table.insert(solutions, path.join(sln.location, sln.name))
-
- -- build a list of supported target platforms that also includes a generic build
- local platforms = sln.platforms or { }
- if not table.contains(platforms, "Native") then
- platforms = table.join(platforms, { "Native" })
+ end,
+
+ onproject = function(prj)
+ for action in premake.action.each() do
+ if action.oncleanproject then
+ action.oncleanproject(prj)
end
+ end
- for prj in premake.eachproject(sln) do
- table.insert(projects, path.join(prj.location, prj.name))
-
- if (prj.objectsdir) then
- os.rmdir(rebase(prj, prj.objectsdir))
- end
+ if (prj.objectsdir) then
+ premake.clean.directory(prj, prj.objectsdir)
+ end
- for _, platform in ipairs(platforms) do
- for cfg in premake.eachconfig(prj, platform) do
- table.insert(targets, path.join(rebase(cfg, cfg.buildtarget.directory), cfg.buildtarget.basename))
-
- -- remove all possible permutations of the target binary
- os.remove(rebase(cfg, premake.gettarget(cfg, "build", "posix", "windows", "windows").fullpath))
- os.remove(rebase(cfg, premake.gettarget(cfg, "build", "posix", "posix", "linux").fullpath))
- os.remove(rebase(cfg, premake.gettarget(cfg, "build", "posix", "posix", "macosx").fullpath))
- os.remove(rebase(cfg, premake.gettarget(cfg, "build", "posix", "PS3", "windows").fullpath))
- if (cfg.kind == "WindowedApp") then
- os.rmdir(rebase(cfg, premake.gettarget(cfg, "build", "posix", "posix", "linux").fullpath .. ".app"))
- end
-
- -- if there is an import library, remove that too
- os.remove(rebase(cfg, premake.gettarget(cfg, "link", "windows", "windows", "windows").fullpath))
- os.remove(rebase(cfg, premake.gettarget(cfg, "link", "posix", "posix", "linux").fullpath))
-
- -- remove the associated objects directory
- os.rmdir(rebase(cfg, cfg.objectsdir))
- end
- end
- end
+ -- build a list of supported target platforms that also includes a generic build
+ local platforms = prj.solution.platforms or { }
+ if not table.contains(platforms, "Native") then
+ platforms = table.join(platforms, { "Native" })
end
- -- Walk the tree again and let the actions clean up after themselves
- for action in premake.action.each() do
- for _, sln in ipairs(_SOLUTIONS) do
- if action.oncleansolution then
- action.oncleansolution(sln)
+ for _, platform in ipairs(platforms) do
+ for cfg in premake.eachconfig(prj, platform) do
+ premake.clean.directory(prj, cfg.objectsdir)
+
+ -- remove all permutations of the target binary
+ premake.clean.file(prj, premake.gettarget(cfg, "build", "posix", "windows", "windows").fullpath)
+ premake.clean.file(prj, premake.gettarget(cfg, "build", "posix", "posix", "linux").fullpath)
+ premake.clean.file(prj, premake.gettarget(cfg, "build", "posix", "posix", "macosx").fullpath)
+ premake.clean.file(prj, premake.gettarget(cfg, "build", "posix", "PS3", "windows").fullpath)
+ if cfg.kind == "WindowedApp" then
+ premake.clean.file(prj, premake.gettarget(cfg, "build", "posix", "posix", "linux").fullpath .. ".app")
end
- cleantemplatefiles(sln, action.solutiontemplates)
- for prj in premake.eachproject(sln) do
- if action.oncleanproject then
- action.oncleanproject(prj)
+ -- if there is an import library, remove that too
+ premake.clean.file(prj, premake.gettarget(cfg, "link", "windows", "windows", "windows").fullpath)
+ premake.clean.file(prj, premake.gettarget(cfg, "link", "posix", "posix", "linux").fullpath)
+
+ -- call action.oncleantarget() with the undecorated target name
+ local target = path.join(premake.project.getfilename(prj, cfg.buildtarget.directory), cfg.buildtarget.basename)
+ for action in premake.action.each() do
+ if action.oncleantarget then
+ action.oncleantarget(target)
end
- cleantemplatefiles(prj, action.projecttemplates)
end
end
-
- if (type(action.onclean) == "function") then
- action.onclean(solutions, projects, targets)
- end
end
- end,
+ end
}
diff --git a/src/actions/vstudio/_vstudio.lua b/src/actions/vstudio/_vstudio.lua
index b66ffac..e40f18a 100644
--- a/src/actions/vstudio/_vstudio.lua
+++ b/src/actions/vstudio/_vstudio.lua
@@ -170,16 +170,12 @@
end
end
-
- function premake.vstudio_clean(solutions, projects, targets)
-
- for _,name in ipairs(targets) do
- os.remove(name .. ".pdb")
- os.remove(name .. ".idb")
- os.remove(name .. ".ilk")
- os.remove(name .. ".vshost.exe")
- os.remove(name .. ".exe.manifest")
- end
+ function premake.vstudio.cleantarget(name)
+ os.remove(name .. ".pdb")
+ os.remove(name .. ".idb")
+ os.remove(name .. ".ilk")
+ os.remove(name .. ".vshost.exe")
+ os.remove(name .. ".exe.manifest")
end
@@ -340,7 +336,7 @@
oncleansolution = premake.vstudio.cleansolution,
oncleanproject = premake.vstudio.cleanproject,
- onclean = premake.vstudio_clean,
+ oncleantarget = premake.vstudio.cleantarget
}
newaction {
@@ -373,7 +369,7 @@
oncleansolution = premake.vstudio.cleansolution,
oncleanproject = premake.vstudio.cleanproject,
- onclean = premake.vstudio_clean,
+ oncleantarget = premake.vstudio.cleantarget
}
newaction {
@@ -406,7 +402,7 @@
oncleansolution = premake.vstudio.cleansolution,
oncleanproject = premake.vstudio.cleanproject,
- onclean = premake.vstudio_clean,
+ oncleantarget = premake.vstudio.cleantarget
}
newaction {
@@ -439,5 +435,5 @@
oncleansolution = premake.vstudio.cleansolution,
oncleanproject = premake.vstudio.cleanproject,
- onclean = premake.vstudio_clean,
+ oncleantarget = premake.vstudio.cleantarget
}