2 scores.cc -- implement some globals
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include <sys/types.h>
24 #include "paper-def.hh"
27 #include "file-path.hh"
28 #include "file-results.hh"
29 #include "my-lily-parser.hh"
31 #include "lily-version.hh"
32 #include "scm-hash.hh"
34 Sources* source_global_l = 0;
35 Array<String> inclusion_global_array;
36 Array<String> target_str_global_array;
37 Link_array<Score> score_global_array;
38 Scheme_hash_table * global_header_p;
41 void write_dependency_file (String fn, Array<String> targets,
44 const int WRAPWIDTH = 65;
46 progress_indication (_f ("dependencies output to `%s'...", fn.ch_C ()));
47 progress_indication ("\n");
48 FILE * f = fopen (fn.ch_C (), "w");
50 warning (_f ("can't open file: `%s'", fn));
52 fprintf (f, "# Generated automatically by: %s\n", gnu_lilypond_version_str ().ch_C());
55 for (int i=0; i < targets.size (); i ++)
56 out += dependency_prefix_global + targets[i] + " ";
59 for (int i=0; i < deps.size (); i ++)
61 if (out.length_i () > WRAPWIDTH)
63 fprintf (f, "%s\\\n", out.ch_C());
67 if (!dependency_prefix_global.empty_b ())
70 if (stat (dep.ch_C (), &stat_buf) == -1 && errno == ENOENT)
73 if (dep.index_i ('/') < 0)
75 dep = dependency_prefix_global + dep;
79 fprintf (f, "%s\n", out.ch_C());
85 if (dependency_global_b)
87 Path p = split_path (output_name_global);
89 write_dependency_file (p.str (),
90 target_str_global_array,
91 inclusion_global_array);
100 global_header_p = new Scheme_hash_table;
101 for (int i=0; i < score_global_array.size (); i++)
103 Score* is_p = score_global_array[i];
105 if (is_p->errorlevel_i_)
107 is_p->warning (_ ("Score contains errors; will not process it"));
108 exit_status_global |= 1;
121 for (int i=0; i < score_global_array.size (); i++)
122 scm_gc_unprotect_object (score_global_array[i]->self_scm ());
123 score_global_array.clear ();
125 inclusion_global_array.clear ();
127 scm_gc_unprotect_object (global_header_p ->self_scm ());
133 do_one_file (String init_str, String file_str)
135 if (init_str.length_i () && global_path.find (init_str).empty_b ())
137 warning (_f ("can't find file: `%s'", init_str));
138 warning (_f ("(search path: `%s')", global_path.str ().ch_C ()));
141 if ((file_str != "-") && global_path.find (file_str).empty_b ())
143 warning (_f ("can't find file: `%s'", file_str));
148 source_global_l = &sources;
149 source_global_l->set_path (&global_path);
151 My_lily_parser parser (source_global_l);
152 parser.set_version_check (false);
153 progress_indication (_f ("Now processing: `%s'", file_str.ch_C ()));
154 progress_indication ("\n");
155 parser.parse_file (init_str, file_str);
157 if (parser.error_level_i_)
159 exit_status_global = 1;