]> git.donarmstrong.com Git - lilypond.git/commitdiff
Make relative-includes configurable with a -d option.
authorJoe Neeman <joeneeman@gmail.com>
Wed, 31 Dec 2008 10:50:54 +0000 (21:50 +1100)
committerJoe Neeman <joeneeman@gmail.com>
Wed, 31 Dec 2008 10:50:54 +0000 (21:50 +1100)
lily/includable-lexer.cc
lily/include/includable-lexer.hh
lily/include/lily-lexer.hh
lily/program-option-scheme.cc
scm/lily.scm

index 09b97da0178a3c5a7e15e16a8bf30ee73c0f8798..e241b66230af3724439045acff458aa195315aa0 100644 (file)
@@ -37,6 +37,8 @@ using namespace std;
   (yy_buffer_stack != 0 ? yy_buffer_stack[yy_buffer_stack_top] : 0)
 #endif
 
+extern bool relative_includes;
+
 Includable_lexer::Includable_lexer ()
 {
 #if HAVE_FLEXLEXER_YY_CURRENT_BUFFER
@@ -48,8 +50,9 @@ Includable_lexer::Includable_lexer ()
 void
 Includable_lexer::new_input (string name, Sources *sources)
 {
-  string current_dir = include_stack_.size () ?
-    dir_name (include_stack_.back ()->name_string ()) : "";
+  string current_dir = dir_name (main_input_name_);
+  if (relative_includes)
+    current_dir = include_stack_.size () ? dir_name (include_stack_.back ()->name_string ()) : "";
 
   Source_file *file = sources->get_file (name, current_dir);
   if (!file)
index 1e35012f335fe9c48fd357a34c2fcefe08ef7818..f5d0d44a7153c5464abee2f7fa1b39954f046d2e 100644 (file)
@@ -36,6 +36,7 @@ public:
 
   Includable_lexer ();
   ~Includable_lexer ();
+  string main_input_name_;
 
   /// store dependencies for Makefile stuff.
   vector<string> file_name_strings_;
index 83a9f89b9353fa70257bf97b7d74c126dbabe118..284e5636c6ec208db8e0fa9014d83793077d1bc1 100644 (file)
@@ -38,7 +38,6 @@ private:
   int hidden_state_;
 public:
   vector<int> extra_token_types_;
-  string main_input_name_;
   void *lexval;
   Input *lexloc;
   bool is_main_input_;
index 1dd74ff69e8a13495e943974898f3c73223302f0..d68af75ab1a1d7e759ad9c91761bc50dd04eb2a3 100644 (file)
@@ -23,6 +23,8 @@ bool debug_skylines;
 bool debug_property_callbacks;
 bool debug_page_breaking_scoring;
 
+bool relative_includes;
+
 /*
   Backwards compatibility.
 */
@@ -103,6 +105,11 @@ void internal_set_option (SCM var, SCM val)
       /* ignore input value. */
       val = ly_string2scm (lilypond_datadir);
     }
+  else if (var == ly_symbol2scm ("relative-includes"))
+    {
+      relative_includes = to_boolean (val);
+      val = scm_from_bool (to_boolean (val));
+    }
 
 
   scm_hashq_set_x (option_hash, var, val);
index bddb9982a7e7a4c819c60f86d0d7024ff74541f7..2c1eb188e69054341b91df7db63b1c33cb30bd12 100644 (file)
@@ -80,6 +80,8 @@ on errors, and print a stack trace.")
     
     (resolution 101 "resolution for generating PNG bitmaps")
     (read-file-list #f "Read files to be processed from command line arguments")
+    (relative-includes #f "When processing an \\include command, look for the included file
+relative to the current file (instead of the root file)")
 
     (safe #f "Run safely")
     (strict-infinity-checking #f "If yes, crash on encountering Inf/NaN.")