1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
--
-- 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()
_ACTION = "gmake"
_OPTIONS.os = "linux"
sln = solution "MySolution"
configurations { "Debug", "Release" }
platforms { "native" }
prj = project "MyProject"
language "C++"
kind "ConsoleApp"
end
local function prepare()
premake.bake.buildconfigs()
end
--
-- 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
CC = gcc
CXX = g++
AR = ar
ifndef RESCOMP
ifdef WINDRES
RESCOMP = $(WINDRES)
else
RESCOMP = windres
endif
endif
]]
end
--
-- Test configuration blocks
--
function T.gmake_cpp.BasicCfgBlock()
prepare()
local cfg = premake.getconfig(prj, "Debug")
premake.gmake_cpp_config(cfg, premake.gcc)
test.capture [[
ifeq ($(config),debug)
OBJDIR = obj/Debug
TARGETDIR = .
TARGET = $(TARGETDIR)/MyProject
DEFINES +=
INCLUDES +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
ALL_LDFLAGS += $(LDFLAGS) -s
LDDEPS +=
LIBS += $(LDDEPS)
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
endif
]]
end
function T.gmake_cpp.BasicCfgBlockWithPlatformCc()
platforms { "ps3" }
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
OBJDIR = obj/PS3/Debug
TARGETDIR = .
TARGET = $(TARGETDIR)/MyProject.elf
DEFINES +=
INCLUDES +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH)
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
ALL_LDFLAGS += $(LDFLAGS) -s
LDDEPS +=
LIBS += $(LDDEPS)
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
endif
]]
end
function T.gmake_cpp.PlatformSpecificBlock()
platforms { "x64" }
prepare()
local cfg = premake.getconfig(prj, "Debug", "x64")
premake.gmake_cpp_config(cfg, premake.gcc)
test.capture [[
ifeq ($(config),debug64)
OBJDIR = obj/x64/Debug
TARGETDIR = .
TARGET = $(TARGETDIR)/MyProject
DEFINES +=
INCLUDES +=
ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -m64
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
ALL_LDFLAGS += $(LDFLAGS) -s -m64 -L/usr/lib64
LDDEPS +=
LIBS += $(LDDEPS)
LINKCMD = $(CXX) -o $(TARGET) $(OBJECTS) $(RESOURCES) $(ARCH) $(ALL_LDFLAGS) $(LIBS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
endif
]]
end
function T.gmake_cpp.UniversalStaticLibBlock()
kind "StaticLib"
platforms { "universal32" }
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 +=
ALL_CPPFLAGS += $(CPPFLAGS) $(DEFINES) $(INCLUDES)
ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) $(ARCH) -arch i386 -arch ppc
ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS)
ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES)
ALL_LDFLAGS += $(LDFLAGS) -s -arch i386 -arch ppc
LDDEPS +=
LIBS += $(LDDEPS)
LINKCMD = libtool -o $(TARGET) $(OBJECTS)
define PREBUILDCMDS
endef
define PRELINKCMDS
endef
define POSTBUILDCMDS
endef
endif
]]
end
|