Replies: 9 comments 18 replies
-
|
So I'll try to address these one by one:
Overall, I think these are changes that are worth at a minimum investigating from our end (personal opinion: and implementing). |
Beta Was this translation helpful? Give feedback.
-
You might do an other way:
There is
Same as 3
What do you mean by disabling projects exactly? BTW, You can run |
Beta Was this translation helpful? Give feedback.
-
|
@Jarod42 @nickclark2016 When it comes to a toolchain file does that mean something like KCONFIG? like with ESP-IDF? where we generate an premakeConfig.h file and an premakeConfig.lua so one could do conditional compilation etc (ofcoarse this would be a module) where you could have a menuconfig action whete the action can change the sdkconfig.premake file itself |
Beta Was this translation helpful? Give feedback.
-
|
Greetings @nickclark2016 @Jarod42 @lolrobbe2 Sorry for the delay. I haven't had enough capacity to work on this until now. See the following links:
The main idea of a conan generator is to provide an interface for managing, calling, accessing the tool below.
#!lua
include "conanutils.premake5.lua"
t_conandeps = {}
t_conandeps["release_arm64"] = {}
t_conandeps["release_arm64"]["fmt"] = {}
t_conandeps["release_arm64"]["fmt"]["includedirs"] = {"/Users/perseo/.conan2/p/b/fmtf45352c521e23/p/include"}
t_conandeps["release_arm64"]["fmt"]["libdirs"] = {"/Users/perseo/.conan2/p/b/fmtf45352c521e23/p/lib"}
t_conandeps["release_arm64"]["fmt"]["bindirs"] = {"/Users/perseo/.conan2/p/b/fmtf45352c521e23/p/bin"}
t_conandeps["release_arm64"]["fmt"]["libs"] = {"fmt"}
t_conandeps["release_arm64"]["fmt"]["system_libs"] = {}
t_conandeps["release_arm64"]["fmt"]["defines"] = {}
t_conandeps["release_arm64"]["fmt"]["cxxflags"] = {}
t_conandeps["release_arm64"]["fmt"]["cflags"] = {}
t_conandeps["release_arm64"]["fmt"]["sharedlinkflags"] = {}
t_conandeps["release_arm64"]["fmt"]["exelinkflags"] = {}
t_conandeps["release_arm64"]["fmt"]["frameworks"] = {}
if conandeps == nil then conandeps = {} end
conan_premake_tmerge(conandeps, t_conandeps)The cool part about conan is that this information, the dependencies information, are automatically generated by conan no matters which build tool where used in the dependency itself.
#!lua
include("/Users/perseo/sources/conan-premake-example/consumer_premake/premake5.lua")
include("/Users/perseo/sources/conan-premake-example/consumer_premake/build-release/conan/conantoolchain.premake5.lua")But a toolchain could and probably should be able to do more things. def generate(self):
deps = PremakeDeps(self)
deps.generate()
tc = PremakeToolchain(self)
tc.extra_defines["TEST"] = False
tc.extra_cflags = ["-Werror"]
tc.extra_cxxflags = ["-Wall", "-Wextra"]
tc.extra_ldflags = ["-lm"]
tc.generate()This will update global workspace resulting a script with the following content: include("conandeps.premake5.lua") -- This will only appear if PremakeDeps is called
-- Redirect build objects and binaries to proper build folder (source folder in conan should never me modified to keep integrity)
local locationDir = "/Users/perseo/sources/conan-premake-example/consumer_premake/build-release"
workspace "*"
cppdialect "gnu++17" -- This will be automatically obtained from conan profile
location(locationDir)
targetdir(path.join(locationDir, "bin"))
objdir(path.join(locationDir, "obj"))
filter { "language:C" }
buildoptions { "-Werror" }
filter {}
filter { "language:C++" }
buildoptions { "-Wall","-Wextra" }
filter {}
linkoptions { "-lm" }
defines { "TEST=0", }
conan_setup()
def build(self):
premake = Premake(self)
premake.configure()
premake.build(workspace="App")
Questions
See log: workspace "App"
configurations { "Debug", "Release" }
defines { "TEST=1" } -- define in projectAnd it will keep the value declared in the original
Thank you very much for your time and I hope this collaboration leads us to a good end! |
Beta Was this translation helpful? Give feedback.
-
For API taking list (as 'app' would be a shared library and not a static library.
I don't think so
I think you want Note that some prefix/postfix might be applied with some generators. |
Beta Was this translation helpful? Give feedback.
-
|
I have another question, sorry for bothering you guys. This is for the sake of having a great integration with conan! I'm encountering some problems with Consider this example: In that folder, I have a static library and a dynamic library: In macos,
This works |
Beta Was this translation helpful? Give feedback.
-
|
Greetings again! Is there a premake way of redefining a project in a workspace loop only if that project exists in the current workspace? for wks in premake.global.eachWorkspace() do
workspace(wks.name)
location(locationDir)
-- ... more configuration
project "main"
-- Only update this project if it exists in current wks
defines { "TEST=0" }
endI have tried several premake lua functions like this one https://github.com/premake/premake-core/blob/v5.0.0-beta6/src/base/workspace.lua#L168 ( Any idea? |
Beta Was this translation helpful? Give feedback.
-
|
I have another question! How could I do this? |
Beta Was this translation helpful? Give feedback.
-
|
Greetings, long time no see! I've yet another question. I can see in the premake docs:
Are you working on this feature? install(TARGETS pkg DESTINATION "."
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)By defining What do you think @Jarod42 @nickclark2016? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Greetings,
I’m part of the Conan-io team, and while reviewing our Premake generator, I encountered some issues and have a few questions.
I’m opening this thread as a centralized place to discuss our integration. I’m completely new to Premake, but I find it very interesting and promising. We want to provide great support for your build system and make it easier for users to integrate Conan with Premake.
For those unfamiliar with Conan, it is an open-source C/C++ package manager that has had a significant impact on both open-source projects and enterprise environments.
Conan provides “generators,” which, depending on the upstream build tool used, allow wrapping the project’s configuration and build process. This helps automate compilation and linking, not just for the project itself but also for its dependencies.
A contributor has implemented a Premake generator, but it is still incomplete and has some limitations.
Generator example
This generator essentially works as follows:
Note: The above conanfile.py might be incomplete or incorrect—it’s just a quick mockup.
With the following source code:
$ conan install . --build=missing$ tree build-release build-release └── conan ├── conan_fmt.premake5.lua ├── conan_fmt_vars_release_armv8.premake5.lua ├── conan_ninja.premake5.lua ├── conan_ninja_vars_release_armv8.premake5.lua ├── conanbuild.sh ├── conanbuildenv-release-armv8.sh ├── conandeps.premake5.lua ├── conanrun.sh ├── conanrunenv-release-armv8.sh ├── conanutils.premake5.lua ├── deactivate_conanbuild.sh └── deactivate_conanrun.shThe files we want to focus on is
conandeps.premake5.luaandconan_fmt_vars_release_armv8.premake5.lua:conan_fmt_vars_release_armv8.premake5.lua:As it can be seen, this file is an autogenerated conan file which has the information of our
fmtcompiled library, where are the include files, the libs, etc located in the system.conandeps.premake5.lua:This file defines a
conan_setupfunction which will be in charge of defining in the proper premake way, the libs, bins, etc of our dependencies (in this case, fmt)premake5.luafile:or
$ conan build .We will successfully build our source code using a dependency brought from Conan Center Index
Problems and questions
Architecture Support for macOS M-Chip (armv8)
I am using macOS with an M-series chip, and Conan detects the architecture as armv8. However, this architecture does not appear to be supported in Premake’s predefined architectures (Premake architecture documentation).
Because of this, our generator does not work automatically on these machines. I haven’t found a way to pass
--arch=armv8to Premake. Could you consider supporting this architecture or allowing users to define a custom architecture?Automated Toolchain Integration (Similar to CMake)
CMake allows defining toolchains that load automatically before/after parsing the main CMakeLists.txt file without modifying the original build script.
This is a great feature because it lets users integrate Conan without altering existing CMake scripts. I’ve searched Premake’s documentation for a similar feature—something like a script injection capability—but couldn’t find anything.
The lack of such a feature forces us to patch upstream recipes that use Premake, requiring us to modify the premake5.lua file directly.
Defining the Build Location Outside premake5.lua
Related to the previous point: Conan organizes folders (source_folder, build_folder, etc.), and it would be great if Premake allowed specifying the build location from the CLI or via script injection, without modifying premake5.lua.
Is there a way to achieve this in Premake? I couldn’t find one in the latest Premake 5 release.
Configuring
cppdialectExternallyIn other Conan generators, Conan defines the C++ standard. However, with Premake, it seems we must modify premake5.lua manually to set cppdialect.
Again, a way to inject this information externally—without modifying premake5.lua—would be very beneficial.
Disabling Specific Projects in a Premake Workspace
Take a look at this project: yojimbo.
I don’t know if this project follows best practices for Premake, but I couldn’t find a way to disable specific test projects. In Conan Center Index, we do not compile upstream tests (as that is the responsibility of the upstream project).
Is there an official way to disable specific projects using Premake?
Proposal: Automatic Toolchain Loading for Premake
To summarize, consider implementing a way to automatically load a “Premake toolchain” file that could be generated by external tools like Conan.
This toolchain file could define:
Such a feature would significantly improve Conan’s integration with Premake while keeping build scripts clean and unmodified.
Thank you very much for your time and your amazing project ❤️
Beta Was this translation helpful? Give feedback.
All reactions