2019-03-08 19:58:27 +00:00
# `embark-compiler`
2018-12-14 16:48:48 +00:00
2019-03-08 19:58:27 +00:00
> Embark compiler module
2018-12-14 16:48:48 +00:00
2019-03-08 19:58:27 +00:00
Visit [embark.status.im ](https://embark.status.im/ ) to get started with
[Embark ](https://github.com/embark-framework/embark ).
This module abstracts the compiler interface. It exposes a plugin api to
register contract extensions and how to handle them. It accepts command
requests to compile and returns the aggregated compilation result.
## API
2018-12-14 16:48:48 +00:00
**command: `compiler:contracts` **
arguments:
* `contractFiles` - < array of embark File Objects >
2019-01-14 11:21:40 +00:00
* `options` - < object > config object `{isCoverage: boolean (default: false)}`
2018-12-14 16:48:48 +00:00
response:
* `error`
* `compiledObject` - compilation result
```
{
runtimeBytecode: < deployed bytecode >
realRuntimeByteCode: < deployed bytecode without swarm hash >
code: < bytecode >
abiDefinition: < abi object >
swarmHash: (optional)
gasEstimates: (optional)
functionHashes: (optional)
filename: (optional) < contract relative filename >
originalFilename: (optional) < contract real filename >
}
```
example:
```
2019-01-14 11:21:40 +00:00
import { File } from 'src/lib/core/file.js';
const contractFiles = [(new File({path: "simplestorage.sol", type: "custom", resolver: (cb) => { return cb(".. contract code...") }}))];
2018-12-14 16:48:48 +00:00
embark.events.request("compiler:contracts", contractFiles, {}, (err, compiledObject) => {
})
```
2019-03-08 19:58:27 +00:00
## Plugins
2018-12-14 16:48:48 +00:00
This module enables the `registerCompiler` plugin API. see [documentation ](https://embark.status.im/docs/plugin_reference.html#embark-registerCompiler-extension-callback-contractFiles-doneCallback )
***embark.registerCompiler***
arguments:
* `extension` - extension of the contract language (e.g `.sol` )
* response callback
* `contractFiles` : filenames matching the extension
* `callback(error, compiledObject)`
2019-03-08 19:58:27 +00:00
## Dependencies
2018-12-14 16:48:48 +00:00
* async.eachObject