diff options
Diffstat (limited to 'tests/actions')
-rw-r--r-- | tests/actions/make/test_make_linking.lua | 198 | ||||
-rw-r--r-- | tests/actions/make/test_wiidev.lua | 24 |
2 files changed, 112 insertions, 110 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 |