Skip to content

winksaville/craftr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Craftr 2.x

Note: This is the development version of the new version of Craftr. It is different from the initial Craftr version in many ways and can not be used interchangibly. The latest version of Craftr 1 can be found under tag v1.1.4-unreleased.

Craftr is a meta build system based on Python 3 scripts which produces Ninja build manifests. It enforces the use of modular build definitions that can be re-used easily. Craftr provides a standard library to support various programming languages and common libraries out of the box:

  • C/C++
  • Cython
  • C#
  • Java
  • Vala

Below you can find an example to compile a simple C++ program to get a taste of what Craftr looks like. Note that every module requires a manifest.json together with a Craftrfile to make a package.

Note: You can start a new package easily with the craftr startpackage command.

manifest.json

{
  "name": "examples.c",
  "version": "1.0.0",
  "dependencies": {
    "lang.cxx": "*"
  },
  "options": {
    "debug": {
      "type": "bool"
    },
    "outbin": {
      "type": "string",
      "default": "my_app"
    }
  }
}

Craftrfile

# examples.c

from os import environ
load_module('lang.cxx.*')

program = cxx_binary(
  inputs = c_compile(
    sources = glob(['src/*.c'])
  ),
  output = options.outbin
)

run = runtarget(program, environ.get('USERNAME', 'John'), "sunny")

To build the project, use

$ craftr export
$ craftr build
$ craftr build run
Hello, John. You are facing a sunny day

Note that the build command accepts target names as additional arguments. Since run is just another target, that's how we can invoke the test command that we created with runtarget().

Due to the way Craftr organizes the build tree, the output file will be located in build/examples.c-1.0.0/my_app. If you want to define an exact path for the output file, use an absolute path. For example local() gives you an absolute path assuming the path you give it is relative to your project directory.

# ...
  output = local(options.outbin)
# ...

Options can either be specified on the command-line or in configuration files. By default, ~/.craftrconfig and ./.craftrconfig files are loaded if they exist. The -c <filename> option can be used to pass one or more configuration filenames that will be loaded instead of ./.craftrconfig (note that the file in the user home directory is still loaded).

# .craftrconfig
[__global__]
  debug = true
[examples.c]
  outbin = my_app
[include "config/another.config"]

You can also find this example in examples/examples.c.

Check out the Documentation.

Features

  • Moduler build scripts (Craftr packages) with dependency management
  • Loaders: if required, automatically download and build libraries from source!
  • Package manager (hosted on Craftr.net)
  • Dependency-version lockfiles
  • RTS and Tasks (as Craftr 1 used to have)

Installation

Craftr 2.x is currently not on PyPI so you have to install it from the Git repository. Note that the most recent version of Craftr might also require an unreleased version of the nr module, thus it is recommended to install it from the Git repository as well.

$ virtualenv -p python3 env && source env/bin/activate
$ git clone https://github.com/NiklasRosenstein/py-nr.git
$ pip install -e py-nr
$ git clone https://github.com/craftr-build/craftr.git
$ pip install -e craftr
$ craftr version
2.0.0-dev

Requirements

License

The Craftr build system
Copyright (C) 2016  Niklas Rosenstein

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

For more information, see the LICENSE.txt file.

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.8%
  • C 3.1%
  • C++ 0.1%