blob: ef853532c00c9da30922c9bfb6bd63e9f3c1ffc7 (
plain)
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
|
--
-- 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 cpp = premake.make.cpp
--
-- Setup
--
local sln, prj
function suite.setup()
_OS = "linux"
sln, prj = test.createsolution()
end
local function prepare()
premake.bake.buildconfigs()
cfg = premake.getconfig(prj, "Debug")
cpp.linker(cfg, premake.gcc)
end
--
-- 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
--
-- 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
--
-- 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
--
-- 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
--
-- When referencing an external library via a path, the directory
-- should be added to the library search paths, and the library
-- itself included via an -l flag.
--
function suite.onExternalLibraryWithPath()
location "MyProject"
links { "libs/SomeLib" }
prepare()
test.capture [[
ALL_LDFLAGS += $(LDFLAGS) -L../libs -s
LIBS += -lSomeLib
LDDEPS +=
]]
end
|