title: "Community Update #6" tags: [community-updates] author: starkos author_url: https://github.com/starkos author_image_url: https://avatars.githubusercontent.com/u/249247?v=4
The focus for this cycle was getting an exporter—I settled on Visual Studio—up and running and able to generate a basic, mostly hardcoded workspace and project. More details below, but TL;DR:
For those of you who are more interested in "is it done yet?" than "what's new?", here's my current thinking on what comes next:
Somewhere in there I should also backfill the documentation so people know what's working. All of this is subject to change and peer pressure, feedback welcome.
I'm doing my best to keep an inventory of the major changes here; let me know if you spot anything missing (and thanks to those who have already).
Premake4/5's scoping rules have always been a big gotcha. Tough for newcomers, easy to break even for experienced users, and very difficult to debug. I'm proposing that scoping be made explicit using function callbacks. Here's what a simple Hello World script might look with the new approach (apologies again for the images; if OpenCollective's editor supports code blocks I haven't been able to find them yet).
workspace('HelloWorld', function ()
configurations { 'Debug', 'Release' }
project('HelloWorld', function ()
kind 'ConsoleApplication'
files { '**.h', '**.cpp' }
when({ configurations='Debug' }, function ()
defines { 'DEBUG' }
symbols 'On'
end)
when({ configurations='Release' }, function ()
defines { 'NDEBUG' }
optimize 'On'
end)
end)
end)
(Keep in mind, only workspace, project, location, and filename are implemented so far, the rest will be coming online ASAP. The name when() is a proposal, feedback welcome.)
Under the hood, the provided configuration functions are called immediately. Under the hood, that workspace() helper looks like:
function workspace(name, fn)
workspaces(name)
when({ workspaces = name }, function ()
baseDir(_SCRIPT_DIR)
fn()
end)
end)
…so things still work the same as in Premake5, but scopes are now clearly explicit, and the indentation actually makes real sense (and gets syntax-aware editor support.
The syntax is, unfortunately, noisy. Down the road I wouldn't be opposed to tweaking Premake's embedded Lua runtime to provide a simpler syntax.
The command to export a project for Visual Studio now looks like this:
# target the latest version of Visual Studio we support
premake6 vstudio
# target a specific version
premake6 vstudio=2017
As anyone working on the Visual Studio or Xcode exporters is well aware, tool vendors are no longer waiting for the next major release to add features and change project formats. While more work is needed, the new command line syntax at least opens up the possibility of doing something like…
premake6 vstudio=14.0.25431.01
…which will allow us to support people who need to target a specific build of one of these tools.
In Premake4+, projects were required to be declared within one and only one workspace; this is now loosened up. The earlier Hello, World example could also be written like:
workspaces { 'HelloWorld' }
projects { 'HelloWorld' }
when({ 'workspaces:HelloWorld' }, function ()
projects { 'HelloWorld' }
end)
Projects can be shared between workspaces, or even be completely standalone, if the target toolset supports it.
I covered this above, but an RFC to coordinate v5 vs. vNext development is currently next on my to-do list.
These are big changes and I welcome questions, suggestions, and concerns. Everything is up for discussion, from the feature set, to the coding style. You can message or DM me at @premakeapp, email at [email protected], or open an issue on the premake-next GitHub project.
Many thanks to my co-maintainer @samsinsane, who has been doing a stellar job of keeping the shop running while I've been distracted with the new code, and to @nickclark2016, @noresources, @nickgravelyn, @Jarod42, and @cos-public for helping out with issues and new pull requests—very much appreciated!
And another big shout out to CitizenFX Collective for their continued strong financial support—as well as [all of our monthly backers](https://opencollective.com/premake#section-contributors!
Doing my best to get this new version fully up to speed ASAP for all of you.
~st.