]> git.lyx.org Git - features.git/commitdiff
Enable tex2lyx to run in-place.
authorAngus Leeming <leeming@lyx.org>
Mon, 31 Jan 2005 19:57:03 +0000 (19:57 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 31 Jan 2005 19:57:03 +0000 (19:57 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9562 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/lyx_main.C
src/support/ChangeLog
src/support/package.C.in
src/support/package.h
src/tex2lyx/ChangeLog
src/tex2lyx/tex2lyx.C

index 9231149145921966271644c32dda07bb636a556b..b18132a27edca722efda58f83fb5517c223b552c 100644 (file)
@@ -1,3 +1,8 @@
+2005-01-31  Angus Leeming  <leeming@lyx.org>
+
+       * lyx_main.C (priv_exec): specify explicitly the relative location
+       of the top level build directory when run in-place.
+
 2005-01-27  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * BufferView_pimpl.C (MenuInsertLyXFile): do breakParagraph on the
index 9d0bdf105a5b81782b4221e97c23034a9fb54b9d..fea5a59702d04b453e6817e0235d23293c655edf 100644 (file)
@@ -205,7 +205,8 @@ void LyX::priv_exec(int & argc, char * argv[])
        // we need to parse for "-dbg" and "-help"
        bool const want_gui = easyParse(argc, argv);
 
-       lyx::support::init_package(argv[0], cl_system_support, cl_user_support);
+       lyx::support::init_package(argv[0], cl_system_support, cl_user_support,
+                                  lyx::support::top_build_dir_is_one_level_up);
 
        if (want_gui)
                lyx_gui::parse_init(argc, argv);
index 297aeb547953af929e7cb508a377ed07ffad8ebb..1649f11cbe28767b4da4945fab79ecdc5b512ef3 100644 (file)
@@ -1,3 +1,9 @@
+2005-01-31  Angus Leeming  <leeming@lyx.org>
+
+       * package.[Ch] (init_package, c-tor): define and use an enum to
+       specify explicitly the location of the top level build directory
+       when the executable is run in-place.
+
 2005-01-31  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * fs_extras.C: add changes from Asgers Win32 patch.
index 70a5e2b99ff4a80507d5182f93f2e607c531dba3..f7db4a77fa2f8bec776124687e79fcf81deaa55f 100644 (file)
@@ -66,7 +66,8 @@ bool initialised_ = false;
 
 void init_package(string const & command_line_arg0,
                  string const & command_line_system_support_dir,
-                 string const & command_line_user_support_dir)
+                 string const & command_line_user_support_dir,
+                 exe_build_dir_to_top_build_dir top_build_dir_location)
 {
        // Can do so only once.
        if (initialised_)
@@ -74,7 +75,8 @@ void init_package(string const & command_line_arg0,
 
        package_ = Package(command_line_arg0,
                           command_line_system_support_dir,
-                          command_line_user_support_dir);
+                          command_line_user_support_dir,
+                          top_build_dir_location);
        initialised_ = true;
 }
 
@@ -93,7 +95,9 @@ namespace {
 
 string const abs_path_from_binary_name(string const & exe);
 
-std::pair<string, string> const get_build_dirs(string const & abs_binary);
+std::pair<string, string> const
+get_build_dirs(string const & abs_binary,
+              exe_build_dir_to_top_build_dir top_build_dir_location);
 
 string const get_document_dir(string const & home_dir);
 
@@ -117,7 +121,8 @@ get_user_support_dir(string const & default_user_support_dir,
 
 Package::Package(string const & command_line_arg0,
                 string const & command_line_system_support_dir,
-                string const & command_line_user_support_dir)
+                string const & command_line_user_support_dir,
+                exe_build_dir_to_top_build_dir top_build_dir_location)
        : explicit_user_support_dir_(false)
 {
        home_dir_ = get_home_dir();
@@ -129,7 +134,7 @@ Package::Package(string const & command_line_arg0,
 
        // Is LyX being run in-place from the build tree?
        boost::tie(build_support_dir_, system_support_dir_) =
-               get_build_dirs(abs_binary);
+               get_build_dirs(abs_binary, top_build_dir_location);
 
        if (build_support_dir_.empty())
                system_support_dir_ =
@@ -224,7 +229,27 @@ string const win32_folder_path(int folder_id)
 #endif
 
 
-std::pair<string, string> const get_build_dirs(string const & abs_binary)
+std::string const
+get_build_support_dir(std::string const & binary_dir,
+                     exe_build_dir_to_top_build_dir top_build_dir_location)
+{
+       string indirection;
+       switch (top_build_dir_location) {
+       case top_build_dir_is_one_level_up:
+               indirection = "../lib";
+               break;
+       case top_build_dir_is_two_levels_up:
+               indirection = "../../lib";
+               break;
+       }
+
+       return NormalizePath(AddPath(binary_dir, indirection));
+}
+
+
+std::pair<string, string> const
+get_build_dirs(string const & abs_binary,
+              exe_build_dir_to_top_build_dir top_build_dir_location)
 {
        string const check_text = "Checking whether LyX is run in place...";
 
@@ -241,7 +266,7 @@ std::pair<string, string> const get_build_dirs(string const & abs_binary)
                // Try and find "lyxrc.defaults".
                string const binary_dir = OnlyPath(binary);
                string const build_support_dir =
-                       NormalizePath(AddPath(binary_dir, "../lib"));
+                       get_build_support_dir(binary_dir, top_build_dir_location);
 
                if (!FileSearch(build_support_dir, "lyxrc.defaults").empty()) {
                        // Try and find "chkconfig.ltx".
index cfe1828c41b4099f440d26c2e855bdc7f2133c8c..dcbb52949af33b196fbd74a2ba561cb97e7f5f49 100644 (file)
@@ -22,6 +22,16 @@ namespace support {
 
 class Package;
 
+/** When run in-place <build-dir>/src/lyx is one level up from
+ *  the <build-dir> whilst <build-dir>/src/tex2lyx/tex2lyx is
+ *  two levels up.
+ */
+enum exe_build_dir_to_top_build_dir {
+       top_build_dir_is_one_level_up,
+       top_build_dir_is_two_levels_up
+};
+
+
 /** Initialise package() with the command line data.
  *  This data is exactly as it was passed in the argv[] array.
  *
@@ -36,7 +46,8 @@ class Package;
  */
 void init_package(std::string const & command_line_arg0,
                  std::string const & command_line_system_support_dir,
-                 std::string const & command_line_user_support_dir);
+                 std::string const & command_line_user_support_dir,
+                 exe_build_dir_to_top_build_dir);
 
 /** Accessor to the global data.
  *  Asserts that init_package() has been called first.
@@ -53,7 +64,8 @@ public:
         */
        Package(std::string const & command_line_arg0,
                std::string const & command_line_system_support_dir,
-               std::string const & command_line_user_support_dir);
+               std::string const & command_line_user_support_dir,
+               exe_build_dir_to_top_build_dir);
 
        /** The directory containing the LyX executable.
         */
index bb75355ecf1be864acde49a92b5f03b4cc8152eb..4d4b312a89dc00526a3c3a2b330007ce38ea9837 100644 (file)
@@ -1,3 +1,10 @@
+2005-01-31  Angus Leeming  <leeming@lyx.org>
+
+       * tex2lyx.C (main): enable tex2lyx to find the top level
+       build directory when run in-place.
+
+       Also add "fs::path::default_name_check(fs::no_check);"
+
 2005-01-31  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * tex2lyx.C: rewrite to use boost.filesystem
index 2ba23661a9b79062d59e16474b811f5d1f55f09f..f32fdcca28e7519bff747cddc947801b2a389d25 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <boost/function.hpp>
 #include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/path.hpp>
 
 #include <cctype>
 #include <fstream>
@@ -381,6 +382,8 @@ bool tex2lyx(string const &infilename, string const &outfilename)
 
 int main(int argc, char * argv[])
 {
+       fs::path::default_name_check(fs::no_check);
+
        easyParse(argc, argv);
 
        if (argc <= 1) {
@@ -390,7 +393,8 @@ int main(int argc, char * argv[])
        }
 
        lyx::support::os::init(argc, argv);
-       lyx::support::init_package(argv[0], cl_system_support, cl_user_support);
+       lyx::support::init_package(argv[0], cl_system_support, cl_user_support,
+                                  lyx::support::top_build_dir_is_two_levels_up);
 
        string const system_syntaxfile = lyx::support::LibFileSearch("reLyX", "syntax.default");
        if (system_syntaxfile.empty()) {