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
path: root/tests
diff options
context:
space:
mode:
authorJason Perkins <starkos@industriousone.com>2013-01-24 22:19:06 +0400
committerJason Perkins <starkos@industriousone.com>2013-01-24 22:19:06 +0400
commit53b6b39a8d1db9b6cabaf190c326a42064217266 (patch)
treefc1303ee86c8abfd9b6c12ddfc47506a5a3670df /tests
parenta3829657a1d29e7f863f8618414cf898cebf52a5 (diff)
Clean up GMake link tests in preparation for a bug fix
Diffstat (limited to 'tests')
-rw-r--r--tests/actions/make/test_make_linking.lua198
-rw-r--r--tests/actions/make/test_wiidev.lua24
-rw-r--r--tests/test_gmake_cpp.lua66
3 files changed, 145 insertions, 143 deletions
diff --git a/tests/actions/make/test_make_linking.lua b/tests/actions/make/test_make_linking.lua
index 7a346e6..f9d9c5d 100644
--- a/tests/actions/make/test_make_linking.lua
+++ b/tests/actions/make/test_make_linking.lua
@@ -1,112 +1,108 @@
-
- T.gcc_linking = { }
+--
+-- tests/actions/make/test_make_linking.lua
+-- Validate library references in makefiles.
+-- Copyright (c) 2010-2013 Jason Perkins and the Premake project
+--
+
+ T.gcc_linking = {}
local suite = T.gcc_linking
-
- local staticPrj
- local linksToStaticProj
- local sln
-
+ local cpp = premake.make.cpp
+
+--
+-- Setup
+--
+
+ local sln, prj
+
function suite.setup()
- _ACTION = "gmake"
-
- sln = solution "MySolution"
- configurations { "Debug" }
- platforms {}
-
- staticPrj = project "staticPrj"
- targetdir 'bar'
- language 'C++'
- kind "StaticLib"
-
- linksToStaticProj = project "linksToStaticProj"
- language 'C++'
- kind 'ConsoleApp'
- links{'staticPrj'}
- end
-
- function suite.teardown()
- staticPrj = nil
- linksToStaticProj = nil
- sln = nil
+ _OS = "linux"
+ sln, prj = test.createsolution()
end
-
- local get_buffer = function(projectName)
- io.capture()
+
+ local function prepare()
premake.bake.buildconfigs()
- local cfg = premake.getconfig(projectName, 'Debug', 'Native')
- premake.gmake_cpp_config(cfg, premake.gcc)
- local buffer = io.endcapture()
- return buffer
- end
-
- function suite.projectLinksToStaticPremakeMadeLibrary_linksUsingTheFormat_pathNameExtension()
- local buffer = get_buffer(linksToStaticProj)
- local format_exspected = 'LIBS %+%= bar/libstaticPrj.a'
- test.string_contains(buffer,format_exspected)
+ cfg = premake.getconfig(prj, "Debug")
+ cpp.linker(cfg, premake.gcc)
end
- T.link_suite= { }
- local firstProject = nil
- local linksToFirstProject = nil
-
- function T.link_suite.setup()
- _ACTION = "gmake"
- solution('dontCareSolution')
- configurations{'Debug'}
- end
-
- function T.link_suite.teardown()
- _ACTION = nil
- firstProject = nil
- linksToFirstProject = nil
+
+--
+-- Check linking to a shared library sibling project. Should add the library
+-- path using -L, and link using the base name with -l flag.
+--
+
+ function suite.onSharedLibrarySibling()
+ links { "MyProject2" }
+ test.createproject(sln)
+ kind "SharedLib"
+ targetdir "libs"
+ prepare()
+ test.capture [[
+ ALL_LDFLAGS += $(LDFLAGS) -Llibs -s
+ LIBS += -lMyProject2
+ LDDEPS += libs/libMyProject2.so
+ ]]
end
-
- function T.link_suite.projectLinksToSharedPremakeMadeLibrary_linksUsingFormat_dashLName()
-
- firstProject = project 'firstProject'
- kind 'SharedLib'
- language 'C'
-
- linksToFirstProject = project 'linksToFirstProject'
- kind 'ConsoleApp'
- language 'C'
- links{'firstProject'}
-
- local buffer = get_buffer(linksToFirstProject)
- local format_exspected = 'LIBS %+%= %-lfirstProject'
- test.string_contains(buffer,format_exspected)
+
+
+--
+-- Check linking to a static library sibling project. Should use the full
+-- decorated library name, relative path, and no -l flag.
+--
+
+ function suite.onStaticLibrarySibling()
+ links { "MyProject2" }
+ test.createproject(sln)
+ kind "StaticLib"
+ targetdir "libs"
+ prepare()
+ test.capture [[
+ ALL_LDFLAGS += $(LDFLAGS) -Llibs -s
+ LIBS += libs/libMyProject2.a
+ LDDEPS += libs/libMyProject2.a
+ ]]
end
-
- function T.link_suite.projectLinksToPremakeMadeConsoleApp_doesNotLinkToConsoleApp()
-
- firstProject = project 'firstProject'
- kind 'ConsoleApp'
- language 'C'
-
- linksToFirstProject = project 'linksToFirstProject'
- kind 'ConsoleApp'
- language 'C'
- links{'firstProject'}
-
- local buffer = get_buffer(linksToFirstProject)
- local format_exspected = 'LIBS %+%=%s+\n'
- test.string_contains(buffer,format_exspected)
+
+
+--
+-- If an executable is listed in the links, no linking should happen (a
+-- build dependency would have been created at the solution level)
+--
+
+ function suite.onConsoleAppSibling()
+ links { "MyProject2" }
+ test.createproject(sln)
+ kind "ConsoleApp"
+ targetdir "libs"
+ prepare()
+ test.capture [[
+ ALL_LDFLAGS += $(LDFLAGS) -s
+ LIBS +=
+ LDDEPS +=
+ ]]
end
-
- function T.link_suite.projectLinksToStaticPremakeMadeLibrary_projectDifferInDirectoryHeights_linksUsingCorrectRelativePath()
-
- firstProject = project 'firstProject'
- kind 'StaticLib'
- language 'C'
-
- linksToFirstProject = project 'linksToFirstProject'
- kind 'ConsoleApp'
- language 'C'
- links{'firstProject'}
- location './foo/bar'
-
- local buffer = get_buffer(linksToFirstProject)
- local format_exspected = 'LIBS %+%= ../../libfirstProject.a'
- test.string_contains(buffer,format_exspected)
+
+
+--
+-- Make sure that project locations are taken into account when building
+-- the path to the library.
+--
+
+
+ function suite.onProjectLocations()
+ location "MyProject"
+ links { "MyProject2" }
+
+ test.createproject(sln)
+ kind "SharedLib"
+ location "MyProject2"
+ targetdir "MyProject2"
+
+ prepare()
+ test.capture [[
+ ALL_LDFLAGS += $(LDFLAGS) -L../MyProject2 -s
+ LIBS += -lMyProject2
+ LDDEPS += ../MyProject2/libMyProject2.so
+ ]]
end
diff --git a/tests/actions/make/test_wiidev.lua b/tests/actions/make/test_wiidev.lua
index 4561b0c..f3787a0 100644
--- a/tests/actions/make/test_wiidev.lua
+++ b/tests/actions/make/test_wiidev.lua
@@ -3,23 +3,23 @@
-- Tests for Wii homebrew support in makefiles.
-- Copyright (c) 2011 Jason Perkins and the Premake project
--
-
+
T.make_wiidev = { }
local suite = T.make_wiidev
local make = premake.make
local cpp = premake.make.cpp
-
+
local sln, prj, cfg
-
+
function suite.setup()
_ACTION = "gmake"
sln = solution("MySolution")
configurations { "Debug", "Release" }
- platforms { "WiiDev" }
-
+ platforms { "WiiDev" }
+
prj = project("MyProject")
-
+
premake.bake.buildconfigs()
cfg = premake.getconfig(prj, "Debug", "WiiDev")
end
@@ -33,10 +33,16 @@
cpp.flags(cfg, premake.gcc)
test.capture [[
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP -I$(LIBOGC_INC) $(MACHDEP) -MP $(DEFINES) $(INCLUDES)
- ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)
- ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
+ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)
+ ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
+ ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
+ ]]
+ end
+
+ function suite.writesCorrectLinkFlags()
+ cpp.linker(cfg, premake.gcc)
+ test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -s -L$(LIBOGC_LIB) $(MACHDEP)
- RESFLAGS += $(DEFINES) $(INCLUDES)
]]
end
diff --git a/tests/test_gmake_cpp.lua b/tests/test_gmake_cpp.lua
index d87a1bf..4a6992e 100644
--- a/tests/test_gmake_cpp.lua
+++ b/tests/test_gmake_cpp.lua
@@ -18,16 +18,16 @@
sln = solution "MySolution"
configurations { "Debug", "Release" }
platforms { "native" }
-
+
prj = project "MyProject"
language "C++"
- kind "ConsoleApp"
+ kind "ConsoleApp"
end
local function prepare()
premake.bake.buildconfigs()
end
-
+
--
@@ -60,9 +60,9 @@ ifndef RESCOMP
endif
]]
end
-
-
-
+
+
+
--
-- Test configuration blocks
--
@@ -76,15 +76,15 @@ ifeq ($(config),debug)
OBJDIR = obj/Debug
TARGETDIR = .
TARGET = $(TARGETDIR)/MyProject
- DEFINES +=
- INCLUDES +=
+ DEFINES +=
+ INCLUDES +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
- ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)
- ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
+ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)
+ ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
+ ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
ALL_LDFLAGS += $(LDFLAGS) -s
- RESFLAGS += $(DEFINES) $(INCLUDES)
- LIBS +=
- LDDEPS +=
+ LIBS +=
+ LDDEPS +=
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(ALL_LDFLAGS)
define PREBUILDCMDS
endef
@@ -95,7 +95,7 @@ ifeq ($(config),debug)
endif
]]
end
-
+
function T.gmake_cpp.BasicCfgBlockWithPlatformCc()
platforms { "ps3" }
@@ -110,15 +110,15 @@ ifeq ($(config),debugps3)
OBJDIR = obj/PS3/Debug
TARGETDIR = .
TARGET = $(TARGETDIR)/MyProject.elf
- DEFINES +=
- INCLUDES +=
+ DEFINES +=
+ INCLUDES +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
- ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)
- ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
+ ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)
+ ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
+ ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
ALL_LDFLAGS += $(LDFLAGS) -s
- RESFLAGS += $(DEFINES) $(INCLUDES)
- LIBS +=
- LDDEPS +=
+ LIBS +=
+ LDDEPS +=
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(ALL_LDFLAGS)
define PREBUILDCMDS
endef
@@ -141,15 +141,15 @@ ifeq ($(config),debug64)
OBJDIR = obj/x64/Debug
TARGETDIR = .
TARGET = $(TARGETDIR)/MyProject
- DEFINES +=
- INCLUDES +=
+ DEFINES +=
+ INCLUDES +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -m64
- ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
+ ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
+ ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
ALL_LDFLAGS += $(LDFLAGS) -s -m64 -L/usr/lib64
- RESFLAGS += $(DEFINES) $(INCLUDES)
- LIBS +=
- LDDEPS +=
+ LIBS +=
+ LDDEPS +=
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(ALL_LDFLAGS)
define PREBUILDCMDS
endef
@@ -173,15 +173,15 @@ ifeq ($(config),debuguniv32)
OBJDIR = obj/Universal32/Debug
TARGETDIR = .
TARGET = $(TARGETDIR)/libMyProject.a
- DEFINES +=
- INCLUDES +=
+ DEFINES +=
+ INCLUDES +=
ALL_CPPFLAGS += $(CPPFLAGS) $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -arch i386 -arch ppc
- ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
+ ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
+ ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
ALL_LDFLAGS += $(LDFLAGS) -s -arch i386 -arch ppc
- RESFLAGS += $(DEFINES) $(INCLUDES)
- LIBS +=
- LDDEPS +=
+ LIBS +=
+ LDDEPS +=
LINKCMD = libtool -o $(TARGET) $(OBJECTS)
define PREBUILDCMDS
endef