From 18c498f7b3fc7de9d2993fd831f51c3a75821112 Mon Sep 17 00:00:00 2001 From: starkos Date: Tue, 29 Sep 2009 18:32:34 +0000 Subject: [PATCH] Set up _OS for xcode tests --- src/_premake_main.lua | 9 +++---- src/actions/xcode/_xcode.lua | 47 ++++++++++++++++++------------------ src/base/action.lua | 17 +++++++++++++ tests/actions/test_xcode.lua | 1 + tests/base/test_action.lua | 11 +++++++++ 5 files changed, 55 insertions(+), 30 deletions(-) diff --git a/src/_premake_main.lua b/src/_premake_main.lua index fb966def..3fbe75b7 100644 --- a/src/_premake_main.lua +++ b/src/_premake_main.lua @@ -63,13 +63,10 @@ end - -- Some actions imply a particular operating system. Set it early so - -- it can be picked up by the scripts. + -- Set up the environment for the chosen action early, so side-effects + -- can be picked up by the scripts. - local action = premake.action.current() - if action then - _OS = action.os or _OS - end + premake.action.set(_ACTION) -- Seed the random number generator so actions don't have to do it themselves diff --git a/src/actions/xcode/_xcode.lua b/src/actions/xcode/_xcode.lua index 1b726b46..d216b85d 100644 --- a/src/actions/xcode/_xcode.lua +++ b/src/actions/xcode/_xcode.lua @@ -6,27 +6,26 @@ premake.xcode = { } --- turned off for the 4.1.2 release --- newaction --- { --- trigger = "xcode3", --- shortname = "Xcode 3", --- description = "Apple Xcode 3 (experimental)", --- os = "macosx", --- --- valid_kinds = { "ConsoleApp", "WindowedApp", "SharedLib", "StaticLib" }, --- --- valid_languages = { "C", "C++" }, --- --- valid_tools = { --- cc = { "gcc" }, --- }, --- --- onsolution = function(sln) --- premake.generate(sln, "%%.xcodeproj/project.pbxproj", premake.xcode.pbxproj) --- end, --- --- oncleansolution = function(sln) --- premake.clean.directory(sln, "%%.xcodeproj") --- end, --- } + newaction + { + trigger = "xcode3", + shortname = "Xcode 3", + description = "Apple Xcode 3 (experimental)", + os = "macosx", + + valid_kinds = { "ConsoleApp", "WindowedApp", "SharedLib", "StaticLib" }, + + valid_languages = { "C", "C++" }, + + valid_tools = { + cc = { "gcc" }, + }, + + onsolution = function(sln) + premake.generate(sln, "%%.xcodeproj/project.pbxproj", premake.xcode.pbxproj) + end, + + oncleansolution = function(sln) + premake.clean.directory(sln, "%%.xcodeproj") + end, + } diff --git a/src/base/action.lua b/src/base/action.lua index 0ec7c560..2e7edc9c 100644 --- a/src/base/action.lua +++ b/src/base/action.lua @@ -114,6 +114,23 @@ end +-- +-- Activates a particular action. +-- +-- @param name +-- The name of the action to activate. +-- + + function premake.action.set(name) + _ACTION = name + -- Some actions imply a particular operating system + local action = premake.action.get(name) + if action then + _OS = action.os or _OS + end + end + + -- -- Determines if an action supports a particular language or target type. -- diff --git a/tests/actions/test_xcode.lua b/tests/actions/test_xcode.lua index 86a818c1..98a88a2d 100644 --- a/tests/actions/test_xcode.lua +++ b/tests/actions/test_xcode.lua @@ -51,6 +51,7 @@ local sln, tr function T.xcode3.setup() + premake.action.set("xcode3") -- reset the list of generated IDs used_ids = { } sln = test.createsolution() diff --git a/tests/base/test_action.lua b/tests/base/test_action.lua index b912471d..9aee2f9c 100644 --- a/tests/base/test_action.lua +++ b/tests/base/test_action.lua @@ -58,3 +58,14 @@ function T.action.CallSkipsCallbacksIfNotPresent() test.success(premake.action.call, "fake") end + + +-- +-- Tests for set() +-- + + function T.action.set_SetsActionOS() + _OS = "linux" + premake.action.set("vs2008") + test.isequal(_OS, "windows") + end