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>
21 #include "paper-def.hh"
24 #include "file-path.hh"
25 #include "file-results.hh"
26 #include "my-lily-parser.hh"
28 #include "lily-version.hh"
29 #include "scm-hash.hh"
31 Sources* source_global_l = 0;
32 Array<String> inclusion_global_array;
33 Array<String> target_str_global_array;
34 Link_array<Score> score_global_array;
35 Scheme_hash_table * global_header_p;
38 void write_dependency_file (String fn, Array<String> targets,
41 const int WRAPWIDTH = 65;
43 progress_indication (_f ("dependencies output to `%s'...", fn.ch_C ()));
44 progress_indication ("\n");
45 ofstream f (fn.ch_C ());
47 warning (_f ("can't open file: `%s'", fn));
49 f << "# Generated automatically by: " << gnu_lilypond_version_str () << '\n';
51 for (int i=0; i < targets.size (); i ++)
52 out += dependency_prefix_global + targets[i] + " ";
57 for (int i=0; i < deps.size (); i ++)
59 if (out.length_i () > WRAPWIDTH)
65 if (!dependency_prefix_global.empty_b ())
68 if (stat (dep.ch_C (), &stat_buf) == -1 && errno == ENOENT)
71 if (dep.index_i ('/') < 0)
73 dep = dependency_prefix_global + dep;
83 if (dependency_global_b)
85 Path p = split_path (output_name_global);
87 write_dependency_file (p.str (),
88 target_str_global_array,
89 inclusion_global_array);
98 global_header_p = new Scheme_hash_table;
99 for (int i=0; i < score_global_array.size (); i++)
101 Score* is_p = score_global_array[i];
103 if (is_p->errorlevel_i_)
105 is_p->warning (_ ("Score contains errors; will not process it"));
106 exit_status_global |= 1;
119 for (int i=0; i < score_global_array.size (); i++)
120 scm_gc_unprotect_object (score_global_array[i]->self_scm ());
121 score_global_array.clear ();
123 inclusion_global_array.clear ();
125 scm_gc_unprotect_object (global_header_p ->self_scm ());
131 do_one_file (String init_str, String file_str)
133 if (init_str.length_i () && global_path.find (init_str).empty_b ())
135 warning (_f ("can't find file: `%s'", init_str));
136 warning (_f ("(search path: `%s')", global_path.str ().ch_C ()));
139 if ((file_str != "-") && global_path.find (file_str).empty_b ())
141 warning (_f ("can't find file: `%s'", file_str));
146 source_global_l = &sources;
147 source_global_l->set_path (&global_path);
149 My_lily_parser parser (source_global_l);
150 parser.set_version_check (false);
151 progress_indication (_f ("Now processing: `%s'", file_str.ch_C ()));
152 progress_indication ("\n");
153 parser.parse_file (init_str, file_str);
155 if (parser.error_level_i_)
157 exit_status_global = 1;