build_tools 0.0.14

build_tools #

Build tools is a build automation tool with a built-in command line shell.

Build tools includes libraries build_tools and build_shell.

The build_tools is a main library and used for specifying the targets, rules and files used in the project.

The build_shell library can be used for working with your project from the command line shell.

Without using the command line shell the configuration is performed directly in the source code.

Example of usage build_tools for bulding the Dart VM C++ native extension.

Short example:

import "dart:async";
import "dart:io";
import "package:build_tools/build_shell.dart";
import "package:build_tools/build_tools.dart";

Future main(List args) async {
  target("default", ["breakfast"], (t, args) {
    print("Very good!");
  });

  target("breakfast", ["eat sandwich", "drink coffee"], (t, args) {
    print(t.name);
  });

  before(["breakfast"], (t, args) {
    print("wash hands before ${t.name}");
  });

  after(["breakfast"], (t, args) {
    print("smoke a cigar after ${t.name}");
  });

  target("drink coffee", ["make coffee"], (t, args) {
    print(t.name);
  });

  target("eat sandwich", ["make sandwich"], (t, args) {
    print(t.name);
  });

  target("make coffee", [], (t, args) {
    print(t.name);
  });

  target("make sandwich", ["take bread", "take sausage"], (t, args) {
    print(t.name);
  });

  target("take bread", [], (t, args) {
    print(t.name);
  });

  target("take sausage", [], (t, args) {
    print(t.name);
  });

  exit(await new BuildShell().run(args));
}

Output:

wash hands before breakfast
take bread
take sausage
make sandwich
eat sandwich
make coffee
drink coffee
breakfast
smoke a cigar after breakfast
Very good!

Short list of features:

Targets (tasks)

The targets describes the tasks and their dependencies (sources).

target("build", ["compile", "link"], (Target t, Map args) {
  // build after compile and link  
});

Both types of target actions supported, synchronous and asynchronous.

target("build", ["compile", "link"], (Target t, Map args) {
  // failed
  return new Future.value(-1);
}, description: "Build project", reusable: true);

File targets

The file targets automatically generates the targets for files.

These targets executed only when files are out of date or does not exists.

file("hello.obj", ["hello.c"], (Target t, Map args) {
  // compile
});

Directory targets

The directory targets automatically generates the targets for directories.

These targets perform a single task, they create a directories.

directory("dist");
directories(["dist, "temp"]);

Rules

The rules automatically generates the targets by specified patterns.

rule("%.o", ["%.cc"], (Target t, Map args) {
  // compile %.cc => %.obj 
});
rules(["%.html", "%.htm"], ["%.md"], (Target t, Map args) {
  // transform %.html => %.md
  // transform %.htm => %.md
});

Hooks

The hooks allows specifying the target actions that will be performed before or after target actions.

after(["git:commit"], (Target t, Map args) {
  // action
});
before(["compile", "link"], (Target t, Map args) {
  // action
});

Build shell

The built-in build shell allows use the build scripts as command line scripts.

exit(await new BuildShell().run(args));

example/example.dart

import "dart:async";
import "dart:io";
import "package:build_tools/build_shell.dart";
import "package:build_tools/build_tools.dart";

Future main(List args) async {
  target("default", ["breakfast"], (t, args) {
    print("Very good!");
  });

  target("breakfast", ["eat sandwich", "drink coffee"], (t, args) {
    print(t.name);
  });

  before(["breakfast"], (t, args) {
    print("wash hands before ${t.name}");
  });

  after(["breakfast"], (t, args) {
    print("smoke a cigar after ${t.name}");
  });

  target("drink coffee", ["make coffee"], (t, args) {
    print(t.name);
  });

  target("eat sandwich", ["make sandwich"], (t, args) {
    print(t.name);
  });

  target("make coffee", [], (t, args) {
    print(t.name);
  });

  target("make sandwich", ["take bread", "take sausage"], (t, args) {
    print(t.name);
  });

  target("take bread", [], (t, args) {
    print(t.name);
  });

  target("take sausage", [], (t, args) {
    print(t.name);
  });

  exit(await new BuildShell().run(args));
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  build_tools: ^0.0.14

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:build_tools/build_tools.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
15
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
8
Learn more about scoring.

This package version is not analyzed, because it is more than two years old. Check the latest stable version for its analysis.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.