Author Topic: New plugin: Premake5 exporter (premake5cb)  (Read 729 times)

Offline cacb

  • Regular
  • ***
  • Posts: 472
New plugin: Premake5 exporter (premake5cb)
« on: July 20, 2021, 12:08:30 pm »
Hi all,

I have many Code::Blocks workspaces and enjoy the IDE, thanks for the great work done by the C::B developers!  Sometimes, however, I need to share my work with others who do not use Code::Blocks. Some people expect Visual Studio solutions for example, so I was considering how to do it.

It was suggested to me to maintain a separate CMake script along the C::B workspace/projects, but that idea did not appeal to me. I do want the convenience of Code::Blocks, I don't want to maintain a parallel build system and finally I think the CMake syntax is awful and difficult.  Therefore, a different idea was instead to create a Code::Blocks plugin to automatically generate a  Premake5 script, because Premake5 seems well structured and well documented. It can generate GNU makefiles as well as Visual Studio solutions. Thus, the idea of Premake5 exporter plugin for Code::Blocks was born.

Of course, some will say this can never work and it is a bad idea. In a way it is true, because there will always be examples that don't work properly. Still, if I can apply some assumptions and make it work for my Code::Blocks workspaces, it is still useful to me, and quite possibly to others as well.

You can find the plugin at https://github.com/arnholm/premake5cb , please see the README documentation with screenshots there.

An example Code::Blocks workspace at https://github.com/arnholm/pm5example1 .

The plugin currently builds on Linux only, it is possible that the project file does not correspond 100% to other plugins, I had to tweak it to make it work, but it does work fine here, and it is even possible to generate the required Visual Studio solution with premake5 under Linux.

If you have constructive suggestions, please share. This is somewhat experimental at this stage!

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13393
    • Travis build status
Re: New plugin: Premake5 exporter (premake5cb)
« Reply #1 on: July 20, 2021, 12:15:01 pm »
If you look at https://github.com/obfuscated/cb_editor_navigation you could probably add a minimal autotools build system.
This would make packaging your plugin possible for linux distros.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline cacb

  • Regular
  • ***
  • Posts: 472
Re: New plugin: Premake5 exporter (premake5cb)
« Reply #2 on: July 20, 2021, 01:53:43 pm »
Thanks, that would indeed be a good idea. I have zero experience with autotools, and even looking at your example I am quite mystified about what to do. If someone wants to help with that, I would be happy to include it!

Offline cacb

  • Regular
  • ***
  • Posts: 472
Re: New plugin: Premake5 exporter (premake5cb)
« Reply #3 on: July 24, 2021, 12:53:40 pm »
It sometimes possible to perform a "roundtrip" :

Code::Blocks workspace  ---(1)--> Premake5 script  ---(2)--> Code::Blocks workspace

(1) is obviously done using the Premake5 exporter plugin

(2) is done using a Premake5 plugin generating Code::Blocks workspaces :-)

To install and use (2)

cd ~
mkdir ./.premake
cd .premake
git clone  https://github.com/chris-be/premake-codeblocks  codeblocks


Using the https://github.com/arnholm/pm5example1 example, add the following to the pm5example1_premake5.lua file:

require "codeblocks"

Then run Premake5
premake5 --file=pm5example1_premake5.lua codeblocks

The result is a new set of Code::Blocks .workspace and .cbp files in a subfolder.