parent
5f44748ddd
commit
16fa657304
7 changed files with 80 additions and 12 deletions
@ -0,0 +1 @@ |
||||
generated_function |
@ -0,0 +1,5 @@ |
||||
#include"data.h" |
||||
|
||||
int main(int, char **) { |
||||
return generated_function() != 52; |
||||
} |
@ -0,0 +1,16 @@ |
||||
project('selfbuilt custom', 'cpp') |
||||
|
||||
# Build an exe and use it in a custom target |
||||
# whose output is used to build a different exe. |
||||
|
||||
tool = executable('tool', 'tool.cpp') |
||||
|
||||
hfile = custom_target('datah', |
||||
output : 'data.h', |
||||
input : 'data.dat', |
||||
command : [tool, '@INPUT@', '@OUTPUT@'], |
||||
) |
||||
|
||||
main = executable('mainprog', 'mainprog.cpp', hfile) |
||||
|
||||
test('maintest', main) |
@ -0,0 +1,34 @@ |
||||
#include<iostream> |
||||
#include<fstream> |
||||
#include<string> |
||||
|
||||
using namespace std; |
||||
|
||||
const char prefix[] = "int "; |
||||
const char suffix[] = " () {\n return 52;}\n"; |
||||
|
||||
int main(int argc, char **argv) { |
||||
if(argc != 3) { |
||||
cout << "You is fail.\n"; |
||||
return 1; |
||||
} |
||||
ifstream is(argv[1], ifstream::binary); |
||||
if(!is) { |
||||
cout << "Opening input file failed.\n"; |
||||
return 1; |
||||
} |
||||
string funcname; |
||||
is >> funcname; |
||||
ofstream os(argv[2], ofstream::binary); |
||||
if(!os) { |
||||
cout << "Opening output file failed.\n"; |
||||
return 1; |
||||
} |
||||
os << prefix << funcname << suffix; |
||||
os.close(); |
||||
if(!os.good()) { |
||||
cout << "Writing data out failed.\n"; |
||||
return 1; |
||||
} |
||||
return 0; |
||||
} |
Loading…
Reference in new issue