Skip to content

Commit 0a28ce9

Browse files
committed
small improvements
1 parent f8c8d0a commit 0a28ce9

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ jobs:
4848

4949
- run: expect -v
5050

51-
- name: Build platform binary
52-
run: ./roc_nightly/roc ./build.roc --release --cli ./roc_nightly/roc
53-
5451
- name: Run all tests
5552
run: ROC=./roc_nightly/roc EXAMPLES_DIR=./examples/ ./ci/all_tests.sh
5653

.github/workflows/ci_nix.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ jobs:
3131
- name: print architecture
3232
run: uname -m
3333

34-
- name: Build platform binary
35-
run: nix develop -c sh -c 'roc ./build.roc --release'
36-
3734
- name: Run all tests
3835
run: nix develop -c sh -c 'export ROC=roc && export EXAMPLES_DIR=./examples/ && ./ci/all_tests.sh'
3936

build.roc

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
11
app [main] {
2-
cli: platform "https://github.com/roc-lang/basic-cli/releases/download/0.12.0/cf_TpThUd4e69C7WzHxCbgsagnDmk3xlb_HmEKXTICw.tar.br",
3-
weaver: "https://github.com/smores56/weaver/releases/download/0.2.0/BBDPvzgGrYp-AhIDw0qmwxT0pWZIQP_7KOrUrZfp_xw.tar.br",
2+
cli: platform "TODO use updated basic-cli 0.12.0 (requires changes from github.com/roc-lang/basic-cli/pull/224)",
43
}
54

65
import cli.Task exposing [Task]
76
import cli.Cmd
87
import cli.Stdout
98
import cli.Env
109
import cli.Arg
11-
import weaver.Opt
12-
import weaver.Cli
13-
10+
import cli.Arg.Opt as Opt
11+
import cli.Arg.Cli as Cli
12+
13+
## Builds the basic-cli [platform](https://www.roc-lang.org/platforms).
14+
##
15+
## run with: roc ./build.roc --release
16+
##
17+
main : Task {} _
1418
main =
1519

1620
cliParser =
17-
Cli.weave {
18-
release: <- Opt.flag { short: "r", long: "release", help: "Release build" },
19-
maybeRoc: <- Opt.maybeStr { short: "c", long: "cli", help: "Path to the roc cli"},
21+
Cli.build {
22+
releaseMode: <- Opt.flag { short: "r", long: "release", help: "Release build. Passes `--release` to `cargo build`." },
23+
maybeRoc: <- Opt.maybeStr { short: "p", long: "roc", help: "Path to the roc executable. Can be just `roc` or a full path."},
2024
}
2125
|> Cli.finish {
22-
name: "basic-webserver",
26+
name: "basic-cli-builder",
2327
version: "",
2428
authors: ["Luke Boswell <https://github.com/lukewilliamboswell>"],
25-
description: "This build script generates the binaries and packages the platform for distribution.",
29+
description: "Generates all files needed by Roc to use this basic-cli platform.",
2630
}
2731
|> Cli.assertValid
2832

2933
when Cli.parseOrDisplayMessage cliParser (Arg.list!) is
3034
Ok args -> run args
31-
Err message -> Task.err (Exit 1 message)
35+
Err errMsg -> Task.err (Exit 1 errMsg)
3236

33-
run = \{ release, maybeRoc } ->
37+
run : { releaseMode : Bool, maybeRoc : Result Str err} -> Task {} _
38+
run = \{ releaseMode, maybeRoc } ->
3439

3540
roc = maybeRoc |> Result.withDefault "roc"
3641

@@ -39,39 +44,40 @@ run = \{ release, maybeRoc } ->
3944
|> Cmd.exec ["glue", "glue.roc", "crates/", "platform/main.roc"]
4045
|> Task.mapErr! ErrGeneratingGlue
4146

47+
# target is MacosArm64, LinuxX64,...
4248
info! "Getting the native target ..."
4349
target =
4450
Env.platform
4551
|> Task.await! getNativeTarget
4652

47-
stubPath = "platform/libapp.$(stubExt target)"
53+
stubPath = "platform/libapp.$(stubFileExtension target)"
4854

4955
info! "Building stubbed app shared library ..."
5056
roc
5157
|> Cmd.exec ["build", "--lib", "platform/libapp.roc", "--output", stubPath]
5258
|> Task.mapErr! ErrBuildingAppStub
5359

54-
(cargoBuildArgs, message) =
55-
if release then
60+
(cargoBuildArgs, infoMessage) =
61+
if releaseMode then
5662
(["build", "--release"], "Building host in RELEASE mode ...")
5763
else
5864
(["build"], "Building host in DEBUG mode ...")
5965

60-
info! message
66+
info! infoMessage
6167
"cargo"
6268
|> Cmd.exec cargoBuildArgs
6369
|> Task.mapErr! ErrBuildingHostBinaries
6470

65-
hostBuildPath = if release then "target/release/libhost.a" else "target/debug/libhost.a"
66-
hostDestPath = "platform/$(prebuiltStaticLibrary target)"
71+
hostBuildPath = if releaseMode then "target/release/libhost.a" else "target/debug/libhost.a"
72+
hostDestPath = "platform/$(prebuiltStaticLibFile target)"
6773

6874
info! "Moving the prebuilt binary from $(hostBuildPath) to $(hostDestPath) ..."
6975
"cp"
7076
|> Cmd.exec [hostBuildPath, hostDestPath]
7177
|> Task.mapErr! ErrMovingPrebuiltLegacyBinary
7278

7379
info! "Preprocessing surgical host ..."
74-
surgicalBuildPath = if release then "target/release/host" else "target/debug/host"
80+
surgicalBuildPath = if releaseMode then "target/release/host" else "target/debug/host"
7581
roc
7682
|> Cmd.exec ["preprocess-host", surgicalBuildPath, "platform/main.roc", stubPath]
7783
|> Task.mapErr! ErrPreprocessingSurgicalBinary
@@ -96,15 +102,15 @@ getNativeTarget =\{os, arch} ->
96102
(LINUX, X64) -> Task.ok LinuxX64
97103
_ -> Task.err (UnsupportedNative os arch)
98104

99-
stubExt : RocTarget -> Str
100-
stubExt = \target ->
105+
stubFileExtension : RocTarget -> Str
106+
stubFileExtension = \target ->
101107
when target is
102108
MacosX64 | MacosArm64 -> "dylib"
103109
LinuxArm64 | LinuxX64-> "so"
104110
WindowsX64| WindowsArm64 -> "dll"
105111

106-
prebuiltStaticLibrary : RocTarget -> Str
107-
prebuiltStaticLibrary = \target ->
112+
prebuiltStaticLibFile : RocTarget -> Str
113+
prebuiltStaticLibFile = \target ->
108114
when target is
109115
MacosArm64 -> "macos-arm64.a"
110116
MacosX64 -> "macos-x64.a"

ci/all_tests.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ if [ -z "${ROC}" ]; then
1919
exit 1
2020
fi
2121

22+
# build the basic-cli platform
23+
$ROC ./build.roc --release --roc $ROC
24+
2225
# roc check
2326
for roc_file in $EXAMPLES_DIR*.roc; do
2427
$ROC check $roc_file

0 commit comments

Comments
 (0)