Skip to content

Commit 4c53566

Browse files
authored
premake docs (#3925)
1 parent 8b5917a commit 4c53566

File tree

7 files changed

+126
-7
lines changed

7 files changed

+126
-7
lines changed
4.5 KB
Loading

integrations.rst

+1-7
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,7 @@ Xcode.
2222
integrations/makefile
2323
integrations/xcode
2424
integrations/meson
25+
integrations/premake
2526
integrations/android
2627
integrations/jfrog
2728
integrations/ros
28-
29-
.. warning::
30-
31-
Even though there is a plugin for the Visual Studio IDE, it is not recommended to use
32-
it right now because it has not been updated for the 2.0 version yet. However, we
33-
intend to resume working on this plugin and enhance its functionality soon after Conan 2.0
34-
is released.

integrations/premake.rst

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. _integrations_premake:
2+
3+
|premake_logo| Premake
4+
======================
5+
6+
Conan provides different tools to help manage your projects using Premake. They can be
7+
imported from ``conan.tools.premake``. The most relevant tools are:
8+
9+
- ``PremakeDeps``: the dependencies generator for Premake, to allow consuming dependencies from Premake projects
10+
11+
- ``Premake``: the Premake build helper. It's simply a wrapper around the command line invocation of Premake.
12+
13+
.. seealso::
14+
15+
- Reference for :ref:`conan_tools_premake_premakedeps`.
16+
- Reference for :ref:`conan_tools_premake_premake`.
17+
18+
19+
.. |premake_logo| image:: ../images/integrations/conan-premake-logo.png

reference/tools.rst

+1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ Contents:
4242
tools/ros
4343
tools/scm
4444
tools/scons
45+
tools/premake
4546
tools/system

reference/tools/premake.rst

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.. _conan_tools_premake:
2+
3+
conan.tools.premake
4+
===================
5+
6+
.. toctree::
7+
:maxdepth: 2
8+
9+
premake/premake
10+
premake/premakedeps

reference/tools/premake/premake.rst

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.. _conan_tools_premake_premake:
2+
3+
Premake
4+
=======
5+
6+
.. include:: ../../../common/experimental_warning.inc
7+
8+
9+
The ``Premake`` build helper is a wrapper around the command line invocation of Premake. It will abstract the
10+
project configuration command.
11+
12+
The helper is intended to be used in the *conanfile.py* ``build()`` method, to call Premake commands automatically
13+
when a package is being built directly by Conan (create, install)
14+
15+
16+
.. code-block:: python
17+
18+
from conan.tools.premake import Premake
19+
from conan.tools.microsoft import MSBuild
20+
21+
class Pkg(ConanFile):
22+
settings = "os", "compiler", "build_type", "arch"
23+
24+
# The VCVars generator might be needed in Windows-MSVC
25+
generators = "VCVars"
26+
27+
def build(self):
28+
p = Premake(self)
29+
p.configure()
30+
# At the moment Premake does not contain .build() method
31+
# report in Github issues your use cases and feedback to request it
32+
build_type = str(self.settings.build_type)
33+
if self.settings.os == "Windows":
34+
msbuild = MSBuild(self)
35+
msbuild.build("HelloWorld.sln")
36+
else:
37+
self.run(f"make config={build_type.lower()}_x86_64")
38+
p = os.path.join(self.build_folder, "bin", build_type, "HelloWorld")
39+
self.run(f'"{p}"')
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
.. _conan_tools_premake_premakedeps:
2+
3+
PremakeDeps
4+
===========
5+
6+
.. include:: ../../../common/experimental_warning.inc
7+
8+
The ``PremakeDeps`` is the dependencies generator for Premake.
9+
10+
The ``PremakeDeps`` generator can be used by name in conanfiles:
11+
12+
.. code-block:: python
13+
:caption: conanfile.py
14+
15+
class Pkg(ConanFile):
16+
generators = "PremakeDeps"
17+
18+
19+
.. code-block:: text
20+
:caption: conanfile.txt
21+
22+
[generators]
23+
PremakeDeps
24+
25+
And it can also be fully instantiated in the conanfile ``generate()`` method:
26+
27+
.. code:: python
28+
29+
from conan import ConanFile
30+
from conan.tools.premake import PremakeDeps
31+
32+
class App(ConanFile):
33+
settings = "os", "arch", "compiler", "build_type"
34+
requires = "zlib/1.2.11"
35+
36+
def generate(self):
37+
bz = PremakeDeps(self)
38+
bz.generate()
39+
40+
Generated files
41+
---------------
42+
43+
When the ``PremakeDeps`` generator is used, every invocation of ``conan install`` will
44+
generate a ``include('conandeps.premake5.lua')`` that can be included and used in the project:
45+
46+
47+
.. code-block:: lua
48+
49+
-- premake5.lua
50+
51+
include('conandeps.premake5.lua')
52+
53+
workspace "HelloWorld"
54+
conan_setup()
55+
configurations { "Debug", "Release" }
56+
platforms { "x86_64" }

0 commit comments

Comments
 (0)