From 23d9c229e3a7202cc871a6b25f4af35cc3afc088 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Mon, 31 Jan 2005 19:57:03 +0000 Subject: [PATCH] Enable tex2lyx to run in-place. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9562 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 +++++ src/lyx_main.C | 3 ++- src/support/ChangeLog | 6 ++++++ src/support/package.C.in | 39 ++++++++++++++++++++++++++++++++------- src/support/package.h | 16 ++++++++++++++-- src/tex2lyx/ChangeLog | 7 +++++++ src/tex2lyx/tex2lyx.C | 6 +++++- 7 files changed, 71 insertions(+), 11 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 9231149145..b18132a27e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2005-01-31 Angus Leeming + + * 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 * BufferView_pimpl.C (MenuInsertLyXFile): do breakParagraph on the diff --git a/src/lyx_main.C b/src/lyx_main.C index 9d0bdf105a..fea5a59702 100644 --- a/src/lyx_main.C +++ b/src/lyx_main.C @@ -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); diff --git a/src/support/ChangeLog b/src/support/ChangeLog index 297aeb5479..1649f11cbe 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,9 @@ +2005-01-31 Angus Leeming + + * 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 * fs_extras.C: add changes from Asgers Win32 patch. diff --git a/src/support/package.C.in b/src/support/package.C.in index 70a5e2b99f..f7db4a77fa 100644 --- a/src/support/package.C.in +++ b/src/support/package.C.in @@ -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 const get_build_dirs(string const & abs_binary); +std::pair 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 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 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 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". diff --git a/src/support/package.h b/src/support/package.h index cfe1828c41..dcbb52949a 100644 --- a/src/support/package.h +++ b/src/support/package.h @@ -22,6 +22,16 @@ namespace support { class Package; +/** When run in-place /src/lyx is one level up from + * the whilst /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. */ diff --git a/src/tex2lyx/ChangeLog b/src/tex2lyx/ChangeLog index bb75355ecf..4d4b312a89 100644 --- a/src/tex2lyx/ChangeLog +++ b/src/tex2lyx/ChangeLog @@ -1,3 +1,10 @@ +2005-01-31 Angus Leeming + + * 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 * tex2lyx.C: rewrite to use boost.filesystem diff --git a/src/tex2lyx/tex2lyx.C b/src/tex2lyx/tex2lyx.C index 2ba23661a9..f32fdcca28 100644 --- a/src/tex2lyx/tex2lyx.C +++ b/src/tex2lyx/tex2lyx.C @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -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()) {