-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new target family presets to add-target command
- family.json is the database of presets - add-target help info describes the presets - `neon add-target` can take a present e.g. `neon add-target linux` - we won't yet change the `"targets"` section format but we'll get ready to in the future: * `neon tarball` in the future won't ever take a --target and create a temp dir, it'll require `--in-dir` * so for now let's add `neon rust-target` to do the node2rust conversion for a project, and we'll use that in neon-actions/build in a future iteration * to be ready for that, this repo will always use `--in-dir` instead of `--target` * in the next commit in this PR, let's make `neon add-target` create the template package directory for a target
- Loading branch information
David Herman
committed
Nov 22, 2023
1 parent
7f267f7
commit e98c206
Showing
15 changed files
with
427 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ jobs: | |
uses: neon-actions/[email protected] | ||
with: | ||
working-directory: ./pkgs/cargo-messages | ||
target: linux-x64-gnu | ||
input-directory: npm/linux-x64-gnu | ||
node-version: ${{ env.NODE_VERSION }} | ||
use-cross: false | ||
npm-publish: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,7 +65,7 @@ jobs: | |
uses: neon-actions/[email protected] | ||
with: | ||
working-directory: ./pkgs/cargo-messages | ||
target: ${{ matrix.target }} | ||
input-directory: npm/${{ matrix.target }} | ||
node-version: ${{ env.NODE_VERSION }} | ||
npm-publish: false | ||
github-release: ${{ needs.setup.outputs.action == 'publish' }} | ||
|
@@ -102,7 +102,7 @@ jobs: | |
uses: neon-actions/[email protected] | ||
with: | ||
working-directory: ./pkgs/cargo-messages | ||
target: ${{ matrix.target }} | ||
input-directory: npm/${{ matrix.target }} | ||
node-version: ${{ env.NODE_VERSION }} | ||
npm-publish: false | ||
github-release: ${{ needs.setup.outputs.action == 'publish' }} | ||
|
@@ -139,7 +139,7 @@ jobs: | |
uses: neon-actions/[email protected] | ||
with: | ||
working-directory: ./pkgs/cargo-messages | ||
target: ${{ matrix.target }} | ||
input-directory: npm/${{ matrix.target }} | ||
node-version: ${{ env.NODE_VERSION }} | ||
use-cross: true | ||
npm-publish: false | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"windows": { | ||
"win32-x64-msvc": "x86_64-pc-windows-msvc" | ||
}, | ||
"macos": { | ||
"darwin-x64": "x86_64-apple-darwin", | ||
"darwin-arm64": "aarch64-apple-darwin" | ||
}, | ||
"linux": { | ||
"linux-x64-gnu": "x86_64-unknown-linux-gnu", | ||
"linux-arm-gnueabihf": "armv7-unknown-linux-gnueabihf" | ||
}, | ||
"desktop": { | ||
"win32-x64-msvc": "x86_64-pc-windows-msvc", | ||
"darwin-x64": "x86_64-apple-darwin", | ||
"darwin-arm64": "aarch64-apple-darwin", | ||
"linux-x64-gnu": "x86_64-unknown-linux-gnu" | ||
}, | ||
"mobile": { | ||
"win32-arm64-msvc": "aarch64-pc-windows-msvc", | ||
"linux-arm-gnueabihf": "armv7-unknown-linux-gnueabihf", | ||
"android-arm-eabi": "armv7-linux-androideabi" | ||
}, | ||
"common": ["desktop"], | ||
"extended": ["desktop", "mobile"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import commandLineArgs from 'command-line-args'; | ||
import { Command, CommandDetail, CommandSection } from '../command.js'; | ||
import { isNodeTarget, NodeTarget } from '../target.js'; | ||
import { SourceManifest } from '../manifest.js'; | ||
|
||
const OPTIONS = [ | ||
{ name: 'platform', alias: 'p', type: String, defaultValue: null }, | ||
{ name: 'arch', alias: 'a', type: String, defaultValue: null }, | ||
{ name: 'abi', type: String, defaultValue: null }, | ||
{ name: 'verbose', alias: 'v', type: Boolean, defaultValue: false } | ||
]; | ||
|
||
export default class RustTarget implements Command { | ||
static summary(): string { return 'Look up the Rust target triple for a given build target.'; } | ||
static syntax(): string { return 'neon rust-target <target> | (-p <plat> -a <arch> [--abi <abi>])'; } | ||
static options(): CommandDetail[] { | ||
return [ | ||
{ name: '<target>', summary: 'Full target name in Node convention.' }, | ||
{ name: '-p, --platform <plat>', summary: 'Target platform name.' }, | ||
{ name: '-a, --arch <arch>', summary: 'Target architecture name.' }, | ||
{ name: '--abi <abi>', summary: 'Target ABI name. (Default: null)' }, | ||
{ name: '-v, --verbose', summary: 'Enable verbose logging. (Default: false)' } | ||
]; | ||
} | ||
static seeAlso(): CommandDetail[] | void { } | ||
static extraSection(): CommandSection | void { } | ||
|
||
private _platform: string | null; | ||
private _arch: string | null; | ||
private _abi: string | null; | ||
private _target: NodeTarget; | ||
private _verbose: boolean; | ||
|
||
constructor(argv: string[]) { | ||
const options = commandLineArgs(OPTIONS, { argv, partial: true }); | ||
|
||
this._platform = options.platform || null; | ||
this._arch = options.arch || null; | ||
this._abi = options.abi || null; | ||
this._verbose = !!options.verbose; | ||
|
||
if (options.platform && !options.arch) { | ||
throw new Error("Option --platform requires option --arch to be specified as well."); | ||
} | ||
|
||
if (!options.platform && options.arch) { | ||
throw new Error("Option --arch requires option --platform to be specified as well."); | ||
} | ||
|
||
if (options.abi && (!options.platform || !options.arch)) { | ||
throw new Error("Option --abi requires both options --platform and --arch to be specified as well."); | ||
} | ||
|
||
let target: string; | ||
|
||
if (!options.platform && !options.arch && !options.abi) { | ||
if (!options._unknown || options._unknown.length === 0) { | ||
throw new Error("No arguments found, expected <target> or -p and -a options."); | ||
} | ||
target = options._unknown[0]; | ||
} else { | ||
target = `${options.platform}-${options.arch}`; | ||
|
||
if (!!options.abi) { | ||
target = `${target}-${options.abi}`; | ||
} | ||
} | ||
|
||
if (!isNodeTarget(target)) { | ||
throw new Error(`${target} is not a valid Node target.`); | ||
} | ||
|
||
this._target = target; | ||
} | ||
|
||
log(msg: string) { | ||
if (this._verbose) { | ||
console.error("[neon rust-target] " + msg); | ||
} | ||
} | ||
|
||
async run() { | ||
this.log(`reading package.json`); | ||
const sourceManifest = await SourceManifest.load(); | ||
this.log(`manifest: ${sourceManifest.stringify()}`); | ||
|
||
const targets = sourceManifest.cfg().targets; | ||
const rust = targets[this._target]; | ||
if (!rust) { | ||
throw new Error(`no Rust target found for ${this._target}`); | ||
} | ||
console.log(rust); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.