Skip to content

Commit 573bf95

Browse files
committed
Added more premake tests
1 parent 31b6304 commit 573bf95

File tree

3 files changed

+93
-15
lines changed

3 files changed

+93
-15
lines changed

conan/tools/premake/toolchain.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ class PremakeToolchain:
157157
{% endif %}
158158
159159
filter { "system:macosx" }
160-
-- runpathdirs { "@loader_path" }
161-
-- TODO Fix shared libs
160+
-- Shared libs
162161
linkoptions { "-Wl,-rpath,@loader_path" }
163162
filter {}
164163

test/integration/toolchains/premake/test_premake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def generate(self):
8888
def build(self):
8989
premake = Premake(self)
9090
premake.configure()
91-
premake.build(workspace="Project")
91+
premake.build(workspace="Project", targets=["app"])
9292
""")
9393

9494
client.save({"consumer/conanfile.py": conanfile,

test/integration/toolchains/premake/test_premaketoolchain.py

Lines changed: 91 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import textwrap
23

34
from conan.test.utils.tools import TestClient
@@ -13,7 +14,6 @@ def test_extra_flags_via_conf():
1314
compiler=gcc
1415
compiler.version=9
1516
compiler.cppstd=17
16-
compiler.cstd=11
1717
compiler.libcxx=libstdc++
1818
build_type=Release
1919
@@ -28,16 +28,14 @@ def test_extra_flags_via_conf():
2828
tools.build:sharedlinkflags+=["-flag5"]
2929
tools.build:exelinkflags+=["-flag6"]
3030
tools.build:defines=["define1=0"]
31-
"""
31+
"""
3232
)
33-
t = TestClient()
34-
t.save({"conanfile.txt": "[generators]\nPremakeToolchain", "profile": profile})
33+
tc = TestClient()
34+
tc.save({"conanfile.txt": "[generators]\nPremakeToolchain", "profile": profile})
3535

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)
3938
assert 'cppdialect "c++17"' in content
40-
# assert 'cdialect "99"' in content # TODO
4139

4240
assert (
4341
"""
@@ -58,8 +56,89 @@ def test_extra_flags_via_conf():
5856
)
5957

6058
assert 'linkoptions { "-flag02", "-other=val2", "-flag5", "-flag6" }' in content
59+
assert 'defines { "define1=0" }' in content
6160

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

Comments
 (0)