build_tools 0.1.0

  • README.md
  • Example
  • Installing
  • Versions
  • 58

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<String> 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<String> 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.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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';
  
Version Uploaded Documentation Archive
0.1.0 Aug 14, 2018 Go to the documentation of build_tools 0.1.0 Download build_tools 0.1.0 archive
0.0.15 Apr 24, 2015 Go to the documentation of build_tools 0.0.15 Download build_tools 0.0.15 archive
0.0.14 Apr 23, 2015 Go to the documentation of build_tools 0.0.14 Download build_tools 0.0.14 archive
0.0.12 Mar 12, 2015 Go to the documentation of build_tools 0.0.12 Download build_tools 0.0.12 archive
0.0.11 Mar 11, 2015 Go to the documentation of build_tools 0.0.11 Download build_tools 0.0.11 archive
0.0.10 Mar 11, 2015 Go to the documentation of build_tools 0.0.10 Download build_tools 0.0.10 archive
0.0.9 Mar 3, 2015 Go to the documentation of build_tools 0.0.9 Download build_tools 0.0.9 archive
0.0.8 Dec 24, 2014 Go to the documentation of build_tools 0.0.8 Download build_tools 0.0.8 archive
0.0.7 Aug 2, 2014 Go to the documentation of build_tools 0.0.7 Download build_tools 0.0.7 archive
0.0.6 Aug 2, 2014 Go to the documentation of build_tools 0.0.6 Download build_tools 0.0.6 archive

All 13 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
24
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
58
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: Flutter, other

Primary library: package:build_tools/build_tools.dart with components: io.

Health suggestions

Fix lib/src/build_shell.dart. (-0.50 points)

Analysis of lib/src/build_shell.dart reported 1 hint:

line 129 col 33: The exception variable 'e' isn't used, so the 'catch' clause can be removed.

Fix lib/src/file_target.dart. (-0.50 points)

Analysis of lib/src/file_target.dart reported 1 hint:

line 48 col 43: 'NOT_FOUND' is deprecated and shouldn't be used.

Maintenance issues and suggestions

Maintain CHANGELOG.md. (-20 points)

Changelog entries help clients to follow the progress in your code.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
args ^1.5.0 1.5.1
file_utils ^0.1.1 0.1.1
globbing ^0.2.0 0.2.0
logging ^0.11.3+2 0.11.3+2
patsubst ^0.1.0 0.1.0
Transitive dependencies
path 1.6.2