-
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
1 parent
3610d17
commit e847e2c
Showing
4 changed files
with
128 additions
and
1 deletion.
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 |
---|---|---|
@@ -1 +1,22 @@ | ||
# GCC | ||
|
||
<br> | ||
|
||
<div align = center> | ||
|
||
# GCC | ||
|
||
***[Deno]*** *module for **[GCC]**.* | ||
|
||
<br> | ||
<br> | ||
|
||
|
||
</div> | ||
|
||
<br> | ||
|
||
|
||
<!-----------------------------------------------------------------------------> | ||
|
||
[Deno]: https://deno.land/ | ||
[GCC]: https://gcc.gnu.org/ |
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,20 @@ | ||
|
||
## GCC | ||
|
||
*Wrapper for the **[GCC]** command line interface.* | ||
|
||
<br> | ||
<br> | ||
|
||
```js | ||
import { version } from 'https://deno.land/x/gcc/mod.ts' | ||
|
||
console.log('GCC Version:',await version()); | ||
``` | ||
|
||
<br> | ||
|
||
|
||
<!-----------------------------------------------------------------------------> | ||
|
||
[GCC]: https://gcc.gnu.org/ |
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,57 @@ | ||
|
||
const { errors , run } = Deno; | ||
const { NotFound } = errors; | ||
|
||
|
||
export default async function ( options ){ | ||
|
||
const { | ||
workingDirectory = null , | ||
returnErrors = false , | ||
returnOutput = false , | ||
parameters = [] | ||
} = options; | ||
|
||
try { | ||
|
||
const config = { | ||
stdout : 'null' , | ||
stderr : 'null' , | ||
cwd : workingDirectory , | ||
cmd : [ 'gcc' , ... parameters ] | ||
} | ||
|
||
if(returnErrors) | ||
config.stderr = 'piped'; | ||
|
||
if(returnOutput) | ||
config.stdout = 'piped'; | ||
|
||
const process = await run(config); | ||
|
||
|
||
const { success , code } = await process.status(); | ||
|
||
if(!success) | ||
throw new Error(`GCC encountered a fatal error. Code: ${ code }`); | ||
|
||
const data = {} | ||
|
||
if(returnErrors) | ||
data.errors = new TextDecoder() | ||
.decode(await process.stderrOutput()); | ||
|
||
if(returnOutput) | ||
data.output = new TextDecoder() | ||
.decode(await process.output()); | ||
|
||
return data; | ||
|
||
} catch ( error ) { | ||
|
||
if(error instanceof NotFound) | ||
error = new NotFound('GCC executable is missing.'); | ||
|
||
throw error | ||
} | ||
} |
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,29 @@ | ||
|
||
import run from './Run.js' | ||
|
||
|
||
/** | ||
* @brief Return the gcc version string | ||
* which includes the system version. | ||
*/ | ||
|
||
export async function versionString (){ | ||
|
||
const { output } = await run ({ | ||
parameters : [ '--version' ] , | ||
returnOutput : true , | ||
}) | ||
|
||
return output.split('\n')[0]; | ||
} | ||
|
||
|
||
/** | ||
* @brief Return the gcc version. | ||
*/ | ||
|
||
export async function version (){ | ||
return (await versionString()) | ||
.split(' ') | ||
.pop(); | ||
} |