- If you are going to contribute to the project fork it from GitHub and clone your fork
- Otherwise run
git clone https://github.com/DontBelieveMe/nx-build.git
- Navigate into that root directory
- Run
npm install
to install all all npm dependencies - Now we can run the code by executing '
node index.js
- For example to generate project files in the
examples/ex
folder runnode ../../index.js
from that directory. - This is generate project files in a
build
subdirectory. (This subfolder name is hardcoded for now).
nx-build
scripts are written in plain Javascript and have full access to the node ecosystem
- Mostly - you can
require
all default node modules and any modules exposed bynx-build
- At the moment you cannot install any external packages via
npm
or any other package manager.
In order to use nx-build
create a nx.build.js
file in the root of your project.
A simple nx.build.js
file may look like this
var nx = require('nx');
var target = nx.createTarget();
target.setName('helloWorld');
target.setType('executable');
target.addSrcFile('src/main.c');
nx.addTarget(target);
var nx = require('nx');
-> This will include thenx
generator system API for you to use.var target = nx.createTarget()
-> This creates a new target. A target is a binary file that is either an executable, a static library or a shared library.target.setName('helloWorld');
-> Sets the name of the target, In this case the executable will be calledhelloWorld
target.setType('executable');
-> Sets the type of the target, e.g executable, shared/static library. In this case it the source files are going to compile into a executable.target.addSrcFile('src/main.c');
-> Adds a source file to be compiled into the target. File paths such as these are all relative to the directory of thenx.build.js
.nx.addTarget(target)
-> This finally will include target as part of that module. This will eventually allow for having multiple targets in one project.
That is the anatomy of a simple nx.build.js
file. Of course, because they are scripted in JS, anything you can do in JS you can do in these scripts, for example conditionally add source files depending on the OS (exposed through Nodes os
module), modify the filesystem (Nodes fs
module), or even use the node HTTP/HTTPS
API to download or upload files!
- Currently the project is going through a 'bit' (read a lot) of a restructure and converting to typescript whilst i'm at it. So yeah, that.
- Visual Studio project generation
- Allowing a structure that supports 'subprojects' or adding external
nx-build
projects.- Like CMakes
add_directory
function - It would be really cool to be able to integrate this functionality with git submodules (e.g similar to Vim & Vundle) - Specify a GitHub address (
name/project
) andnx-build
should clone that and integrate it.
- Like CMakes
- All Issues