X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=lily%2Fscores.cc;h=7d611e494aa3489f1e7d20a5e925cfeab8ac66d6;hb=f988425624a6f6d1a48aea0ac0c1c84ff0857e56;hp=90fbcf17a703d2916cd8a16f7113d9f83460f349;hpb=cec6dfa6bf0fb931eb7f42b1ee44ca2ec19a9f34;p=lilypond.git diff --git a/lily/scores.cc b/lily/scores.cc index 90fbcf17a7..7d611e494a 100644 --- a/lily/scores.cc +++ b/lily/scores.cc @@ -3,54 +3,134 @@ source file of the GNU LilyPond music typesetter - (c) 1997 Han-Wen Nienhuys + (c) 1997--2000 Han-Wen Nienhuys */ - +#include #include "main.hh" #include "score.hh" #include "string.hh" #include "paper-def.hh" -#include "header.hh" +#include "scope.hh" #include "debug.hh" #include "parray.hh" +#include "file-path.hh" +#include "file-results.hh" +#include "my-lily-parser.hh" +#include "source.hh" +#include "lily-version.hh" + +Sources* source_global_l = 0; +Array inclusion_global_array; +Array target_str_global_array; +Link_array score_global_array; +Scope * header_global_p; + + +void write_dependency_file (String fn, Array targets, + Array deps) +{ + const int WRAPWIDTH = 65; + + progress_indication (_f ("Writing dependency file: `%s'...", fn.ch_C ())); + progress_indication ("\n"); + ofstream f (fn.ch_C ()); + if (!f) + warning (_f ("can't open file: `%s'", fn)); + + f << "# Automatically generated by " << gnu_lilypond_version_str () << '\n'; + String out; + for (int i=0; i < targets.size (); i ++) + out += targets[i] + " "; + out += ": "; + for (int i=0; i < deps.size (); i ++) + { + if (out.length_i() > WRAPWIDTH) + { + f << out << "\\\n"; + out = " "; + } + out += " " + deps[i]; + } + f << out << endl; +} + +void +do_deps() +{ + if (dependency_global_b) + { + write_dependency_file (default_outname_base_global + ".dep", target_str_global_array, + inclusion_global_array); + } +} -static Link_array global_score_array; -String default_out_fn = "lelie"; void do_scores() { - for (int i=0; i < global_score_array.size(); i++) + if (!header_global_p) + header_global_p = new Scope; + for (int i=0; i < score_global_array.size(); i++) { - Score *&is_p = global_score_array[i]; - if (is_p->header_p_) - is_p->header_p_->lily_id_str_ = "Lily was here, " + - get_version_number_str(); - if (is_p->errorlevel_i_) + Score* is_p = score_global_array[i]; + + if (is_p->errorlevel_i_) { - is_p->warning ("Score contains errors. Will not process it. "); + is_p->warning (_("Score contains errors; will not process it")); exit_status_i_ |= 1; } - else + else { is_p->process(); } - delete is_p; - is_p =0; - } - global_score_array.clear(); + do_deps (); } void -add_score (Score * s) +clear_scores () { - global_score_array.push (s); + junk_pointer_array (score_global_array); + + inclusion_global_array.clear (); + delete header_global_p ; + header_global_p =0; } + void -set_default_output (String s) +do_one_file (String init_str, String file_str) { - default_out_fn = s; + if (init_str.length_i () && global_path.find (init_str).empty_b ()) + { + warning (_f ("can't find file: `%s'", init_str)); + warning (_f ("(search path: `%s')", global_path.str ().ch_C())); + return; + } + if ((file_str != "-") && global_path.find (file_str).empty_b ()) + { + warning (_f ("can't find file: `%s'", file_str)); + return; + } + + Sources sources; + source_global_l = &sources; + source_global_l->set_path (&global_path); + { + My_lily_parser parser (source_global_l); + parser.set_version_check (false); + progress_indication (_f ("Now processing: `%s'", file_str.ch_C ())); + progress_indication ("\n"); + parser.parse_file (init_str, file_str); + + if (parser.error_level_i_) + { + exit_status_i_ = 1; + } + else + do_scores (); + clear_scores (); + } + source_global_l = 0; }