Skip to content

Commit

Permalink
Add Windows support (#3)
Browse files Browse the repository at this point in the history
* Test on Windows

* Attempt to fix Windows support

* Attempt to fix Windows support, again

* Run Windows installer with sh

* Use sh -c in test

* Manually set URLGETTER to curl

* Add Windows test

* Fix escaping

* Set SMLNJ_HOME manually

* Move SMLNJ_HOME

* Add msvc-dev-cmd

Needed for `nmake` on Windows.

* Download msi

Instead of building from scratch.

* Fix bugs

* Fix typo

* Switch Windows run to debug output

* Confirm sml command available
  • Loading branch information
HarrisonGrodin committed Aug 20, 2020
1 parent 7dbb74b commit ddd7a60
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 26 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
smlnj-version: [110.87, 110.97, 110.98]
exclude:
# SML/NJ versions before 110.94 do not support 64-bit
Expand All @@ -22,5 +22,12 @@ jobs:
- uses: ./
with:
smlnj-version: ${{ matrix.smlnj-version }}
- run: |
- name: Test version output (Unix)
if: matrix.os != 'windows-latest'
run: |
[[ $(sml @SMLversion) == "sml ${{ matrix.smlnj-version }}" ]]
- name: Test version output (Windows)
if: matrix.os == 'windows-latest'
run: |
# "$(sml @SMLversion)" -eq "sml ${{ matrix.smlnj-version }}"
Get-Command sml
55 changes: 43 additions & 12 deletions lib/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,50 @@ function getNJ(version) {
exports.getNJ = getNJ;
function acquireNJ(version) {
return __awaiter(this, void 0, void 0, function* () {
if (process.platform === "linux") {
// install required 32-bit support libraries
yield exec.exec("sudo", ["apt-get", "update"]);
yield exec.exec("sudo", [
"apt-get",
"install",
"-y",
"--no-install-recommends",
"gcc-multilib",
"lib32ncurses5",
"lib32z1"
]);
switch (process.platform) {
case "win32":
return acquireNJWindows(version);
case "linux":
return acquireNJLinux(version);
default:
return acquireNJUnix(version);
}
});
}
function acquireNJWindows(version) {
return __awaiter(this, void 0, void 0, function* () {
let downloadUrl = util.format("https://smlnj.org/dist/working/%s/smlnj-%s.msi", version, version);
core.debug("Downloading SML/NJ from: " + downloadUrl);
let downloadPath = null;
try {
downloadPath = yield tc.downloadTool(downloadUrl);
}
catch (error) {
core.debug(error);
throw `Failed to download version ${version}: ${error}`;
}
yield exec.exec("msiexec", ["/qn", "/i", downloadPath]);
return new Promise((resolve, _) => resolve(path.join("C:", "Program Files (x86)", "SMLNJ")));
});
}
function acquireNJLinux(version) {
return __awaiter(this, void 0, void 0, function* () {
// install required 32-bit support libraries
yield exec.exec("sudo", ["apt-get", "update"]);
yield exec.exec("sudo", [
"apt-get",
"install",
"-y",
"--no-install-recommends",
"gcc-multilib",
"lib32ncurses5",
"lib32z1"
]);
return acquireNJUnix(version);
});
}
function acquireNJUnix(version) {
return __awaiter(this, void 0, void 0, function* () {
let downloadUrl = util.format("http://smlnj.cs.uchicago.edu/dist/working/%s/config.tgz", version);
core.debug("Downloading SML/NJ from: " + downloadUrl);
let downloadPath = null;
Expand Down
61 changes: 49 additions & 12 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,57 @@ export async function getNJ(version: string) {
}

async function acquireNJ(version: string): Promise<string> {
if (process.platform === "linux") {
// install required 32-bit support libraries
await exec.exec("sudo", ["apt-get", "update"]);
await exec.exec("sudo", [
"apt-get",
"install",
"-y",
"--no-install-recommends",
"gcc-multilib",
"lib32ncurses5",
"lib32z1"
]);
switch (process.platform) {
case "win32":
return acquireNJWindows(version);
case "linux":
return acquireNJLinux(version);
default:
return acquireNJUnix(version);
}
}

async function acquireNJWindows(version: string): Promise<string> {
let downloadUrl: string = util.format(
"https://smlnj.org/dist/working/%s/smlnj-%s.msi",
version,
version
);

core.debug("Downloading SML/NJ from: " + downloadUrl);

let downloadPath: string | null = null;
try {
downloadPath = await tc.downloadTool(downloadUrl);
} catch (error) {
core.debug(error);

throw `Failed to download version ${version}: ${error}`;
}

await exec.exec("msiexec", ["/qn", "/i", downloadPath]);
return new Promise((resolve, _) =>
resolve(path.join("C:", "Program Files (x86)", "SMLNJ"))
);
}

async function acquireNJLinux(version: string): Promise<string> {
// install required 32-bit support libraries
await exec.exec("sudo", ["apt-get", "update"]);
await exec.exec("sudo", [
"apt-get",
"install",
"-y",
"--no-install-recommends",
"gcc-multilib",
"lib32ncurses5",
"lib32z1"
]);

return acquireNJUnix(version);
}

async function acquireNJUnix(version: string): Promise<string> {
let downloadUrl: string = util.format(
"http://smlnj.cs.uchicago.edu/dist/working/%s/config.tgz",
version
Expand Down

0 comments on commit ddd7a60

Please sign in to comment.