Giter Club home page Giter Club logo

puppetcpp's Introduction

Puppet Compiler in C++

Build Status Code Coverage

Build History

This is a (very early) attempt to write a Puppet 4.x compiler in C++14.

Parser status:

  • Puppet 4.x compliant lexer
  • Puppet 4.x compliant parser
  • AST construction

Expression evaluator status:

  • literal expressions
  • variable assignment
  • + operator
  • - operator (binary)
  • - operator (unary)
  • * operator (binary)
  • * operator (unary)
  • / operator
  • % operator
  • << operator
  • >> operator
  • logical and
  • logical or
  • logical not
  • == operator
  • != operator
  • =~ operator
  • !~ operator
  • < operator
  • <= operator
  • > operator
  • >= operator
  • -> operator
  • ~> operator
  • <- operator
  • <~ operator
  • in operator
  • if expressions
  • unless expressions
  • selector expressions
  • case expressions
  • method call expressions
  • function call expressions
  • lambdas
  • resource expressions
  • resource metaparameters
  • virtual resource expressions
  • exported resource expressions
  • resource defaults expressions (see note below)
  • resource override expressions
  • class definition statements
  • defined type statements
  • node definition statements
  • resource collection statements
  • exported resource collection expressions (NYI: importing resources)
  • break statements
  • return statements
  • next statements
  • loading classes from modules
  • loading defined types from modules
  • access expressions
  • global scope
  • local scope
  • node scope
  • string interpolation
  • Puppet type aliases
  • custom functions written in Puppet
  • custom functions written in Ruby
  • custom types written in Puppet
  • custom types written in Ruby
  • external data binding (i.e. hiera)
  • module data functions in Ruby
  • module data functions in Puppet
  • EPP support
  • application orchestration (NYI: evaluation)

Note: resource default expressions use "static scoping" instead of "dynamic scoping"

Type system implemented:

  • Any
  • Array
  • Boolean
  • Callable
  • CatalogEntry
  • Collection
  • Data
  • Default
  • Enum
  • Float
  • Hash
  • Integer
  • Iterable
  • Iterator
  • Class
  • NotUndef
  • Numeric
  • Optional
  • Pattern
  • Regexp
  • Resource
  • Runtime
  • Scalar
  • String
  • Struct
  • Tuple
  • Type
  • Undef
  • Variant

Puppet functions implemented:

  • alert
  • assert_type
  • contain
  • create_resources
  • crit
  • debug
  • defined
  • digest
  • each
  • emerg
  • epp
  • err
  • fail
  • file
  • filter
  • fqdn_rand
  • generate
  • hiera
  • hiera_array
  • hiera_hash
  • hiera_include
  • include
  • info
  • inline_epp
  • inline_template
  • lookup
  • map
  • match
  • md5
  • new
  • notice
  • realize
  • reduce
  • regsubst
  • require
  • reverse_each
  • scanf
  • sha1
  • shellquote
  • slice
  • split
  • sprintf
  • step
  • tag
  • tagged
  • template
  • type
  • versioncmp
  • warning
  • with

Catalog compiling status:

  • Facts from files and Facter
  • JSON catalog generation

Running With Docker

The peterhuene/puppetcpp image on Docker Hub contains a pre-built version of the prototype compiler.

Use the following docker command to run the compiler:

$ docker run -it peterhuene/puppetcpp

This image is not yet automatically updated when commits are merged into master; it will be periodically updated when new features are merged.

Build Requirements

Pre-Build

All of the following examples start by assuming the current directory is the root of the repo.

Before building, use cmake to generate build files:

$ mkdir release
$ cd release
$ cmake ..

To generate a fully debug build use -DCMAKE_BUILD_TYPE=Debug when invoking cmake.

To speed up builds, it is recommended to use ccache as the "compiler":

$ cd release
$ CCACHE_SLOPPINESS=pch_defines,time_macros cmake .. -DCMAKE_C_COMPILER=$(which ccache) -DCMAKE_C_COMPILER_ARG1=cc -DCMAKE_CXX_COMPILER=$(which ccache) -DCMAKE_CXX_COMPILER_ARG1=c++

Note: the environment variable CCACHE_SLOPPINESS must be set to pch_defines,time_macros for precompiled headers to work with ccache.

Also consider using Ninja as a replacement for GNU Make:

$ cd release
$ cmake .. -GNinja -DDISABLE_PCH=1 -DCMAKE_C_COMPILER=$(which ccache) -DCMAKE_C_COMPILER_ARG1=cc -DCMAKE_CXX_COMPILER=$(which ccache) -DCMAKE_CXX_COMPILER_ARG1=c++

Then use ninja instead of make in the examples below.

Note: tracking precompiled header changes with ninja is currently unsupported in CMake so it is recommended to add -DDISABLE_PCH=1 when running cmake.

Build

Currently Boost 1.61 and later has a breaking change that prevents building this project; see the PR to revert the change.

Boost can be patched by simply updating include/boost/spirit/home/x3/operator/detail/sequence.hpp to the previous version. The previous version is available here.

To build puppetcpp, use 'make':

$ cd release
$ make

To build puppetcpp with debug information:

$ cd debug
$ make

Run

You can run puppetcpp from its output directory:

$ release/bin/puppetcpp help

For a debug build:

$ debug/bin/puppetcpp help

Test

You can run puppetcpp tests using the test target:

$ cd release
$ make test

For a debug build:

$ cd debug
$ make test

For verbose test output, run ctest instead of using the test target:

$ cd release
$ ctest -V

Install

You can install puppetcpp into your system:

$ cd release
$ make && sudo make install

By default, puppetcpp will install files into /usr/local/bin, /usr/local/lib, and /usr/local/include.

To install to a different location, set the install prefix:

$ cd release
$ cmake -DCMAKE_INSTALL_PREFIX=~/puppetcpp ..
$ make clean install

This would install puppetcpp into ~/puppetcpp/bin, ~/puppetcpp/lib, and ~/puppetcpp/include.

Uninstall

Run the following command to remove files that were previously installed:

$ sudo xargs rm < release/install_manifest.txt

Documentation

To generate API documentation, install doxygen 1.8.7 or later.

$ doxygen

To view the documentation, open html/index.html in a web browser.

puppetcpp's People

Contributors

hlindberg avatar iankronquist avatar peterhuene avatar thallgren avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.