From 2ed8641380b2fa1202af031d9ea7cb9b88bfb854 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 23 May 2002 22:32:37 +0000 Subject: [PATCH] finalize VC++ port --- ppremake/acconfig.h | 4 +- ppremake/config_msvc.h | 4 +- ppremake/configure.in | 2 +- ppremake/filename.cxx | 31 +++++++++++----- ppremake/ppCommandFile.cxx | 2 +- ppremake/ppScope.cxx | 75 ++------------------------------------ ppremake/ppremake.h | 2 +- 7 files changed, 33 insertions(+), 87 deletions(-) diff --git a/ppremake/acconfig.h b/ppremake/acconfig.h index 22fa6b37e6..76ba765d4e 100644 --- a/ppremake/acconfig.h +++ b/ppremake/acconfig.h @@ -20,8 +20,8 @@ /* Define if the C++ iostream library supports ios::binary. */ #undef HAVE_IOS_BINARY -/* Define if we're compiling for Cygwin. */ -#undef PLATFORM_CYGWIN +/* Define if we're compiling with Cygwin. */ +#undef HAVE_CYGWIN /* Define if we're compiling using Windows Microsoft Visual C++. */ #undef WIN32_VC diff --git a/ppremake/config_msvc.h b/ppremake/config_msvc.h index 9b0ecfc121..05525a52fb 100644 --- a/ppremake/config_msvc.h +++ b/ppremake/config_msvc.h @@ -12,8 +12,8 @@ /* Define if the C++ iostream library supports ios::binary. */ /* #undef HAVE_IOS_BINARY */ -/* Define if we're compiling for Cygwin. */ -/* #undef PLATFORM_CYGWIN */ +/* Define if we're compiling with Cygwin. */ +/* #undef HAVE_CYGWIN */ /* Define if we're compiling using Windows Microsoft Visual C++. */ #define WIN32_VC 1 diff --git a/ppremake/configure.in b/ppremake/configure.in index b46a41f9e8..866ac4d82d 100644 --- a/ppremake/configure.in +++ b/ppremake/configure.in @@ -74,7 +74,7 @@ else fi if test "$PLATFORM" = "Cygwin"; then - AC_DEFINE(PLATFORM_CYGWIN) + AC_DEFINE(HAVE_CYGWIN) fi AC_DEFINE_UNQUOTED(PLATFORM, "$PLATFORM") diff --git a/ppremake/filename.cxx b/ppremake/filename.cxx index b345bb43bf..8e7252104f 100644 --- a/ppremake/filename.cxx +++ b/ppremake/filename.cxx @@ -52,6 +52,16 @@ #include #endif +// We might have been linked with the Cygwin dll. This is ideal if it +// is available, because it allows Panda to access all the Cygwin +// mount definitions if they are in use. If the Cygwin dll is not +// available, we fall back to our own convention for converting +// pathnames. +#ifdef HAVE_CYGWIN +extern "C" void cygwin_conv_to_win32_path(const char *path, char *win32); +//extern "C" void cygwin_conv_to_posix_path(const char *path, char *posix); +#endif + static string front_to_back_slash(const string &str) { string result = str; @@ -85,10 +95,6 @@ get_panda_root() { if (!got_panda_root) { const char *envvar = getenv("PANDA_ROOT"); - if (envvar == (const char *)NULL) { - envvar = getenv("CYGWIN_ROOT"); - } - if (envvar != (const char *)NULL) { panda_root = front_to_back_slash(envvar); } @@ -145,10 +151,18 @@ convert_pathname(const string &unix_style_pathname) { } else { // It starts with a slash, but the first part is not a single - // letter, so prefix $PANDA_ROOT. + // letter. +#ifdef HAVE_CYGWIN + // Use Cygwin to convert it if possible. + char result[4096] = ""; + cygwin_conv_to_win32_path(unix_style_pathname.c_str(), result); + windows_pathname = result; +#else // HAVE_CYGWIN + // Without Cygwin, just prefix $PANDA_ROOT. windows_pathname = get_panda_root() + front_to_back_slash(unix_style_pathname.substr(1)); +#endif // HAVE_CYGWIN } return windows_pathname; @@ -250,7 +264,7 @@ Filename(const Filename &dirname, const Filename &basename) { //////////////////////////////////////////////////////////////////// Filename Filename:: from_os_specific(const string &os_specific, Filename::Type type) { -#if defined(WIN32) +#ifdef WIN32 string result = back_to_front_slash(os_specific); const string &panda_root = get_panda_root(); @@ -291,13 +305,12 @@ from_os_specific(const string &os_specific, Filename::Type type) { Filename filename(result); filename.set_type(type); return filename; - -#else +#else // WIN32 // Generic Unix-style filenames--no conversion necessary. Filename filename(os_specific); filename.set_type(type); return filename; -#endif +#endif // WIN32 } //////////////////////////////////////////////////////////////////// diff --git a/ppremake/ppCommandFile.cxx b/ppremake/ppCommandFile.cxx index 51d087cb5a..a4463b8b50 100644 --- a/ppremake/ppCommandFile.cxx +++ b/ppremake/ppCommandFile.cxx @@ -1694,7 +1694,7 @@ compare_output(const string &new_contents, Filename filename, diff_ok = true; } out_b.close(); - string command = "diff -u '" + filename.get_fullpath() + "' '" + + string command = "diff -ub '" + filename.get_fullpath() + "' '" + temp_filename.get_fullpath() + "'"; int sys_result = system(command.c_str()); if (sys_result < 0) { diff --git a/ppremake/ppScope.cxx b/ppremake/ppScope.cxx index 3000c094bf..5cff0d51f4 100644 --- a/ppremake/ppScope.cxx +++ b/ppremake/ppScope.cxx @@ -47,11 +47,6 @@ PPScope::MapVariableDefinition PPScope::_null_map_def; PPScope::ScopeStack PPScope::_scope_stack; -#ifdef PLATFORM_CYGWIN -extern "C" void cygwin_conv_to_win32_path(const char *path, char *win32); -extern "C" void cygwin_conv_to_posix_path(const char *path, char *posix); -#endif - //////////////////////////////////////////////////////////////////// // Function: PPScope::Constructor // Access: Public @@ -895,9 +890,11 @@ r_expand_variable(const string &str, size_t &vp, } else if (funcname == "unixfilename") { return expand_unixfilename(params); } else if (funcname == "cygpath_w") { - return expand_cygpath_w(params); + // This maps to osfilename for historical reasons. + return expand_osfilename(params); } else if (funcname == "cygpath_p") { - return expand_cygpath_p(params); + // This maps to unixfilename for historical reasons. + return expand_unixfilename(params); } else if (funcname == "wildcard") { return expand_wildcard(params); } else if (funcname == "isdir") { @@ -1205,70 +1202,6 @@ expand_unixfilename(const string ¶ms) { return result; } -//////////////////////////////////////////////////////////////////// -// Function: PPScope::expand_cygpath_w -// Access: Private -// Description: Expands the "cygpath_w" function variable. -// -// This converts the Unix-style filename to a Windows -// filename using the Cygwin rules when ppremake has -// been compiled with Cygwin; it is thus equivalent to -// the result of the cygpath -w command. -// -// When Cygwin is not available, this returns the same -// as the "osfilename" variable. -//////////////////////////////////////////////////////////////////// -string PPScope:: -expand_cygpath_w(const string ¶ms) { - string filename = trim_blanks(expand_string(params)); - -#ifdef PLATFORM_CYGWIN - char result[4096]; - - // In Win32, we're either running Cygwin, in which case this - // function is statically linked in and definitely non-NULL, or - // we're running native Win32, in which case this function may or - // may not have been dynamically linked in. In either case, use it - // if we've got it. - cygwin_conv_to_win32_path(filename.c_str(), result); - filename = result; -#else - Filename fn(filename); - filename = fn.to_os_specific(); -#endif // PLATFORM_CYGWIN - - return filename; -} - -//////////////////////////////////////////////////////////////////// -// Function: PPScope::expand_cygpath_p -// Access: Private -// Description: Expands the "cygpath_p" function variable. -// -// This converts the Windows filename to a Unix-style -// filename using the Cygwin rules when ppremake has -// been compiled with Cygwin; it is thus equivalent to -// the result of the cygpath -p command. -// -// When Cygwin is not available, this returns the same -// as the "unixfilename" variable. -//////////////////////////////////////////////////////////////////// -string PPScope:: -expand_cygpath_p(const string ¶ms) { - string filename = trim_blanks(expand_string(params)); - -#ifdef PLATFORM_CYGWIN - char result[4096]; - - cygwin_conv_to_posix_path(filename.c_str(), result); - filename = result; -#else - filename = Filename::from_os_specific(filename); -#endif // PLATFORM_CYGWIN - - return filename; -} - //////////////////////////////////////////////////////////////////// // Function: PPScope::expand_wildcard // Access: Private diff --git a/ppremake/ppremake.h b/ppremake/ppremake.h index 45364d92c9..07e77556b0 100644 --- a/ppremake/ppremake.h +++ b/ppremake/ppremake.h @@ -27,7 +27,7 @@ #include #endif -#if defined(PLATFORM_CYGWIN) || defined(WIN32_VC) +#if defined(HAVE_CYGWIN) || defined(WIN32_VC) // Either Cygwin or Visual C++ is a Win32 environment. #define WIN32 #endif