Angus Leeming wrote:
> Jose' Matos wrote:
>>> Hmmmm. Any ideas on how best to tackle this?
>>
>> Add another argument for the relative depth, with 0 for lyx and 1 for
>> tex2lyx?
>>
>> NormalizePath(AddPath(binary_dir, "../" * (depth + 1) + "lib"));
>>
>> I am not sure how serious this is. ;-)
>
> Not bad actually. Not bad at all.
I took the idea and made this patch, which I'll now commit.
Many thanks, José, both for the bug report and for the solution.
--
Angus
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2106
diff -u -p -r1.2106 ChangeLog
--- src/ChangeLog 31 Jan 2005 17:21:16 -0000 1.2106
+++ src/ChangeLog 31 Jan 2005 19:03:43 -0000
@@ -1,3 +1,8 @@
+2005-01-31 Angus Leeming <[EMAIL PROTECTED]>
+
+ * 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 <[EMAIL PROTECTED]>
* BufferView_pimpl.C (MenuInsertLyXFile): do breakParagraph on the
Index: src/lyx_main.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_main.C,v
retrieving revision 1.198
diff -u -p -r1.198 lyx_main.C
--- src/lyx_main.C 31 Jan 2005 10:42:19 -0000 1.198
+++ src/lyx_main.C 31 Jan 2005 19:03:45 -0000
@@ -205,7 +205,8 @@ void LyX::priv_exec(int & argc, char * a
// 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: src/support/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/ChangeLog,v
retrieving revision 1.319
diff -u -p -r1.319 ChangeLog
--- src/support/ChangeLog 31 Jan 2005 15:26:39 -0000 1.319
+++ src/support/ChangeLog 31 Jan 2005 19:03:47 -0000
@@ -1,3 +1,9 @@
+2005-01-31 Angus Leeming <[EMAIL PROTECTED]>
+
+ * 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 Asger Ottar Alstrup <[EMAIL PROTECTED]>
* chdir.C (chdir):
Index: src/support/package.C.in
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/package.C.in,v
retrieving revision 1.6
diff -u -p -r1.6 package.C.in
--- src/support/package.C.in 31 Jan 2005 10:42:25 -0000 1.6
+++ src/support/package.C.in 31 Jan 2005 19:03:47 -0000
@@ -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
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 & defa
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_
// 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 folde
#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_buil
// 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: src/support/package.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/package.h,v
retrieving revision 1.2
diff -u -p -r1.2 package.h
--- src/support/package.h 10 Jan 2005 19:17:43 -0000 1.2
+++ src/support/package.h 31 Jan 2005 19:03:47 -0000
@@ -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: src/tex2lyx/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tex2lyx/ChangeLog,v
retrieving revision 1.75
diff -u -p -r1.75 ChangeLog
--- src/tex2lyx/ChangeLog 31 Jan 2005 10:42:26 -0000 1.75
+++ src/tex2lyx/ChangeLog 31 Jan 2005 19:03:48 -0000
@@ -1,3 +1,10 @@
+2005-01-31 Angus Leeming <[EMAIL PROTECTED]>
+
+ * 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 <[EMAIL PROTECTED]>
* tex2lyx.C: rewrite to use boost.filesystem
Index: src/tex2lyx/tex2lyx.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tex2lyx/tex2lyx.C,v
retrieving revision 1.65
diff -u -p -r1.65 tex2lyx.C
--- src/tex2lyx/tex2lyx.C 31 Jan 2005 10:42:26 -0000 1.65
+++ src/tex2lyx/tex2lyx.C 31 Jan 2005 19:03:49 -0000
@@ -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, s
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()) {