Coder Social home page Coder Social logo

dcourtois / premake-compilationunit Goto Github PK

View Code? Open in Web Editor NEW
16.0 3.0 8.0 29 KB

Premake module adding support for compilation speed up through the use of the "single compilation unit" pattern, slightly modified.

License: Do What The F*ck You Want To Public License

Lua 100.00%
premake lua addon compilation speedup scu

premake-compilationunit's Introduction

Compilation Unit Addon

Compilation Units is a technique used to speed up compilation of huge projects, by regrouping compilation unit files (basically the .cpp and .c files) into a few big ones. Basically, instead of compiling foo.cpp and bar.cpp you compile a single foobaz.cpp one which contains the following :

#include "foo.cpp"
#include "bar.cpp"

This technique is based on the one known as Single Compilation Unit, but it allows creating N big compilation units, where N usually is the number of cores of your CPU. This allows you to take advantage of parallel compilation, while retaining the huge speed up introduced by the SCU technique.

How to use

Clone this repository some place where Premake will be able to locate. Then in your project's Premake script, include the main file like this :

require( "premake-compilationunit/compilationunit.lua" )

Then in the projects where you want to enable support for compilation units :

compilationunitenabled ( true )

The final step is to invoke Premake using the compilationunit option:

premake5 --compilationunit=8 <action>

Here I tell the module to use 8 compilation unit files, for projects where it has been enabled.

API

Most of the API commands of this addon are scoped to the current configuration, so unless specified otherwise, assume that the documented command only applies to the current configuration block.

compilationunitenabled boolean

Enable or disable the compilation unit generation for the current filter. By default it's disabled.

compilationunitsonly boolean

If this option is set to true then the generated projects will not include the original files. By defaut this option is false to allow easily editing / browsing the original code in IDEs, but it can be set to true in case you don't need that (think automated build systems, etc.)

compilationunitdir "path"

The path where the compilation unit files will be generated. If not specified, the obj dir will be used. This is a per-project configuration. The addon takes care of handling the various configurations for you.

compilationunitextensions table

By default the extension of the generated compilation units is .c for C files, and .cpp for C++ files. You can use a table to override these extensions. For instance, if you want to enable compilation units on an Objective-C project:

filter {}
    compilationunitextensions {
        "C" = ".m",
        "C++" = ".mm"
    }

premake-compilationunit's People

Contributors

dcourtois avatar j-jorge avatar m00tm00t avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

premake-compilationunit's Issues

Excessive recompilation of compilation units.

The __compilation_unit__x.cpp files are rewritten each time premake is run, even if their content does not change. This cause the compilation units to be compiled every time premake and make are run, although nothing should be done.

Add a license

Hi!

Would you mind adding a license to this repo to clarify what the terms of using it are? It's an awesome plugin, but without any license you kind of have to assume the worst and it makes it scary to fork and change anything in it.

Also, is there currently a way to exclude individual files from being included in the generated cpp files but still have them included in the build? I went through the source but I wasn't quite sure how the fileconfig stuff works in premake and can't seem to find any documentation about it. Using a filter and setting compilationunitenabled to false inside it did not seem to work.

Thank you for your time.

Visual Studio error: Cannot open source file

Commit 5d9fe72 added the project name into the path for the cpp files.
I'm running into the errors below with this change on premake 5 alpha 11.
Reverting 5d9fe72 fixes the compilation.
Here's the premake file that I'm using: https://github.com/SizzlingStats/demboyz/blob/master/premake/premake5.lua

I'm wondering which version of the alpha and what configuration was being used that needed the project name to be added to the path. I tested alpha versions 6 to 11 and didn't experience any problem without the project name in the path. @tdev ?

1>__compilation_unit__1.cpp
1>__compilation_unit__2.cpp
1>__compilation_unit__3.cpp
1>__compilation_unit__4.cpp
1>__compilation_unit__5.cpp
1>__compilation_unit__6.cpp
1>__compilation_unit__7.cpp
1>__compilation_unit__8.cpp
1>c1xx : fatal error C1083: Cannot open source file: 'obj\x32\Debug\demboyz\__compilation_unit__1.cpp': No such file or directory
1>c1xx : fatal error C1083: Cannot open source file: 'obj\x32\Debug\demboyz\__compilation_unit__5.cpp': No such file or directory
1>c1xx : fatal error C1083: Cannot open source file: 'obj\x32\Debug\demboyz\__compilation_unit__3.cpp': No such file or directory
1>c1xx : fatal error C1083: Cannot open source file: 'obj\x32\Debug\demboyz\__compilation_unit__4.cpp': No such file or directory
1>c1xx : fatal error C1083: Cannot open source file: 'obj\x32\Debug\demboyz\__compilation_unit__2.cpp': No such file or directory
1>c1xx : fatal error C1083: Cannot open source file: 'obj\x32\Debug\demboyz\__compilation_unit__7.cpp': No such file or directory
1>c1xx : fatal error C1083: Cannot open source file: 'obj\x32\Debug\demboyz\__compilation_unit__8.cpp': No such file or directory
1>c1xx : fatal error C1083: Cannot open source file: 'obj\x32\Debug\demboyz\__compilation_unit__6.cpp': No such file or directory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.