-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,549 additions
and
1,655 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -638,11 +638,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
SOFTWARE. | ||
|
||
|
||
uuid | ||
unicorn-magic | ||
MIT | ||
The MIT License (MIT) | ||
MIT License | ||
|
||
Copyright (c) 2010-2020 Robert Kieffer and other contributors | ||
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
|
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,89 @@ | ||
import { execa } from 'execa' | ||
|
||
export interface CMakeVariable { | ||
name: string | ||
type?: string | ||
value: string | ||
} | ||
|
||
export interface CMakeGenerateOptions { | ||
buildPath?: string | ||
generator?: string | ||
variables?: CMakeVariable[] | ||
} | ||
|
||
export interface CMakeBuildOptions { | ||
config?: string | ||
preset?: string | ||
target?: string | ||
} | ||
|
||
export interface CMakeInstallOptions { | ||
config?: string | ||
prefix?: string | ||
} | ||
|
||
// https://cmake.org/cmake/help/latest/manual/cmake.1.html | ||
export class CMake { | ||
public async generate (sourcePath: string, options: CMakeGenerateOptions = {}): Promise<void> { | ||
const args = [sourcePath] | ||
|
||
if (options.buildPath !== undefined) { | ||
args.push('-B', options.buildPath) | ||
} | ||
|
||
if (options.generator !== undefined) { | ||
args.push('-G', options.generator) | ||
} | ||
|
||
if (options.variables !== undefined) { | ||
args.push(...this.variables(options.variables)) | ||
} | ||
|
||
await execa('cmake', args) | ||
} | ||
|
||
public async build (dir: string, options: CMakeBuildOptions = {}): Promise<void> { | ||
const args = ['--build', dir] | ||
|
||
if (options.config !== undefined) { | ||
args.push('--config', options.config) | ||
} | ||
|
||
if (options.preset !== undefined) { | ||
args.push('--preset', options.preset) | ||
} | ||
|
||
if (options.target !== undefined) { | ||
args.push('--target', options.target) | ||
} | ||
|
||
await execa('cmake', args) | ||
} | ||
|
||
public async install (dir: string, options: CMakeInstallOptions = {}): Promise<void> { | ||
const args = ['--install', dir] | ||
|
||
if (options.config !== undefined) { | ||
args.push('--config', options.config) | ||
} | ||
|
||
if (options.prefix !== undefined) { | ||
args.push('--prefix', options.prefix) | ||
} | ||
|
||
await execa('cmake', args) | ||
} | ||
|
||
private variables (variables: CMakeVariable[]): string[] { | ||
return variables.map((variable) => { | ||
if (variable.type !== undefined) { | ||
return ['-D', `${variable.name}:${variable.type}=${variable.value}`] | ||
} | ||
|
||
return ['-D', `${variable.name}=${variable.value}`] | ||
}).flat() | ||
} | ||
} | ||
|
||
export const cmake = new CMake() |
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,31 @@ | ||
import { execa } from 'execa' | ||
|
||
export interface GitCloneOptions { | ||
depth?: number | ||
directory?: string | ||
singleBranch?: boolean | ||
} | ||
|
||
export class Git { | ||
public async clone (repository: string, options: GitCloneOptions = {}): Promise<void> { | ||
const args = ['clone'] | ||
|
||
if (options.depth !== undefined) { | ||
args.push('--depth', options.depth.toString()) | ||
} | ||
|
||
if (options.singleBranch !== undefined) { | ||
args.push('--single-branch') | ||
} | ||
|
||
args.push(repository) | ||
|
||
if (options.directory !== undefined) { | ||
args.push(options.directory) | ||
} | ||
|
||
await execa('git', args) | ||
} | ||
} | ||
|
||
export const git = new Git() |
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