Started work on pipelines by adding generator test case skeleton.

pull/15/head
Jussi Pakkanen 12 years ago
parent d200ad2e2e
commit 40012fad45
  1. 10
      environment.py
  2. 6
      meson.py
  3. 1
      test cases/30 pipeline/input_src.dat
  4. 3
      test cases/30 pipeline/meson.build
  5. 5
      test cases/30 pipeline/prog.c
  6. 33
      test cases/30 pipeline/srcgen.c

@ -228,6 +228,7 @@ header_suffixes = ['h', 'hh', 'hpp', 'hxx', 'H']
class Environment():
def __init__(self, source_dir, build_dir, main_script_file, options):
assert(main_script_file[0] == '/')
assert(not os.path.islink(main_script_file))
self.source_dir = source_dir
self.build_dir = build_dir
self.meson_script_file = main_script_file
@ -247,14 +248,7 @@ class Environment():
self.object_suffix = 'o'
def get_script_dir(self):
fullfile = self.meson_script_file
while os.path.islink(fullfile):
resolved = os.readlink(fullfile)
if resolved[0] != '/':
fullfile = os.path.join(os.path.dirname(fullfile), resolved)
else:
fullfile = resolved
return os.path.dirname(fullfile)
return os.path.dirname(self.meson_script_file)
def get_build_command(self):
return self.meson_script_file

@ -112,6 +112,12 @@ if __name__ == '__main__':
else:
dir2 = '.'
this_file = os.path.abspath(__file__)
while os.path.islink(this_file):
resolved = os.readlink(this_file)
if resolved[0] != '/':
this_file = os.path.join(os.path.dirname(this_file), resolved)
else:
this_file = resolved
app = MesonApp(dir1, dir2, this_file, options)
print ('Source dir: ' + app.source_dir)
print ('Build dir: ' + app.build_dir)

@ -0,0 +1 @@
int func() { return 0; }

@ -0,0 +1,3 @@
project('pipeline test', 'c')
e1 = executable('srcgen', 'srcgen.c')

@ -0,0 +1,5 @@
int func();
int main(int argc, char **argv) {
return func();
}

@ -0,0 +1,33 @@
#include<stdio.h>
#include<assert.h>
int main(int argc, char **argv) {
const int ARRSIZE = 80;
char arr[ARRSIZE];
if(argc != 3) {
fprintf(stderr, "%s <input file> <output file>\n", argv[0]);
return 1;
}
char *ifilename = argv[1];
char *ofilename = argv[2];
printf("%s\n", ifilename);
FILE *ifile = fopen(ifilename, "r");
if(!ifile) {
fprintf(stderr, "Could not open source file %s.\n", ifilename);
return 1;
}
FILE *ofile = fopen(ofilename, "w");
if(!ofile) {
fprintf(stderr, "Could not open target file %s\n", ofilename);
return 1;
}
size_t bytes;
bytes = fread(arr, 1, ARRSIZE, ifile);
assert(bytes < 80);
assert(bytes > 0);
fwrite(arr, 1, bytes, ofile);
fclose(ifile);
fclose(ofile);
return 0;
}
Loading…
Cancel
Save