2 scores.cc -- implement some globals
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2004 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"
35 bool store_locations_global_b;
38 TODO: should merge with My_lily_parser.
42 no ! suffix since it doesn't modify 1st argument.
44 LY_DEFINE(ly_set_point_and_click, "ly:set-point-and-click", 1, 0, 0,
46 "Set the options for Point-and-click source specials output. The\n"
47 "argument is a symbol. Possible options are @code{none} (no source specials),\n"
48 "@code{line} and @code{line-column}")
54 if (ly_symbol2scm ("line-column") == what)
55 val = gh_eval_str ("line-column-location");
56 else if (what == ly_symbol2scm ("line"))
57 val = gh_eval_str ("line-location");
59 extern SCM lily_module;
60 scm_module_define (lily_module, ly_symbol2scm ("point-and-click"), val);
62 store_locations_global_b =gh_procedure_p (val);
63 return SCM_UNSPECIFIED;
67 write_dependency_file (String fn,
68 Array<String> targets,
71 const int WRAPWIDTH = 65;
73 progress_indication (_f ("dependencies output to `%s'...", fn.to_str0 ()));
74 progress_indication ("\n");
75 FILE * f = fopen (fn.to_str0 (), "w");
77 warning (_f ("can't open file: `%s'", fn));
79 fprintf (f, "# Generated automatically by: %s\n", gnu_lilypond_version_string ().to_str0 ());
82 for (int i=0; i < targets.size (); i ++)
83 out += dependency_prefix_global + targets[i] + " ";
86 for (int i=0; i < deps.size (); i ++)
88 if (out.length () > WRAPWIDTH)
90 fprintf (f, "%s\\\n", out.to_str0 ());
94 if (!dependency_prefix_global.is_empty ())
96 if (dep.index ('/') < 0)
97 dep = dependency_prefix_global + dep;
101 fprintf (f, "%s\n", out.to_str0 ());
106 Input_file_results::do_deps (String output)
108 if (dependency_global_b)
110 Path p = split_path (output);
112 write_dependency_file (p.to_string (),
118 Input_file_results::~Input_file_results ()
120 inclusion_names_.clear ();
124 global_input_file =0;
126 ly_clear_anonymous_modules();
131 Input_file_results* global_input_file;
133 Input_file_results::Input_file_results (String init, String in_file, String out_file)
135 header_ = ly_make_anonymous_module ();
136 global_input_file = this;
138 sources_.set_path (&global_path);
141 progress_indication (_f ("Now processing: `%s'", in_file.to_str0 ()));
142 progress_indication ("\n");
144 My_lily_parser parser (this);
145 parser.parse_file (init, in_file, out_file);
147 if (parser.error_level_)
149 exit_status_global = 1;
150 failed_files.push (in_file);
159 do_one_file (String init, String in_file, String out_file)
161 if (init.length () && global_path.find (init).is_empty ())
163 warning (_f ("can't find file: `%s'", init));
164 warning (_f ("(search path: `%s')", global_path.to_string ().to_str0 ()));
168 if ((in_file != "-") && global_path.find (in_file).is_empty ())
170 warning (_f ("can't find file: `%s'", in_file));
176 proc = scm_c_eval_string ("dump-gc-protects");
178 Input_file_results inp_file (init, in_file, out_file);