1
+ import os
1
2
import textwrap
2
3
3
4
from conan .test .utils .tools import TestClient
@@ -13,7 +14,6 @@ def test_extra_flags_via_conf():
13
14
compiler=gcc
14
15
compiler.version=9
15
16
compiler.cppstd=17
16
- compiler.cstd=11
17
17
compiler.libcxx=libstdc++
18
18
build_type=Release
19
19
@@ -28,16 +28,14 @@ def test_extra_flags_via_conf():
28
28
tools.build:sharedlinkflags+=["-flag5"]
29
29
tools.build:exelinkflags+=["-flag6"]
30
30
tools.build:defines=["define1=0"]
31
- """
31
+ """
32
32
)
33
- t = TestClient ()
34
- t .save ({"conanfile.txt" : "[generators]\n PremakeToolchain" , "profile" : profile })
33
+ tc = TestClient ()
34
+ tc .save ({"conanfile.txt" : "[generators]\n PremakeToolchain" , "profile" : profile })
35
35
36
- t .run ("install . -pr:a=profile" )
37
- content = t .load (PremakeToolchain .filename )
38
- print (content )
36
+ tc .run ("install . -pr:a=profile" )
37
+ content = tc .load (PremakeToolchain .filename )
39
38
assert 'cppdialect "c++17"' in content
40
- # assert 'cdialect "99"' in content # TODO
41
39
42
40
assert (
43
41
"""
@@ -58,8 +56,89 @@ def test_extra_flags_via_conf():
58
56
)
59
57
60
58
assert 'linkoptions { "-flag02", "-other=val2", "-flag5", "-flag6" }' in content
59
+ assert 'defines { "define1=0" }' in content
61
60
62
- # assert "cpp_args = ['-flag0', '-other=val', '-m64', '-flag1', '-flag2', '-Ddefine1=0', '-D_GLIBCXX_USE_CXX11_ABI=0']" in content
63
- # assert "c_args = ['-flag0', '-other=val', '-m64', '-flag3', '-flag4', '-Ddefine1=0']" in content
64
- # assert "c_link_args = ['-flag0', '-other=val', '-m64', '-flag5', '-flag6']" in content
65
- # assert "cpp_link_args = ['-flag0', '-other=val', '-m64', '-flag5', '-flag6']" in content
61
+
62
+ def test_project_configuration ():
63
+ tc = TestClient (path_with_spaces = False )
64
+
65
+ conanfile = textwrap .dedent (
66
+ """
67
+ from conan import ConanFile
68
+ from conan.tools.layout import basic_layout
69
+ from conan.tools.premake import Premake, PremakeDeps, PremakeToolchain
70
+ import os
71
+
72
+ class Pkg(ConanFile):
73
+ settings = "os", "compiler", "build_type", "arch"
74
+ name = "pkg"
75
+ version = "1.0"
76
+
77
+ def layout(self):
78
+ basic_layout(self, src_folder="src")
79
+
80
+ def generate(self):
81
+ tc = PremakeToolchain(self)
82
+ tc.extra_defines = ["VALUE=2"]
83
+ tc.extra_cflags = ["-Wextra"]
84
+ tc.extra_cxxflags = ["-Wall", "-Wextra"]
85
+ tc.extra_ldflags = ["-lm"]
86
+ tc.project("main").extra_defines = ["TEST=False"]
87
+ tc.project("test").disable = True
88
+ tc.project("main").extra_cxxflags = ["-FS"]
89
+ tc.generate()
90
+ """
91
+ )
92
+ tc .save ({"conanfile.py" : conanfile })
93
+ tc .run ("install ." )
94
+
95
+ toolchain = tc .load (
96
+ os .path .join ("build-release" , "conan" , "conantoolchain.premake5.lua" )
97
+ )
98
+ print (toolchain )
99
+
100
+ assert (
101
+ """
102
+ filter {"files:**.c"}
103
+ buildoptions { "-Wextra" }
104
+ filter {}
105
+ """
106
+ in toolchain
107
+ )
108
+ assert (
109
+ """
110
+ filter {"files:**.cpp", "**.cxx", "**.cc"}
111
+ buildoptions { "-Wall", "-Wextra" }
112
+ filter {}
113
+ """
114
+ in toolchain
115
+ )
116
+ assert 'linkoptions { "-lm" }' in toolchain
117
+ assert 'defines { "VALUE=2" }' in toolchain
118
+ assert 'linkoptions { "-Wl,-rpath,@loader_path" }' in toolchain
119
+ assert (
120
+ textwrap .dedent (
121
+ """
122
+ project "main"
123
+ -- Project flags (specific)
124
+ -- Workspace flags
125
+
126
+ -- CXX flags retrieved from CXXFLAGS environment, conan.conf(tools.build:cxxflags) and extra_cxxflags
127
+ filter {"files:**.cpp", "**.cxx", "**.cc"}
128
+ buildoptions { "-FS" }
129
+ filter {}
130
+ -- Defines retrieved from DEFINES environment, conan.conf(tools.build:defines) and extra_defines
131
+ defines { "TEST=False" }
132
+ """
133
+ )
134
+ in toolchain
135
+ )
136
+ assert (
137
+ textwrap .dedent (
138
+ """
139
+ project "test"
140
+ kind "None"
141
+ """
142
+ )
143
+ in toolchain
144
+ )
0 commit comments