2009-04-23 18:26:31 +00:00
|
|
|
--
|
|
|
|
-- tests/test_gmake_cpp.lua
|
|
|
|
-- Automated test suite for GNU Make C/C++ project generation.
|
|
|
|
-- Copyright (c) 2009 Jason Perkins and the Premake project
|
|
|
|
--
|
|
|
|
|
|
|
|
T.gmake_cpp = { }
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Configure a solution for testing
|
|
|
|
--
|
|
|
|
|
|
|
|
local sln, prj
|
|
|
|
function T.gmake_cpp.setup()
|
2009-05-08 20:18:47 +00:00
|
|
|
_ACTION = "gmake"
|
|
|
|
_OPTIONS.os = "linux"
|
|
|
|
|
2009-04-23 18:26:31 +00:00
|
|
|
sln = solution "MySolution"
|
|
|
|
configurations { "Debug", "Release" }
|
2012-01-03 22:08:22 +00:00
|
|
|
platforms { "Native" }
|
2009-04-23 18:26:31 +00:00
|
|
|
|
|
|
|
prj = project "MyProject"
|
|
|
|
language "C++"
|
2009-05-08 20:18:47 +00:00
|
|
|
kind "ConsoleApp"
|
2009-04-23 18:26:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function prepare()
|
2011-05-18 21:32:04 +00:00
|
|
|
premake.bake.buildconfigs()
|
2009-04-23 18:26:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-05-01 19:50:45 +00:00
|
|
|
--
|
|
|
|
-- Test the header
|
|
|
|
--
|
|
|
|
|
|
|
|
function T.gmake_cpp.BasicHeader()
|
|
|
|
prepare()
|
|
|
|
premake.gmake_cpp_header(prj, premake.gcc, sln.platforms)
|
|
|
|
test.capture [[
|
|
|
|
# GNU Make project makefile autogenerated by Premake
|
|
|
|
ifndef config
|
|
|
|
config=debug
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef verbose
|
|
|
|
SILENT = @
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef CC
|
|
|
|
CC = gcc
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef CXX
|
|
|
|
CXX = g++
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef AR
|
|
|
|
AR = ar
|
|
|
|
endif
|
2011-12-21 20:52:26 +00:00
|
|
|
|
|
|
|
ifndef RESCOMP
|
|
|
|
ifdef WINDRES
|
|
|
|
RESCOMP = $(WINDRES)
|
|
|
|
else
|
|
|
|
RESCOMP = windres
|
|
|
|
endif
|
|
|
|
endif
|
2009-05-01 19:50:45 +00:00
|
|
|
]]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Test configuration blocks
|
|
|
|
--
|
|
|
|
|
2009-04-23 18:26:31 +00:00
|
|
|
function T.gmake_cpp.BasicCfgBlock()
|
|
|
|
prepare()
|
|
|
|
local cfg = premake.getconfig(prj, "Debug")
|
2009-04-24 14:34:54 +00:00
|
|
|
premake.gmake_cpp_config(cfg, premake.gcc)
|
2009-04-23 18:26:31 +00:00
|
|
|
test.capture [[
|
|
|
|
ifeq ($(config),debug)
|
2009-05-22 20:27:05 +00:00
|
|
|
OBJDIR = obj/Debug
|
2009-04-23 18:26:31 +00:00
|
|
|
TARGETDIR = .
|
|
|
|
TARGET = $(TARGETDIR)/MyProject
|
|
|
|
DEFINES +=
|
|
|
|
INCLUDES +=
|
2009-12-17 15:15:13 +00:00
|
|
|
CPPFLAGS += -MMD -MP $(DEFINES) $(INCLUDES)
|
2009-04-23 18:26:31 +00:00
|
|
|
CFLAGS += $(CPPFLAGS) $(ARCH)
|
|
|
|
CXXFLAGS += $(CFLAGS)
|
2009-04-23 22:30:29 +00:00
|
|
|
LDFLAGS += -s
|
2009-04-23 18:26:31 +00:00
|
|
|
RESFLAGS += $(DEFINES) $(INCLUDES)
|
2011-09-15 20:45:48 +00:00
|
|
|
LIBS +=
|
2009-04-23 18:26:31 +00:00
|
|
|
LDDEPS +=
|
2011-12-08 21:25:50 +00:00
|
|
|
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(LDFLAGS)
|
2009-04-23 18:26:31 +00:00
|
|
|
define PREBUILDCMDS
|
|
|
|
endef
|
|
|
|
define PRELINKCMDS
|
|
|
|
endef
|
|
|
|
define POSTBUILDCMDS
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
]]
|
|
|
|
end
|
2009-05-01 19:50:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
function T.gmake_cpp.BasicCfgBlockWithPlatformCc()
|
2012-01-03 22:08:22 +00:00
|
|
|
platforms { "PS3" }
|
2009-05-01 19:50:45 +00:00
|
|
|
prepare()
|
|
|
|
local cfg = premake.getconfig(prj, "Debug", "PS3")
|
|
|
|
premake.gmake_cpp_config(cfg, premake.gcc)
|
|
|
|
test.capture [[
|
|
|
|
ifeq ($(config),debugps3)
|
|
|
|
CC = ppu-lv2-g++
|
|
|
|
CXX = ppu-lv2-g++
|
|
|
|
AR = ppu-lv2-ar
|
2009-05-22 20:27:05 +00:00
|
|
|
OBJDIR = obj/PS3/Debug
|
2009-05-01 19:50:45 +00:00
|
|
|
TARGETDIR = .
|
2009-05-08 20:18:47 +00:00
|
|
|
TARGET = $(TARGETDIR)/MyProject.elf
|
2009-05-01 19:50:45 +00:00
|
|
|
DEFINES +=
|
|
|
|
INCLUDES +=
|
2009-12-17 15:15:13 +00:00
|
|
|
CPPFLAGS += -MMD -MP $(DEFINES) $(INCLUDES)
|
2009-05-01 19:50:45 +00:00
|
|
|
CFLAGS += $(CPPFLAGS) $(ARCH)
|
|
|
|
CXXFLAGS += $(CFLAGS)
|
|
|
|
LDFLAGS += -s
|
|
|
|
RESFLAGS += $(DEFINES) $(INCLUDES)
|
2011-09-15 20:45:48 +00:00
|
|
|
LIBS +=
|
2009-05-01 19:50:45 +00:00
|
|
|
LDDEPS +=
|
2011-12-08 21:25:50 +00:00
|
|
|
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(LDFLAGS)
|
2009-05-01 19:50:45 +00:00
|
|
|
define PREBUILDCMDS
|
|
|
|
endef
|
|
|
|
define PRELINKCMDS
|
|
|
|
endef
|
|
|
|
define POSTBUILDCMDS
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
]]
|
|
|
|
end
|
2009-04-23 18:26:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
function T.gmake_cpp.PlatformSpecificBlock()
|
2009-05-01 19:50:45 +00:00
|
|
|
platforms { "x64" }
|
2009-04-23 18:26:31 +00:00
|
|
|
prepare()
|
|
|
|
local cfg = premake.getconfig(prj, "Debug", "x64")
|
2009-04-24 14:34:54 +00:00
|
|
|
premake.gmake_cpp_config(cfg, premake.gcc)
|
2009-04-23 18:26:31 +00:00
|
|
|
test.capture [[
|
|
|
|
ifeq ($(config),debug64)
|
2009-05-22 20:27:05 +00:00
|
|
|
OBJDIR = obj/x64/Debug
|
2009-04-23 18:26:31 +00:00
|
|
|
TARGETDIR = .
|
|
|
|
TARGET = $(TARGETDIR)/MyProject
|
|
|
|
DEFINES +=
|
|
|
|
INCLUDES +=
|
2009-12-17 15:15:13 +00:00
|
|
|
CPPFLAGS += -MMD -MP $(DEFINES) $(INCLUDES)
|
2009-04-23 18:26:31 +00:00
|
|
|
CFLAGS += $(CPPFLAGS) $(ARCH) -m64
|
|
|
|
CXXFLAGS += $(CFLAGS)
|
|
|
|
LDFLAGS += -s -m64 -L/usr/lib64
|
|
|
|
RESFLAGS += $(DEFINES) $(INCLUDES)
|
2011-09-15 20:45:48 +00:00
|
|
|
LIBS +=
|
2009-04-23 18:26:31 +00:00
|
|
|
LDDEPS +=
|
2011-12-08 21:25:50 +00:00
|
|
|
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(LIBS) $(LDFLAGS)
|
2009-04-23 18:26:31 +00:00
|
|
|
define PREBUILDCMDS
|
|
|
|
endef
|
|
|
|
define PRELINKCMDS
|
|
|
|
endef
|
|
|
|
define POSTBUILDCMDS
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
]]
|
|
|
|
end
|
2009-07-13 18:34:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
function T.gmake_cpp.UniversalStaticLibBlock()
|
|
|
|
kind "StaticLib"
|
2012-01-03 22:08:22 +00:00
|
|
|
platforms { "Universal32" }
|
2009-07-13 18:34:26 +00:00
|
|
|
prepare()
|
|
|
|
local cfg = premake.getconfig(prj, "Debug", "Universal32")
|
|
|
|
premake.gmake_cpp_config(cfg, premake.gcc)
|
|
|
|
test.capture [[
|
|
|
|
ifeq ($(config),debuguniv32)
|
|
|
|
OBJDIR = obj/Universal32/Debug
|
|
|
|
TARGETDIR = .
|
|
|
|
TARGET = $(TARGETDIR)/libMyProject.a
|
|
|
|
DEFINES +=
|
|
|
|
INCLUDES +=
|
|
|
|
CPPFLAGS += $(DEFINES) $(INCLUDES)
|
|
|
|
CFLAGS += $(CPPFLAGS) $(ARCH) -arch i386 -arch ppc
|
|
|
|
CXXFLAGS += $(CFLAGS)
|
|
|
|
LDFLAGS += -s -arch i386 -arch ppc
|
|
|
|
RESFLAGS += $(DEFINES) $(INCLUDES)
|
2011-09-15 20:45:48 +00:00
|
|
|
LIBS +=
|
2009-07-13 18:34:26 +00:00
|
|
|
LDDEPS +=
|
|
|
|
LINKCMD = libtool -o $(TARGET) $(OBJECTS)
|
|
|
|
define PREBUILDCMDS
|
|
|
|
endef
|
|
|
|
define PRELINKCMDS
|
|
|
|
endef
|
|
|
|
define POSTBUILDCMDS
|
|
|
|
endef
|
|
|
|
endif
|
|
|
|
]]
|
|
|
|
end
|