@@ -41,6 +41,9 @@ void printHelp()
41
41
std::cout << " Set the input file to be compiled" << std::endl;
42
42
std::cout << " \t codeGGcompiler --in=<path>" << std::endl << std::endl;
43
43
44
+ std::cout << " Set the output file (default is the input path+.cg)" << std::endl;
45
+ std::cout << " \t codeGGcompiler --out=<path>" << std::endl << std::endl;
46
+
44
47
std::cout << " Print the version (and do nothing else)" << std::endl;
45
48
std::cout << " \t codeGGcompiler --version" << std::endl << std::endl;
46
49
@@ -63,6 +66,7 @@ int main(int argc, char **argv)
63
66
}
64
67
65
68
std::string fileInPath;
69
+ std::string fileOutPath;
66
70
67
71
std::vector<std::string> commands (argv, argv + argc);
68
72
@@ -103,6 +107,11 @@ int main(int argc, char **argv)
103
107
fileInPath = splitedCommand[1 ];
104
108
continue ;
105
109
}
110
+ if ( splitedCommand[0 ] == " --out" )
111
+ {
112
+ fileOutPath = splitedCommand[1 ];
113
+ continue ;
114
+ }
106
115
}
107
116
108
117
// Unknown command
@@ -115,6 +124,10 @@ int main(int argc, char **argv)
115
124
std::cout << " No input file !" << std::endl;
116
125
return -1 ;
117
126
}
127
+ if ( fileOutPath.empty () )
128
+ {
129
+ fileOutPath = fileInPath+" .cg" ;
130
+ }
118
131
119
132
// /Opening files
120
133
std::ifstream fileIn ( fileInPath );
@@ -124,10 +137,10 @@ int main(int argc, char **argv)
124
137
return -1 ;
125
138
}
126
139
127
- std::ofstream fileOutBinary ( fileInPath+ " .cg " , std::ios::binary | std::ios::trunc );
140
+ std::ofstream fileOutBinary ( fileOutPath , std::ios::binary | std::ios::trunc );
128
141
if ( !fileOutBinary )
129
142
{
130
- std::cout << " Can't write the file \" " << fileInPath <<" .cg\" " << std::endl;
143
+ std::cout << " Can't write the file \" " << fileOutPath <<" .cg\" " << std::endl;
131
144
return -1 ;
132
145
}
133
146
std::ofstream fileOutReadable ( fileInPath+" .rcg" , std::ios::trunc );
@@ -138,6 +151,7 @@ int main(int argc, char **argv)
138
151
}
139
152
140
153
std::cout << " Input file : \" " << fileInPath <<" \" " << std::endl;
154
+ std::cout << " Output file : \" " << fileOutPath <<" \" " << std::endl;
141
155
142
156
// /Creating default pool
143
157
codeg::Pool defaultPool (" global" );
0 commit comments