aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-03-08 20:26:18 +0100
committerGitHub <noreply@github.com>2018-03-08 20:26:18 +0100
commit9cefd83cc7b96d9a20ae8aae5ad5f2c4a02a74f4 (patch)
tree2933dd4aa96bd42eb8939c7a2afe2fcf544834f1
parentd82621877b72ee8322a5b88adaba4edd5ad3b308 (diff)
parent0adf950ccf9a0057c552a349d79a716ff7be6f8f (diff)
downloadrneovim-9cefd83cc7b96d9a20ae8aae5ad5f2c4a02a74f4.tar.gz
rneovim-9cefd83cc7b96d9a20ae8aae5ad5f2c4a02a74f4.tar.bz2
rneovim-9cefd83cc7b96d9a20ae8aae5ad5f2c4a02a74f4.zip
Merge #8084 'build/win: support MSVC'
-rw-r--r--CMakeLists.txt4
-rw-r--r--appveyor.yml5
-rw-r--r--ci/build.bat53
-rw-r--r--cmake/FindMsgpack.cmake2
-rw-r--r--src/nvim/eval.c8
-rwxr-xr-xsrc/nvim/generators/gen_declarations.lua21
-rw-r--r--src/nvim/lib/kvec.h1
-rw-r--r--src/nvim/main.c13
-rw-r--r--src/nvim/option.c8
-rw-r--r--src/nvim/os/os_defs.h8
-rw-r--r--src/nvim/os/unix_defs.h3
-rw-r--r--src/nvim/os/win_defs.h4
-rw-r--r--src/nvim/spellfile.c1
-rw-r--r--test/functional/fixtures/shell-test.c5
-rw-r--r--third-party/CMakeLists.txt7
-rw-r--r--third-party/cmake/BuildLibtermkey.cmake9
-rw-r--r--third-party/cmake/BuildLibuv.cmake12
-rw-r--r--third-party/cmake/BuildLibvterm.cmake13
-rw-r--r--third-party/cmake/BuildLuajit.cmake5
-rw-r--r--third-party/cmake/BuildLuarocks.cmake23
-rw-r--r--third-party/cmake/BuildMsgpack.cmake3
-rw-r--r--third-party/cmake/BuildUnibilium.cmake67
-rw-r--r--third-party/cmake/UnibiliumCMakeLists.txt27
-rw-r--r--third-party/msvc-compat/unistd.h10
-rw-r--r--third-party/patches/libvterm-Remove-VLAs-for-MSVC.patch50
-rw-r--r--third-party/patches/luarocks-Change-default-downloader-to-curl.patch24
26 files changed, 290 insertions, 96 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f4ff4d5ac3..8147afb14f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -204,6 +204,7 @@ int main(void)
if(MSVC)
# XXX: /W4 gives too many warnings. #3241
add_definitions(/W3 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
+ add_definitions(-DWIN32)
else()
add_definitions(-Wall -Wextra -pedantic -Wno-unused-parameter
-Wstrict-prototypes -std=gnu99)
@@ -223,6 +224,9 @@ endif()
if(MINGW)
# Use POSIX compatible stdio in Mingw
add_definitions(-D__USE_MINGW_ANSI_STDIO)
+endif()
+if(WIN32)
+ # Windows Vista is the minimum supported version
add_definitions(-D_WIN32_WINNT=0x0600)
endif()
diff --git a/appveyor.yml b/appveyor.yml
index 30b7947da0..8c2c89560c 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,12 +1,17 @@
version: '{build}'
environment:
APPVEYOR_CACHE_ENTRY_ZIP_ARGS: "-t7z -m0=lzma -mx=9"
+image: Visual Studio 2017
configuration:
+- MSVC_64
+- MSVC_32
- MINGW_64
- MINGW_32
- MINGW_64-gcov
matrix:
allow_failures:
+ - configuration: MSVC_64
+ - configuration: MSVC_32
- configuration: MINGW_64-gcov
install: []
before_build:
diff --git a/ci/build.bat b/ci/build.bat
index 5c7f14ad0a..3fa185f646 100644
--- a/ci/build.bat
+++ b/ci/build.bat
@@ -1,27 +1,34 @@
-:: 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 "%CONFIGURATION%" == "MINGW_32" (
set ARCH=i686
set BITS=32
-) else (
+) else if "%CONFIGURATION:~0,8%" == "MINGW_64" (
set ARCH=x86_64
set BITS=64
+ if "%CONFIGURATION%" == "MINGW_64-gcov" (
+ set USE_GCOV="-DUSE_GCOV=ON"
+ )
+) else if "%CONFIGURATION%" == "MSVC_32" (
+ set CMAKE_GENERATOR="Visual Studio 15 2017"
+) else if "%CONFIGURATION%" == "MSVC_64" (
+ set CMAKE_GENERATOR="Visual Studio 15 2017 Win64"
)
-if "%CONFIGURATION%" == "MINGW_64-gcov" (
- set USE_GCOV="-DUSE_GCOV=ON"
-)
-
-:: 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%
-:: The default cpack in the PATH is not CMake
-set PATH=C:\Program Files (x86)\CMake\bin\cpack.exe;%PATH%
-:: Build third-party dependencies
-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%-diffutils mingw-w64-%ARCH%-unibilium gperf" || goto :error
+if "%CONFIGURATION:~0,5%" == "MINGW" (
+ :: 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.
+ set CMAKE_GENERATOR="MinGW Makefiles"
+ set CMAKE_GENERATOR_ARGS=VERBOSE=1
+ :: Add MinGW to the PATH and remove the Git directory because it
+ :: has a conflicting sh.exe
+ set "PATH=C:\msys64\mingw%BITS%\bin;C:\Windows\System32;C:\Windows;%PATH:C:\Program Files\Git\usr\bin;=%"
+ :: Build third-party dependencies
+ 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%-diffutils mingw-w64-%ARCH%-unibilium gperf" || goto :error
+) else if "%CONFIGURATION:~0,4%" == "MSVC" (
+ set CMAKE_GENERATOR_ARGS=/verbosity:normal
+)
:: Setup python (use AppVeyor system python)
C:\Python27\python.exe -m pip install neovim || goto :error
@@ -42,19 +49,19 @@ where.exe neovim-node-host.cmd || goto :error
mkdir .deps
cd .deps
-cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo ..\third-party\ || goto :error
-mingw32-make VERBOSE=1 || goto :error
+cmake -G %CMAKE_GENERATOR% -DCMAKE_BUILD_TYPE=RelWithDebInfo ..\third-party\ || goto :error
+cmake --build . -- %CMAKE_GENERATOR_ARGS% || goto :error
cd ..
:: Build Neovim
mkdir build
cd build
-cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUSTED_OUTPUT_TYPE=nvim %USE_GCOV% -DGPERF_PRG="C:\msys64\usr\bin\gperf.exe" .. || goto :error
-mingw32-make VERBOSE=1 || goto :error
+cmake -G %CMAKE_GENERATOR% -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUSTED_OUTPUT_TYPE=nvim %USE_GCOV% -DGPERF_PRG="C:\msys64\usr\bin\gperf.exe" .. || goto :error
+cmake --build . --config RelWithDebInfo -- %CMAKE_GENERATOR_ARGS% || goto :error
bin\nvim --version || goto :error
:: Functional tests
-mingw32-make functionaltest VERBOSE=1 || goto :error
+cmake --build . --config RelWithDebInfo --target functionaltest -- %CMAKE_GENERATOR_ARGS% || goto :error
if defined USE_GCOV (
C:\msys64\usr\bin\bash -lc "cd /c/projects/neovim; bash <(curl -s https://codecov.io/bash) -c -F functionaltest || echo 'codecov upload failed.'"
@@ -63,13 +70,15 @@ if defined USE_GCOV (
:: Old tests
setlocal
set PATH=%PATH%;C:\msys64\usr\bin
-mingw32-make -C "%~dp0\..\src\nvim\testdir" VERBOSE=1
+cmake --build "%~dp0\..\src\nvim\testdir" -- %CMAKE_GENERATOR_ARGS%
endlocal
if defined USE_GCOV (
C:\msys64\usr\bin\bash -lc "cd /c/projects/neovim; bash <(curl -s https://codecov.io/bash) -c -F oldtest || echo 'codecov upload failed.'"
)
+:: The default cpack in the PATH is not CMake
+set PATH=C:\Program Files (x86)\CMake\bin\cpack.exe;%PATH%
:: Build artifacts
cpack -G ZIP -C RelWithDebInfo
if defined APPVEYOR_REPO_TAG_NAME cpack -G NSIS -C RelWithDebInfo
diff --git a/cmake/FindMsgpack.cmake b/cmake/FindMsgpack.cmake
index 6716289a98..cca0a00c20 100644
--- a/cmake/FindMsgpack.cmake
+++ b/cmake/FindMsgpack.cmake
@@ -44,7 +44,7 @@ endif()
if(MSVC)
# The import library for the msgpack DLL has a different name
- list(APPEND MSGPACK_NAMES msgpack_import)
+ list(APPEND MSGPACK_NAMES msgpackc_import)
else()
list(APPEND MSGPACK_NAMES msgpackc msgpack)
endif()
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 2e4d246f4b..4140eebdf6 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -5936,6 +5936,14 @@ static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate)
}
#ifdef INCLUDE_GENERATED_DECLARATIONS
+
+#ifdef _MSC_VER
+// This prevents MSVC from replacing the functions with intrinsics,
+// and causing errors when trying to get their addresses in funcs.generated.h
+#pragma function (ceil)
+#pragma function (floor)
+#endif
+
# include "funcs.generated.h"
#endif
diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua
index 065c043557..c40c37bb3e 100755
--- a/src/nvim/generators/gen_declarations.lua
+++ b/src/nvim/generators/gen_declarations.lua
@@ -224,23 +224,15 @@ local static = header
local filepattern = '^#%a* (%d+) "([^"]-)/?([^"/]+)"'
local curfile
-local init = 0
+local init = 1
local curfile = nil
local neededfile = fname:match('[^/]+$')
local declline = 0
local declendpos = 0
local curdir = nil
local is_needed_file = false
+local init_is_nl = true
while init ~= nil do
- init = text:find('[\n;}]', init)
- if init == nil then
- break
- end
- local init_is_nl = text:sub(init, init) == '\n'
- init = init + 1
- if init_is_nl and is_needed_file then
- declline = declline + 1
- end
if init_is_nl and text:sub(init, init) == '#' then
local line, dir, file = text:match(filepattern, init)
if file ~= nil then
@@ -293,6 +285,15 @@ while init ~= nil do
declendpos = e
end
end
+ init = text:find('[\n;}]', init)
+ if init == nil then
+ break
+ end
+ init_is_nl = text:sub(init, init) == '\n'
+ init = init + 1
+ if init_is_nl and is_needed_file then
+ declline = declline + 1
+ end
end
non_static = non_static .. footer
diff --git a/src/nvim/lib/kvec.h b/src/nvim/lib/kvec.h
index ee1b890cb9..ad56c9237b 100644
--- a/src/nvim/lib/kvec.h
+++ b/src/nvim/lib/kvec.h
@@ -41,6 +41,7 @@
#include <string.h>
#include "nvim/memory.h"
+#include "nvim/os/os_defs.h"
#define kv_roundup32(x) \
((--(x)), \
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 4fd55f1491..4288d7f9d7 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -7,11 +7,6 @@
#include <string.h>
#include <stdbool.h>
-#ifdef WIN32
-# include <wchar.h>
-# include <winnls.h>
-#endif
-
#include <msgpack.h>
#include "nvim/ascii.h"
@@ -795,7 +790,7 @@ static void command_line_scan(mparm_T *parmp)
mch_exit(0);
} else if (STRICMP(argv[0] + argv_idx, "api-info") == 0) {
FileDescriptor fp;
- const int fof_ret = file_open_fd(&fp, OS_STDOUT_FILENO, true);
+ const int fof_ret = file_open_fd(&fp, STDOUT_FILENO, true);
msgpack_packer *p = msgpack_packer_new(&fp, msgpack_file_write);
if (fof_ret != 0) {
@@ -1256,10 +1251,10 @@ static void check_and_set_isatty(mparm_T *paramp)
paramp->err_isatty = os_isatty(fileno(stderr));
#ifndef WIN32
int tty_fd = paramp->input_isatty
- ? OS_STDIN_FILENO
+ ? STDIN_FILENO
: (paramp->output_isatty
- ? OS_STDOUT_FILENO
- : (paramp->err_isatty ? OS_STDERR_FILENO : -1));
+ ? STDOUT_FILENO
+ : (paramp->err_isatty ? STDERR_FILENO : -1));
pty_process_save_termios(tty_fd);
#endif
TIME_MSG("window checked");
diff --git a/src/nvim/option.c b/src/nvim/option.c
index eff436eb4d..d6903c8db7 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -2436,6 +2436,11 @@ static bool valid_filetype(char_u *val)
return true;
}
+#ifdef _MSC_VER
+// MSVC optimizations are disabled for this function because it
+// incorrectly generates an empty string for SHM_ALL.
+#pragma optimize("", off)
+#endif
/*
* Handle string options that need some action to perform when changed.
* Returns NULL for success, or an error message for an error.
@@ -3305,6 +3310,9 @@ did_set_string_option (
return errmsg;
}
+#ifdef _MSC_VER
+#pragma optimize("", on)
+#endif
/*
* Simple int comparison function for use with qsort()
diff --git a/src/nvim/os/os_defs.h b/src/nvim/os/os_defs.h
index 87f8d214bd..f81785675e 100644
--- a/src/nvim/os/os_defs.h
+++ b/src/nvim/os/os_defs.h
@@ -4,7 +4,6 @@
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -14,13 +13,6 @@
# include "nvim/os/unix_defs.h"
#endif
-/// File descriptor number used for standard IO streams
-enum {
- OS_STDIN_FILENO = STDIN_FILENO,
- OS_STDOUT_FILENO = STDOUT_FILENO,
- OS_STDERR_FILENO = STDERR_FILENO,
-};
-
#define BASENAMELEN (NAME_MAX - 5)
// Use the system path length if it makes sense.
diff --git a/src/nvim/os/unix_defs.h b/src/nvim/os/unix_defs.h
index 5c9daca476..60a2dfa882 100644
--- a/src/nvim/os/unix_defs.h
+++ b/src/nvim/os/unix_defs.h
@@ -1,9 +1,8 @@
#ifndef NVIM_OS_UNIX_DEFS_H
#define NVIM_OS_UNIX_DEFS_H
-// Windows doesn't have unistd.h, so we include it here to avoid numerous
-// instances of `#ifdef WIN32'.
#include <unistd.h>
+#include <sys/param.h>
// POSIX.1-2008 says that NAME_MAX should be in here
#include <limits.h>
diff --git a/src/nvim/os/win_defs.h b/src/nvim/os/win_defs.h
index 8fd2e51f8b..faee06304c 100644
--- a/src/nvim/os/win_defs.h
+++ b/src/nvim/os/win_defs.h
@@ -45,6 +45,9 @@
# ifndef restrict
# define restrict __restrict
# endif
+# ifndef STDIN_FILENO
+# define STDIN_FILENO _fileno(stdin)
+# endif
# ifndef STDOUT_FILENO
# define STDOUT_FILENO _fileno(stdout)
# endif
@@ -60,6 +63,7 @@
#ifdef _MSC_VER
typedef SSIZE_T ssize_t;
+typedef int mode_t;
#endif
#ifndef SSIZE_MAX
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index df066e7ad3..f5d5d408a1 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -228,7 +228,6 @@
#include <stdio.h>
#include <stdint.h>
#include <wctype.h>
-#include <strings.h>
#include "nvim/vim.h"
#include "nvim/spell_defs.h"
diff --git a/test/functional/fixtures/shell-test.c b/test/functional/fixtures/shell-test.c
index 38695ce76b..a744d5df46 100644
--- a/test/functional/fixtures/shell-test.c
+++ b/test/functional/fixtures/shell-test.c
@@ -4,7 +4,12 @@
#include <stdio.h>
#include <string.h>
#include <stdint.h>
+#ifdef _MSC_VER
+#include <Windows.h>
+#define usleep(usecs) Sleep(usecs/1000)
+#else
#include <unistd.h>
+#endif
static void wait(void)
{
diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt
index c523ecea00..7c95bbb91d 100644
--- a/third-party/CMakeLists.txt
+++ b/third-party/CMakeLists.txt
@@ -50,6 +50,13 @@ endif()
option(USE_EXISTING_SRC_DIR "Skip download of deps sources in case of existing source directory." OFF)
+if(WIN32)
+ find_package(Git)
+ if(NOT Git_FOUND)
+ message(FATAL_ERROR "Git is required to apply patches for Windows.")
+ endif()
+endif()
+
if(UNIX)
find_program(MAKE_PRG NAMES gmake make)
if(MAKE_PRG)
diff --git a/third-party/cmake/BuildLibtermkey.cmake b/third-party/cmake/BuildLibtermkey.cmake
index bc4db4c9b1..b5cd0c4ca6 100644
--- a/third-party/cmake/BuildLibtermkey.cmake
+++ b/third-party/cmake/BuildLibtermkey.cmake
@@ -1,5 +1,3 @@
-find_package(PkgConfig REQUIRED)
-
if(WIN32)
ExternalProject_Add(libtermkey
PREFIX ${DEPS_BUILD_DIR}
@@ -24,6 +22,8 @@ ExternalProject_Add(libtermkey
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE}
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE})
else()
+find_package(PkgConfig REQUIRED)
+
ExternalProject_Add(libtermkey
PREFIX ${DEPS_BUILD_DIR}
URL ${LIBTERMKEY_URL}
@@ -48,7 +48,4 @@ ExternalProject_Add(libtermkey
endif()
list(APPEND THIRD_PARTY_DEPS libtermkey)
-if(NOT WIN32)
- # There is no unibilium build recipe for Windows yet
- add_dependencies(libtermkey unibilium)
-endif()
+add_dependencies(libtermkey unibilium)
diff --git a/third-party/cmake/BuildLibuv.cmake b/third-party/cmake/BuildLibuv.cmake
index 06b527e5a2..a1c7e7f986 100644
--- a/third-party/cmake/BuildLibuv.cmake
+++ b/third-party/cmake/BuildLibuv.cmake
@@ -76,15 +76,19 @@ elseif(WIN32 AND MSVC)
endif()
include(TargetArch)
- if("${TARGET_ARCH}" STREQUAL "X86_64")
+ if(TARGET_ARCH STREQUAL "X86_64")
set(TARGET_ARCH x64)
elseif(TARGET_ARCH STREQUAL "X86")
set(TARGET_ARCH x86)
endif()
- string(TOLOWER ${CMAKE_BUILD_TYPE} LOWERCASE_BUILD_TYPE)
- set(UV_OUTPUT_DIR ${DEPS_BUILD_DIR}/src/libuv/${CMAKE_BUILD_TYPE})
+ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(TARGET_CONFIG debug)
+ else()
+ set(TARGET_CONFIG release)
+ endif()
+ set(UV_OUTPUT_DIR ${DEPS_BUILD_DIR}/src/libuv/${TARGET_CONFIG})
BuildLibUv(
- BUILD_COMMAND set PYTHON=${PYTHON_EXECUTABLE} COMMAND ${DEPS_BUILD_DIR}/src/libuv/vcbuild.bat shared ${LOWERCASE_BUILD_TYPE} ${TARGET_ARCH}
+ BUILD_COMMAND set PYTHON=${PYTHON_EXECUTABLE} COMMAND ${DEPS_BUILD_DIR}/src/libuv/vcbuild.bat shared ${TARGET_CONFIG} ${TARGET_ARCH}
INSTALL_COMMAND ${CMAKE_COMMAND} -E make_directory ${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
diff --git a/third-party/cmake/BuildLibvterm.cmake b/third-party/cmake/BuildLibvterm.cmake
index 12e8fdd7d0..73e2990654 100644
--- a/third-party/cmake/BuildLibvterm.cmake
+++ b/third-party/cmake/BuildLibvterm.cmake
@@ -6,7 +6,7 @@ function(BuildLibvterm)
cmake_parse_arguments(_libvterm
""
""
- "CONFIGURE_COMMAND;BUILD_COMMAND;INSTALL_COMMAND"
+ "PATCH_COMMAND;CONFIGURE_COMMAND;BUILD_COMMAND;INSTALL_COMMAND"
${ARGN})
if(NOT _libvterm_CONFIGURE_COMMAND AND NOT _libvterm_BUILD_COMMAND
@@ -26,6 +26,7 @@ function(BuildLibvterm)
-DTARGET=libvterm
-DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
+ PATCH_COMMAND "${_libvterm_PATCH_COMMAND}"
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND "${_libvterm_CONFIGURE_COMMAND}"
@@ -34,7 +35,12 @@ function(BuildLibvterm)
endfunction()
if(WIN32)
- # MinGW
+ if(MSVC)
+ set(LIBVTERM_PATCH_COMMAND
+ ${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/libvterm init
+ COMMAND ${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/libvterm apply
+ ${CMAKE_CURRENT_SOURCE_DIR}/patches/libvterm-Remove-VLAs-for-MSVC.patch)
+ endif()
set(LIBVTERM_CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/cmake/LibvtermCMakeLists.txt
${DEPS_BUILD_DIR}/src/libvterm/CMakeLists.txt
@@ -53,7 +59,8 @@ else()
install)
endif()
-BuildLibvterm(CONFIGURE_COMMAND ${LIBVTERM_CONFIGURE_COMMAND}
+BuildLibvterm(PATCH_COMMAND ${LIBVTERM_PATCH_COMMAND}
+ CONFIGURE_COMMAND ${LIBVTERM_CONFIGURE_COMMAND}
BUILD_COMMAND ${LIBVTERM_BUILD_COMMAND}
INSTALL_COMMAND ${LIBVTERM_INSTALL_COMMAND})
diff --git a/third-party/cmake/BuildLuajit.cmake b/third-party/cmake/BuildLuajit.cmake
index c8eee282bf..e65a81bba5 100644
--- a/third-party/cmake/BuildLuajit.cmake
+++ b/third-party/cmake/BuildLuajit.cmake
@@ -101,7 +101,10 @@ elseif(MSVC)
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
- COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/lua51.lib ${DEPS_INSTALL_DIR}/lib
+ # Luarocks searches for lua51.lib
+ COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/lua51.lib ${DEPS_INSTALL_DIR}/lib/lua51.lib
+ # Luv searches for luajit.lib
+ COMMAND ${CMAKE_COMMAND} -E copy ${DEPS_BUILD_DIR}/src/luajit/src/lua51.lib ${DEPS_INSTALL_DIR}/lib/luajit.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)
diff --git a/third-party/cmake/BuildLuarocks.cmake b/third-party/cmake/BuildLuarocks.cmake
index 2a59ad3b46..47c6412d86 100644
--- a/third-party/cmake/BuildLuarocks.cmake
+++ b/third-party/cmake/BuildLuarocks.cmake
@@ -12,7 +12,7 @@ function(BuildLuarocks)
cmake_parse_arguments(_luarocks
""
""
- "CONFIGURE_COMMAND;BUILD_COMMAND;INSTALL_COMMAND"
+ "PATCH_COMMAND;CONFIGURE_COMMAND;BUILD_COMMAND;INSTALL_COMMAND"
${ARGN})
if(NOT _luarocks_CONFIGURE_COMMAND AND NOT _luarocks_BUILD_COMMAND
@@ -32,6 +32,7 @@ function(BuildLuarocks)
-DTARGET=luarocks
-DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
+ PATCH_COMMAND "${_luarocks_PATCH_COMMAND}"
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND "${_luarocks_CONFIGURE_COMMAND}"
BUILD_COMMAND "${_luarocks_BUILD_COMMAND}"
@@ -50,6 +51,11 @@ if(NOT MSVC)
# version already knows, and passing them here breaks the build
set(LUAROCKS_BUILDARGS CC=${HOSTDEPS_C_COMPILER} LD=${HOSTDEPS_C_COMPILER})
endif()
+if(WIN32)
+ # Use our bundled curl.exe for downloading packages
+ set(LUAROCKS_BUILDARGS ${LUAROCKS_BUILDARGS} CURL=${DEPS_BIN_DIR}/curl.exe)
+endif()
+
if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING))
@@ -70,11 +76,18 @@ if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING))
elseif(MSVC OR MINGW)
if(MINGW)
- set(MINGW_FLAG /MW)
+ set(COMPILER_FLAG /MW)
+ elseif(MSVC)
+ set(COMPILER_FLAG /MSVC)
endif()
# Ignore USE_BUNDLED_LUAJIT - always ON for native Win32
- BuildLuarocks(INSTALL_COMMAND install.bat /FORCECONFIG /NOREG /NOADMIN /Q /F
+ BuildLuarocks(
+ PATCH_COMMAND
+ ${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/luarocks init
+ COMMAND ${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/luarocks apply
+ ${CMAKE_CURRENT_SOURCE_DIR}/patches/luarocks-Change-default-downloader-to-curl.patch
+ INSTALL_COMMAND install.bat /FORCECONFIG /NOREG /NOADMIN /Q /F
/LUA ${DEPS_INSTALL_DIR}
/LIB ${DEPS_LIB_DIR}
/BIN ${DEPS_BIN_DIR}
@@ -82,10 +95,12 @@ elseif(MSVC OR MINGW)
/P ${DEPS_INSTALL_DIR}/${LUAROCKS_VERSION} /TREE ${DEPS_INSTALL_DIR}
/SCRIPTS ${DEPS_BIN_DIR}
/CMOD ${DEPS_BIN_DIR}
- ${MINGW_FLAG}
+ ${COMPILER_FLAG}
/LUAMOD ${DEPS_BIN_DIR}/lua)
set(LUAROCKS_BINARY ${DEPS_INSTALL_DIR}/${LUAROCKS_VERSION}/luarocks.bat)
+ add_dependencies(luarocks wintools)
+
else()
message(FATAL_ERROR "Trying to build luarocks in an unsupported system ${CMAKE_SYSTEM_NAME}/${CMAKE_C_COMPILER_ID}")
endif()
diff --git a/third-party/cmake/BuildMsgpack.cmake b/third-party/cmake/BuildMsgpack.cmake
index 779cb1ebfe..616b6e5f83 100644
--- a/third-party/cmake/BuildMsgpack.cmake
+++ b/third-party/cmake/BuildMsgpack.cmake
@@ -70,9 +70,6 @@ elseif(MSVC)
# Make sure we use the same generator, otherwise we may
# accidentaly end up using different MSVC runtimes
-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/BuildUnibilium.cmake b/third-party/cmake/BuildUnibilium.cmake
index a1b9a39bb6..f5342e3d34 100644
--- a/third-party/cmake/BuildUnibilium.cmake
+++ b/third-party/cmake/BuildUnibilium.cmake
@@ -1,26 +1,49 @@
if(WIN32)
- message(STATUS "Building Unibilium in Windows is not supported (skipping)")
- return()
+ ExternalProject_Add(unibilium
+ PREFIX ${DEPS_BUILD_DIR}
+ URL ${UNIBILIUM_URL}
+ DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/unibilium
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND}
+ -DPREFIX=${DEPS_BUILD_DIR}
+ -DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/unibilium
+ -DURL=${UNIBILIUM_URL}
+ -DEXPECTED_SHA256=${UNIBILIUM_SHA256}
+ -DTARGET=unibilium
+ -DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
+ CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_CURRENT_SOURCE_DIR}/cmake/UnibiliumCMakeLists.txt
+ ${DEPS_BUILD_DIR}/src/unibilium/CMakeLists.txt
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_CURRENT_SOURCE_DIR}/msvc-compat/unistd.h
+ ${DEPS_BUILD_DIR}/src/unibilium/msvc-compat/unistd.h
+ COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/unibilium
+ -DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
+ # Pass toolchain
+ -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}
+ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+ -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
+ BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE}
+ INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE})
+else()
+ ExternalProject_Add(unibilium
+ PREFIX ${DEPS_BUILD_DIR}
+ URL ${UNIBILIUM_URL}
+ DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/unibilium
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND}
+ -DPREFIX=${DEPS_BUILD_DIR}
+ -DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/unibilium
+ -DURL=${UNIBILIUM_URL}
+ -DEXPECTED_SHA256=${UNIBILIUM_SHA256}
+ -DTARGET=unibilium
+ -DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
+ CONFIGURE_COMMAND ""
+ BUILD_IN_SOURCE 1
+ BUILD_COMMAND ${MAKE_PRG} CC=${DEPS_C_COMPILER}
+ PREFIX=${DEPS_INSTALL_DIR}
+ CFLAGS=-fPIC
+ INSTALL_COMMAND ${MAKE_PRG} PREFIX=${DEPS_INSTALL_DIR} install)
endif()
-ExternalProject_Add(unibilium
- PREFIX ${DEPS_BUILD_DIR}
- URL ${UNIBILIUM_URL}
- DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/unibilium
- DOWNLOAD_COMMAND ${CMAKE_COMMAND}
- -DPREFIX=${DEPS_BUILD_DIR}
- -DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/unibilium
- -DURL=${UNIBILIUM_URL}
- -DEXPECTED_SHA256=${UNIBILIUM_SHA256}
- -DTARGET=unibilium
- -DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
- -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
- CONFIGURE_COMMAND ""
- BUILD_IN_SOURCE 1
- BUILD_COMMAND ${MAKE_PRG} CC=${DEPS_C_COMPILER}
- PREFIX=${DEPS_INSTALL_DIR}
- CFLAGS=-fPIC
- ${DEFAULT_MAKE_CFLAGS}
- INSTALL_COMMAND ${MAKE_PRG} PREFIX=${DEPS_INSTALL_DIR} install)
-
list(APPEND THIRD_PARTY_DEPS unibilium)
diff --git a/third-party/cmake/UnibiliumCMakeLists.txt b/third-party/cmake/UnibiliumCMakeLists.txt
new file mode 100644
index 0000000000..3c419654c4
--- /dev/null
+++ b/third-party/cmake/UnibiliumCMakeLists.txt
@@ -0,0 +1,27 @@
+cmake_minimum_required(VERSION 2.8.7)
+project(unibilium LANGUAGES C)
+
+file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/*.c)
+add_library(unibilium ${SRC_FILES})
+set_target_properties(unibilium PROPERTIES PUBLIC_HEADER ${PROJECT_SOURCE_DIR}/unibilium.h
+ VERSION "${VERSION_MAJOR}.${VERSION_MINOR}")
+
+if(NOT WIN32)
+ execute_process(COMMAND "shell ncursesw6-config --terminfo-dirs 2>/dev/null || \
+ ncurses6-config --terminfo-dirs 2>/dev/null || \
+ ncursesw5-config --terminfo-dirs 2>/dev/null || \
+ ncurses5-config --terminfo-dirs 2>/dev/null || \
+ echo '/etc/terminfo:/lib/terminfo:/usr/share/terminfo:/usr/lib/terminfo:/usr/local/share/terminfo:/usr/local/lib/terminfo'"
+ OUTPUT_VARIABLE TERMINFO_DIRS)
+endif()
+target_compile_definitions(unibilium PUBLIC TERMINFO_DIRS ${TERMINFO_DIRS})
+
+if(MSVC)
+ target_include_directories(unibilium PUBLIC ${PROJECT_SOURCE_DIR}/msvc-compat)
+endif()
+
+include(GNUInstallDirs)
+install(TARGETS unibilium
+ PUBLIC_HEADER
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
diff --git a/third-party/msvc-compat/unistd.h b/third-party/msvc-compat/unistd.h
new file mode 100644
index 0000000000..d9ee57b54b
--- /dev/null
+++ b/third-party/msvc-compat/unistd.h
@@ -0,0 +1,10 @@
+#ifndef GUARD_UNIBILIUM_UNISTD_H_
+#define GUARD_UNIBILIUM_UNISTD_H_
+
+#ifdef _WIN64
+typedef unsigned __int64 ssize_t;
+#else
+typedef _W64 unsigned int ssize_t;
+#endif
+
+#endif
diff --git a/third-party/patches/libvterm-Remove-VLAs-for-MSVC.patch b/third-party/patches/libvterm-Remove-VLAs-for-MSVC.patch
new file mode 100644
index 0000000000..3fb18351be
--- /dev/null
+++ b/third-party/patches/libvterm-Remove-VLAs-for-MSVC.patch
@@ -0,0 +1,50 @@
+From eb386b1d82f7d07363c9133b7aa06902ccd555fe Mon Sep 17 00:00:00 2001
+Date: Tue, 27 Feb 2018 17:54:20 -0600
+Subject: [PATCH] Remove VLAs for MSVC
+
+VLAs are replaced with calls to _alloca() because MSVC does not support them.
+---
+ src/state.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/src/state.c b/src/state.c
+index 84299df..f9aabb3 100644
+--- a/src/state.c
++++ b/src/state.c
+@@ -1,5 +1,6 @@
+ #include "vterm_internal.h"
+
++#include <malloc.h>
+ #include <stdio.h>
+ #include <string.h>
+
+@@ -236,7 +237,7 @@ static int on_text(const char bytes[], size_t len, void *user)
+ VTermPos oldpos = state->pos;
+
+ // We'll have at most len codepoints
+- uint32_t codepoints[len];
++ uint32_t* codepoints = _alloca(len);
+ int npoints = 0;
+ size_t eaten = 0;
+
+@@ -313,7 +314,7 @@ static int on_text(const char bytes[], size_t len, void *user)
+
+ int width = 0;
+
+- uint32_t chars[glyph_ends - glyph_starts + 1];
++ uint32_t* chars = _alloca(glyph_ends - glyph_starts + 1);
+
+ for( ; i < glyph_ends; i++) {
+ chars[i - glyph_starts] = codepoints[i];
+@@ -512,7 +513,7 @@ static int settermprop_int(VTermState *state, VTermProp prop, int v)
+
+ static int settermprop_string(VTermState *state, VTermProp prop, const char *str, size_t len)
+ {
+- char strvalue[len+1];
++ char* strvalue = _alloca(len+1);
+ strncpy(strvalue, str, len);
+ strvalue[len] = 0;
+
+--
+2.16.1.windows.4
+
diff --git a/third-party/patches/luarocks-Change-default-downloader-to-curl.patch b/third-party/patches/luarocks-Change-default-downloader-to-curl.patch
new file mode 100644
index 0000000000..b7109a3b53
--- /dev/null
+++ b/third-party/patches/luarocks-Change-default-downloader-to-curl.patch
@@ -0,0 +1,24 @@
+From 69313032fad04743c96bc8f2a029b691857488f9 Mon Sep 17 00:00:00 2001
+Date: Thu, 1 Mar 2018 21:41:29 -0600
+Subject: [PATCH] Change default downloader to curl
+
+---
+ install.bat | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/install.bat b/install.bat
+index 09cf9aa..76e4059 100644
+--- a/install.bat
++++ b/install.bat
+@@ -1037,7 +1037,7 @@ f:write(S[=[
+ site_config.LUAROCKS_UNAME_M=[[$UNAME_M]]
+ site_config.LUAROCKS_ROCKS_TREE=[[$TREE_ROOT]]
+ site_config.LUAROCKS_PREFIX=[[$PREFIX]]
+-site_config.LUAROCKS_DOWNLOADER=[[wget]]
++site_config.LUAROCKS_DOWNLOADER=[[curl]]
+ site_config.LUAROCKS_MD5CHECKER=[[md5sum]]
+ ]=])
+ if FORCE_CONFIG then
+--
+2.16.1.windows.4
+