0.1.1 • Published 8 years ago

limbus-buildgen v0.1.1

Weekly downloads
6
License
CC0-1.0
Repository
github
Last release
8 years ago

limbus-buildgen

version Public Domain SemVer development stage

Introduction

limbus-buildgen generates build files for small C/C++ code-bases that do not need a very complicated build process. Thus this library can be kept small which makes it easy to test and port to other platforms.

The project consists of a set of Common.js modules written in ES5.1 which can be imported into your project. A CLI front-end is also available to generate build files without additional code.

Table of contents

Installation

Using the CLI

Usage: limbus-buildgen [flags] <path to JSON configuration file>

Options:

  --help                          output usage information
  --host <host>                   override the configured target host
  --buildFile <path>              specify the path and filename for the
                                  generated build file (default: ./Makefile)

Configuration

The JSON configuration files support the following properties:

Required

PropertyDescription
typeSpecifies the type of project to build.
hostSpecifies the target host, i.e. the desired OS & compiler that the makefile should compile with.
inputSpecifies a list of source files.
outputNameSpecifies the name of the final executable.

Optional

PropertyDescription
outputPathSpecifies a path to prepend to the outputName. It defaults to the build directory.
includePathsSpecifies where to find header files to include.
compilerFlagsSpecifies any extra compiler flags that will be passed to the compiler as is.
linkerFlagsSpecifies any extra linkers flags that will be passed to the linker as is.
librariesSpecifies any libraries to link with when building an application or dynamic library.

Example configuration file

configuration.json
{
    "type": "application",
    "host": "darwin-clang",
    "files": [
        "main.c"
    ],
    "outputName": "my-application",

    "outputPath": "some/path",
    "includePaths": [
        "include/"
    ],
    "compilerFlags": "-g -O0 -coverage",
    "linkerFlags": "-coverage",
    "libraries": [
        "png"
    ]
}

A makefile for the above example can be generated using:

limbus-buildgen configuration.json

Configuration Properties

type

There are three types of projects which can be generated:

TypeDescription
applicationAn executable application
static-libraryA library that can be linked to at compile-time
dynamic-libraryA library that can be linked to at run-time

host

The following host identifiers can be used to target the corresponding operating system & compiler:

IdentifierTarget OSCompiler
linuxLinuxGNU GCC
linux-clangLinuxClang/LLVM
linux-gccLinuxGNU GCC
darwinMac OS XClang/LLVM
darwin-clangMac OS XClang/LLVM
darwin-gccMac OS XGNU GCC
win32WindowsCL
win32-clWindowsCL
freebsdFreeBSDClang/LLVM
freebsd-clangFreeBSDClang/LLVM
freebsd-gccFreeBSDGNU GCC

input

The input property takes an array of strings. Each string contains a path to a input file relative to the build directory.

outputName

The property outputName takes a string with the name of the final executable or library. Depending on the compiler and type, the name given by outputName is prepended, appended or both to form a system specific file name.

Given a configuration with "outputName": "file" the following table shows the resulting file name:

CompilerTypeFile name
GNU GCCapplicationfile
GNU GCCstatic-librarylibfile.a
GNU GCCdynamic-librarylibfile.so
Clangapplicationfile
Clangstatic-librarylibfile.a
Clangdynamic-librarylibfile.so
CLapplicationfile.exe
CLstatic-libraryfile.lib
CLdynamic-libraryfile.dll

The output name cannot be a path.

outputPath

The outputPath property takes a string with a path to be prepended to the outputName to give the final location of the executable or library when built. The path can have a trailing path separator but does not require one.

includePaths

The includePaths property takes an array of strings. Each string contains a path relative to the build directory to use to include header files.

compilerFlags

Compiler flags are added to the compile command.

linkerFlags

Linker flags are added to the link command. Which link command is used depends on the type and compiler specified. This needs to be taken into account when flags are added to the configuration.

The following table describes what commands are used and how flags are inserted for all compiler/type combinations:

CompilerTypeCommand
GNU GCCapplicationgcc -o executable file.o flags
GNU GCCstatic-libraryar rcsflags liblibrary.a file.o
GNU GCCdynamic-librarygcc -shared -o liblibrary.so file.o flags
Clangapplicationclang -o executable file.o flags
Clangstatic-libraryar rcsflags liblibrary.a file.o
Clangdynamic-libraryclang -shared -o liblibrary.so file.o flags
CLapplicationcl /Feexecutable.exe file.obj flags
CLstatic-librarylib /OUT:library file.obj flags
CLdynamic-librarylink /DLL /OUT:library file.obj flags

libraries

The libraries property takes an array of strings. Each string contains a path to a library file to link to.

Paths

All paths in the configuration are given as POSIX paths. The generators take care of adapting the paths to the final build operating system.

. specifies the current directory. .. specifies the parent directory of the current one. / separates each directory with the last part giving the target file or directory of the path.

Javascript API

Generate Makefiles

var makefile_generator = require('../source/makefile-generator');

// Returns a string with the generated makefile.
var makefile = makefile_generator.generate({
    // The following options are required:
    // Specifies the type of project to build, can be either 'application', 'dynamic-library' or 'static-library'.
    type: 'application',
    // Specifies the target host, i.e. the desired OS & compiler that the makefile should compile with.
    host: 'darwin-clang',
    // Specifies a list of source files.
    files: [
        'main.c'
    ],
    // Specifies the name of the final executable.
    outputName: 'my-application',

    // The following options are optional:
    // Specifies a path to prepend to the outputName.
    outputPath: "some/path",
    // Specifies where to find header files to include.
    includePaths: [
        'include/'
    ],
    // Specifies any extra compiler flags that will be passed to the compiler as is.
    compilerFlags: '-g -O0 -coverage',
    // Specifies any extra linker flags that will be passed to the linker as is.
    linkerFlags: '-coverage',
    // Specifies any libraries to link with when building an application or dynamic library.
    libraries: [
        'png'
    ]
});

Continuous Integration

Unit- & integration tests are automatically run against several combinations of target hosts, build configurations and Node.js versions at every push.

Integration matrix

Target HostBuild StatusBuilt ConfigurationsNode.js Versions
linux-clangtravis-ci build statusx645.9.0, 4.4.0
linux-gcctravis-ci build statusx645.9.0, 4.4.0
darwin-clangtravis-ci build statusx645.9.0, 4.4.0
darwin-gcctravis-ci build statusx645.9.0, 4.4.0
win32-clappveyor build statusx86 Release, x64 Release4.4.0
freebsd-clang
freebsd-gcc

FreeBSD is tested from time to time during development of new features but as there is currently no continuous integration on a FreeBSD host it should be considered less stable than the other target hosts.

Building from source

For all platforms, open a terminal and run the following command in the root project directory:

make

limbus-buildgen compiles using build files that it generated itself. To re-generate the makefiles run utility-scripts/generate_build_files.sh on a Unix-like OS after building.

Dependencies

There are very few dependencies and they are downloaded automatically when built. However it is assumed that a standard C compiler is installed. (For Windows users this means having Visual Studio or the Windows SDK installed in their default installation directory. Most Unixes come with a C compiler suite.)

Windows users will need PowerShell 3.0+ installed (which comes with Windows 7 SP1 or later) to automatically download the dependencies. If this is not possible, see Download dependencies manually

Download dependencies manually

Duktape is used for Javascript execution. You can download the Duktape 1.4.0 release package from http://duktape.org/ and extract it into dependencies/duktape-1.4.0.

Development

Dependencies devDependencies

For development you need some extra development dependencies. Install them using NPM with:

npm install

Test

limbus-buildgen performs testing using mocha and should.js.

Run both unit- and integration tests using

npm test

To run each separately, use npm run unit-test for unit tests and npm run integration-test for integration tests.

Code coverage

Coverage Status

limbus-buildgen analyzes code coverage using blanket.js. To produce a report, run:

npm run-script coverage

This will generate a file named coverage.html in the project root directory which can be viewed in a browser.

Roadmap

Planned for a 0.5 version

This release is intended to streamline the user experience and produce a done release that is not fully feature-complete. It will take the project from an alpha phase into beta.

  • Provide an integrated executable for the front-end
  • Provide npm packages for both executable and libraries
  • Create release bundled with dependencies
  • Override all configuration properties using flags
  • Complete documentation
  • Modify makefile generator so that makefiles make use of make's "implicit variables"
  • Library include paths
  • Provide configuration overrides for when different arguments are passed
Planned for a 0.6 release

This release will implement cross compilation to mobile devices.

  • Cross compilation to iOS
  • Cross compilation to Android
Planned for a 0.7 release

This release will implement cross compilation to web browsers through Emscripten.

  • Emscripten compiler support
Planned for a 0.8 release

This release will implement the rest of the features to make it feature-complete.

  • A Visual Studio project generator
Towards a 1.0 release

This release will stabilize the project to make it ready for production.

  • Continuous integration for all supported targets
Further into the future

Features which aren't needed for feature-completeness but are nice to have.

  • Cross compilation to Windows using MinGW
  • Modify makefile to find compilers and use whichever is available.
  • Support for more compiler suites:
    • AMD's Open64
    • Intel's C++ compiler
    • MinGW
    • Solaris Studio
  • Support for more build systems:
    • Ninja
    • Code::Blocks
    • JetBrain's CLion
    • NetBeans C++

Copyright

limbus-buildgen - A "build anywhere" C/C++ makefile/project generator.

Written in 2014-2016 by Jesper Oskarsson jesosk@gmail.com

To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.

You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see http://creativecommons.org/publicdomain/zero/1.0/.

0.1.1

8 years ago

0.1.0

8 years ago