My take on sharing and centralizing configuration settings #2249
richard-sim
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
Due to the flexibility that Premake provides, I would say there isn't really a "right way" to do things. I would do things differently to you, but our experiences are likely different so we prioritise different things.
function use_library(options)
options = options or {}
filter "kind:not StaticLib"
links { options.libname }
filter {}
if options.staticFilter then
filter { options.staticFilter }
defines { options.libname .. "_STATIC" }
filter {}
end
if options.sharedFilter then
filter { options.sharedFilter }
defines { options.libname .. "_SHARED" }
filter {}
end
end
-- Called like this:
use_library { libname = "L0a", staticFilter = depInfo.staticFilter, sharedFilter = depInfo.sharedFilter }
-- Or, you could have `use_library` take two arguments instead and do:
use_library("L0a", depInfo)
There might be other suggestions I could make, but I think it's important for you to find your build scripts to be intuitive. At the end of the day, you will be the one that needs to read them, change them, and debug them. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Taking inspiration from the Premake docs (https://premake.github.io/docs/Sharing-Configuration-Settings/), I've come up with a structure that meets my goals of centralizing and simplifying project configuration (so it can easily be mix & matched in a single place) and not having projects need to know how to configure their dependencies (include dirs, defines, links).
Here's my playground repo:
https://github.com/richard-sim/build-sys-eval/tree/main/foobar/src
The important bits are the top-level
premake5.lua
file (obviously) then the per-projectpremake5.lua
files are mostly very similar, butfoobar/L2a/premake5.lua
andfoobar/L3a/premake5.lua
are good examples to look at as they're a bit more involved and show how it all comes together.I'm quite happy with the structure, but it is a long way from all the examples in the docs and that I see elsewhere around github, so I can't help but think that I may have headed down the wrong path. I'm new to Premake (well, I last used it something like 15 years ago, so...), so I'd love some feedback on it from those with more experience! The project
premake5.lua
files have more boilerplate/repetition between them than I'd like, but I'm not familiar enough with Lua to know of a good way to reduce that while keeping them flexible.What should I do differently, what could be improved, or where may I run into problems? Are there any examples that achieve the same goals but in a more standard way?
Beta Was this translation helpful? Give feedback.
All reactions