From: Asger Ottar Alstrup Date: Tue, 1 Feb 2005 16:08:05 +0000 (+0000) Subject: - Fix compilation for MSVC after latest package.C changes X-Git-Tag: 1.6.10~14589 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ab07b788e38bb0524552aaea26416bd9f263cb80;p=features.git - Fix compilation for MSVC after latest package.C changes - Fix the redundant _moc.C files which aren't necessary in the project file git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9563 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/development/Win32/lyx.vcproj b/development/Win32/lyx.vcproj index 507b641f63..8632aa7b92 100644 --- a/development/Win32/lyx.vcproj +++ b/development/Win32/lyx.vcproj @@ -3807,23 +3807,6 @@ CompileAs="2"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + @@ -8360,6 +8294,25 @@ + + + + + + + + @@ -8379,6 +8332,25 @@ + + + + + + + + @@ -8398,6 +8370,25 @@ + + + + + + + + @@ -8417,6 +8408,25 @@ + + + + + + + + @@ -8466,9 +8476,6 @@ - - @@ -8481,9 +8488,6 @@ - - @@ -8503,15 +8507,9 @@ - - - - @@ -8521,42 +8519,24 @@ - - - - - - - - - - - - @@ -8572,78 +8552,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -8653,105 +8591,51 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -8782,9 +8666,6 @@ - - diff --git a/development/Win32/package.C b/development/Win32/package.C index 530342f974..c7819007e1 100644 --- a/development/Win32/package.C +++ b/development/Win32/package.C @@ -24,8 +24,8 @@ #include "support/os.h" #include -#include #include +#include #include #include @@ -53,7 +53,6 @@ using std::string; namespace fs = boost::filesystem; - namespace lyx { namespace support { @@ -67,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_) @@ -75,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; } @@ -94,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); @@ -118,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(); @@ -130,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_ = @@ -165,20 +169,20 @@ namespace { // configuration-time. string const top_srcdir() { - static string const dir("c:\\lyx\\lyx-devel"); + static string const dir("%TOP_SRCDIR%"); return dir; } string const hardcoded_localedir() { - return string("c:\\lyx\\lyx-devel\\lib\\locale"); + return string("%LOCALEDIR%"); } string const hardcoded_system_support_dir() { - return string("c:\\lyx\\lyx-devel\\lib"); + return string("%LYX_DIR%"); } } // namespace anon @@ -186,7 +190,7 @@ string const hardcoded_system_support_dir() string const & Package::top_srcdir() const { - static string const dir("c:\\lyx\\lyx-devel"); + static string const dir("%TOP_SRCDIR%"); return dir; } @@ -225,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..."; @@ -242,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". @@ -257,7 +281,18 @@ std::pair const get_build_dirs(string const & abs_binary) } } - break; + // Check whether binary is a symbolic link. + // If so, resolve it and repeat the exercise. + if (!fs::symbolic_link_exists(binary)) + break; + + string link; + if (LyXReadLink(binary, link, true)) { + binary = link; + } else { + // Unable to resolve the link. + break; + } } lyxerr[Debug::INIT] << check_text << " no" << std::endl; @@ -307,12 +342,12 @@ string const get_locale_dir(string const & system_support_dir) // be "../locale/".) path = NormalizePath(AddPath(system_support_dir, relative_locale_dir())); - if (fs::is_directory(path)) + if (fs::exists(path) && fs::is_directory(path)) return path; // 3. Fall back to the hard-coded LOCALEDIR. path = hardcoded_localedir(); - if (fs::is_directory(path)) + if (fs::exists(path) && fs::is_directory(path)) return path; return string(); @@ -459,7 +494,46 @@ get_system_support_dir(string const & abs_binary, return lyxdir; } - break; + // Check whether binary is a symbolic link. + // If so, resolve it and repeat the exercise. + if (!fs::symbolic_link_exists(binary)) + break; + + string link; + if (LyXReadLink(binary, link, true)) { + binary = link; + } else { + // Unable to resolve the link. + break; + } + } + + // 4. Repeat the exercise on the directory itself. + string binary_dir = OnlyPath(abs_binary); + while (true) { + // This time test whether the directory is a symbolic link + // *before* looking for "chkconfig.ltx". + // (We've looked relative to the original already.) + if (!fs::symbolic_link_exists(binary)) + break; + + string link; + if (LyXReadLink(binary_dir, link, true)) { + binary_dir = link; + } else { + // Unable to resolve the link. + break; + } + + // Try and find "chkconfig.ltx". + string const lyxdir = + NormalizePath(AddPath(binary_dir, relative_lyxdir)); + searched_dirs.push_back(lyxdir); + + if (!FileSearch(lyxdir, chkconfig_ltx).empty()) { + // Success! "chkconfig.ltx" has been found. + return lyxdir; + } } // 5. In desparation, try the hard-coded system support dir. @@ -604,7 +678,7 @@ bool check_env_var_dir(string const & dir, bool check_env_var_dir(string const & dir, string const & env_var) { - bool const success = fs::is_directory(dir); + bool const success = (fs::exists(dir) && fs::is_directory(dir)); if (!success) { // Put this string on a single line so that the gettext @@ -613,7 +687,7 @@ bool check_env_var_dir(string const & dir, // translation. string const fmt = _("Invalid %1$s environment variable.\n%2$s is not a directory."); - + lyxerr << bformat(fmt, env_var, dir) << std::endl; } diff --git a/development/Win32/readme.txt b/development/Win32/readme.txt index 648dd9da72..484ab6065f 100644 --- a/development/Win32/readme.txt +++ b/development/Win32/readme.txt @@ -9,8 +9,8 @@ To compile using MicroSoft Visual Studio 2003.NET, do this: 3) Apply the win32_kludge.diff using GNU patch. Download from http://gnuwin32.sourceforge.net/packages/patch.htm and type "patch -p0 < development\win32\win32_kludge.diff" - in cmd box with current working directory right outside - lyx-devel + in cmd box with current working directory lyx-devel. + Make sure that patch is in your path. (c:\program files\gnuwin32\bin) 4) Open the development\win32\lyx.sln file in Visual Studio, compile and run. You can probably also use the free version of Microsoft's compiler, but I haven't tried that.