Custom arguments and flags
This commit is contained in:
parent
942b3ce836
commit
e7025f44a0
12
readme.md
12
readme.md
|
@ -93,3 +93,15 @@ If you need to include a directory, do it like this:
|
|||
```
|
||||
include "(include)";
|
||||
```
|
||||
|
||||
If you need to pass an extra flag to the compiler, add this:
|
||||
|
||||
```
|
||||
flag "(flag)";
|
||||
```
|
||||
|
||||
If you need to add an extra argument of any type, do that like this:
|
||||
|
||||
```
|
||||
argument "(argument)";
|
||||
```
|
||||
|
|
22
src/main.cpp
22
src/main.cpp
|
@ -22,7 +22,7 @@ void log(string input) {
|
|||
cout << "\033[37mInfo: \033[39m" << input << endl;
|
||||
}
|
||||
|
||||
int compile(string compiler, string source, string binary, vector<string> libVector, vector<string> incVector, vector<string> libDirVector) {
|
||||
int compile(string compiler, string source, string binary, vector<string> libVector, vector<string> incVector, vector<string> libDirVector, vector<string> compilerFlags, vector<string> compilerArgs) {
|
||||
string libs;
|
||||
for (int i = 0; i < libVector.size(); i++) {
|
||||
libs += (" -l" + libVector[i]);
|
||||
|
@ -35,7 +35,15 @@ int compile(string compiler, string source, string binary, vector<string> libVec
|
|||
for (int i = 0; i < libDirVector.size(); i++) {
|
||||
libs += (" -I " + libDirVector[i]);
|
||||
}
|
||||
string cmd = compiler + libs + " " + source + " -o " + binary;
|
||||
string flags;
|
||||
for (int i = 0; i < compilerFlags.size(); i++) {
|
||||
flags += (" -" + compilerFlags[i]);
|
||||
}
|
||||
string args;
|
||||
for (int i = 0; i < compilerArgs.size(); i++) {
|
||||
args += compilerArgs[i];
|
||||
}
|
||||
string cmd = compiler + flags + libs + " " + source + " -o " + binary;
|
||||
log("Compiling with command " + cmd);
|
||||
return system(cmd.c_str());
|
||||
}
|
||||
|
@ -194,6 +202,8 @@ int main(int argc, char* argv[]) {
|
|||
vector<string> libraries;
|
||||
vector<string> includes;
|
||||
vector<string> libdirs;
|
||||
vector<string> arguments;
|
||||
vector<string> flags;
|
||||
|
||||
string editingTarget;
|
||||
|
||||
|
@ -202,7 +212,7 @@ int main(int argc, char* argv[]) {
|
|||
debug("Token is " + parsed[i][j]);
|
||||
if (j == 0) {
|
||||
if (parsed[i][j] == "compile") {
|
||||
compile(compiler, source, binary, libraries, includes, libdirs);
|
||||
compile(compiler, source, binary, libraries, includes, libdirs, flags, arguments);
|
||||
break;
|
||||
}
|
||||
editingTarget = parsed[i][j];
|
||||
|
@ -226,6 +236,12 @@ int main(int argc, char* argv[]) {
|
|||
} else if (editingTarget == "libdir") {
|
||||
debug("Adding library directory");
|
||||
libdirs.push_back(parsed[i][j]);
|
||||
} else if (editingTarget == "argument") {
|
||||
debug("Adding argument");
|
||||
arguments.push_back(parsed[i][j]);
|
||||
} else if (editingTarget == "flag") {
|
||||
debug("Adding flag");
|
||||
flags.push_back(parsed[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user