2020-12-05 11:10:10 -05:00
|
|
|
## Compiling Executables
|
|
|
|
|
2021-01-04 18:15:52 -05:00
|
|
|
`deno compile [--output <OUT>] <SRC>` will compile the script into a
|
|
|
|
self-contained executable.
|
2020-12-05 11:10:10 -05:00
|
|
|
|
|
|
|
```
|
2021-04-27 06:44:36 -04:00
|
|
|
> deno compile https://deno.land/std/examples/welcome.ts
|
2020-12-05 11:10:10 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
If you omit the `OUT` parameter, the name of the executable file will be
|
|
|
|
inferred.
|
|
|
|
|
2021-01-04 18:15:52 -05:00
|
|
|
### Flags
|
|
|
|
|
|
|
|
As with [`deno install`](./script_installer.md), the runtime flags used to
|
|
|
|
execute the script must be specified at compilation time. This includes
|
|
|
|
permission flags.
|
|
|
|
|
|
|
|
```
|
2021-04-27 06:44:36 -04:00
|
|
|
> deno compile --allow-read --allow-net https://deno.land/std/http/file_server.ts
|
2021-01-04 18:15:52 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
[Script arguments](../getting_started/command_line_interface.md#script-arguments)
|
|
|
|
can be partially embedded.
|
|
|
|
|
|
|
|
```
|
2021-04-27 06:44:36 -04:00
|
|
|
> deno compile --allow-read --allow-net https://deno.land/std/http/file_server.ts -p 8080
|
2021-01-04 18:15:52 -05:00
|
|
|
> ./file_server --help
|
|
|
|
```
|
|
|
|
|
2020-12-05 11:10:10 -05:00
|
|
|
### Cross Compilation
|
|
|
|
|
2021-01-26 23:33:51 -05:00
|
|
|
You can use cross compilation by adding `--target` CLI argument, benefiting that
|
|
|
|
you can create binaries for other platforms in single CI machine. Deno supports
|
|
|
|
compiling to Windows x64, macOS x64, macOS ARM and Linux x64 currently. Use
|
|
|
|
`deno compile --help` to get the full list about compilation targets.
|