alpha
Login
or
Join now
nandi.uk
/
gleam
Star
2
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Fork of daniellemaywood.uk/gleam — Wasm codegen work
Star
2
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
port entrypoint.sh for powershell
author
bun
committer
Louis Pilfold
date
2 years ago
(Nov 5, 2023, 12:21 PM UTC)
commit
aaba151d
aaba151df34bc900bafc655a09d7826100002f86
parent
38293bea
38293bea2c980ead573daf8341d82541ba2c7d22
+50
-3
2 changed files
Expand all
Collapse all
Unified
Split
compiler-cli
src
export.rs
templates
erlang-shipment-entrypoint.ps1
+13
-3
compiler-cli/src/export.rs
View file
Reviewed
···
3
3
Result,
4
4
};
5
5
6
6
+
#[cfg(target_os = "windows")]
7
7
+
static ENTRYPOINT_FILENAME: &str = "entrypoint.ps1";
8
8
+
#[cfg(not(target_os = "windows"))]
9
9
+
static ENTRYPOINT_FILENAME: &str = "entrypoint.sh";
10
10
+
11
11
+
#[cfg(target_os = "windows")]
12
12
+
static ENTRYPOINT_TEMPLATE: &str = include_str!("../templates/erlang-shipment-entrypoint.ps1");
13
13
+
#[cfg(not(target_os = "windows"))]
14
14
+
static ENTRYPOINT_TEMPLATE: &str = include_str!("../templates/erlang-shipment-entrypoint.sh");
15
15
+
6
16
// TODO: start in embedded mode
7
17
// TODO: test
8
18
···
62
72
}
63
73
64
74
// Write entrypoint script
65
65
-
let entrypoint = out.join("entrypoint.sh");
66
66
-
let text = include_str!("../templates/erlang-shipment-entrypoint.sh")
67
67
-
.replace("$PACKAGE_NAME_FROM_GLEAM", &built.root_package.config.name);
75
75
+
let entrypoint = out.join(ENTRYPOINT_FILENAME);
76
76
+
let text =
77
77
+
ENTRYPOINT_TEMPLATE.replace("$PACKAGE_NAME_FROM_GLEAM", &built.root_package.config.name);
68
78
crate::fs::write(&entrypoint, &text)?;
69
79
crate::fs::make_executable(&entrypoint)?;
70
80
+37
compiler-cli/templates/erlang-shipment-entrypoint.ps1
View file
Reviewed
···
1
1
+
$ErrorActionPreference = "Stop"
2
2
+
3
3
+
$PackageName = "$PACKAGE_NAME_FROM_GLEAM"
4
4
+
$BaseDirectory = $PSScriptRoot
5
5
+
$ScriptCommand = $args[0]
6
6
+
7
7
+
$CodePath = Join-Path -Path $BaseDirectory -ChildPath "\*\ebin" -Resolve
8
8
+
9
9
+
function Run {
10
10
+
erl `
11
11
+
-pa $CodePath `
12
12
+
-eval "$PackageName@@main:run($PackageName)" `
13
13
+
-noshell `
14
14
+
-extra $args
15
15
+
}
16
16
+
17
17
+
function Shell {
18
18
+
erl -pa $CodePath
19
19
+
}
20
20
+
21
21
+
switch ($ScriptCommand) {
22
22
+
"run" {
23
23
+
Run $args[1..($args.Length - 1)]
24
24
+
}
25
25
+
"shell" {
26
26
+
Shell
27
27
+
}
28
28
+
default {
29
29
+
Write-Host "usage:"
30
30
+
Write-Host " entrypoint.ps1 `$COMMAND"
31
31
+
Write-Host ""
32
32
+
Write-Host "commands:"
33
33
+
Write-Host " run Run the project main function"
34
34
+
Write-Host " shell Run an Erlang shell"
35
35
+
exit 1
36
36
+
}
37
37
+
}