aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xenvironment.py12
-rwxr-xr-xmeson.py6
-rw-r--r--test cases/30 pipeline/input_src.dat1
-rw-r--r--test cases/30 pipeline/meson.build3
-rw-r--r--test cases/30 pipeline/prog.c5
-rw-r--r--test cases/30 pipeline/srcgen.c33
6 files changed, 51 insertions, 9 deletions
diff --git a/environment.py b/environment.py
index 86b015a..2a523c6 100755
--- a/environment.py
+++ b/environment.py
@@ -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
@@ -245,16 +246,9 @@ class Environment():
self.static_lib_suffix = 'a'
self.static_lib_prefix = 'lib'
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
diff --git a/meson.py b/meson.py
index 2d03d9d..6d6fb1d 100755
--- a/meson.py
+++ b/meson.py
@@ -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)
diff --git a/test cases/30 pipeline/input_src.dat b/test cases/30 pipeline/input_src.dat
new file mode 100644
index 0000000..7412372
--- /dev/null
+++ b/test cases/30 pipeline/input_src.dat
@@ -0,0 +1 @@
+int func() { return 0; }
diff --git a/test cases/30 pipeline/meson.build b/test cases/30 pipeline/meson.build
new file mode 100644
index 0000000..a12495e
--- /dev/null
+++ b/test cases/30 pipeline/meson.build
@@ -0,0 +1,3 @@
+project('pipeline test', 'c')
+
+e1 = executable('srcgen', 'srcgen.c')
diff --git a/test cases/30 pipeline/prog.c b/test cases/30 pipeline/prog.c
new file mode 100644
index 0000000..175a90d
--- /dev/null
+++ b/test cases/30 pipeline/prog.c
@@ -0,0 +1,5 @@
+int func();
+
+int main(int argc, char **argv) {
+ return func();
+}
diff --git a/test cases/30 pipeline/srcgen.c b/test cases/30 pipeline/srcgen.c
new file mode 100644
index 0000000..c4e412b
--- /dev/null
+++ b/test cases/30 pipeline/srcgen.c
@@ -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;
+}