README.md 2.33 KB
Newer Older
Drew's avatar
Drew committed
1 2 3 4
# atbuild

The Anarchy Tools Build Tool.

Drew's avatar
Drew committed
5
`atbuild` is a cross-platform build system, primarily for Swift-language projects, following the [Anarchy Tools philosophy](https://github.com/AnarchyTools/AnarchyTools) of simple, unopinionated, hackable tools.
Drew's avatar
Drew committed
6

Drew's avatar
Drew committed
7
# Tasks
Drew's avatar
Drew committed
8

Drew's avatar
Drew committed
9
With `atbuild` you define a set of *tasks*, representing high-level operations like building, running, and cleaning.  Then you can use these tasks from the command line.
Drew's avatar
Drew committed
10

Drew's avatar
Drew committed
11
```bash
Drew's avatar
Drew committed
12 13 14
$ atbuild build
$ atbuild build-tests
$ atbuild run-tests
Drew's avatar
Drew committed
15
$ atbuild #runs a task named "default"
Drew's avatar
Drew committed
16 17 18
```


Drew's avatar
Drew committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
Tasks are defined in a clojure-like format.  Here's a simple example:

```clojure
;; This is a comment

(package
  :name "foo"

  ;;These "tasks" are just entrypoints on the CLI.
  ;;For example, `atbuild build` runs the `build` task.
  :tasks {
    :run {
      :tool "shell"               ;;Tools are functions built into atbuild.
      :script "echo Hello world!" ;;The shell tool requires a script
    }
  }
)
```

Name that `build.atpkg`.  Now we can call 
Drew's avatar
Drew committed
39 40

```bash
Drew's avatar
Drew committed
41 42 43 44 45 46
$ atbuild run
Building package foo...
Running task run...
Hello world!
Completed task run.
Built package foo.
Drew's avatar
Drew committed
47 48
```

Drew's avatar
Drew committed
49
# Building Swift code
50

Drew's avatar
Drew committed
51
How do we build a Swift project?  There's a built-in tool called `atllbuild`, which is our *low-level build system*.
52

Drew's avatar
Drew committed
53
```clojure
54
(package
Drew's avatar
Drew committed
55
  :name "foo"
56 57

  ;;These "tasks" are just entrypoints on the CLI.
Drew's avatar
Drew committed
58
  ;;For example, `atbuild build` runs the `build` task.
59
  :tasks {
Drew's avatar
Drew committed
60 61 62 63
    :build {
      :tool "atllbuild"
      :source ["src/**.swift"] ;;walk the src directory, looking for Swift files
      :outputType "executable"
Drew's avatar
Drew committed
64
      :name "example"
Drew's avatar
Drew committed
65
    }
66 67
  }
)
Drew's avatar
Drew committed
68 69
```

Drew's avatar
Drew committed
70 71 72 73 74 75 76 77 78
That's all you need to get started!  `atbuild` supports many more usecases than can fit in a README.  For more information, browse our [documentation](/docs).

# Building

We publish [binary releases](https://github.com/AnarchyTools/atbuild/releases), which are the easiest way to get started.

`atbuild` is self-hosting, so building it with an existing copy is usually your best bet.

That said, if you're doing something fancy, or are bootstrapping onto a new platform, use `./bootstrap/build.sh`.
Drew's avatar
Drew committed
79

Drew's avatar
Drew committed
80 81 82 83 84 85 86 87 88 89 90 91
Then you can check the program was built successfully:

```bash
$ ./atbuild --help
atbuild - Anarchy Tools Build Tool 0.1.0-dev
https://github.com/AnarchyTools
© 2016 Anarchy Tools Contributors.

Usage:
atbuild [task]
    task: ["default", "helloworld", "bootstrap"]
```