2 scores.cc -- implement some globals
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include <sys/types.h>
21 #include "paper-def.hh"
25 #include "file-path.hh"
26 #include "file-results.hh"
27 #include "my-lily-parser.hh"
29 #include "lily-version.hh"
30 #include "scm-hash.hh"
32 Sources
* source_global_l
= 0;
33 Array
<String
> inclusion_global_array
;
34 Array
<String
> target_str_global_array
;
35 Link_array
<Score
> score_global_array
;
36 Scheme_hash_table
* global_header_p
;
39 void write_dependency_file (String fn
, Array
<String
> targets
,
42 const int WRAPWIDTH
= 65;
44 progress_indication (_f ("dependencies output to `%s'...", fn
.ch_C ()));
45 progress_indication ("\n");
46 ofstream
f (fn
.ch_C ());
48 warning (_f ("can't open file: `%s'", fn
));
50 f
<< "# Generated automatically by: " << gnu_lilypond_version_str () << '\n';
52 for (int i
=0; i
< targets
.size (); i
++)
53 out
+= dependency_prefix_global
+ targets
[i
] + " ";
58 for (int i
=0; i
< deps
.size (); i
++)
60 if (out
.length_i () > WRAPWIDTH
)
66 if (!dependency_prefix_global
.empty_b ())
69 if (stat (dep
.ch_C (), &stat_buf
) == -1 && errno
== ENOENT
)
72 if (dep
.index_i ('/') < 0)
74 dep
= dependency_prefix_global
+ dep
;
84 if (dependency_global_b
)
86 Path p
= split_path (output_name_global
);
88 write_dependency_file (p
.str (),
89 target_str_global_array
,
90 inclusion_global_array
);
99 global_header_p
= new Scheme_hash_table
;
100 for (int i
=0; i
< score_global_array
.size (); i
++)
102 Score
* is_p
= score_global_array
[i
];
104 if (is_p
->errorlevel_i_
)
106 is_p
->warning (_ ("Score contains errors; will not process it"));
107 exit_status_global
|= 1;
120 for (int i
=0; i
< score_global_array
.size (); i
++)
121 scm_unprotect_object (score_global_array
[i
]->self_scm ());
122 score_global_array
.clear ();
124 inclusion_global_array
.clear ();
126 scm_unprotect_object (global_header_p
->self_scm ());
132 do_one_file (String init_str
, String file_str
)
134 if (init_str
.length_i () && global_path
.find (init_str
).empty_b ())
136 warning (_f ("can't find file: `%s'", init_str
));
137 warning (_f ("(search path: `%s')", global_path
.str ().ch_C ()));
140 if ((file_str
!= "-") && global_path
.find (file_str
).empty_b ())
142 warning (_f ("can't find file: `%s'", file_str
));
147 source_global_l
= &sources
;
148 source_global_l
->set_path (&global_path
);
150 My_lily_parser
parser (source_global_l
);
151 parser
.set_version_check (false);
152 progress_indication (_f ("Now processing: `%s'", file_str
.ch_C ()));
153 progress_indication ("\n");
154 parser
.parse_file (init_str
, file_str
);
156 if (parser
.error_level_i_
)
158 exit_status_global
= 1;