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, "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);
53 return SCM_UNSPECIFIED;
57 write_dependency_file (String fn,
58 Array<String> targets,
61 const int WRAPWIDTH = 65;
63 progress_indication (_f ("dependencies output to `%s'...", fn.to_str0 ()));
64 progress_indication ("\n");
65 FILE * f = fopen (fn.to_str0 (), "w");
67 warning (_f ("can't open file: `%s'", fn));
69 fprintf (f, "# Generated automatically by: %s\n", gnu_lilypond_version_string ().to_str0 ());
72 for (int i=0; i < targets.size (); i ++)
73 out += dependency_prefix_global + targets[i] + " ";
76 for (int i=0; i < deps.size (); i ++)
78 if (out.length () > WRAPWIDTH)
80 fprintf (f, "%s\\\n", out.to_str0 ());
84 if (!dependency_prefix_global.empty_b ())
87 if (stat (dep.to_str0 (), &stat_buf) == -1 && errno == ENOENT)
90 if (dep.index ('/') < 0)
92 dep = dependency_prefix_global + dep;
96 fprintf (f, "%s\n", out.to_str0 ());
101 Input_file_results::do_deps ()
103 if (dependency_global_b)
105 Path p = split_path (output_name_global);
107 write_dependency_file (p.string (),
115 Input_file_results::do_scores ()
117 if (header_ == SCM_EOL)
118 header_ = ly_make_anonymous_module ();
120 for (int i=0; i < scores_.size (); i++)
122 Score* is = scores_[i];
123 is->input_file_ = this;
127 is->warning (_ ("Score contains errors; will not process it"));
128 exit_status_global |= 1;
138 Input_file_results::~Input_file_results ()
140 for (int i=0; i < scores_.size (); i++)
141 scm_gc_unprotect_object (scores_[i]->self_scm ());
144 inclusion_names_.clear ();
148 global_input_file =0;
150 ly_clear_anonymous_modules();
155 Input_file_results* global_input_file;
157 Input_file_results::Input_file_results (String init_string, String file_string)
160 global_input_file = this;
161 ly_set_point_and_click_x (SCM_BOOL_F);
163 sources_.set_path (&global_path);
165 My_lily_parser parser (this);
167 progress_indication (_f ("Now processing: `%s'", file_string.to_str0 ()));
168 progress_indication ("\n");
169 parser.parse_file (init_string, file_string);
171 if (parser.error_level_)
173 exit_status_global = 1;
182 do_one_file (String init_string, String file_string)
184 if (init_string.length () && global_path.find (init_string).empty_b ())
186 warning (_f ("can't find file: `%s'", init_string));
187 warning (_f ("(search path: `%s')", global_path.string ().to_str0 ()));
190 if ((file_string != "-") && global_path.find (file_string).empty_b ())
192 warning (_f ("can't find file: `%s'", file_string));
196 Input_file_results inp_file(init_string, file_string);