2 scores.cc -- implement some globals
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2003 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"
37 no ! suffix since it doesn't modify 1st argument.
39 LY_DEFINE(ly_set_point_and_click
, "ly:set-point-and-click", 1, 0, 0,
41 "Set the options for Point-and-click source specials output. The\n"
42 "argument is a symbol. Possible options are @code{none} (no source specials),\n"
43 "@code{line} and @code{line-column}")
49 if (ly_symbol2scm ("line-column") == what
)
50 val
= gh_eval_str ("line-column-location");
51 else if (what
== ly_symbol2scm ("line"))
52 val
= gh_eval_str ("line-location");
54 extern SCM lily_module
;
55 scm_module_define (lily_module
, ly_symbol2scm ("point-and-click"), val
);
57 store_locations_global_b
=gh_procedure_p (val
);
58 return SCM_UNSPECIFIED
;
62 write_dependency_file (String fn
,
63 Array
<String
> targets
,
66 const int WRAPWIDTH
= 65;
68 progress_indication (_f ("dependencies output to `%s'...", fn
.to_str0 ()));
69 progress_indication ("\n");
70 FILE * f
= fopen (fn
.to_str0 (), "w");
72 warning (_f ("can't open file: `%s'", fn
));
74 fprintf (f
, "# Generated automatically by: %s\n", gnu_lilypond_version_string ().to_str0 ());
77 for (int i
=0; i
< targets
.size (); i
++)
78 out
+= dependency_prefix_global
+ targets
[i
] + " ";
81 for (int i
=0; i
< deps
.size (); i
++)
83 if (out
.length () > WRAPWIDTH
)
85 fprintf (f
, "%s\\\n", out
.to_str0 ());
89 if (!dependency_prefix_global
.empty_b ())
92 if (stat (dep
.to_str0 (), &stat_buf
) == -1 && errno
== ENOENT
)
95 if (dep
.index ('/') < 0)
97 dep
= dependency_prefix_global
+ dep
;
101 fprintf (f
, "%s\n", out
.to_str0 ());
106 Input_file_results::do_deps ()
108 if (dependency_global_b
)
110 Path p
= split_path (output_name_global
);
112 write_dependency_file (p
.to_string (),
120 Input_file_results::do_scores ()
122 if (header_
== SCM_EOL
)
123 header_
= ly_make_anonymous_module ();
125 for (int i
=0; i
< scores_
.size (); i
++)
127 Score
* is
= scores_
[i
];
128 is
->input_file_
= this;
132 is
->warning (_ ("Score contains errors; will not process it"));
133 exit_status_global
|= 1;
143 Input_file_results::~Input_file_results ()
145 for (int i
=0; i
< scores_
.size (); i
++)
146 scm_gc_unprotect_object (scores_
[i
]->self_scm ());
149 inclusion_names_
.clear ();
153 global_input_file
=0;
155 ly_clear_anonymous_modules();
160 Input_file_results
* global_input_file
;
162 Input_file_results::Input_file_results (String init_string
, String file_string
)
165 global_input_file
= this;
166 ly_set_point_and_click (SCM_BOOL_F
);
168 sources_
.set_path (&global_path
);
170 My_lily_parser
parser (this);
172 progress_indication (_f ("Now processing: `%s'", file_string
.to_str0 ()));
173 progress_indication ("\n");
174 parser
.parse_file (init_string
, file_string
);
176 if (parser
.error_level_
)
178 exit_status_global
= 1;
187 do_one_file (String init_string
, String file_string
)
189 if (init_string
.length () && global_path
.find (init_string
).empty_b ())
191 warning (_f ("can't find file: `%s'", init_string
));
192 warning (_f ("(search path: `%s')", global_path
.to_string ().to_str0 ()));
195 if ((file_string
!= "-") && global_path
.find (file_string
).empty_b ())
197 warning (_f ("can't find file: `%s'", file_string
));
201 Input_file_results
inp_file(init_string
, file_string
);