MakeMe File Syntax

A MakeMe file is an Javascript (Ejscript) file that is loaded by the me program. MakeMe files typically have a .me extension and contain a call to the static function Me.load to define build instructions. The argument to Me.load is a object that conforms to the MakeMe Document Object Model (DOM). For example: this is a typical MakeMe file with one simple target.

Me.load({
    targets: {
        hello: {
            type: 'exe',
            sources: [ 'hello.c' ],
        },
    },
})

Typically the DOM object argument is expressed as a Javascript object literal, but it could be constructed in other ways via Javascript code.

let dom = {targets: {}}
dom.targets.hello = {type: 'exe'}
dom.targets.sources = Path('/some/path').files('**.c')
Me.load(dom)

Comments and Lines

You can use either Javascript comments in most places including inside the DOM object. Both the /* comment */ and the // rest-of-line forms are supported.

If you have a long line that you wish to split for formatting purposes, you can use a back-quote \\ at the end of the line. This is typically only required inside embedded shell or make scripts.

Property Types

MakeMe DOM objects consist of an object collection with properties that define targets that specify what to build and instructions for how to build the project. There are four basic types used as values for DOM values:

MakeMe object properties are composed of standard Javascript values with the enhancements noted below. For a full description of the capabilities of Ejscript, see the Ejscript Language API. and Ejscript Documentation.

Object Property Names

MakeMe objects are extend Javascript object syntax by allowing property names to omit quotes if they have no spaces. For example:

program: {
    type: 'exe',
},

Blending

When a MakeMe file is loaded, it is blended with existing MakeMe configuration from previously loaded MakeMe files by overwriting or augmenting prior definitions. MakeMe facilitates this by extending the standard JSON syntax with aggregation prefixes (+, -, =, ?) to describe how to blend property values together. The prefixes are uses at the start of the property name. For example:

targets: {
    hello: {
        '+defines: [ 'WHO=WORLD' ],
    },
},

This adds the define WHO=WORLD to the existing inherited definitions for this target.

The valid prefixes are:

When combining objects, MakeMe will automatically use append collections and so you do not need to use + on object properties.

Strings

Strings are wrapped in single, double or back-tick quote characters. Enhancing Javascript, strings can span multiple lines. Often it is best to use back-tick quotes as you are then free to embed either double or single quote characters without having to back quote.

Variables

MakeMe property names and property string values can embed MakeMe variables. These variables are embedded using the format: ${name}. MakeMe variables are are expanded just prior to execution of any command. Note: you cannot (yet) use MakeMe variables in just any string.

MakeMe variables take their value from three sources:

MakeMe Globals are resolved from the me.globals collection, whereas MakeMe DOM fields are resolved relative to the me object itself. For example:

{
    settings: {
        version: '4.1.0',
    },
    globals: {
        ARCH: 'x64',
    },
    targets: {
        rocket: {
            path: 'output/rocket_${ARCH}_${settings.version}',
            /* ... */
        },
    },
}

Assigning Variables

Variables can be set simply by defining properties in the MakeMe DOM. This can be done literally when loading the DOM object or programmatically in script code. For example:

{
    my: {
        food: 'fish',
    },
    targets: {
        dinner: {
            path: '/meals/${my.food}.txt',
        },
    },
}

If variables are defined in the me.globals collection, they can be accessed without any dot notation. For example:

{
    globals: {
        FOOD: 'fish',
    },
    targets: {
        dinner: {
            path: '/meals/${FOOD}.txt',
        },
    },
}

By convention, globals should be upper case.

To assign variables in script code

{
    action: "
        me.globals.FOOD = 'fish'
        me.my.food = 'steak';
    ",
},

Platform Specific Files

A convenient use of MakeMe global variables is to create per operating system file targets. For example:

cleanup: {
    type: 'exe'
    path: 'cleanup_${OS}',
    sources: [ 'dep_${OS}' ],
},

© Embedthis Software. All rights reserved.