civ build system and pkg manager

Civstack is a full developer tech stack, and the bedrock of that is the build system -- which is this package (civ).

A "build system" is fundamentally a mechanism to convert a set of files and configuration (a package) into a runnable (and testable) software. A package manager is then a way to upload and depend on other packages.

A good build system has two other primary features:

PKG.luk

The PKG.luk file is is how you specify how to build a package and what is exported from that package. Below is an example one which we will walk though. Before we do, a few notes:
Example PKG.luk:
local P = { summary = "Does foo and some bar" }

--- Imports a function to help us create Target
local cc  = import'sys:cc.luk'  -- C build targets
local lua = import'sys:lua.luk' -- Lua build targets

-- Set up metadata for this PKG.luk file, this must be
-- returned at the end with the targets and PoD to provide
-- clients.
--
-- This also creates the global `P` value, which is the data
-- (build information) exported by this file.
P.foo = lua {
  mod = 'foo',
  src = { 'foo.lua' },
  dep = {
    'civ:lib',           -- depend on entire civ lib
    'myhub:foo#libfoo',  -- depend on next target
  },
}

-- test rule
P.test = lua.test {
  src = 'test.lua',
  dep = { 'myhub:foo',
}

-- C build target
P.libfoo = cc {
  hdr = { 'foo.h' },  -- C headers
  src = { 'foo.c' },  -- C source files
  dep = {
    'myhub:bar#libbar', -- depend on another target
  },
}

return P

Every value assigned to P must be either a concrete type or a #civ.Target.

civ output directory

By default, civ build puts files in .out/civ/. Wherever it puts it's output (whether during build or installation), the output structure under that directory is as follows:

Mod civ

The civ build system command.
Types: Init Base Build Test Run Install
Functions

Record Init

civ init arguments. Fields:

Record Base

Fields:

Record Build

Usage: civ build hub:tgt#name Fields:

Record Test

Usage: civ test hub:tgt#name Fields:

Record Run

Usage: civ run hub:tgt#name -- ...args Build+run a single build target which has a single bin output. Fields:

Record Install

Usage: civ install hub:tgt#name Fields:

Mod civ.core

Core civ (build system) types and functions.
Types: TargetName Target CfgBuilder Cfg Civ
Functions

Record TargetName

Represents a pkgname.target parsed from a string Fields: Methods

Record Target

A build target, the result of compiling a package. Fields: Methods

Record CfgBuilder

Fields:

Record Cfg

The user configuration, typically at ./.civconfig.lua Fields: Methods

Record Civ

Holds top-level data structures and algorithms for processing civ build graphs (pkgname graphs). Fields: Methods

Record civ.Worker

Fields: Methods . * fn:link(tgt) * fn:set()
Make self the singleton (future calls to Worker.get will return) * fn:close()
Remove this as singleton.