Skip to content
Ilya Sher edited this page May 14, 2022 · 5 revisions

NGS Make Mode Design (WIP)

This page describes the design of NGS make mode. In this mode, it will be possible to use NGS in a manner similar to make.

Requirements

  • A way to describe build targets in NGS syntax
  • A way to easily run a given target from the command line
  • A way to easily run a given target from other NGS scripts (after they require() the file with the targets)
  • Allow inclusion of additional targets using require()
  • Easy way to pass positional and named parameters when running a target

Design

  • Targets will be NGS methods (functions). This will allow calling the targets from other NGS scripts and from other targets().
  • Targets will live in namespaces and hence must be defined using ns keyword.
    • Namespaces will allow easy lookup of targets when invoked from command line (as opposed to globals())
    • Namespaces allow restricting targets to a particular set of methods
    • Namespaces allow listing of targets
  • For passing parameters from command line, factor out and re-use the parameters matching facility that is currently used to invoke main().

TODO / Open Issues

  • Design dependencies handling
    • Simply call another method? No because of parallelism and dependency graph.
  • Design Parallelism
  • Design rules
  • file target to make a file? Solves namespace issues and .PHONY of GNU Make.
  • Running
    • Run using a command such as ngs-make or directly using the NGS file such as ./make.ngs TARGET
    • Not requiring additional binary/script in path should be a plus
    • ./make.ngs style also makes it obvious how to run alternate "make" files (think make.linux.ngs and make.macosx.ngs)
  • A syntax to define additional constraints on the method arguments (such as ~ Sfx('.o'))
  • Nested namespaces?
  • Looks like too much boilerplate to support require()ing.
  • Lists of files similar to Rake::FileList ?

Sample NGS make script (thoughts)

#!/usr/bin/env ngs

ns {

	doc Builds .o files
	F file(dst:Str) {
		guard dst ~ Sfx('.o')
		...
	}

	doc Removes all generated files
	F clean() {
		...
	}

}

Related Issues