此文档创建于 2024/5/13

NoMake

NoMake is a build system for multi-language and multi-platform projects with the following highlighted practical features:

  1. Type-safe build scripts
  2. Intellisense support
  3. Minimal learning curve
  4. Url-based ruleset sharing
  5. Incremental, asynchronous, and distributed building

Why is NoMake created with TypeScript & Deno?

NoMake achieves most of these features by using TypeScript, a statically typed language that is widely adopted in the industry and has been proven to have a good trade-off between static typing and real-world usability.

Deno fundamentally eases the sharing and reusing of build scripts and ruleset libraries. It also allows distributing the build process across multiple machines by cross-compiling and single-file bundling.

Installation

  1. Install NoMake for your platform.

    Supported platforms: win-x64, linux-x64, macos-x64, linux-arm64, macos-arm64.

    Download the binaries and add them to your PATH: https://github.com/thautwarm/nomake/releases

    Import the latest package from the url https://github.com/thautwarm/nomake/raw/v0.1.5/mod.ts

  2. Run your build script (requires a build.ts file as an entry point).

    nomake help
    nomake <build target>
    
    ## or if you're using nomake as a Deno library:
    # deno run -A build.ts help
    # deno run -A build.ts <build target>
    

See examples at NoMake Examples.

Preview

// build.ts
import * as NM from 'https://github.com/thautwarm/nomake/raw/v0.1.5/mod.ts'

// define options
NM.option('legacy', ({ value }) => { /* do stuff with value */ })

// parse options
NM.parseOptions()

// define one or more targets
NM.target(
    {
        name: 'output.txt',
        deps: { file: 'input.txt' },
        async build({ deps, target })
        {
            const input = await new NM.Path(deps.file).readText();
            await new NM.Path(target).writeText(
                'Hello, ' + input
            )
        }
    })

// trigger the build process
await NM.makefile()

Namespaces

Functionality in NoMake is organized into namespaces. Here are some of the most important ones:

  • NM.Platform: Platform detection and manipulation
  • NM.Env: Type-safe environment variable access
  • NM.Path: Filesystem operations (similar to Python pathlib)
  • NM.Log: Logging utilities
  • NM.Repo: Git repository operations
  • NM.CC: C/C++ compilation toolchain
  • NM.Bflat: C# native compilation toolchain without .NET SDKs & Visual Studio (Linux/Windows only; for macOS support, use .NET SDKs by Microsoft)

The core operations are directly defined in the NM namespace, including:

Patterns

NoMake provides a set of patterns assign type safety for many common jobs in build systems, such as:

  1. Defining and organizing artifacts
  2. Platform-specific build rules
  3. Environment variables of interest
  4. Grouping and retrieving target dependencies