From 0ba391bc6f8b84a7b2a252ac8c435b4d5afdda33 Mon Sep 17 00:00:00 2001 From: Dan Kegel Date: Mon, 5 Jun 2017 17:41:13 -0700 Subject: [PATCH] Miscelaneous tweaks for Visual C in Cygwin compatibility --- main.c | 14 ++++++++++++++ tests/test_env.sh.in | 30 ++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 35a4854..d06b471 100644 --- a/main.c +++ b/main.c @@ -17,6 +17,10 @@ #include #include "config.h" #include "getopt_long.h" +#ifdef _WIN32 +#include /* for _setmode() */ +#include +#endif #define PKG_CFLAGS_ONLY_I (((uint64_t) 1) << 2) #define PKG_CFLAGS_ONLY_OTHER (((uint64_t) 1) << 3) @@ -652,6 +656,16 @@ main(int argc, char *argv[]) want_flags = 0; +#ifdef _WIN32 + /* When running regression tests in cygwin, and building native + * executable, tests fail unless native executable outputs unix + * line endings. Come to think of it, this will probably help + * real people who use cygwin build environments but native pkgconf, too. + */ + _setmode(fileno(stdout), O_BINARY); + _setmode(fileno(stderr), O_BINARY); +#endif + struct pkg_option options[] = { { "version", no_argument, &want_flags, PKG_VERSION|PKG_PRINT_ERRORS, }, { "about", no_argument, &want_flags, PKG_ABOUT|PKG_PRINT_ERRORS, }, diff --git a/tests/test_env.sh.in b/tests/test_env.sh.in index cf0cfc4..3120811 100644 --- a/tests/test_env.sh.in +++ b/tests/test_env.sh.in @@ -1,10 +1,32 @@ -export PATH="$(atf_get_srcdir)/../:${PATH}" +srcdir="$(atf_get_srcdir)" +export PATH="$srcdir/..:${PATH}" + +#--- begin windows kludge --- +# When building with Visual Studio, binaries are in a subdirectory named after the configration... +# and the configuration is not known unless you're in the IDE, or something. +# So just guess. This won't work well if you build more than one configuration. +the_configuration="" +for configuration in Debug Release RelWithDebInfo +do + if test -d "$srcdir/../$configuration" + then + if test "$the_configuration" != "" + then + echo "test_env.sh: FAIL: more than one configuration found" + exit 1 + fi + the_configuration=$configuration + export PATH="$srcdir/../${configuration}:${PATH}" + fi +done +#--- end kludge --- + selfdir="@abs_top_srcdir@/tests" PATH_SEP=":" SYSROOT_DIR="${selfdir}/test" -if [ "$(uname -s)" = "Msys" ]; then - PATH_SEP=";" -fi +case "$(uname -s)" in +Msys|CYGWIN*) PATH_SEP=";";; +esac prefix="@prefix@" exec_prefix="@exec_prefix@"