* Add `--output-directory` to `forc build` and related commands
This is a start at addressing #765.
Users can now specify a directory in which all compiler output artifacts
will be placed by `forc` upon `forc build`.
When unspecified, `--output-directory` defaults to `<project>/out/`.
More specifically, artifacts are placed in `<project>/out/<profile>`
where the `profile` subdirectory is in anticipation of support for
multiple different build profiles. Currently "debug" is assumed.
* Add `out` directory to Sway repo `.gitignore` for forc examples
* Update e2e test harness for addition of `--output-directory`
* sway-core: Expose inter-compilation steps for use in forc
This refactors the bodies of the `compile_to_asm` and
`compile_to_bytecode` functions into `ast_to_asm` and `asm_to_bytecode`
respectively. This allows `forc` to compile the AST (for producing the
ABI JSON) and then re-use the compiled AST to complete the rest of
compilation to bytecode in the same pass.
* Add ABI JSON output to `forc build`
This updates `forc build` and related commands to compile the JSON ABI
and write it to a `<project-name>-abi.json` file in the output
directory.
* Implement `forc json-abi` in terms of `forc build` under the hood
We may want to consider removing the dedicated `forc json-abi` command
altogether in favour of a `--print-json-abi` flag to `forc build` to
make it clear that the output comes directly from `forc build`.
* Address clippy nits
* Always `forc build` at the beginning of `forc test`
This ensures the project can build before attempting to run tests.
This may also make it easier to assume a location for the contract JSON
ABI in tests.
* Update `hello_world` contract example abi location to `out` directory
Now that `cargo test` does `cargo build` first, it's safer to assume the
contract JSON ABI is located in the `out` directory.
* On `forc init` create `.gitignore` containing `out`, `target` dirs
This ensures that forc and cargo's output artifact directories are
discluded from git tracking by default.
* Add a `forc clean` command
Removes the default forc compiler output directory (`<project>/out`).
Also runs `cargo clean` to remove the `target` directory that gets
created when running `cargo test` via `forc test`.
* Fix doc comment to say JSON ABI is generated for both contract *and* lib
* Pretty print JSON ABI output by default
Human-friendly formatting by default, useful for checking/debugging
contract/library ABIs.
This is applied to both the `forc build` JSON of the output directory,
as well as the `forc json-abi` output.
A `--minimize-json-abi` option is added in order to allow for achieving
the original behaviour.
* Rename minimize -> minify. Add `--minify` flag to `forc json-abi`.
* Extract `hello_world` example from the book into a standalone project
Related to #544.
Follows the example set in #731.
Tested with `mdbook serve`.
Also adds the `hello_world` and `subcurrency` examples to the Sway
workspace so that we can test both projects under CI.
* Fix hello_world example project name in forc manifest
* Move fizzbuzz and wallet_smart_contract examples to standalone projects
* Add `build-all-examples` script and associated CI passes
This script walks the examples directory and, for every directory
containing a `forc.toml` file, runs `forc build` for that directory.
Examples that encounter a failure of some kind have their `stdout` and
`stderr` piped through so we can easily identify cause of failure in CI.
This also removes the examples from the workspace.
Currently unsure whether or not the added CI pass to install `forc` will
result in `forc` actually being available on the PATH in the CI worker,
but will find out soon.
Still need to work out how to run `forc test` for each project without
having cargo complain about building within the parent sway workspace.
* Add a clear build summary at the end of `build-all-examples`
Currently, it's tricky to get an idea of how many successes/failures
there were without combing through the stdout/stderr. This adds a little
summary to the end that looks something like this:
```
Build all examples summary:
[✓]: /home/mindtree/programming/rust/fuel/sway/examples/fizzbuzz succeeded!
[✓]: /home/mindtree/programming/rust/fuel/sway/examples/hello_world succeeded!
[x]: /home/mindtree/programming/rust/fuel/sway/examples/wallet_smart_contract failed!
[✓]: /home/mindtree/programming/rust/fuel/sway/examples/subcurrency succeeded!
3 successes, 1 failure
```
* Set build-all-examples script version to 0.0.0
* Exclude examples from workspace, Fix hello_world test harness path
* Temporarily comment out storage related code in wallet example
This example should be updated after #646 lands.
* Install forc with `--debug` to share build artifacts
Currently it takes CI another 7 mins to build and install forc from
scratch. This should allow `cargo` to re-use the artifacts it has
already built during the sway building and testing steps earlier in the
CI job.
* Change author field in examples from mindtree -> Fuel Labs