comparison inst/import_ufl_LinearForm.m @ 231:e3f57f92fa66

Avoid just-in-time compilation when not needed * inst/private/check_hash.m: check whether the previous compilation used the same ufl file * inst/private/save_hash.m: save to disk ufl file's md5sum for future comparison * inst/private/check_oct_files.m: ensure the expected oct files are present * inst/import_ufl_*.m: add checks using the logic above
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Sat, 14 Jun 2014 15:27:43 +0200
parents 0de6ca5e31a2
children 072aee55bb75
comparison
equal deleted inserted replaced
230:1a3674836579 231:e3f57f92fa66
31 error ("import_ufl_LinearForm: wrong number of input parameters."); 31 error ("import_ufl_LinearForm: wrong number of input parameters.");
32 elseif ! ischar (var_prob) 32 elseif ! ischar (var_prob)
33 error ("import_ufl_LinearForm: first argument is not a valid string"); 33 error ("import_ufl_LinearForm: first argument is not a valid string");
34 endif 34 endif
35 35
36 n = length (mfilename ("fullpath")) - length (mfilename()); 36 if (check_hash (var_prob) || ! check_oct_files (var_prob, "LinearForm"))
37 path = strtrunc(mfilename ("fullpath"), n); 37 n = length (mfilename ("fullpath")) - length (mfilename());
38 path = strtrunc(mfilename ("fullpath"), n);
38 39
39 private = fullfile (path, "include/"); 40 private = fullfile (path, "include/");
40 41
41 output = generate_lhs (var_prob); 42 output = generate_lhs (var_prob);
42 output += generate_makefile (var_prob, private); 43 output += generate_makefile (var_prob, private);
43 if output != 0
44 error ("Compilation failed");
45 else
46 [output, textfile] = system (sprintf ("make -f Makefile_%s lhs", var_prob));
47 if output != 0 44 if output != 0
48 display (text);
49 error ("Compilation failed"); 45 error ("Compilation failed");
50 endif 46 else
51 [output, textfile] = system (sprintf ("make -f Makefile_%s clean", var_prob)); 47 [output, textfile] = system (sprintf ("make -f Makefile_%s lhs", var_prob));
52 if output != 0 48 if output != 0
53 display (text); 49 display (text);
54 error ("Compilation failed"); 50 error ("Compilation failed");
51 endif
52 [output, textfile] = system (sprintf ("make -f Makefile_%s clean", var_prob));
53 if output != 0
54 display (text);
55 error ("Compilation failed");
56 endif
57 save_hash (var_prob);
55 endif 58 endif
56 endif 59 endif
57
58 endfunction 60 endfunction