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 = 0;
35 Array<String> inclusion_globals;
36 Array<String> target_string_globals;
37 Link_array<Score> score_globals;
38 Scheme_hash_table * global_header;
41 void write_dependency_file (String fn, Array<String> targets,
44 const int WRAPWIDTH = 65;
46 progress_indication (_f ("dependencies output to `%s'...", fn.to_str0 ()));
47 progress_indication ("\n");
48 FILE * f = fopen (fn.to_str0 (), "w");
50 warning (_f ("can't open file: `%s'", fn));
52 fprintf (f, "# Generated automatically by: %s\n", gnu_lilypond_version_string ().to_str0 ());
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 () > WRAPWIDTH)
63 fprintf (f, "%s\\\n", out.to_str0 ());
67 if (!dependency_prefix_global.empty_b ())
70 if (stat (dep.to_str0 (), &stat_buf) == -1 && errno == ENOENT)
73 if (dep.index ('/') < 0)
75 dep = dependency_prefix_global + dep;
79 fprintf (f, "%s\n", out.to_str0 ());
85 if (dependency_global_b)
87 Path p = split_path (output_name_global);
89 write_dependency_file (p.string (),
90 target_string_globals,
100 global_header = new Scheme_hash_table;
101 for (int i=0; i < score_globals.size (); i++)
103 Score* is = score_globals[i];
107 is->warning (_ ("Score contains errors; will not process it"));
108 exit_status_global |= 1;
121 for (int i=0; i < score_globals.size (); i++)
122 scm_gc_unprotect_object (score_globals[i]->self_scm ());
123 score_globals.clear ();
125 inclusion_globals.clear ();
127 scm_gc_unprotect_object (global_header ->self_scm ());
133 do_one_file (String init_string, String file_string)
135 if (init_string.length () && global_path.find (init_string).empty_b ())
137 warning (_f ("can't find file: `%s'", init_string));
138 warning (_f ("(search path: `%s')", global_path.string ().to_str0 ()));
141 if ((file_string != "-") && global_path.find (file_string).empty_b ())
143 warning (_f ("can't find file: `%s'", file_string));
148 source_global = &sources;
149 source_global->set_path (&global_path);
151 My_lily_parser parser (source_global);
152 parser.set_version_check (false);
153 progress_indication (_f ("Now processing: `%s'", file_string.to_str0 ()));
154 progress_indication ("\n");
155 parser.parse_file (init_string, file_string);
157 if (parser.error_level_)
159 exit_status_global = 1;