From 1fa3951541c46d9cdc8602a4b752c88939ff510e Mon Sep 17 00:00:00 2001 From: Jason Perkins Date: Thu, 7 Jun 2012 16:46:36 -0400 Subject: [PATCH] Added external() to reference non-Premake generated project files --- CHANGES.txt | 1 + src/actions/vstudio/_vstudio.lua | 4 ++-- src/base/action.lua | 4 ++-- src/base/api.lua | 18 +++++++++++++++++- src/project/project.lua | 15 +++++++++++++++ 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 9c6be839..a5092743 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,6 +7,7 @@ * Enabled per-configuration file lists * Enabled per-configuration toolset selection * Added custom build rules +* Added external() to reference non-Premake generated projects * Added remove...() API to remove values from list fields * Folders containing single sub-folder now trimmed from top of source tree * Added debugformat with C7 support for Visual Studio diff --git a/src/actions/vstudio/_vstudio.lua b/src/actions/vstudio/_vstudio.lua index 4f056a85..86a04138 100644 --- a/src/actions/vstudio/_vstudio.lua +++ b/src/actions/vstudio/_vstudio.lua @@ -151,8 +151,8 @@ end local location = project.getlocation(prj) - local filename = path.join(location, prj.name) .. extension - return filename + local filename = path.join(location, project.getfilename(prj)) + return filename .. extension end diff --git a/src/base/action.lua b/src/base/action.lua index 12310c57..57921082 100644 --- a/src/base/action.lua +++ b/src/base/action.lua @@ -63,7 +63,7 @@ a.onsolution(sln) end for prj in premake.solution.eachproject_ng(sln) do - if a.onproject then + if a.onproject and not prj.external then a.onproject(prj) end end @@ -74,7 +74,7 @@ a.onsolution(sln) end for prj in premake.solution.eachproject(sln) do - if a.onproject then + if a.onproject and not prj.external then a.onproject(prj) end end diff --git a/src/base/api.lua b/src/base/api.lua index b7815e62..c0e78e65 100644 --- a/src/base/api.lua +++ b/src/base/api.lua @@ -430,7 +430,7 @@ } api.register { - name = "flags", + name = "flags", scope = "config", kind = "list", allowed = { @@ -1219,6 +1219,22 @@ end +-- +-- Creates a reference to an external, non-Premake generated project. +-- + + function external(name) + -- define it like a regular project + local prj = project(name) + + -- then mark it as external + prj.external = true; + prj.externalname = prj.name + + return prj + end + + -- -- Define a new action. -- diff --git a/src/project/project.lua b/src/project/project.lua index b50cd639..c2904528 100755 --- a/src/project/project.lua +++ b/src/project/project.lua @@ -285,6 +285,21 @@ end +-- +-- Retrieve the project's file name. +-- +-- @param prj +-- The project object to query. +-- @return +-- The project's file name. This will usually match the project's +-- name, or the external name for externally created projects. +-- + + function project.getfilename(prj) + return prj.externalname or prj.name + end + + -- -- Retrieve the project's file system location. --