aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-08-07 17:35:10 -0400
committerGitHub <noreply@github.com>2016-08-07 17:35:10 -0400
commitf1eb3031871b380162cf6407405367d707e7d9cc (patch)
tree9a32d109dcfd6dbeff18ed38a80dbd079909c2bf
parent6050d3f15dea67759afa4bcc68a3cd9feeaabe98 (diff)
parent6bcaea7c41e82a3435d903c6f99fd791cc343059 (diff)
downloadrneovim-f1eb3031871b380162cf6407405367d707e7d9cc.tar.gz
rneovim-f1eb3031871b380162cf6407405367d707e7d9cc.tar.bz2
rneovim-f1eb3031871b380162cf6407405367d707e7d9cc.zip
Merge #5130 from equalsraf/tb-appveyor
Enable MSYS/MinGW builds in Appveyor
-rwxr-xr-x.ci/before_script.sh4
-rw-r--r--.ci/common/build.sh6
-rwxr-xr-x.ci/install.sh7
-rw-r--r--.ci/msys_build.bat24
-rw-r--r--.ci/msys_build_deps.bat27
-rwxr-xr-x.ci/run_tests.sh8
-rw-r--r--.travis.yml8
-rw-r--r--CMakeLists.txt12
-rw-r--r--appveyor.yml38
-rw-r--r--cmake/FindMsgpack.cmake7
-rw-r--r--cmake/WindowsDllCopy.cmake30
-rw-r--r--src/nvim/CMakeLists.txt15
-rw-r--r--src/nvim/main.c7
-rw-r--r--src/nvim/os/fs.c151
-rw-r--r--test/functional/fixtures/tty-test.c4
-rw-r--r--third-party/CMakeLists.txt6
-rw-r--r--third-party/cmake/BuildLibuv.cmake27
-rw-r--r--third-party/cmake/BuildLibvterm.cmake75
-rw-r--r--third-party/cmake/BuildLuajit.cmake30
-rw-r--r--third-party/cmake/BuildLuarocks.cmake15
-rw-r--r--third-party/cmake/BuildLuv.cmake1
-rw-r--r--third-party/cmake/BuildMsgpack.cmake18
-rw-r--r--third-party/cmake/CopyFilesGlob.cmake2
-rw-r--r--third-party/cmake/LibvtermCMakeLists.txt72
24 files changed, 472 insertions, 122 deletions
diff --git a/.ci/before_script.sh b/.ci/before_script.sh
index 23940ab2e2..4a75e89fbe 100755
--- a/.ci/before_script.sh
+++ b/.ci/before_script.sh
@@ -19,10 +19,6 @@ if [[ -n "${LLVM_SYMBOLIZER}" ]] && [[ ! $(type -P "${LLVM_SYMBOLIZER}") ]]; the
echo "\$LLVM_SYMBOLIZER: '${LLVM_SYMBOLIZER}' is not executable."
exit 1
fi
-if [ "${BUILD_32BIT}" = ON ] && [ "${BUILD_MINGW}" = ON ]; then
- >&2 echo "32-bit MinGW builds not supported."
- exit 1
-fi
if [[ "${TRAVIS_OS_NAME}" == osx ]]; then
# Adds user to a dummy group.
diff --git a/.ci/common/build.sh b/.ci/common/build.sh
index c89d4c559b..5cf34935d6 100644
--- a/.ci/common/build.sh
+++ b/.ci/common/build.sh
@@ -2,9 +2,6 @@ build_deps() {
if [[ "${BUILD_32BIT}" == ON ]]; then
DEPS_CMAKE_FLAGS="${DEPS_CMAKE_FLAGS} ${CMAKE_FLAGS_32BIT}"
fi
- if [[ "${BUILD_MINGW}" == ON ]]; then
- DEPS_CMAKE_FLAGS="${DEPS_CMAKE_FLAGS} ${CMAKE_FLAGS_MINGW}"
- fi
if [[ "${FUNCTIONALTEST}" == "functionaltest-lua" ]]; then
DEPS_CMAKE_FLAGS="${DEPS_CMAKE_FLAGS} -DUSE_BUNDLED_LUA=ON"
fi
@@ -47,9 +44,6 @@ build_nvim() {
if [[ "${BUILD_32BIT}" == ON ]]; then
CMAKE_FLAGS="${CMAKE_FLAGS} ${CMAKE_FLAGS_32BIT}"
fi
- if [[ "${BUILD_MINGW}" == ON ]]; then
- CMAKE_FLAGS="${CMAKE_FLAGS} ${CMAKE_FLAGS_MINGW}"
- fi
mkdir -p "${BUILD_DIR}"
cd "${BUILD_DIR}"
diff --git a/.ci/install.sh b/.ci/install.sh
index f809bb06ea..9df5b6e980 100755
--- a/.ci/install.sh
+++ b/.ci/install.sh
@@ -10,13 +10,6 @@ fi
if [[ "${TRAVIS_OS_NAME}" == osx ]]; then
brew install gettext
brew reinstall -s libtool
-elif [[ "${BUILD_MINGW}" == ON ]]; then
- # TODO: When Travis gets a recent version of Mingw-w64 use packages:
- # binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64-dev mingw-w64-tools
-
- echo "Downloading MinGW..."
- curl -sSL "https://github.com/neovim/deps/raw/master/opt/i686-w64-mingw32-gcc-4.8.0-linux64_rubenvb.tar.xz" \
- | tar xJf - -C "${HOME}/.local"
fi
# Use default CC to avoid compilation problems when installing Python modules.
diff --git a/.ci/msys_build.bat b/.ci/msys_build.bat
new file mode 100644
index 0000000000..bf77b5bd34
--- /dev/null
+++ b/.ci/msys_build.bat
@@ -0,0 +1,24 @@
+echo on
+if "%TARGET%" == "MINGW_32" (
+ set ARCH=i686
+ set BITS=32
+) else (
+ set ARCH=x86_64
+ set BITS=64
+)
+:: We cannot have sh.exe in the PATH (MinGW)
+set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
+set PATH=C:\msys64\mingw%BITS%\bin;C:\Windows\System32;C:\Windows;%PATH%
+
+mkdir build
+cd build
+cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release .. || goto :error
+:: FIXME(equalsraf): for now just build nvim and copy DLLs.
+:: We can't generate the helptags just yet (#810 fixes this)
+mingw32-make nvim_dll_deps VERBOSE=1 || goto :error
+bin\nvim --version || goto :error
+cd ..
+
+goto :EOF
+:error
+exit /b %errorlevel%
diff --git a/.ci/msys_build_deps.bat b/.ci/msys_build_deps.bat
new file mode 100644
index 0000000000..67e7c69883
--- /dev/null
+++ b/.ci/msys_build_deps.bat
@@ -0,0 +1,27 @@
+:: These are native MinGW builds, but they use the toolchain inside
+:: MSYS2, this allows using all the dependencies and tools available
+:: in MSYS2, but we cannot build inside the MSYS2 shell.
+echo on
+if "%TARGET%" == "MINGW_32" (
+ set ARCH=i686
+ set BITS=32
+) else (
+ set ARCH=x86_64
+ set BITS=64
+)
+:: We cannot have sh.exe in the PATH (MinGW)
+set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
+set PATH=C:\msys64\mingw%BITS%\bin;C:\Windows\System32;C:\Windows;%PATH%
+
+C:\msys64\usr\bin\bash -lc "pacman --verbose --noconfirm -Su" || goto :error
+C:\msys64\usr\bin\bash -lc "pacman --verbose --noconfirm --needed -S mingw-w64-%ARCH%-cmake mingw-w64-%ARCH%-perl mingw-w64-%ARCH%-python2 mingw-w64-%ARCH%-diffutils" || goto :error
+
+mkdir .deps
+cd .deps
+cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release ..\third-party\ || goto :error
+mingw32-make VERBOSE=1 || goto :error
+cd ..
+
+goto :EOF
+:error
+exit /b %errorlevel%
diff --git a/.ci/run_tests.sh b/.ci/run_tests.sh
index 656ea16e37..d542a2f121 100755
--- a/.ci/run_tests.sh
+++ b/.ci/run_tests.sh
@@ -3,14 +3,6 @@
set -e
set -o pipefail
-# TODO: Stop here for MinGW builds,
-# building Neovim doesn't work yet.
-if [[ "${BUILD_MINGW}" == ON ]]; then
- echo "Neovim doesn't build on MinGW yet; stopping build."
- touch "${SUCCESS_MARKER}"
- exit
-fi
-
CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${CI_DIR}/common/build.sh"
source "${CI_DIR}/common/test.sh"
diff --git a/.travis.yml b/.travis.yml
index 9d529c2632..84caa349ea 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,8 +8,8 @@ env:
# Travis has 1.5 virtual cores according to
# http://docs.travis-ci.com/user/speeding-up-the-build/#Paralellizing-your-build-on-one-VM
- MAKE_CMD="make -j2"
- # Update PATH for pip and MinGW.
- - PATH="$(python2.7 -c 'import site; print(site.getuserbase())')/bin:$HOME/.local/mingw32/bin:$PATH"
+ # Update PATH for pip.
+ - PATH="$(python2.7 -c 'import site; print(site.getuserbase())')/bin:$PATH"
# LLVM symbolizer path.
- LLVM_SYMBOLIZER="$(which llvm-symbolizer-3.4)"
# Build directory for Neovim.
@@ -34,8 +34,6 @@ env:
- CMAKE_FLAGS_32BIT="-DCMAKE_SYSTEM_LIBRARY_PATH=/lib32:/usr/lib32:/usr/local/lib32
-DCMAKE_IGNORE_PATH=/lib:/usr/lib:/usr/local/lib
-DCMAKE_TOOLCHAIN_FILE=$TRAVIS_BUILD_DIR/cmake/i386-linux-gnu.toolchain.cmake"
- # Additional CMake flags for MinGW builds.
- - CMAKE_FLAGS_MINGW="-DCMAKE_TOOLCHAIN_FILE=$TRAVIS_BUILD_DIR/cmake/mingw32-w64-cross-travis.toolchain.cmake"
# Environment variables for Clang sanitizers.
- ASAN_OPTIONS="detect_leaks=1:check_initialization_order=1:log_path=$LOG_DIR/asan"
- ASAN_SYMBOLIZER_PATH="$LLVM_SYMBOLIZER"
@@ -81,8 +79,6 @@ matrix:
compiler: clang
- os: osx
compiler: gcc-4.9
- - os: linux
- env: BUILD_MINGW=ON
fast_finish: true
before_install: .ci/before_install.sh
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1787f4e306..3877699af9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -398,7 +398,11 @@ message(STATUS "Using the Lua interpreter ${LUA_PRG}.")
find_program(BUSTED_PRG busted)
find_program(BUSTED_LUA_PRG busted-lua)
if(NOT BUSTED_OUTPUT_TYPE)
- set(BUSTED_OUTPUT_TYPE "utfTerminal")
+ if(WIN32)
+ set(BUSTED_OUTPUT_TYPE "plainTerminal")
+ else()
+ set(BUSTED_OUTPUT_TYPE "utfTerminal")
+ endif()
endif()
find_program(LUACHECK_PRG luacheck)
@@ -466,7 +470,11 @@ if(BUSTED_PRG)
${CMAKE_BINARY_DIR}/test/config/paths.lua)
set(UNITTEST_PREREQS nvim-test unittest-headers)
- set(FUNCTIONALTEST_PREREQS nvim tty-test shell-test)
+ if(WIN32)
+ set(FUNCTIONALTEST_PREREQS nvim shell-test)
+ else()
+ set(FUNCTIONALTEST_PREREQS nvim tty-test shell-test)
+ endif()
set(BENCHMARK_PREREQS nvim tty-test)
# Useful for automated build systems, if they want to manually run the tests.
diff --git a/appveyor.yml b/appveyor.yml
index c5a768cb41..26008bbed3 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,23 +1,27 @@
version: '{build}'
skip_tags: true
-os: Windows Server 2012 R2
environment:
- GYP_MSVS_VERSION: 2015
+ # The default cpack in the PATH is not CMake
+ CPACK: C:\Program Files (x86)\CMake\bin\cpack.exe
matrix:
- - GENERATOR: Visual Studio 14 Win64
- DEPS_PATH: deps64
- - GENERATOR: Visual Studio 14
- DEPS_PATH: deps32
-matrix:
- # Allow builds to fail
- allow_failures:
- - os: Windows Server 2012 R2
+ - TARGET: MINGW_64
+ BUILD_DEPS_SCRIPT: .ci\msys_build_deps.bat
+ BUILD_SCRIPT: .ci\msys_build.bat
+ - TARGET: MINGW_32
+ BUILD_DEPS_SCRIPT: .ci\msys_build_deps.bat
+ BUILD_SCRIPT: .ci\msys_build.bat
install: []
build_script:
-# See http://help.appveyor.com/discussions/problems/539-cloning-gyp-fails
-- git config --global url."http://".insteadOf https://
-- mkdir %DEPS_PATH%
-- cd %DEPS_PATH%
-- cmake -G "%GENERATOR%" ..\third-party\
-- cmake --build .
-- cd ..
+- if defined BUILD_DEPS_SCRIPT call %BUILD_DEPS_SCRIPT%
+- call %BUILD_SCRIPT%
+# FIXME(equalsraf): don't generate artifacts until the
+# build script builds the main target, for now pack bin/
+artifacts:
+- path: build/bin
+# Build artifacts
+#- cd build
+#- '"%CPACK%" -G NSIS -C Release'
+#- '"%CPACK%" -G ZIP -C Release'
+#artifacts:
+#- path: build/Neovim.zip
+#- path: build/Neovim.exe
diff --git a/cmake/FindMsgpack.cmake b/cmake/FindMsgpack.cmake
index 015737d658..8881a34332 100644
--- a/cmake/FindMsgpack.cmake
+++ b/cmake/FindMsgpack.cmake
@@ -42,7 +42,12 @@ if(MSGPACK_USE_STATIC)
"${CMAKE_STATIC_LIBRARY_PREFIX}msgpack${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()
-list(APPEND MSGPACK_NAMES msgpackc msgpack)
+if(MSVC)
+ # The import library for the msgpack DLL has a different name
+ list(APPEND MSGPACK_NAMES msgpack_import)
+else()
+ list(APPEND MSGPACK_NAMES msgpackc msgpack)
+endif()
find_library(MSGPACK_LIBRARY NAMES ${MSGPACK_NAMES}
# Check each directory for all names to avoid using headers/libraries from
diff --git a/cmake/WindowsDllCopy.cmake b/cmake/WindowsDllCopy.cmake
new file mode 100644
index 0000000000..fbbabf3a0c
--- /dev/null
+++ b/cmake/WindowsDllCopy.cmake
@@ -0,0 +1,30 @@
+# In Windows we need to find dependency DLLs and install them along with our
+# binaries. This script uses the following variables:
+#
+# - BINARY: The binary file whose dependencies need to be installed
+# - DST: The destination path
+# - CMAKE_PREFIX_PATH: A list of directories to search for dependencies
+
+if(NOT DEFINED BINARY)
+ message(FATAL_ERROR "Missing required argument -DBINARY=")
+endif()
+if(NOT DEFINED DST)
+ message(FATAL_ERROR "Missing required arguments -DDST=")
+endif()
+if(NOT DEFINED CMAKE_PREFIX_PATH)
+ message(FATAL_ERROR "Missing required arguments -DCMAKE_PREFIX_PATH=")
+endif()
+
+include(GetPrerequisites)
+get_prerequisites(${BINARY} DLLS 1 1 "" "${CMAKE_PREFIX_PATH}")
+foreach(DLL_NAME ${DLLS})
+ find_program(DLL_PATH ${DLL_NAME})
+ if(NOT DLL_PATH)
+ message(FATAL_ERROR "Unable to find dependency ${DLL_NAME}")
+ endif()
+
+ message("Copying ${DLL_NAME} to ${DST}")
+ execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${DLL_PATH} ${DST})
+ unset(DLL_PATH CACHE)
+endforeach()
+
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index d80add2835..5c4df1be0b 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -259,6 +259,21 @@ add_executable(nvim ${NEOVIM_GENERATED_SOURCES} ${NEOVIM_SOURCES}
target_link_libraries(nvim ${NVIM_EXEC_LINK_LIBRARIES})
install_helper(TARGETS nvim)
+if(WIN32)
+ # Copy DLLs to bin/ and install them along with nvim
+ add_custom_target(nvim_dll_deps ALL DEPENDS nvim
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/windows_runtime_deps
+ COMMAND ${CMAKE_COMMAND}
+ "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"
+ -DBINARY="${PROJECT_BINARY_DIR}/bin/nvim${CMAKE_EXECUTABLE_SUFFIX}"
+ -DDST=${PROJECT_BINARY_DIR}/windows_runtime_deps
+ -P ${PROJECT_SOURCE_DIR}/cmake/WindowsDllCopy.cmake
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_BINARY_DIR}/windows_runtime_deps/
+ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
+ install(DIRECTORY ${PROJECT_BINARY_DIR}/windows_runtime_deps/
+ DESTINATION ${CMAKE_INSTALL_BINDIR})
+endif()
+
if(CLANG_ASAN_UBSAN)
message(STATUS "Enabling Clang address sanitizer and undefined behavior sanitizer for nvim.")
check_c_compiler_flag(-fno-sanitize-recover=all SANITIZE_RECOVER_ALL)
diff --git a/src/nvim/main.c b/src/nvim/main.c
index e052d0d315..b5c51e3444 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -251,8 +251,9 @@ int main(int argc, char **argv)
*/
command_line_scan(&params);
- if (GARGCOUNT > 0)
- fname = get_fname(&params);
+ if (GARGCOUNT > 0) {
+ fname = get_fname(&params, cwd);
+ }
TIME_MSG("expanding arguments");
@@ -1196,7 +1197,7 @@ static void check_and_set_isatty(mparm_T *paramp)
/*
* Get filename from command line, given that there is one.
*/
-static char_u *get_fname(mparm_T *parmp)
+static char_u *get_fname(mparm_T *parmp, char_u *cwd)
{
#if !defined(UNIX)
/*
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index cd943c4843..e63b8b6793 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -399,14 +399,7 @@ ptrdiff_t os_read(const int fd, bool *ret_eof, char *const ret_buf,
assert(read_bytes <= size);
}
if (cur_read_bytes < 0) {
-#ifdef HAVE_UV_TRANSLATE_SYS_ERROR
- const int error = uv_translate_sys_error(errno);
-#else
- const int error = -errno;
- STATIC_ASSERT(-EINTR == UV_EINTR, "Need to translate error codes");
- STATIC_ASSERT(-EAGAIN == UV_EAGAIN, "Need to translate error codes");
- STATIC_ASSERT(-ENOMEM == UV_ENOMEM, "Need to translate error codes");
-#endif
+ const int error = os_translate_sys_error(errno);
errno = 0;
if (error == UV_EINTR || error == UV_EAGAIN) {
continue;
@@ -469,14 +462,7 @@ ptrdiff_t os_readv(int fd, bool *ret_eof, struct iovec *iov, size_t iov_size)
}
}
} else if (cur_read_bytes < 0) {
-#ifdef HAVE_UV_TRANSLATE_SYS_ERROR
- const int error = uv_translate_sys_error(errno);
-#else
- const int error = -errno;
- STATIC_ASSERT(-EINTR == UV_EINTR, "Need to translate error codes");
- STATIC_ASSERT(-EAGAIN == UV_EAGAIN, "Need to translate error codes");
- STATIC_ASSERT(-ENOMEM == UV_ENOMEM, "Need to translate error codes");
-#endif
+ const int error = os_translate_sys_error(errno);
errno = 0;
if (error == UV_EINTR || error == UV_EAGAIN) {
continue;
@@ -515,15 +501,7 @@ ptrdiff_t os_write(const int fd, const char *const buf, const size_t size)
written_bytes += (size_t)cur_written_bytes;
}
if (cur_written_bytes < 0) {
-#ifdef HAVE_UV_TRANSLATE_SYS_ERROR
- const int error = uv_translate_sys_error(errno);
-#else
- const int error = -errno;
- STATIC_ASSERT(-EINTR == UV_EINTR, "Need to translate error codes");
- STATIC_ASSERT(-EAGAIN == UV_EAGAIN, "Need to translate error codes");
- // According to the man page open() may fail with ENOMEM, but write()
- // can’t.
-#endif
+ const int error = os_translate_sys_error(errno);
errno = 0;
if (error == UV_EINTR || error == UV_EAGAIN) {
continue;
@@ -1023,3 +1001,126 @@ shortcut_end:
}
#endif
+
+int os_translate_sys_error(int sys_errno) {
+#ifdef HAVE_UV_TRANSLATE_SYS_ERROR
+ return uv_translate_sys_error(sys_errno);
+#elif WIN32
+ // TODO(equalsraf): libuv does not yet expose uv_translate_sys_error()
+ // in its public API, include a version here until it can be used.
+ // See https://github.com/libuv/libuv/issues/79
+# ifndef ERROR_SYMLINK_NOT_SUPPORTED
+# define ERROR_SYMLINK_NOT_SUPPORTED 1464
+# endif
+
+ if (sys_errno <= 0) {
+ return sys_errno; // If < 0 then it's already a libuv error
+ }
+
+ switch (sys_errno) {
+ case ERROR_NOACCESS: return UV_EACCES;
+ case WSAEACCES: return UV_EACCES;
+ case ERROR_ADDRESS_ALREADY_ASSOCIATED: return UV_EADDRINUSE;
+ case WSAEADDRINUSE: return UV_EADDRINUSE;
+ case WSAEADDRNOTAVAIL: return UV_EADDRNOTAVAIL;
+ case WSAEAFNOSUPPORT: return UV_EAFNOSUPPORT;
+ case WSAEWOULDBLOCK: return UV_EAGAIN;
+ case WSAEALREADY: return UV_EALREADY;
+ case ERROR_INVALID_FLAGS: return UV_EBADF;
+ case ERROR_INVALID_HANDLE: return UV_EBADF;
+ case ERROR_LOCK_VIOLATION: return UV_EBUSY;
+ case ERROR_PIPE_BUSY: return UV_EBUSY;
+ case ERROR_SHARING_VIOLATION: return UV_EBUSY;
+ case ERROR_OPERATION_ABORTED: return UV_ECANCELED;
+ case WSAEINTR: return UV_ECANCELED;
+ case ERROR_NO_UNICODE_TRANSLATION: return UV_ECHARSET;
+ case ERROR_CONNECTION_ABORTED: return UV_ECONNABORTED;
+ case WSAECONNABORTED: return UV_ECONNABORTED;
+ case ERROR_CONNECTION_REFUSED: return UV_ECONNREFUSED;
+ case WSAECONNREFUSED: return UV_ECONNREFUSED;
+ case ERROR_NETNAME_DELETED: return UV_ECONNRESET;
+ case WSAECONNRESET: return UV_ECONNRESET;
+ case ERROR_ALREADY_EXISTS: return UV_EEXIST;
+ case ERROR_FILE_EXISTS: return UV_EEXIST;
+ case ERROR_BUFFER_OVERFLOW: return UV_EFAULT;
+ case WSAEFAULT: return UV_EFAULT;
+ case ERROR_HOST_UNREACHABLE: return UV_EHOSTUNREACH;
+ case WSAEHOSTUNREACH: return UV_EHOSTUNREACH;
+ case ERROR_INSUFFICIENT_BUFFER: return UV_EINVAL;
+ case ERROR_INVALID_DATA: return UV_EINVAL;
+ case ERROR_INVALID_PARAMETER: return UV_EINVAL;
+ case ERROR_SYMLINK_NOT_SUPPORTED: return UV_EINVAL;
+ case WSAEINVAL: return UV_EINVAL;
+ case WSAEPFNOSUPPORT: return UV_EINVAL;
+ case WSAESOCKTNOSUPPORT: return UV_EINVAL;
+ case ERROR_BEGINNING_OF_MEDIA: return UV_EIO;
+ case ERROR_BUS_RESET: return UV_EIO;
+ case ERROR_CRC: return UV_EIO;
+ case ERROR_DEVICE_DOOR_OPEN: return UV_EIO;
+ case ERROR_DEVICE_REQUIRES_CLEANING: return UV_EIO;
+ case ERROR_DISK_CORRUPT: return UV_EIO;
+ case ERROR_EOM_OVERFLOW: return UV_EIO;
+ case ERROR_FILEMARK_DETECTED: return UV_EIO;
+ case ERROR_GEN_FAILURE: return UV_EIO;
+ case ERROR_INVALID_BLOCK_LENGTH: return UV_EIO;
+ case ERROR_IO_DEVICE: return UV_EIO;
+ case ERROR_NO_DATA_DETECTED: return UV_EIO;
+ case ERROR_NO_SIGNAL_SENT: return UV_EIO;
+ case ERROR_OPEN_FAILED: return UV_EIO;
+ case ERROR_SETMARK_DETECTED: return UV_EIO;
+ case ERROR_SIGNAL_REFUSED: return UV_EIO;
+ case WSAEISCONN: return UV_EISCONN;
+ case ERROR_CANT_RESOLVE_FILENAME: return UV_ELOOP;
+ case ERROR_TOO_MANY_OPEN_FILES: return UV_EMFILE;
+ case WSAEMFILE: return UV_EMFILE;
+ case WSAEMSGSIZE: return UV_EMSGSIZE;
+ case ERROR_FILENAME_EXCED_RANGE: return UV_ENAMETOOLONG;
+ case ERROR_NETWORK_UNREACHABLE: return UV_ENETUNREACH;
+ case WSAENETUNREACH: return UV_ENETUNREACH;
+ case WSAENOBUFS: return UV_ENOBUFS;
+ case ERROR_BAD_PATHNAME: return UV_ENOENT;
+ case ERROR_DIRECTORY: return UV_ENOENT;
+ case ERROR_FILE_NOT_FOUND: return UV_ENOENT;
+ case ERROR_INVALID_NAME: return UV_ENOENT;
+ case ERROR_INVALID_DRIVE: return UV_ENOENT;
+ case ERROR_INVALID_REPARSE_DATA: return UV_ENOENT;
+ case ERROR_MOD_NOT_FOUND: return UV_ENOENT;
+ case ERROR_PATH_NOT_FOUND: return UV_ENOENT;
+ case WSAHOST_NOT_FOUND: return UV_ENOENT;
+ case WSANO_DATA: return UV_ENOENT;
+ case ERROR_NOT_ENOUGH_MEMORY: return UV_ENOMEM;
+ case ERROR_OUTOFMEMORY: return UV_ENOMEM;
+ case ERROR_CANNOT_MAKE: return UV_ENOSPC;
+ case ERROR_DISK_FULL: return UV_ENOSPC;
+ case ERROR_EA_TABLE_FULL: return UV_ENOSPC;
+ case ERROR_END_OF_MEDIA: return UV_ENOSPC;
+ case ERROR_HANDLE_DISK_FULL: return UV_ENOSPC;
+ case ERROR_NOT_CONNECTED: return UV_ENOTCONN;
+ case WSAENOTCONN: return UV_ENOTCONN;
+ case ERROR_DIR_NOT_EMPTY: return UV_ENOTEMPTY;
+ case WSAENOTSOCK: return UV_ENOTSOCK;
+ case ERROR_NOT_SUPPORTED: return UV_ENOTSUP;
+ case ERROR_BROKEN_PIPE: return UV_EOF;
+ case ERROR_ACCESS_DENIED: return UV_EPERM;
+ case ERROR_PRIVILEGE_NOT_HELD: return UV_EPERM;
+ case ERROR_BAD_PIPE: return UV_EPIPE;
+ case ERROR_NO_DATA: return UV_EPIPE;
+ case ERROR_PIPE_NOT_CONNECTED: return UV_EPIPE;
+ case WSAESHUTDOWN: return UV_EPIPE;
+ case WSAEPROTONOSUPPORT: return UV_EPROTONOSUPPORT;
+ case ERROR_WRITE_PROTECT: return UV_EROFS;
+ case ERROR_SEM_TIMEOUT: return UV_ETIMEDOUT;
+ case WSAETIMEDOUT: return UV_ETIMEDOUT;
+ case ERROR_NOT_SAME_DEVICE: return UV_EXDEV;
+ case ERROR_INVALID_FUNCTION: return UV_EISDIR;
+ case ERROR_META_EXPANSION_TOO_LONG: return UV_E2BIG;
+ default: return UV_UNKNOWN;
+ }
+#else
+ const int error = -errno;
+ STATIC_ASSERT(-EINTR == UV_EINTR, "Need to translate error codes");
+ STATIC_ASSERT(-EAGAIN == UV_EAGAIN, "Need to translate error codes");
+ STATIC_ASSERT(-ENOMEM == UV_ENOMEM, "Need to translate error codes");
+ return error;
+#endif
+}
diff --git a/test/functional/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c
index 40ba131003..ca905ce65e 100644
--- a/test/functional/fixtures/tty-test.c
+++ b/test/functional/fixtures/tty-test.c
@@ -31,12 +31,14 @@ static void walk_cb(uv_handle_t *handle, void *arg) {
}
}
+#ifndef WIN32
static void sigwinch_handler(int signum)
{
int width, height;
uv_tty_get_winsize(&tty, &width, &height);
fprintf(stderr, "rows: %d, cols: %d\n", height, width);
}
+#endif
// static void sigwinch_cb(uv_signal_t *handle, int signum)
// {
@@ -135,6 +137,7 @@ int main(int argc, char **argv)
uv_tty_set_mode(&tty, UV_TTY_MODE_RAW);
tty.data = &interrupted;
uv_read_start((uv_stream_t *)&tty, alloc_cb, read_cb);
+#ifndef WIN32
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
@@ -144,6 +147,7 @@ int main(int argc, char **argv)
// uv_signal_init(uv_default_loop(), &sigwinch_watcher);
// sigwinch_watcher.data = &tty;
// uv_signal_start(&sigwinch_watcher, sigwinch_cb, SIGWINCH);
+#endif
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
return 0;
diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt
index 9fc1b2eb36..7eba17aba3 100644
--- a/third-party/CMakeLists.txt
+++ b/third-party/CMakeLists.txt
@@ -5,6 +5,12 @@ project(NEOVIM_DEPS)
# Point CMake at any custom modules we may ship
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
+# In Windows/MSVC CMAKE_BUILD_TYPE changes the paths/linking of the build
+# recipes (libuv, msgpack), make sure it is set
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Release)
+endif()
+
set(DEPS_INSTALL_DIR "${CMAKE_BINARY_DIR}/usr" CACHE PATH "Dependencies install directory.")
set(DEPS_BIN_DIR "${DEPS_INSTALL_DIR}/bin" CACHE PATH "Dependencies binary install directory.")
set(DEPS_LIB_DIR "${DEPS_INSTALL_DIR}/lib" CACHE PATH "Dependencies library install directory.")
diff --git a/third-party/cmake/BuildLibuv.cmake b/third-party/cmake/BuildLibuv.cmake
index 1d8d69e64e..5482f28557 100644
--- a/third-party/cmake/BuildLibuv.cmake
+++ b/third-party/cmake/BuildLibuv.cmake
@@ -5,7 +5,7 @@ include(CMakeParseArguments)
# Failing to pass a command argument will result in no command being run
function(BuildLibuv)
cmake_parse_arguments(_libuv
- ""
+ "BUILD_IN_SOURCE"
"TARGET"
"CONFIGURE_COMMAND;BUILD_COMMAND;INSTALL_COMMAND"
${ARGN})
@@ -30,6 +30,7 @@ function(BuildLibuv)
-DTARGET=${_libuv_TARGET}
-DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
+ BUILD_IN_SOURCE ${_libuv_BUILD_IN_SOURCE}
CONFIGURE_COMMAND "${_libuv_CONFIGURE_COMMAND}"
BUILD_COMMAND "${_libuv_BUILD_COMMAND}"
INSTALL_COMMAND "${_libuv_INSTALL_COMMAND}")
@@ -56,6 +57,16 @@ elseif(MINGW AND CMAKE_CROSSCOMPILING)
CONFIGURE_COMMAND ${UNIX_CFGCMD} --host=${CROSS_TARGET}
INSTALL_COMMAND ${MAKE_PRG} V=1 install)
+elseif(MINGW)
+
+ # Native MinGW
+ BuildLibUv(BUILD_IN_SOURCE
+ BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} -f Makefile.mingw
+ INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/lib
+ COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/libuv/libuv.a ${DEPS_INSTALL_DIR}/lib
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/include
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${DEPS_BUILD_DIR}/src/libuv/include ${DEPS_INSTALL_DIR}/include
+ )
elseif(WIN32 AND MSVC)
@@ -70,11 +81,17 @@ elseif(WIN32 AND MSVC)
else()
set(VS_ARCH x64)
endif()
- BuildLibuv(
- # By default this creates Debug builds
- BUILD_COMMAND set PYTHON=${PYTHON_EXECUTABLE} COMMAND ${DEPS_BUILD_DIR}/src/libuv/vcbuild.bat static debug ${VS_ARCH}
+ string(TOLOWER ${CMAKE_BUILD_TYPE} LOWERCASE_BUILD_TYPE)
+ set(UV_OUTPUT_DIR ${DEPS_BUILD_DIR}/src/libuv/${CMAKE_BUILD_TYPE})
+ BuildLibUv(
+ BUILD_COMMAND set PYTHON=${PYTHON_EXECUTABLE} COMMAND ${DEPS_BUILD_DIR}/src/libuv/vcbuild.bat shared ${LOWERCASE_BUILD_TYPE} ${VS_ARCH}
INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/lib
- COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/libuv/Debug/lib/libuv.lib ${DEPS_INSTALL_DIR}/lib
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/bin
+ COMMAND ${CMAKE_COMMAND} -E copy ${UV_OUTPUT_DIR}/libuv.lib ${DEPS_INSTALL_DIR}/lib
+ # Some applications (lua-client/luarocks) look for uv.lib instead of libuv.lib
+ COMMAND ${CMAKE_COMMAND} -E copy ${UV_OUTPUT_DIR}/libuv.lib ${DEPS_INSTALL_DIR}/lib/uv.lib
+ COMMAND ${CMAKE_COMMAND} -E copy ${UV_OUTPUT_DIR}/libuv.dll ${DEPS_INSTALL_DIR}/bin/
+ COMMAND ${CMAKE_COMMAND} -E copy ${UV_OUTPUT_DIR}/libuv.dll ${DEPS_INSTALL_DIR}/bin/uv.dll
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/include
COMMAND ${CMAKE_COMMAND} -E copy_directory ${DEPS_BUILD_DIR}/src/libuv/include ${DEPS_INSTALL_DIR}/include)
diff --git a/third-party/cmake/BuildLibvterm.cmake b/third-party/cmake/BuildLibvterm.cmake
index ec9ba0d741..5ea8314da5 100644
--- a/third-party/cmake/BuildLibvterm.cmake
+++ b/third-party/cmake/BuildLibvterm.cmake
@@ -1,26 +1,59 @@
+include(CMakeParseArguments)
+
+# BuildLibvterm(CONFIGURE_COMMAND ... BUILD_COMMAND ... INSTALL_COMMAND ...)
+# Failing to pass a command argument will result in no command being run
+function(BuildLibvterm)
+ cmake_parse_arguments(_libvterm
+ ""
+ ""
+ "CONFIGURE_COMMAND;BUILD_COMMAND;INSTALL_COMMAND"
+ ${ARGN})
+
+ if(NOT _libvterm_CONFIGURE_COMMAND AND NOT _libvterm_BUILD_COMMAND
+ AND NOT _libvterm_INSTALL_COMMAND)
+ message(FATAL_ERROR "Must pass at least one of CONFIGURE_COMMAND, BUILD_COMMAND, INSTALL_COMMAND")
+ endif()
+
+ ExternalProject_Add(libvterm
+ PREFIX ${DEPS_BUILD_DIR}
+ URL ${LIBVTERM_URL}
+ DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/libvterm
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND}
+ -DPREFIX=${DEPS_BUILD_DIR}
+ -DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/libvterm
+ -DURL=${LIBVTERM_URL}
+ -DEXPECTED_SHA256=${LIBVTERM_SHA256}
+ -DTARGET=libvterm
+ -DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
+ CONFIGURE_COMMAND ""
+ BUILD_IN_SOURCE 1
+ CONFIGURE_COMMAND "${_libvterm_CONFIGURE_COMMAND}"
+ BUILD_COMMAND "${_libvterm_BUILD_COMMAND}"
+ INSTALL_COMMAND "${_libvterm_INSTALL_COMMAND}")
+endfunction()
+
if(WIN32)
- message(STATUS "Building libvterm in Windows is not supported (skipping)")
- return()
+ # MinGW
+ set(LIBVTERM_CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/LibvtermCMakeLists.txt
+ ${DEPS_BUILD_DIR}/src/libvterm/CMakeLists.txt
+ COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/libvterm
+ -DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
+ "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_COMPILER_ARG1} -fPIC"
+ -DCMAKE_GENERATOR=${CMAKE_GENERATOR})
+ set(LIBVTERM_BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE})
+ set(LIBVTERM_INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE})
+else()
+ set(LIBVTERM_INSTALL_COMMAND ${MAKE_PRG} CC=${DEPS_C_COMPILER}
+ PREFIX=${DEPS_INSTALL_DIR}
+ CFLAGS=-fPIC
+ install)
endif()
-ExternalProject_Add(libvterm
- PREFIX ${DEPS_BUILD_DIR}
- URL ${LIBVTERM_URL}
- DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/libvterm
- DOWNLOAD_COMMAND ${CMAKE_COMMAND}
- -DPREFIX=${DEPS_BUILD_DIR}
- -DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/libvterm
- -DURL=${LIBVTERM_URL}
- -DEXPECTED_SHA256=${LIBVTERM_SHA256}
- -DTARGET=libvterm
- -DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
- -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
- CONFIGURE_COMMAND ""
- BUILD_IN_SOURCE 1
- BUILD_COMMAND ""
- INSTALL_COMMAND ${MAKE_PRG} CC=${DEPS_C_COMPILER}
- PREFIX=${DEPS_INSTALL_DIR}
- CFLAGS=-fPIC
- install)
+BuildLibvterm(CONFIGURE_COMMAND ${LIBVTERM_CONFIGURE_COMMAND}
+ BUILD_COMMAND ${LIBVTERM_BUILD_COMMAND}
+ INSTALL_COMMAND ${LIBVTERM_INSTALL_COMMAND})
list(APPEND THIRD_PARTY_DEPS libvterm)
diff --git a/third-party/cmake/BuildLuajit.cmake b/third-party/cmake/BuildLuajit.cmake
index 83aceecb59..c8eee282bf 100644
--- a/third-party/cmake/BuildLuajit.cmake
+++ b/third-party/cmake/BuildLuajit.cmake
@@ -40,7 +40,6 @@ set(INSTALLCMD_UNIX ${MAKE_PRG} CFLAGS=-fPIC
CFLAGS+=-DLUA_USE_APICHECK
CFLAGS+=-DLUA_USE_ASSERT
CCDEBUG+=-g
- BUILDMODE=static
Q=
install)
@@ -71,13 +70,36 @@ elseif(MINGW AND CMAKE_CROSSCOMPILING)
Q=
INSTALL_TSYMNAME=luajit.exe)
-elseif(WIN32 AND MSVC)
+elseif(MINGW)
+
+
+ BuildLuaJit(BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} CC=${DEPS_C_COMPILER}
+ PREFIX=${DEPS_INSTALL_DIR}
+ CFLAGS+=-DLUAJIT_DISABLE_JIT
+ CFLAGS+=-DLUA_USE_APICHECK
+ CFLAGS+=-DLUA_USE_ASSERT
+ CCDEBUG+=-g
+ BUILDMODE=static
+ # Build a DLL too
+ COMMAND ${CMAKE_MAKE_PROGRAM} CC=${DEPS_C_COMPILER} BUILDMODE=dynamic
+
+ INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/bin
+ COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/luajit.exe ${DEPS_INSTALL_DIR}/bin
+ COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/lua51.dll ${DEPS_INSTALL_DIR}/bin
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/lib
+ # Luarocks searches for lua51.dll in lib
+ COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/lua51.dll ${DEPS_INSTALL_DIR}/lib
+ COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/libluajit.a ${DEPS_INSTALL_DIR}/lib
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/include/luajit-2.0
+ COMMAND ${CMAKE_COMMAND} -DFROM_GLOB=${DEPS_BUILD_DIR}/src/luajit/src/*.h -DTO=${DEPS_INSTALL_DIR}/include/luajit-2.0 -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/CopyFilesGlob.cmake
+ )
+elseif(MSVC)
BuildLuaJit(
- BUILD_COMMAND ${CMAKE_COMMAND} -E chdir ${DEPS_BUILD_DIR}/src/luajit/src ${DEPS_BUILD_DIR}/src/luajit/src/msvcbuild.bat static
+ BUILD_COMMAND ${CMAKE_COMMAND} -E chdir ${DEPS_BUILD_DIR}/src/luajit/src ${DEPS_BUILD_DIR}/src/luajit/src/msvcbuild.bat
INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/luajit.exe ${DEPS_INSTALL_DIR}/bin
- COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/lua51.lib ${DEPS_INSTALL_DIR}/bin
+ COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/lua51.dll ${DEPS_INSTALL_DIR}/bin
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/lib
COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/lua51.lib ${DEPS_INSTALL_DIR}/lib
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEPS_INSTALL_DIR}/include/luajit-2.0
diff --git a/third-party/cmake/BuildLuarocks.cmake b/third-party/cmake/BuildLuarocks.cmake
index 1bff020691..daf39ec271 100644
--- a/third-party/cmake/BuildLuarocks.cmake
+++ b/third-party/cmake/BuildLuarocks.cmake
@@ -3,7 +3,7 @@
# writing a recipe that is meant for cross-compile, use the HOSTDEPS_* variables
# instead of DEPS_* - check the main CMakeLists.txt for a list.
-if(MSVC)
+if(MSVC OR (MINGW AND NOT CMAKE_CROSSCOMPILING))
message(STATUS "Building busted in Windows is not supported (skipping)")
else()
option(USE_BUNDLED_BUSTED "Use the bundled version of busted to run tests." ON)
@@ -46,11 +46,9 @@ endfunction()
set(LUAROCKS_BINARY ${HOSTDEPS_BIN_DIR}/luarocks)
# Arguments for calls to 'luarocks build'
-if(MSVC)
- # In native Win32 don't pass the compiler/linker to luarocks, the bundled
+if(NOT MSVC)
+ # In MSVC don't pass the compiler/linker to luarocks, the bundled
# version already knows, and passing them here breaks the build
- set(LUAROCKS_BUILDARGS CFLAGS=/MT)
-else()
set(LUAROCKS_BUILDARGS CC=${HOSTDEPS_C_COMPILER} LD=${HOSTDEPS_C_COMPILER})
endif()
@@ -67,8 +65,12 @@ if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING))
--prefix=${HOSTDEPS_INSTALL_DIR} --force-config ${LUAROCKS_OPTS}
--lua-suffix=jit
INSTALL_COMMAND ${MAKE_PRG} bootstrap)
+elseif(MSVC OR MINGW)
+
+ if(MINGW)
+ set(MINGW_FLAG /MW)
+ endif()
-elseif(MSVC)
# Ignore USE_BUNDLED_LUAJIT - always ON for native Win32
BuildLuarocks(INSTALL_COMMAND install.bat /FORCECONFIG /NOREG /NOADMIN /Q /F
/LUA ${DEPS_INSTALL_DIR}
@@ -78,6 +80,7 @@ elseif(MSVC)
/P ${DEPS_INSTALL_DIR} /TREE ${DEPS_INSTALL_DIR}
/SCRIPTS ${DEPS_BIN_DIR}
/CMOD ${DEPS_BIN_DIR}
+ ${MINGW_FLAG}
/LUAMOD ${DEPS_BIN_DIR}/lua)
set(LUAROCKS_BINARY ${DEPS_INSTALL_DIR}/2.2/luarocks.bat)
diff --git a/third-party/cmake/BuildLuv.cmake b/third-party/cmake/BuildLuv.cmake
index 3060590bce..8ba4a0b41b 100644
--- a/third-party/cmake/BuildLuv.cmake
+++ b/third-party/cmake/BuildLuv.cmake
@@ -43,6 +43,7 @@ set(LUV_PATCH_COMMAND
set(LUV_CONFIGURE_COMMAND_COMMON
${CMAKE_COMMAND} ${LUV_SRC_DIR}
+ -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
-DLUA_BUILD_TYPE=System
-DWITH_SHARED_LIBUV=ON
diff --git a/third-party/cmake/BuildMsgpack.cmake b/third-party/cmake/BuildMsgpack.cmake
index 4b6b361e85..6b38508b0b 100644
--- a/third-party/cmake/BuildMsgpack.cmake
+++ b/third-party/cmake/BuildMsgpack.cmake
@@ -37,10 +37,12 @@ set(MSGPACK_CONFIGURE_COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/msgpack
-DMSGPACK_BUILD_TESTS=OFF
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
- "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_COMPILER_ARG1} -fPIC")
+ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+ "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_COMPILER_ARG1} -fPIC"
+ -DCMAKE_GENERATOR=${CMAKE_GENERATOR})
-set(MSGPACK_BUILD_COMMAND ${CMAKE_COMMAND} --build .)
-set(MSGPACK_INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install)
+set(MSGPACK_BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE})
+set(MSGPACK_INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE})
if(MINGW AND CMAKE_CROSSCOMPILING)
get_filename_component(TOOLCHAIN ${CMAKE_TOOLCHAIN_FILE} REALPATH)
@@ -50,6 +52,7 @@ if(MINGW AND CMAKE_CROSSCOMPILING)
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
# Pass toolchain
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}
+ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
# Hack to avoid -rdynamic in Mingw
-DCMAKE_SHARED_LIBRARY_LINK_C_FLAGS="")
elseif(MSVC)
@@ -60,12 +63,13 @@ elseif(MSVC)
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
"-DCMAKE_C_FLAGS:STRING=${CMAKE_C_COMPILER_ARG1}"
+ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
# Make sure we use the same generator, otherwise we may
# accidentaly end up using different MSVC runtimes
- -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
- # Use static runtime
- -DCMAKE_C_FLAGS_DEBUG="-MTd"
- -DCMAKE_C_FLAGS_RELEASE="-MT")
+ -DCMAKE_GENERATOR=${CMAKE_GENERATOR})
+ # Place the DLL in the bin folder
+ set(MSGPACK_INSTALL_COMMAND ${MSGPACK_INSTALL_COMMAND}
+ COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_INSTALL_DIR}/lib/msgpack.dll ${DEPS_INSTALL_DIR}/bin)
endif()
BuildMsgpack(CONFIGURE_COMMAND ${MSGPACK_CONFIGURE_COMMAND}
diff --git a/third-party/cmake/CopyFilesGlob.cmake b/third-party/cmake/CopyFilesGlob.cmake
index 056da32fd4..8950ead1e5 100644
--- a/third-party/cmake/CopyFilesGlob.cmake
+++ b/third-party/cmake/CopyFilesGlob.cmake
@@ -9,6 +9,8 @@ if(NOT TO)
message(FATAL_ERROR "TO must be set")
endif()
+execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${TO})
+
file(GLOB files ${FROM_GLOB})
foreach(file ${files})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${file} ${TO} RESULT_VARIABLE rv)
diff --git a/third-party/cmake/LibvtermCMakeLists.txt b/third-party/cmake/LibvtermCMakeLists.txt
new file mode 100644
index 0000000000..72183e4b4c
--- /dev/null
+++ b/third-party/cmake/LibvtermCMakeLists.txt
@@ -0,0 +1,72 @@
+cmake_minimum_required(VERSION 2.8.11)
+project(libvterm LANGUAGES C)
+
+include(GNUInstallDirs)
+find_package(Perl REQUIRED)
+
+if(MSVC)
+ add_definitions(/W3 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
+else()
+ add_definitions(-Wall -std=c99)
+endif()
+
+# Generate includes from tables
+file(GLOB TBL_FILES ${CMAKE_SOURCE_DIR}/src/encoding/*.tbl)
+set(TBL_FILES_HEADERS)
+foreach(file ${TBL_FILES})
+ get_filename_component(basename ${file} NAME_WE)
+ set(tname encoding/${basename}.inc)
+ add_custom_command(OUTPUT
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/encoding/
+ COMMAND ${PERL_EXECUTABLE} -CSD ${CMAKE_SOURCE_DIR}/tbl2inc_c.pl ${file} > ${CMAKE_BINARY_DIR}/${tname}
+ COMMENT "Generating ${tname}"
+ OUTPUT ${CMAKE_BINARY_DIR}/${tname}
+ )
+ list(APPEND TBL_FILES_HEADERS ${tname})
+endforeach()
+
+include_directories(${CMAKE_SOURCE_DIR}/include)
+include_directories(${CMAKE_BINARY_DIR})
+
+file(GLOB VTERM_SOURCES ${CMAKE_SOURCE_DIR}/src/*.c)
+add_library(vterm ${VTERM_SOURCES} ${TBL_FILES_HEADERS})
+install(TARGETS vterm ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+add_library(vterm-shared SHARED ${VTERM_SOURCES} ${TBL_FILES_HEADERS})
+set_target_properties(vterm-shared PROPERTIES
+ OUTPUT_NAME vterm
+ SOVERSION 0)
+install(TARGETS vterm-shared
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+
+install(FILES include/vterm.h include/vterm_keycodes.h
+ DESTINATION include)
+
+if(NOT WIN32)
+ file(GLOB BIN_SOURCES ${CMAKE_SOURCE_DIR}/bin/*.c)
+ foreach(EXE_C ${BIN_SOURCES})
+ get_filename_component(target_name ${EXE_C} NAME_WE)
+ add_executable(${target_name} ${EXE_C})
+ target_link_libraries(${target_name} vterm)
+ install(TARGETS ${target_name} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+ endforeach()
+endif()
+
+# Tests
+add_executable(harness EXCLUDE_FROM_ALL t/harness.c)
+target_link_libraries(harness vterm)
+set_target_properties(harness PROPERTIES
+ # run-test.pl expects to find the harness in t/.libs/
+ RUNTIME_OUTPUT_DIRECTORY t/.libs)
+
+file(GLOB TESTFILES ${CMAKE_SOURCE_DIR}/t/*.test)
+add_custom_target(check)
+foreach(testfile ${TESTFILES})
+ get_filename_component(target_name ${testfile} NAME_WE)
+ add_custom_target(${target_name}
+ COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/t/run-test.pl ${testfile}
+ COMMENT "**${target_name} **"
+ DEPENDS harness)
+ add_dependencies(check ${target_name})
+endforeach()