Merge pull request #232 from aminya/macos

This commit is contained in:
Amin Yahyaabadi 2024-02-18 23:43:15 -08:00 committed by GitHub
commit 41a235324f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
41 changed files with 1014 additions and 731 deletions

View File

@ -146,6 +146,7 @@ jobs:
- windows-2019 - windows-2019
- ubuntu-22.04 - ubuntu-22.04
- ubuntu-20.04 - ubuntu-20.04
- macos-13
- macos-12 - macos-12
- macos-11 - macos-11
node: node:

View File

@ -8,7 +8,7 @@ Setting up a **cross-platform** environment for building and testing C++/C proje
`setup-cpp` can be used locally from terminal, from CI services like GitHub Actions and GitLab Pipelines, and inside containers like Docker. `setup-cpp` can be used locally from terminal, from CI services like GitHub Actions and GitLab Pipelines, and inside containers like Docker.
`setup-cpp` is supported on many platforms. It is continuously tested on several configurations including Windows (11, 10, 2022, 2019), Linux (Ubuntu 22.04, Ubuntu 20.04, Fedora, ArchLinux), and macOS (12, 11, 10.15). `setup-cpp` is backed by unit tests for each tool and integration tests for compiling cpp projects. `setup-cpp` is supported on many platforms. It is continuously tested on several configurations including Windows (11, 10, 2022, 2019), Linux (Ubuntu 22.04, Ubuntu 20.04, Fedora, ArchLinux), and macOS (13, 12, 11, 10.15). `setup-cpp` is backed by unit tests for each tool and integration tests for compiling cpp projects.
## Features ## Features

View File

@ -90,7 +90,7 @@ inputs:
required: false required: false
runs: runs:
using: "node16" using: "node20"
main: "dist/actions/setup-cpp.js" main: "dist/actions/setup-cpp.js"
branding: branding:

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/actions/hdi.89f0ed6f.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/actions/hdi.89f0ed6f.js.map vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/legacy/hdi.069dd8f5.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/legacy/hdi.069dd8f5.js.map vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/modern/hdi.9d60a332.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/modern/hdi.9d60a332.js.map vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -31,7 +31,7 @@
"build": "run-s clean build.packages && run-p lint.tsc build.parcel copy.matchers", "build": "run-s clean build.packages && run-p lint.tsc build.parcel copy.matchers",
"build.packages": "pnpm run -r build", "build.packages": "pnpm run -r build",
"build.parcel": "cross-env NODE_ENV=production parcel build && babel ./dist --out-dir dist --plugins @upleveled/babel-plugin-remove-node-prefix --compact --no-babelrc --source-maps true", "build.parcel": "cross-env NODE_ENV=production parcel build && babel ./dist --out-dir dist --plugins @upleveled/babel-plugin-remove-node-prefix --compact --no-babelrc --source-maps true",
"bump": "ncu -u -x numerous,execa,prettier && pnpm update", "bump": "ncu -u -x numerous,execa,prettier,@types/node && pnpm update",
"clean": "shx rm -rf ./dist ./exe ./packages/*/dist/ && shx mkdir -p ./dist/legacy ./dist/actions ./dist/modern ", "clean": "shx rm -rf ./dist ./exe ./packages/*/dist/ && shx mkdir -p ./dist/legacy ./dist/actions ./dist/modern ",
"copy.matchers": "run-p copy.matchers.legacy copy.matchers.actions copy.matchers.modern", "copy.matchers": "run-p copy.matchers.legacy copy.matchers.actions copy.matchers.modern",
"copy.matchers.legacy": "shx cp ./src/gcc/gcc_matcher.json ./dist/legacy/ && shx cp ./src/msvc/msvc_matcher.json ./dist/legacy/ && shx cp ./src/python/python_matcher.json ./dist/legacy/ && shx cp ./src/llvm/llvm_matcher.json ./dist/legacy/", "copy.matchers.legacy": "shx cp ./src/gcc/gcc_matcher.json ./dist/legacy/ && shx cp ./src/msvc/msvc_matcher.json ./dist/legacy/ && shx cp ./src/python/python_matcher.json ./dist/legacy/ && shx cp ./src/llvm/llvm_matcher.json ./dist/legacy/",
@ -75,15 +75,16 @@
"@actions/exec": "^1.1.1", "@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3", "@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1", "@actions/tool-cache": "^2.0.1",
"@babel/cli": "^7.23.4", "@babel/cli": "^7.23.9",
"@swc/jest": "^0.2.31", "@shockpkg/archive-files": "https://github.com/aminya/archive-files#54ec59fad46aca736ac6feb6c7bb526528141b9d",
"@swc/jest": "^0.2.36",
"@types/cross-spawn": "^6.0.6", "@types/cross-spawn": "^6.0.6",
"@types/eslint": "^8.56.2", "@types/eslint": "^8.56.2",
"@types/jest": "^29.5.11", "@types/jest": "^29.5.12",
"@types/mri": "^1.1.5", "@types/mri": "^1.1.5",
"@types/node": "^20.11.5", "@types/node": "^12",
"@types/prettier": "2.7.3", "@types/prettier": "2.7.3",
"@types/semver": "^7.5.6", "@types/semver": "^7.5.7",
"@types/which": "^3.0.3", "@types/which": "^3.0.3",
"@upleveled/babel-plugin-remove-node-prefix": "github:aminya/babel-plugin-remove-node-prefix#95fcbd92405b99a6eece48c493548996f12e6519", "@upleveled/babel-plugin-remove-node-prefix": "github:aminya/babel-plugin-remove-node-prefix#95fcbd92405b99a6eece48c493548996f12e6519",
"admina": "^1.0.1", "admina": "^1.0.1",
@ -102,12 +103,13 @@
"execa": "^7.2.0", "execa": "^7.2.0",
"is-url-online": "^1.5.0", "is-url-online": "^1.5.0",
"jest": "^29.7.0", "jest": "^29.7.0",
"macos-release": "^3.2.0",
"micro-memoize": "^4.1.2", "micro-memoize": "^4.1.2",
"mkdirp": "^3.0.1", "mkdirp": "^3.0.1",
"mri": "^1.2.0", "mri": "^1.2.0",
"msvc-dev-cmd": "github:aminya/msvc-dev-cmd#97843d525947e3f3776ee359b597316909754c4d", "msvc-dev-cmd": "github:aminya/msvc-dev-cmd#97843d525947e3f3776ee359b597316909754c4d",
"npm-check-updates": "^16.14.12", "npm-check-updates": "^16.14.15",
"npm-run-all2": "^6.1.1", "npm-run-all2": "^6.1.2",
"numerous": "1.0.3", "numerous": "1.0.3",
"p-timeout": "^6.1.2", "p-timeout": "^6.1.2",
"parcel": "2.11.0", "parcel": "2.11.0",
@ -117,7 +119,7 @@
"prettier-config-atomic": "^4.0.0", "prettier-config-atomic": "^4.0.0",
"readme-md-generator": "^1.0.0", "readme-md-generator": "^1.0.0",
"retry-as-promised": "^7.0.4", "retry-as-promised": "^7.0.4",
"semver": "7.5.4", "semver": "7.6.0",
"setup-python": "github:aminya/setup-python#a783db655c6e40317e2c0c96f9d162d9c9f4a751", "setup-python": "github:aminya/setup-python#a783db655c6e40317e2c0c96f9d162d9c9f4a751",
"shx": "0.3.4", "shx": "0.3.4",
"simple-update-notifier": "^2.0.0", "simple-update-notifier": "^2.0.0",
@ -184,12 +186,8 @@
"electron": false, "electron": false,
"patha": "patha/dist/index.node.mjs", "patha": "patha/dist/index.node.mjs",
"admina": "admina/dist/index.mjs", "admina": "admina/dist/index.mjs",
"fs/promises": "./src/utils/compat/fs/promises.ts" "fs/promises": "./src/utils/compat/fs/promises.ts",
}, "stream/promises": "./src/utils/compat/stream/promises.ts"
"pnpm": {
"overrides": {
"@actions/http-client": "2.1.0"
}
}, },
"targets": { "targets": {
"main": { "main": {
@ -206,7 +204,7 @@
"actions": { "actions": {
"context": "node", "context": "node",
"engines": { "engines": {
"node": ">=16.x" "node": ">=20.x"
}, },
"includeNodeModules": { "includeNodeModules": {
"update-notifier": false "update-notifier": false

File diff suppressed because it is too large Load Diff

View File

@ -4,9 +4,15 @@ import { InstallationInfo } from "../../utils/setup/setupBin"
import { getVersion } from "../../versions/versions" import { getVersion } from "../../versions/versions"
import which from "which" import which from "which"
import { ubuntuVersion } from "../../utils/env/ubuntu_version" import { ubuntuVersion } from "../../utils/env/ubuntu_version"
import { macosVersion } from "../../utils/env/macos_version"
jest.setTimeout(300000) jest.setTimeout(300000)
describe("setup-doxygen", () => { describe("setup-doxygen", () => {
if (process.platform === "darwin" && macosVersion()[0] <= 11) {
test.skip("Skipping doxygen test on macOS 11 or earlier", () => {})
return
}
let directory: string let directory: string
beforeAll(async () => { beforeAll(async () => {
directory = await setupTmpDir("doxygen") directory = await setupTmpDir("doxygen")

View File

@ -17,6 +17,8 @@ import { isUbuntu } from "../utils/env/isUbuntu"
import { pathExists } from "path-exists" import { pathExists } from "path-exists"
import retry from "retry-as-promised" import retry from "retry-as-promised"
import { ubuntuVersion } from "../utils/env/ubuntu_version" import { ubuntuVersion } from "../utils/env/ubuntu_version"
import { macosVersion } from "../utils/env/macos_version"
import { setupDmg } from "../utils/setup/setupDmg"
/** Get the platform data for cmake */ /** Get the platform data for cmake */
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
@ -42,6 +44,16 @@ function getDoxygenPackageInfo(version: string, platform: NodeJS.Platform, _arch
url: `https://www.doxygen.nl/files/${folderName}.windows.x64.bin.zip`, url: `https://www.doxygen.nl/files/${folderName}.windows.x64.bin.zip`,
} }
} }
case "darwin": {
const folderName = `Doxygen-${version}`
return {
binRelativeDir: "Doxygen/Doxygen.app/Contents/Resources/",
binFileName: addExeExt("doxygen"),
extractedFolderName: folderName,
extractFunction: setupDmg,
url: `https://doxygen.nl/files/${folderName}.dmg`,
}
}
default: default:
throw new Error(`Unsupported platform '${platform}'`) throw new Error(`Unsupported platform '${platform}'`)
} }
@ -63,8 +75,17 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
return installationInfo return installationInfo
} }
case "darwin": { case "darwin": {
// let installationInfo: InstallationInfo
// try {
// installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
// } catch {
const installationInfo = await setupBrewPack("doxygen", undefined) const installationInfo = await setupBrewPack("doxygen", undefined)
await setupGraphviz(getVersion("graphviz", undefined), "", arch) // }
// only install graphviz if the macOS version is greater than 11
if (macosVersion()[0] > 11) {
await setupGraphviz(getVersion("graphviz", undefined), "", arch)
}
return installationInfo return installationInfo
} }
case "linux": { case "linux": {
@ -83,7 +104,11 @@ export async function setupDoxygen(version: string, setupDir: string, arch: stri
try { try {
// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself // doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch) installationInfo = await setupBin("doxygen", version, getDoxygenPackageInfo, setupDir, arch)
await setupAptPack([{ name: "libclang-cpp9" }]) try {
await setupAptPack([{ name: "libclang-cpp9" }])
} catch (err) {
info(`Failed to download libclang-cpp9 that might be needed for running doxygen. ${err}`)
}
} catch (err) { } catch (err) {
notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`) notice(`Failed to download doxygen binary. ${err}. Falling back to apt-get.`)
installationInfo = await setupAptPack([{ name: "doxygen" }]) installationInfo = await setupAptPack([{ name: "doxygen" }])

View File

@ -3,9 +3,15 @@ import { cleanupTmpDir, setupTmpDir, testBin } from "../../utils/tests/test-help
import { InstallationInfo } from "../../utils/setup/setupBin" import { InstallationInfo } from "../../utils/setup/setupBin"
import { getVersion } from "../../versions/versions" import { getVersion } from "../../versions/versions"
import { ubuntuVersion } from "../../utils/env/ubuntu_version" import { ubuntuVersion } from "../../utils/env/ubuntu_version"
import { macosVersion } from "../../utils/env/macos_version"
jest.setTimeout(300000) jest.setTimeout(300000)
describe("setup-graphviz", () => { describe("setup-graphviz", () => {
if (process.platform === "darwin" && macosVersion()[0] <= 11) {
test.skip("Skipping graphviz test on macOS 11 or earlier", () => {})
return
}
let directory: string let directory: string
beforeAll(async () => { beforeAll(async () => {
directory = await setupTmpDir("graphviz") directory = await setupTmpDir("graphviz")

View File

@ -1,5 +1,5 @@
import { promises } from "fs" import * as fs from "fs"
export default promises export default fs.promises
export const { export const {
access, access,
@ -26,4 +26,14 @@ export const {
unlink, unlink,
utimes, utimes,
writeFile, writeFile,
} = promises } = fs.promises
import { promisify } from "util"
export const rm =
"rm" in fs.promises
? (
fs.promises as typeof fs.promises & {
rm: (path: string, options?: fs.RmDirOptions) => Promise<void>
}
).rm
: promisify(fs.unlink)

View File

@ -0,0 +1,15 @@
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as stream from "stream"
import { promisify } from "util"
export const pipeline =
"promises" in stream && "pipeline" in (stream as any).promises
? ((stream.promises as any).pipeline as Function)
: promisify(stream.pipeline)
export const finished =
"promises" in stream && "finished" in (stream as any).promises
? ((stream.promises as any).finished as Function)
: promisify(stream.finished)

17
src/utils/env/macos_version.ts vendored Normal file
View File

@ -0,0 +1,17 @@
import macosRelease from "macos-release"
import memoize from "micro-memoize"
/**
* Get macOS version
*
* @returns {number[]} - The macOS version as an array of numbers
*/
function macosVersion_raw() {
if (process.platform !== "darwin") {
return []
}
const { version } = macosRelease()
return version.split(".").map((v) => parseInt(v, 10))
}
export const macosVersion = memoize(macosVersion_raw)

View File

@ -38,6 +38,10 @@ export const ubuntuVersion = memoize(ubuntuVersion_raw, { isPromise: true })
/** Detect Ubuntu version using os.version() for Ubuntu based distros */ /** Detect Ubuntu version using os.version() for Ubuntu based distros */
function detectUsingOsVersion() { function detectUsingOsVersion() {
if (!("version" in os && typeof os.version === "function")) {
return null
}
// #46~22.04.1-Ubuntu SMP ... // #46~22.04.1-Ubuntu SMP ...
const osVersion = os.version() const osVersion = os.version()
const versionSplitted = osVersion.split(".") const versionSplitted = osVersion.split(".")

3
src/utils/setup/archive-files.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
declare module "@shockpkg/archive-files/esm/archive/hdi.mjs" {
export { ArchiveHdi } from "@shockpkg/archive-files/dts/archive/hdi.d.ts"
}

View File

@ -235,6 +235,9 @@ export async function isPackageInstalled(regexp: string) {
try { try {
// check if a package matching the regexp is installed // check if a package matching the regexp is installed
const { stdout } = await execa("dpkg", ["-l", regexp]) const { stdout } = await execa("dpkg", ["-l", regexp])
if (typeof stdout !== "string") {
return false
}
const lines = stdout.split("\n") const lines = stdout.split("\n")
// check if the output contains any lines that start with "ii" // check if the output contains any lines that start with "ii"
return lines.some((line) => line.startsWith("ii")) return lines.some((line) => line.startsWith("ii"))

View File

@ -26,7 +26,7 @@ export type PackageInfo = {
binFileName: string binFileName: string
/** The function to extract the downloaded archive. It can be `undefined`, if the binary itself is downloaded directly. */ /** The function to extract the downloaded archive. It can be `undefined`, if the binary itself is downloaded directly. */
extractFunction?: { extractFunction?: {
(file: string, dest: string): Promise<string> | Promise<void> (file: string, dest: string): Promise<unknown>
} }
} }

View File

@ -0,0 +1,10 @@
import { join } from "path"
export async function setupDmg(path: string, destDir: string) {
const { ArchiveHdi } = await import("@shockpkg/archive-files/esm/archive/hdi.mjs")
const dmg = new ArchiveHdi(path)
await dmg.read(async (entry) => {
await entry.extract(join(destDir, entry.path))
})
}

View File

@ -17,7 +17,8 @@
"preserveSymlinks": true, "preserveSymlinks": true,
"removeComments": false, "removeComments": false,
"skipLibCheck": true, "skipLibCheck": true,
"lib": ["ES2020", "dom"], // target Node.js 12 https://node.green/#ES2019
"lib": ["ES2019", "dom"],
"target": "ESNext", "target": "ESNext",
"allowJs": true, "allowJs": true,
"esModuleInterop": true, "esModuleInterop": true,