Multiplatform Premake Script

I am the author of Node9, a hosted hybrid OS that combines Inferno and LuaJIT to create an interactive distributed development environment. See the project here: https://github.com/jvburnes/node9

I created a main 4.x premake script to compile all dependencies and main source code for OSX, but now people are asking to create configs for Linux, BSD and Windows. I have the code for this and I want to create preconfigurations to build and run Node9 on these OSs. I need to install a library and include search paths, compiler names, and also define each platform.

  • Can anyone point me to a good multiplatform premium script?
  • Am I using "premake gmake" and somehow sense my own platform or do I need to explicitly place the target platform on the command line and refer to that platform in the preconfiguration and platform sections?
  • I heard that premake 4.x was a legacy and that premake 5.x is a future solution. Is it stable and buildable for all of these platforms?

I know there are many questions, but I want to get it right.

Thank.

+3


source to share


3 answers


I'm not an expert on multiplatform compilation, but here are some things that might help you. First, I highly recommend you upgrade to Premake5. It's stable, the community is working on it and is pretty active, and you have module support (Android ?: P) and lots of cool other features.

As for your questions:



  • I can't, but in principle it should be as simple as something like this:

    solution "multiplatform_solution"
        configurations { "debug", "release", "whatever" }
    
        -- now here, you define your supported platforms
        platforms {
            "win32",
            "win64",
            "macos",
            "linux86",
            "linux64",
            -- etc.
        }
    
        project "some_project"
    
            -- now you can configure some things per platform:
            filter { "platforms:win32" }
                -- some defines, some specific paths to libs, etc.
                -- specific to win 32
                defines { "WIN32" }
            filter { "platforms:macos" }
                -- macos specific configurations
                defines { "you_fool_" } -- yes, it a troll :p
            -- etc.
    
            -- and configure the rest as usual
    
          

  • When you call premake gmake

    , you simply say that you want to create a makefile for gmake. If you have gmake for Windows, macOS, and Linux, you can use it premake gmake

    for all platforms. When you actually build, you just need to specify your configuration and platform. I don't know gmake well enough, but it might look something like this:gmake config=release platform=linux32

  • As I said, you probably want to update Premake 5. I think it is stable enough and in case of a problem you can ask questions here :)

+2


source


Can anyone point me to a good multiplatform premium script?

If you look at the original packet Premake, you will see that it contains several make files, one for each target platform, the directories named as the build/gmake.windows

and build/gmake.macosx

. This is one of the options.

Another approach is to put it all in one Makefile, like @Citron suggested in his script, and select the desired configuration on the command line at build time. In this case, your build command should look like this:

$ make config=debug_win32

      

If you run the target help

in the generated Premake Makefile, it will give you a list of all valid config options:



$ make help

      

Or, if you don't mind having your developers install Premake locally, they can generate a makefile customized for their environment before building. In this case, your script might look something like this:

solution "MySolution"
   configuration { "Debug", "Release" }

   filter { "system:Windows" }
      -- windows specific stuff

   filter { "system:MacOSX" }
      -- mac specific stuff

   filter { "system:Linux" }
      -- etc.

      

In this case, launching premake5 gmake

will create a makefile targeting the current environment.

+1


source


It's pretty close. I think a slightly closer answer would be to use a filter on "system:". I believe there is a difference between using premake to create a multi-platform make and using it to create the current make-platform file.

This is the closest answer, so I will be promoting it.

0


source







All Articles