Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_make_linking.lua « make « actions « tests - github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bf43581d61f3e44a3f6293c7d0c5287a6816ae42 (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
126
--
-- 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. In order to support
-- custom target prefixes and extensions, use the full, relative path
-- to the library.
--

	function suite.onSharedLibrarySibling()
		links { "MyProject2" }
		test.createproject(sln)
		kind "SharedLib"
		targetdir "libs"
		prepare()
		test.capture [[
  ALL_LDFLAGS   += $(LDFLAGS) -Llibs -s
  LDDEPS    += libs/libMyProject2.so
  LIBS      += $(LDDEPS)
		]]
	end


--
-- Check linking to a static library sibling project. As with shared
-- libraries, it should list out the full relative path.
--

	function suite.onStaticLibrarySibling()
		links { "MyProject2" }
		test.createproject(sln)
		kind "StaticLib"
		targetdir "libs"
		prepare()
		test.capture [[
  ALL_LDFLAGS   += $(LDFLAGS) -Llibs -s
  LDDEPS    += libs/libMyProject2.a
  LIBS      += $(LDDEPS)
		]]
	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
  LDDEPS    +=
  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
  LDDEPS    += ../MyProject2/libMyProject2.so
  LIBS      += $(LDDEPS)
		]]
	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
  LDDEPS    +=
  LIBS      += $(LDDEPS) -lSomeLib
	]]
 end