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 "input-file-results.hh"
29 #include "my-lily-parser.hh"
31 #include "lily-version.hh"
32 #include "scm-hash.hh"
33 #include "ly-modules.hh"
36 LY_DEFINE(ly_set_point_and_click_x, "ly:set-point-and-click!", 1, 0, 0,
38 "Set the options for Point-and-click source specials output. The
39 argument is a symbol. Possible options are @code{none} (no source specials),
40 @code{line} and @code{line-column}")
46 if (ly_symbol2scm ("line-column") == what)
47 val = gh_eval_str ("line-column-location");
48 else if (what == ly_symbol2scm ("line"))
49 val = gh_eval_str ("line-location");
51 extern SCM lily_module;
52 scm_module_define (lily_module, ly_symbol2scm ("point-and-click"), val);
54 store_locations_global_b =gh_procedure_p (val);
55 return SCM_UNSPECIFIED;
59 write_dependency_file (String fn,
60 Array<String> targets,
63 const int WRAPWIDTH = 65;
65 progress_indication (_f ("dependencies output to `%s'...", fn.to_str0 ()));
66 progress_indication ("\n");
67 FILE * f = fopen (fn.to_str0 (), "w");
69 warning (_f ("can't open file: `%s'", fn));
71 fprintf (f, "# Generated automatically by: %s\n", gnu_lilypond_version_string ().to_str0 ());
74 for (int i=0; i < targets.size (); i ++)
75 out += dependency_prefix_global + targets[i] + " ";
78 for (int i=0; i < deps.size (); i ++)
80 if (out.length () > WRAPWIDTH)
82 fprintf (f, "%s\\\n", out.to_str0 ());
86 if (!dependency_prefix_global.empty_b ())
89 if (stat (dep.to_str0 (), &stat_buf) == -1 && errno == ENOENT)
92 if (dep.index ('/') < 0)
94 dep = dependency_prefix_global + dep;
98 fprintf (f, "%s\n", out.to_str0 ());
103 Input_file_results::do_deps ()
105 if (dependency_global_b)
107 Path p = split_path (output_name_global);
109 write_dependency_file (p.string (),
117 Input_file_results::do_scores ()
119 if (header_ == SCM_EOL)
120 header_ = ly_make_anonymous_module ();
122 for (int i=0; i < scores_.size (); i++)
124 Score* is = scores_[i];
125 is->input_file_ = this;
129 is->warning (_ ("Score contains errors; will not process it"));
130 exit_status_global |= 1;
140 Input_file_results::~Input_file_results ()
142 for (int i=0; i < scores_.size (); i++)
143 scm_gc_unprotect_object (scores_[i]->self_scm ());
146 inclusion_names_.clear ();
150 global_input_file =0;
152 ly_clear_anonymous_modules();
157 Input_file_results* global_input_file;
159 Input_file_results::Input_file_results (String init_string, String file_string)
162 global_input_file = this;
163 ly_set_point_and_click_x (SCM_BOOL_F);
165 sources_.set_path (&global_path);
167 My_lily_parser parser (this);
169 progress_indication (_f ("Now processing: `%s'", file_string.to_str0 ()));
170 progress_indication ("\n");
171 parser.parse_file (init_string, file_string);
173 if (parser.error_level_)
175 exit_status_global = 1;
184 do_one_file (String init_string, String file_string)
186 if (init_string.length () && global_path.find (init_string).empty_b ())
188 warning (_f ("can't find file: `%s'", init_string));
189 warning (_f ("(search path: `%s')", global_path.string ().to_str0 ()));
192 if ((file_string != "-") && global_path.find (file_string).empty_b ())
194 warning (_f ("can't find file: `%s'", file_string));
198 Input_file_results inp_file(init_string, file_string);