Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

port entrypoint.sh for powershell

+50 -3
+13 -3
compiler-cli/src/export.rs
··· 3 3 Result, 4 4 }; 5 5 6 + #[cfg(target_os = "windows")] 7 + static ENTRYPOINT_FILENAME: &str = "entrypoint.ps1"; 8 + #[cfg(not(target_os = "windows"))] 9 + static ENTRYPOINT_FILENAME: &str = "entrypoint.sh"; 10 + 11 + #[cfg(target_os = "windows")] 12 + static ENTRYPOINT_TEMPLATE: &str = include_str!("../templates/erlang-shipment-entrypoint.ps1"); 13 + #[cfg(not(target_os = "windows"))] 14 + static ENTRYPOINT_TEMPLATE: &str = include_str!("../templates/erlang-shipment-entrypoint.sh"); 15 + 6 16 // TODO: start in embedded mode 7 17 // TODO: test 8 18 ··· 62 72 } 63 73 64 74 // Write entrypoint script 65 - let entrypoint = out.join("entrypoint.sh"); 66 - let text = include_str!("../templates/erlang-shipment-entrypoint.sh") 67 - .replace("$PACKAGE_NAME_FROM_GLEAM", &built.root_package.config.name); 75 + let entrypoint = out.join(ENTRYPOINT_FILENAME); 76 + let text = 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
··· 1 + $ErrorActionPreference = "Stop" 2 + 3 + $PackageName = "$PACKAGE_NAME_FROM_GLEAM" 4 + $BaseDirectory = $PSScriptRoot 5 + $ScriptCommand = $args[0] 6 + 7 + $CodePath = Join-Path -Path $BaseDirectory -ChildPath "\*\ebin" -Resolve 8 + 9 + function Run { 10 + erl ` 11 + -pa $CodePath ` 12 + -eval "$PackageName@@main:run($PackageName)" ` 13 + -noshell ` 14 + -extra $args 15 + } 16 + 17 + function Shell { 18 + erl -pa $CodePath 19 + } 20 + 21 + switch ($ScriptCommand) { 22 + "run" { 23 + Run $args[1..($args.Length - 1)] 24 + } 25 + "shell" { 26 + Shell 27 + } 28 + default { 29 + Write-Host "usage:" 30 + Write-Host " entrypoint.ps1 `$COMMAND" 31 + Write-Host "" 32 + Write-Host "commands:" 33 + Write-Host " run Run the project main function" 34 + Write-Host " shell Run an Erlang shell" 35 + exit 1 36 + } 37 + }