0.0.48 • Published 7 years ago

wilu v0.0.48

Weekly downloads
4
License
GPLv3
Repository
github
Last release
7 years ago

Wilu

Wilu generates makefiles without additional dependencies.

Features

  • Import native code from npm as if they were node.js modules
  • Build instructions in package.json
  • Incremental build instructions

Generate the makefile

make.js:

const wilu = require('wilu');
const pkg = require('./package.json');

(async function () {
	try {
		pkg.build = pkg.build || {};
		Object.assign(pkg.build, {
			name: pkg.name,
			version: pkg.version
		});
		await wilu(pkg.build);
	} catch(e) {
		console.error(e);
	}
})();
npm i --save-dev wilu
node make.js

Now you have makefile in your current directory.

Build instructions

Goes to package.json under build as an object. See the package.json of this project.

The build targets are defined in build under property + as an object where the key is the target name and the value is an object that has all the same rules the build has in package.json.

Each target in + will inherit the properties of the parent merging with its own properties. The build targets can define more targets under their property +.

Example package.json

{
	"name": "app",
	"version": "0.0.1",
	"build": {
		"sources": {
			"include": ["*.c"]
		},
		"options": {
			"compiler": {
				"all": ["Wall"],
				"c": ["std=c11", "Wstrict-prototypes"]
			}
		}
		"+": {
			"release": {
				"options": {
					"compiler": {
						"all": ["O3"]
					}
				}
			},
			"debug": {
				"options": {
					"compiler": {
						"all": ["O0", "ggdb"]
					}
				}
			}
		}
	}
}

This results to the below structure when using the above make.js. The result is used later to generate the makefile. The make targets are release and debug.

{
	"release": {
		"name": "app",
		"version": "0.0.1",
		"sources": {
			"include": ["*.c"]
		},
		"options": {
			"compiler": {
				"all": ["Wall", "O3"],
				"c": ["std=c11", "Wstrict-prototypes"]
			}
		}
	},
	"debug": {
		"name": "app",
		"version": "0.0.1",
		"sources": {
			"include": ["*.c"]
		},
		"options": {
			"compiler": {
				"all": ["Wall", "O0", "ggdb"],
				"c": ["std=c11", "Wstrict-prototypes"]
			}
		}
	}
}

Properties

  • name: defines the output name
  • version: defines the version
  • sources
    • include: array of glob rules
    • exclude: array of glob rules
    • path: path to the base of source files, the above rules are based on this. Defaults to 'src'.
    • subpath: added to path before finding sources
  • options
    • compiler
      • all: array of flags for all targets
      • c: array of flags for c language targets
      • c++: array of flags for c++ language targets
      • asm: array of flags for assembler language targets
    • linker: array of flags for the linker
    • assembler: array of flags for the assembler
  • machine: array of machine flags
  • definitions: array of defines
  • search
    • includes: array of paths for includes
    • libraries: array of paths for libraries
    • scripts: array of paths for linker scritps
  • libraries
    • static: array of static link libraries
    • shared: array of shared link libraries
  • directories
    • base: output directory. Defaults to 'build'.
    • output: subdirectory in base. Defaults to 'bin'.
    • objects: subdirectory for the objects. Defaults to 'obj'.
  • import: array of modules to be imported with targets prefixed with the module name and an underscore
  • depends: array of targets to build before linking
  • merge: array of targets to inherit properties from. Same as adding under + property, but can be used to interlink targets or continue an imported target.
  • library: a boolean, which turns the target into a static library. The output name is changed into 'libname.a'
  • shared: a boolean, which turns a library target into a shared library. The output name is changed into 'libname.so.version' and symbolic links will be generated.
  • node: a boolean, which turns the target into a node.js native addon
  • variables: object of variables where the keys are the variable names. Each property is turned into 'key= value'. This allows to specify a modifier to the equal sign, e.g. ':' or '?'.
  • commands: array of commands to be executed after linking
  • toolset: prefix the tools. For example 'arm-none-eabi' will produce arm-none-eabi-gcc with the default tools.
  • tools: object of tools where the key is the purpose and the value is the actual tool without prefix. Defaults are: c: gcc, c++: g++ and asm: gcc -x assembler-with-cpp.
0.0.48

7 years ago

0.0.47

7 years ago

0.0.46

7 years ago

0.0.45

7 years ago

0.0.44

7 years ago

0.0.43

7 years ago

0.0.42

7 years ago

0.0.41

7 years ago

0.0.40

7 years ago

0.0.39

7 years ago

0.0.38

7 years ago

0.0.37

7 years ago

0.0.36

7 years ago

0.0.35

7 years ago

0.0.34

7 years ago

0.0.33

7 years ago

0.0.32

7 years ago

0.0.31

7 years ago

0.0.30

7 years ago

0.0.28

8 years ago

0.0.27

8 years ago

0.0.26

8 years ago

0.0.25

8 years ago

0.0.24

8 years ago

0.0.23

8 years ago

0.0.22

8 years ago

0.0.21

8 years ago

0.0.20

8 years ago

0.0.19

8 years ago

0.0.18

8 years ago

0.0.17

8 years ago

0.0.16

8 years ago

0.0.15

8 years ago

0.0.14

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago