MAKEFILE.md
1 Makefile 2 ======== 3 4 To build, verify, and install `lnd` from source, use the following 5 commands: 6 ```shell 7 $ make 8 $ make check 9 $ make install 10 ``` 11 12 The command `make check` requires `bitcoind` (almost any version should do) to 13 be available in the system's `$PATH` variable. Otherwise, some tests will 14 fail. 15 16 Developers 17 ========== 18 19 This document specifies all commands available from `lnd`'s `Makefile`. 20 The commands included handle: 21 - Installation of all go-related dependencies. 22 - Compilation and installation of `lnd` and `lncli`. 23 - Compilation and installation of `btcd` and `btcctl`. 24 - Running unit and integration suites. 25 - Testing, debugging, and flake hunting. 26 - Formatting and linting. 27 28 Commands 29 ======== 30 31 - [`all`](#scratch) 32 - [`btcd`](#btcd) 33 - [`build`](#build) 34 - [`check`](#check) 35 - [`clean`](#clean) 36 - [`default`](#default) 37 - [`dep`](#dep) 38 - [`flake-unit`](#flake-unit) 39 - [`flakehunter`](#flakehunter) 40 - [`fmt`](#fmt) 41 - [`install`](#install) 42 - [`itest`](#itest) 43 - [`lint`](#lint) 44 - [`list`](#list) 45 - [`rpc`](#rpc) 46 - [`scratch`](#scratch) 47 - [`travis`](#travis) 48 - [`unit`](#unit) 49 - [`unit-cover`](#unit-cover) 50 - [`unit-race`](#unit-race) 51 52 `all` 53 ----- 54 Compiles, tests, and installs `lnd` and `lncli`. Equivalent to 55 [`scratch`](#scratch) [`check`](#check) [`install`](#install). 56 57 `btcd` 58 ------ 59 Ensures that the [`github.com/btcsuite/btcd`][btcd] repository is checked out 60 locally. Lastly, installs the version of 61 [`github.com/btcsuite/btcd`][btcd] specified in `Gopkg.toml` 62 63 `build` 64 ------- 65 Compiles the current source and vendor trees, creating `./lnd` and 66 `./lncli`. 67 68 `check` 69 ------- 70 Installs the version of [`github.com/btcsuite/btcd`][btcd] specified 71 in `Gopkg.toml`, then runs the unit tests followed by the integration 72 tests. 73 74 Related: [`unit`](#unit) [`itest`](#itest) 75 76 `clean` 77 ------- 78 Removes compiled versions of both `./lnd` and `./lncli`, and removes the 79 `vendor` tree. 80 81 `default` 82 --------- 83 Alias for [`scratch`](#scratch). 84 85 `flake-unit` 86 ------------ 87 Runs the unit test endlessly until a failure is detected. 88 89 Arguments: 90 - `pkg=<package>` 91 - `case=<testcase>` 92 - `timeout=<timeout>` 93 94 Related: [`unit`](#unit) 95 96 `flakehunter` 97 ------------- 98 Runs the integration test suite endlessly until a failure is detected. 99 100 Arguments: 101 - `icase=<itestcase>` 102 - `timeout=<timeout>` 103 104 Related: [`itest`](#itest) 105 106 `fmt` 107 ----- 108 Runs `go fmt` on the entire project. 109 110 `install` 111 --------- 112 Copies the compiled `lnd` and `lncli` binaries into `$GOPATH/bin`. 113 114 `itest` 115 ------- 116 Installs the version of [`github.com/btcsuite/btcd`][btcd] specified in 117 `Gopkg.toml`, builds the `./lnd` and `./lncli` binaries, then runs the 118 integration test suite. 119 120 Arguments: 121 - `icase=<itestcase>` (the snake_case version of the testcase name field in the testCases slice (i.e. sweep_coins), not the test func name) 122 - `timeout=<timeout>` 123 124 `itest-parallel` 125 ------ 126 Does the same as `itest` but splits the total set of tests into 127 `NUM_ITEST_TRANCHES` tranches (currently set to 6 by default, can be overwritten 128 by setting `tranches=Y`) and runs them in parallel. 129 130 Arguments: 131 - `icase=<itestcase>`: The snake_case version of the testcase name field in the 132 testCases slice (i.e. `sweep_coins`, not the test func name) or any regular 133 expression describing a set of tests. 134 - `timeout=<timeout>` 135 - `tranches=<number_of_tranches>`: The number of parts/tranches to split the 136 total set of tests into. 137 - `parallel=<number_of_threads>`: The number of threads to run in parallel. Must 138 be greater or equal to `tranches`, otherwise undefined behavior is expected. 139 140 `flakehunter-parallel` 141 ------ 142 Runs the test specified by `icase` simultaneously `parallel` (default=6) times 143 until an error occurs. Useful for hunting flakes. 144 145 Example: 146 ```shell 147 $ make flakehunter-parallel icase='(data_loss_protection|channel_backup)' backend=neutrino 148 ``` 149 150 `lint` 151 ------ 152 Ensures that [`gopkg.in/alecthomas/gometalinter.v1`][gometalinter] is 153 installed, then lints the project. 154 155 `list` 156 ------ 157 Lists all known make targets. 158 159 `rpc` 160 ----- 161 Compiles the `lnrpc` proto files. 162 163 `sample-conf-check` 164 ------------------- 165 Checks whether all required options of `lnd --help` are included in [sample-lnd.conf](github.com/lightningnetwork/lnd/blob/master/sample-lnd.conf) and that the default values of `lnd --help` are also mentioned correctly. 166 167 `scratch` 168 --------- 169 Compiles all dependencies and builds the `./lnd` and `./lncli` binaries. 170 Equivalent to [`lint`](#lint) [`btcd`](#btcd) 171 [`unit-race`](#unit-race). 172 173 `unit` 174 ------ 175 Runs the unit test suite. By default, this will run all known unit tests. 176 177 Arguments: 178 - `pkg=<package>` 179 - `case=<testcase>` 180 - `timeout=<timeout>` 181 - `log="stdlog[ <log-level>]"` prints logs to stdout 182 - `<log-level>` can be `info` (default), `debug`, `trace`, `warn`, `error`, `critical`, or `off` 183 184 `unit-cover` 185 ------------ 186 Runs the unit test suite with test coverage, compiling the statistics in 187 `profile.cov`. 188 189 Arguments: 190 - `pkg=<package>` 191 - `case=<testcase>` 192 - `timeout=<timeout>` 193 - `log="stdlog[ <log-level>]"` prints logs to stdout 194 - `<log-level>` can be `info` (default), `debug`, `trace`, `warn`, `error`, `critical`, or `off` 195 196 Related: [`unit`](#unit) 197 198 `unit-race` 199 ----------- 200 Runs the unit test suite with go's race detector. 201 202 Arguments: 203 - `pkg=<package>` 204 - `case=<testcase>` 205 - `timeout=<timeout>` 206 - `log="stdlog[ <log-level>]"` prints logs to stdout 207 - `<log-level>` can be `info` (default), `debug`, `trace`, `warn`, `error`, `critical`, or `off` 208 209 Related: [`unit`](#unit) 210 211 [btcd]: https://github.com/btcsuite/btcd (github.com/btcsuite/btcd") 212 [gometalinter]: https://gopkg.in/alecthomas/gometalinter.v1 (gopkg.in/alecthomas/gometalinter.v1)