GithubHelp home page GithubHelp logo

rleh / library-builder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dergraaf/library-builder

0.0 2.0 0.0 314 KB

Module based library builder for source code libraries

License: BSD 2-Clause "Simplified" License

Makefile 0.84% Python 98.96% C++ 0.20%

library-builder's Introduction

https://travis-ci.org/modm-io/library-builder.svg?branch=develop

Introduction

lbuild is a library builder used to generate a blob of files from a source code repository.

Definition of Terms

Repository:
Collection of modules. A repository contains a number of options which are used to select which module can be build.
Module:

When a module is selected and build it copies a number of files to a specified output location. It is also possible to use the Jinja2 template engine to create new files.

A module can define its own options used during the build of the module. It can also access the options of other modules it depends upon and the repository options.

Repository file:

Python script used to declare the name of the repository, the location of the module files within the repository and repository options.

Must declare the following functions:

def init(repo):
    ....
def prepare(repo, options):
    ...
Module file:

Python script defining a module. A module gets the repository options to select whether it can be build with selection of options and which other modules are needed.

Additional options can be defined within the module file. These options are available later during the build of the module.

Must declare the following functions:

def init(module):
    ...
def prepare(module, options):
    ...
def build(env):
    ...
Options:

There are two kind of options: repository and module options. The repository options use the following naming schema:

repository:option

Module options use an additional field for the module name:

repository:module:option

The repository and module name can be empty. In this case the current repository/module name is used.

Configuration file:

XML file used to define repository/module options and to select which modules should be build.

Defining options in the configuration file follow the same naming schema for repository and module options. The only difference being that when the repository or module name is left blank all options matching the remaining fields are set.

E.g. defining a value for abc::xyz will set the given value for all modules in the abc repository which define an option with the name xyz.

API Overview

Repository description ('repo.lb'):

def init(repo):
        repo.set_name("..")

        repo.add_option(StringOption(name="..", description=".."))

def prepare(repo, options):
        repo.add_modules(repo.glob("*/*.lb"))
        repo.add_modules("..")

        repo.find_modules

Module description ('module.lb'):

def init(module):
        module.set_name("..")
        module.set_description("..")

        module.add_option(StringOption(name, description, default))

def prepare(module, options):
        option_value = options[".."]

        module.depends([".."])

def build(env):
        env.copy(src, dest, ignore=env.ignore_files("main.*"))
        env.template(src, dest, substitutions)

        modulepath  = env.modulepath(local_path)
        output_path = env.output(local_path)

        option_value = env[".."]

Project configuration ('project.xml'):

<library>
  <options>
        <option name=".." value=".." />
        ...
  </options>
  <modules>
        <module>..</module>
        ...
  </modules>
</library>

Operation

lbuild gets the path to a number of repository files and a configuration file. The repository files define what modules and global options are available and where the modules are located.

The functions in the python files are called in the following order:

for all repositories
   repository:prepare()

Consolidate repository options

for all modules
  module:init()

Consolidate module options

for all modules
  module:prepare()

Use available modules to resolve dependencies between modules

for all modules selected in configuration file or through dependency
  module:build()

library-builder's People

Contributors

amarokmclion avatar dergraaf avatar salkinium avatar

Watchers

 avatar  avatar

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.