Skip to content

Commit

Permalink
Use osx-universal ldc2 builds on macOS (#59)
Browse files Browse the repository at this point in the history
Co-authored-by: WebFreak001 <[email protected]>
  • Loading branch information
LunaTheFoxgirl and WebFreak001 authored Oct 15, 2022
1 parent 69ee273 commit 43589c2
Show file tree
Hide file tree
Showing 7 changed files with 363 additions and 33 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

244 changes: 239 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"typed-rest-client": "^1.8.4"
},
"devDependencies": {
"@types/node": "^14.17.3",
"@types/node": "^14.18.28",
"@vercel/ncc": "^0.27.0",
"typescript": "^4.3.2"
}
Expand Down
76 changes: 56 additions & 20 deletions src/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as tc from '@actions/tool-cache';
import { cmpSemver, parseSimpleSemver } from './semver';
import { body_as_text } from './utils';

export interface CompilerDescription {
name: string;
version: string;
url: string;
binpath: string;
libpath : string[];
libpath: string[];
sig?: string;
dub?: DubDescription;
}
Expand Down Expand Up @@ -179,7 +180,7 @@ async function ldc_resolve_master(gh_token: string): Promise<CompilerDescription
switch (process.platform) {
case "win32": suffix = 'windows-multilib'; ext = '7z'; break;
case "linux": suffix = 'linux-x86_64'; ext = 'tar.xz'; break;
case "darwin": suffix = 'osx-x86_64'; ext = 'tar.xz'; break;
case "darwin": suffix = 'osx-universal'; ext = 'tar.xz'; break;
default:
throw new Error("unsupported platform: " + process.platform);
}
Expand Down Expand Up @@ -221,15 +222,25 @@ async function ldc_resolve_master(gh_token: string): Promise<CompilerDescription
});

const latest = assets[0];

const base_path = (process.platform == "win32") ?
`\\ldc2-${latest.version}-${suffix}\\` :
`/ldc2-${latest.version}-${suffix}/`;
let libpath: string[] = [];
switch (process.platform) {
case "win32": libpath = [`${base_path}lib64`]; break;
case "linux": libpath = [`${base_path}lib`, `${base_path}lib64`]; break;
case "darwin": libpath = [`${base_path}lib-arm64`, `${base_path}lib-x86_64`]; break;
default:
throw new Error("unsupported platform: " + process.platform);
}

return {
name: "ldc2",
version: latest.version,
url: "https://github.com/ldc-developers/ldc/releases/download/CI/" + latest.name,
binpath: `${base_path}bin`,
libpath: [ `${base_path}lib64` ]
libpath: libpath
};
}

Expand All @@ -256,25 +267,50 @@ async function ldc(version: string, dub_vers: string, gh_token: string): Promise
version: version,
url: `${base_url}-windows-multilib.7z`,
binpath: `\\ldc2-${version}-windows-multilib\\bin`,
libpath: [ `\\ldc2-${version}-windows-multilib\\lib64` ],
dub: await dub(dub_vers, gh_token, false)
};
case "linux": return {
name: "ldc2",
version: version,
url: `${base_url}-linux-x86_64.tar.xz`,
binpath: `/ldc2-${version}-linux-x86_64/bin`,
libpath: [ `/ldc2-${version}-linux-x86_64/lib64` ],
dub: await dub(dub_vers, gh_token, false)
};
case "darwin": return {
name: "ldc2",
version: version,
url: `${base_url}-osx-x86_64.tar.xz`,
binpath: `/ldc2-${version}-osx-x86_64/bin`,
libpath: [ `/ldc2-${version}-osx-x86_64/lib64` ],
libpath: [`\\ldc2-${version}-windows-multilib\\lib64`],
dub: await dub(dub_vers, gh_token, false)
};
case "linux":
var arch: string = "";
switch (process.arch) {
case "ia32": arch = "x86"; break; // supported on very old LDC releases
case "x64": arch = "x86_64"; break;
case "arm": arch = "armhf"; break; // supported on old LDC releases
case "arm64": arch = "aarch64"; break;
}
return {
name: "ldc2",
version: version,
url: `${base_url}-linux-${arch}.tar.xz`,
binpath: `/ldc2-${version}-linux-${arch}/bin`,
libpath: [`/ldc2-${version}-linux-${arch}/lib`, `/ldc2-${version}-linux-${arch}/lib64`],
dub: await dub(dub_vers, gh_token, false)
};
case "darwin":
var arch: string = "";
switch (process.arch) {
case "ia32":
case "x64": arch = "x86_64"; break;
case "arm":
case "arm64": arch = "aarch64"; break;
}
return cmpSemver(parseSimpleSemver(version),
[1, 30, 0, ["beta1"]]) >= 0 ?
{
name: "ldc2",
version: version,
url: `${base_url}-osx-universal.tar.xz`,
binpath: `/ldc2-${version}-osx-universal/bin`,
libpath: [`/ldc2-${version}-osx-universal/lib-arm64`, `/ldc2-${version}-osx-universal/lib-x86_64`],
dub: await dub(dub_vers, gh_token, false)
} : {
name: "ldc2",
version: version,
url: `${base_url}-osx-${arch}.tar.xz`,
binpath: `/ldc2-${version}-osx-${arch}/bin`,
libpath: [`/ldc2-${version}-osx-${arch}/lib-arm64`, `/ldc2-${version}-osx-${arch}/lib`],
dub: await dub(dub_vers, gh_token, false)
};
default:
throw new Error("unsupported platform: " + process.platform);
}
Expand Down
Loading

0 comments on commit 43589c2

Please sign in to comment.