update interface
This commit is contained in:
parent
28624c15c0
commit
6245631894
@ -1,4 +1,4 @@
|
|||||||
export default abstract class Compiler{
|
export default interface Compiler{
|
||||||
abstract compilerPath:string;
|
compilerPath:string;
|
||||||
abstract compilerVersion:string;
|
compilerVersion:string;
|
||||||
}
|
}
|
@ -1,14 +1,11 @@
|
|||||||
import { execSync } from "child_process";
|
|
||||||
import getExecutablePathsFromEnv from "../Tools/GetExecutablePathsFromEnv";
|
import getExecutablePathsFromEnv from "../Tools/GetExecutablePathsFromEnv";
|
||||||
import getFilesFromPath from "../Tools/GetPathsFromEnv";
|
|
||||||
import tryGetCompilerVersion from "../Tools/TryGetCompilerVersion";
|
import tryGetCompilerVersion from "../Tools/TryGetCompilerVersion";
|
||||||
import Compiler from "./Compiler";
|
import Compiler from "./Compiler";
|
||||||
|
|
||||||
export default class GppCompiler extends Compiler{
|
export default class GppCompiler implements Compiler{
|
||||||
compilerPath: string;
|
compilerPath: string;
|
||||||
compilerVersion: string;
|
compilerVersion: string;
|
||||||
constructor(){
|
constructor(){
|
||||||
super()
|
|
||||||
const compilerPaths = getExecutablePathsFromEnv("g++")
|
const compilerPaths = getExecutablePathsFromEnv("g++")
|
||||||
if(compilerPaths.length==0)throw Error("cannot find g++ compiler")
|
if(compilerPaths.length==0)throw Error("cannot find g++ compiler")
|
||||||
this.compilerPath=`"${compilerPaths[0]}"`
|
this.compilerPath=`"${compilerPaths[0]}"`
|
||||||
|
21
src/Project/CppProject.ts
Normal file
21
src/Project/CppProject.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import GppCompiler from "../Compiler/GppCompiler";
|
||||||
|
import SourceFiles from "./interface/SourceFiles";
|
||||||
|
import Project from "./Project";
|
||||||
|
|
||||||
|
export default class CppProject implements Project , SourceFiles {
|
||||||
|
name: string;
|
||||||
|
compiler: GppCompiler;
|
||||||
|
sourceFiles: string[]=[];
|
||||||
|
|
||||||
|
constructor(name:string)
|
||||||
|
constructor(name:string,compiler:GppCompiler)
|
||||||
|
|
||||||
|
constructor(name:string,compiler?:GppCompiler){
|
||||||
|
if(compiler){
|
||||||
|
this.compiler=compiler
|
||||||
|
}else{
|
||||||
|
this.compiler=new GppCompiler()
|
||||||
|
}
|
||||||
|
this.name=name
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import Compiler from "../Compiler/Compiler"
|
import Compiler from "../Compiler/Compiler"
|
||||||
|
|
||||||
export default abstract class Project{
|
export default interface Project{
|
||||||
abstract name:string
|
name:string
|
||||||
abstract compiler:Compiler
|
compiler:Compiler
|
||||||
}
|
}
|
3
src/Project/interface/SourceFiles.ts
Normal file
3
src/Project/interface/SourceFiles.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export default interface SourceFiles{
|
||||||
|
sourceFiles:string[]
|
||||||
|
}
|
@ -6,7 +6,13 @@ const execPromise =util.promisify(exec);
|
|||||||
const tryGetCompilerVersion =(path:string,command:string):string=>{
|
const tryGetCompilerVersion =(path:string,command:string):string=>{
|
||||||
const exec_command = `${path} ${command}`
|
const exec_command = `${path} ${command}`
|
||||||
printDebug(exec_command)
|
printDebug(exec_command)
|
||||||
return execSync(exec_command).toString().trim()
|
let ret:string = ""
|
||||||
|
try{
|
||||||
|
ret = execSync(exec_command).toString().trim()
|
||||||
|
}catch(e){
|
||||||
|
throw Error("cannot get compiler version!")
|
||||||
|
}
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
export default tryGetCompilerVersion
|
export default tryGetCompilerVersion
|
@ -1,7 +1,9 @@
|
|||||||
|
import { execSync } from "child_process";
|
||||||
import GppCompiler from "../../src/Compiler/GppCompiler";
|
import GppCompiler from "../../src/Compiler/GppCompiler";
|
||||||
|
|
||||||
|
|
||||||
(global as any).isDebug=true;
|
(global as any).isDebug=true;
|
||||||
const a = new GppCompiler()
|
// const a = new GppCompiler()
|
||||||
console.log(a.compilerVersion)
|
// console.log(a.compilerVersion)
|
||||||
|
console.log(execSync("g++ -v").toLocaleString())
|
||||||
// console.log(execSync("g++ --version").toString().trim())
|
// console.log(execSync("g++ --version").toString().trim())
|
||||||
|
Loading…
Reference in New Issue
Block a user