@@ -7,27 +7,16 @@ import cli.Task exposing [Task]
77import cli.Cmd
88import cli.Stdout
99import cli.Env
10- import cli.File
1110import cli.Arg
1211import weaver.Opt
1312import weaver.Cli
1413
15- RocTarget : [
16- MacosArm64 ,
17- MacosX64 ,
18- LinuxArm64 ,
19- LinuxX64 ,
20- WindowsArm64 ,
21- WindowsX64 ,
22- ]
23-
2414main =
2515
2616 cliParser =
2717 Cli . weave {
2818 release: <- Opt . flag { short: " r" , long: " release" , help: " Release build" },
29- path: <- Opt . maybeStr { short: " p" , long: " path" , help: " Path to the workspace root" },
30- roc: <- Opt . str { short: " d" , long: " roc" , help: " Path to the roc binary" },
19+ maybeRoc: <- Opt . maybeStr { short: " c" , long: " cli" , help: " Path to the roc cli" },
3120 }
3221 |> Cli . finish {
3322 name: " basic-webserver" ,
@@ -41,36 +30,25 @@ main =
4130 Ok args -> run args
4231 Err message -> Task . err (Exit 1 message)
4332
44- run = \{ release, path, roc } ->
45-
46- root = path |> Result . withDefault " "
33+ run = \{ release, maybeRoc } ->
4734
48- info! " Checking working directory ..."
49- " $( root) flake.nix"
50- |> File . isFile
51- |> Task . await \exists -> if exists then Task . ok {} else Task . err (ErrInvalidWorkingDir root)
52- |> Task . mapErr ! \err -> ErrWorkingDirectory err root
53-
54- info! " Listing working directory ..."
55- " ls"
56- |> Cmd . exec [" -R" , " $( root) " ]
57- |> Task . mapErr ! ErrListingWorkingDir
35+ roc = maybeRoc |> Result . withDefault " roc"
5836
5937 info! " Generating glue for builtins ..."
6038 roc
61- |> Cmd . exec [" glue" , " $( root ) glue.roc" , " $( root ) crates/" , " $( root ) platform/main.roc" ]
39+ |> Cmd . exec [" glue" , " glue.roc" , " crates/" , " platform/main.roc" ]
6240 |> Task . mapErr ! ErrGeneratingGlue
6341
6442 info! " Getting the native target ..."
6543 target =
6644 Env . platform
6745 |> Task . await ! getNativeTarget
6846
69- stubPath = " $( root ) platform/libapp.$( stubExt target) "
47+ stubPath = " platform/libapp.$( stubExt target) "
7048
7149 info! " Building stubbed app shared library ..."
7250 roc
73- |> Cmd . exec [" build" , " --lib" , " $( root ) platform/libapp.roc" , " --output" , stubPath]
51+ |> Cmd . exec [" build" , " --lib" , " platform/libapp.roc" , " --output" , stubPath]
7452 |> Task . mapErr ! ErrBuildingAppStub
7553
7654 (cargoBuildArgs, message) =
@@ -84,31 +62,31 @@ run = \{ release, path, roc } ->
8462 |> Cmd . exec cargoBuildArgs
8563 |> Task . mapErr ! ErrBuildingHostBinaries
8664
87- hostBuildPath = if release then " $( root ) target/release/libhost.a" else " $( root ) target/debug/libhost.a"
88- hostDestPath = " $( root ) platform/$( prebuiltStaticLibrary target) "
65+ hostBuildPath = if release then " target/release/libhost.a" else " target/debug/libhost.a"
66+ hostDestPath = " platform/$( prebuiltStaticLibrary target) "
8967
9068 info! " Moving the prebuilt binary from $( hostBuildPath) to $( hostDestPath) ..."
9169 " cp"
9270 |> Cmd . exec [hostBuildPath, hostDestPath]
9371 |> Task . mapErr ! ErrMovingPrebuiltLegacyBinary
9472
95- # TODO remove this, just a temporary workaround to see if this makes CI happy
96- # if so we know that linux requires an object `.o` file for some reason...
97- prebuiltObjectPath = " $( root) platform/$( prebuiltObject target) "
98- info! " Moving the prebuilt binary from $( hostBuildPath) to $( prebuiltObjectPath) ..."
99- " cp"
100- |> Cmd . exec [hostBuildPath, prebuiltObjectPath]
101- |> Task . mapErr ! ErrMovingPrebuiltLegacyObject
102-
103- # SURGICAL LINKER IS NOT YET SUPPORTED need to merge https://github.com/roc-lang/roc/pull/6808
104- #info! "Preprocessing surgical host ..."
105- #surgicalBuildPath = if release then "target/release/host" else "target/debug/host"
106- #roc
107- # |> Cmd.exec ["preprocess-host", surgicalBuildPath, "platform/main.roc", stubPath]
108- # |> Task.mapErr! ErrPreprocessingSurgicalBinary
73+ info! " Preprocessing surgical host ..."
74+ surgicalBuildPath = if release then " target/release/host" else " target/debug/host"
75+ roc
76+ |> Cmd . exec [" preprocess-host" , surgicalBuildPath, " platform/main.roc" , stubPath]
77+ |> Task . mapErr ! ErrPreprocessingSurgicalBinary
10978
11079 info! " Successfully completed building platform binaries."
11180
81+ RocTarget : [
82+ MacosArm64 ,
83+ MacosX64 ,
84+ LinuxArm64 ,
85+ LinuxX64 ,
86+ WindowsArm64 ,
87+ WindowsX64 ,
88+ ]
89+
11290getNativeTarget : _ -> Task RocTarget _
11391getNativeTarget =\{os, arch} ->
11492 when (os, arch) is
@@ -135,16 +113,6 @@ prebuiltStaticLibrary = \target ->
135113 WindowsArm64 -> " windows-arm64.lib"
136114 WindowsX64 -> " windows-x64.lib"
137115
138- prebuiltObject : RocTarget -> Str
139- prebuiltObject = \target ->
140- when target is
141- MacosArm64 -> " macos-arm64.a"
142- MacosX64 -> " macos-x64.a"
143- LinuxArm64 -> " linux-arm64.a"
144- LinuxX64 -> " linux-x64.a"
145- WindowsArm64 -> " windows-arm64.lib"
146- WindowsX64 -> " windows-x64.lib"
147-
148116info : Str -> Task {} _
149117info = \msg ->
150118 Stdout . line ! " \u( 001b ) [34mINFO:\u( 001b ) [0m $( msg) "
0 commit comments