aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.travis.yml1
-rw-r--r--CMakeLists.txt34
-rw-r--r--cmake/FindLibIntl.cmake12
-rw-r--r--makedeps.bat18
-rw-r--r--src/nvim/CMakeLists.txt6
-rw-r--r--src/nvim/mbyte.c48
-rw-r--r--src/nvim/os/win_defs.h1
-rw-r--r--src/nvim/po/CMakeLists.txt2
-rw-r--r--third-party/CMakeLists.txt11
10 files changed, 110 insertions, 25 deletions
diff --git a/.gitignore b/.gitignore
index 85b371b926..cf0a11804d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
# Tools
.ropeproject/
+# Visual Studio
+/.vs/
# Build/deps dir
/build/
diff --git a/.travis.yml b/.travis.yml
index b275a5262d..fa884bd021 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -53,6 +53,7 @@ jobs:
compiler: clang
env: >
CLANG_SANITIZER=ASAN_UBSAN
+ # Use Lua so that ASAN can test our embedded Lua support. 8fec4d53d0f6
CMAKE_FLAGS="$CMAKE_FLAGS -DPREFER_LUA=ON"
sudo: true
- os: linux
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4cafdef73f..9660fae527 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,9 +13,9 @@ include(PreventInTreeBuilds)
# Prefer our bundled versions of dependencies.
if(DEFINED ENV{DEPS_BUILD_DIR})
-set(DEPS_PREFIX "$ENV{DEPS_BUILD_DIR}/usr" CACHE PATH "Path prefix for finding dependencies")
+ set(DEPS_PREFIX "$ENV{DEPS_BUILD_DIR}/usr" CACHE PATH "Path prefix for finding dependencies")
else()
-set(DEPS_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/.deps/usr" CACHE PATH "Path prefix for finding dependencies")
+ set(DEPS_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/.deps/usr" CACHE PATH "Path prefix for finding dependencies")
endif()
if(CMAKE_CROSSCOMPILING AND NOT UNIX)
list(INSERT CMAKE_FIND_ROOT_PATH 0 ${DEPS_PREFIX})
@@ -53,6 +53,14 @@ if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(USE_FNAME_CASE TRUE)
endif()
+option(ENABLE_LIBINTL "enable libintl" ON)
+if(MSVC)
+ add_definitions(-DDYNAMIC_ICONV)
+ option(ENABLE_LIBICONV "enable libiconv" OFF)
+else()
+ option(ENABLE_LIBICONV "enable libiconv" ON)
+endif()
+
# Set default build type.
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "CMAKE_BUILD_TYPE not given, defaulting to 'Debug'.")
@@ -331,6 +339,7 @@ if(PREFER_LUA)
find_package(Lua REQUIRED)
set(LUA_PREFERRED_INCLUDE_DIRS ${LUA_INCLUDE_DIR})
set(LUA_PREFERRED_LIBRARIES ${LUA_LIBRARIES})
+ # Passive (not REQUIRED): if LUAJIT_FOUND is not set, nvim-test is skipped.
find_package(LuaJit)
else()
find_package(LuaJit REQUIRED)
@@ -399,31 +408,30 @@ if((CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN) AND NOT CMAKE_C_COMPILER_ID MA
message(FATAL_ERROR "Sanitizers are only supported for Clang.")
endif()
-if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD|FreeBSD")
- message(STATUS "detected OpenBSD/FreeBSD; disabled jemalloc. #5318")
+if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD|FreeBSD|Windows") # see #5318
+ message(STATUS "skipping jemalloc on this system: ${CMAKE_SYSTEM_NAME}")
option(ENABLE_JEMALLOC "enable jemalloc" OFF)
else()
option(ENABLE_JEMALLOC "enable jemalloc" ON)
endif()
-if (ENABLE_JEMALLOC)
+if(ENABLE_JEMALLOC)
if(CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN)
message(STATUS "Sanitizers have been enabled; don't use jemalloc.")
else()
- find_package(JeMalloc)
- if(JEMALLOC_FOUND)
- include_directories(SYSTEM ${JEMALLOC_INCLUDE_DIRS})
- endif()
+ find_package(JeMalloc REQUIRED)
+ include_directories(SYSTEM ${JEMALLOC_INCLUDE_DIRS})
endif()
endif()
-find_package(LibIntl)
-if(LibIntl_FOUND)
+if(ENABLE_LIBINTL)
+ # LibIntl (not Intl) selects our FindLibIntl.cmake script. #8464
+ find_package(LibIntl REQUIRED)
include_directories(SYSTEM ${LibIntl_INCLUDE_DIRS})
endif()
-find_package(Iconv)
-if(Iconv_FOUND)
+if(ENABLE_LIBICONV)
+ find_package(Iconv REQUIRED)
include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
endif()
diff --git a/cmake/FindLibIntl.cmake b/cmake/FindLibIntl.cmake
index f8442566a9..738ae39983 100644
--- a/cmake/FindLibIntl.cmake
+++ b/cmake/FindLibIntl.cmake
@@ -34,9 +34,8 @@ if (LibIntl_INCLUDE_DIR)
set(CMAKE_REQUIRED_INCLUDES "${LibIntl_INCLUDE_DIR}")
endif()
-# This is required because some operating systems don't have a separate
-# libintl--it is built into glibc. So we only need to specify the library
-# if one was actually found.
+# On some systems (linux+glibc) libintl is passively available.
+# So only specify the library if one was found.
if (LibIntl_LIBRARY)
set(CMAKE_REQUIRED_LIBRARIES "${LibIntl_LIBRARY}")
endif()
@@ -53,6 +52,13 @@ int main(int argc, char** argv) {
}" HAVE_WORKING_LIBINTL)
if (HAVE_WORKING_LIBINTL)
+ # On some systems (linux+glibc) libintl is passively available.
+ # If HAVE_WORKING_LIBINTL then we consider the requirement satisfied.
+ # Unset REQUIRED so that libfind_process(LibIntl) can proceed.
+ if(LibIntl_FIND_REQUIRED)
+ unset(LibIntl_FIND_REQUIRED)
+ endif()
+
check_variable_exists(_nl_msg_cat_cntr HAVE_NL_MSG_CAT_CNTR)
endif()
diff --git a/makedeps.bat b/makedeps.bat
new file mode 100644
index 0000000000..a614885568
--- /dev/null
+++ b/makedeps.bat
@@ -0,0 +1,18 @@
+echo off
+
+if not defined VS150COMNTOOLS (
+ echo error: missing VS150COMNTOOLS environment variable.
+ echo Run this script from the 'Developer Command Prompt'.
+ exit /b 1
+)
+
+echo on
+
+set CMAKE=%VS150COMNTOOLS%\..\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe
+
+mkdir .deps
+cd .deps
+"%CMAKE%" -G "Visual Studio 15 2017" "-DCMAKE_BUILD_TYPE=RelWithDebInfo" ..\third-party\
+"%CMAKE%" --build . --config RelWithDebInfo -- "/verbosity:normal"
+cd ..
+
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 2d803792c8..65c3c6bbb9 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -457,6 +457,8 @@ if(WIN32)
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/Qt5Widgets.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/winpty.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
+ COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/libiconv-2.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
+
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/platforms/qwindows.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/platforms/
)
add_dependencies(nvim_runtime_deps external_blobs)
@@ -484,7 +486,9 @@ set_property(
APPEND_STRING PROPERTY COMPILE_FLAGS " -DMAKE_LIB "
)
-if(LUAJIT_FOUND)
+if(NOT LUAJIT_FOUND)
+ message(STATUS "luajit not found, skipping nvim-test (unit tests) target")
+else()
set(NVIM_TEST_LINK_LIBRARIES ${NVIM_LINK_LIBRARIES} ${LUAJIT_LIBRARIES})
add_library(
nvim-test
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index a52ab9f5d3..05e326104b 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -37,6 +37,8 @@
#ifdef HAVE_LOCALE_H
# include <locale.h>
#endif
+#include "nvim/eval.h"
+#include "nvim/path.h"
#include "nvim/iconv.h"
#include "nvim/mbyte.h"
#include "nvim/charset.h"
@@ -72,6 +74,9 @@ struct interval {
# include "unicode_tables.generated.h"
#endif
+char_u e_loadlib[] = "E370: Could not load library %s";
+char_u e_loadfunc[] = "E448: Could not load library function %s";
+
// To speed up BYTELEN(); keep a lookup table to quickly get the length in
// bytes of a UTF-8 character from the first byte of a UTF-8 string. Bytes
// which are illegal when used as the first byte have a 1. The NUL byte has
@@ -2038,9 +2043,10 @@ void * my_iconv_open(char_u *to, char_u *from)
return (void *)-1; /* detected a broken iconv() previously */
#ifdef DYNAMIC_ICONV
- /* Check if the iconv.dll can be found. */
- if (!iconv_enabled(true))
+ // Check if the iconv.dll can be found.
+ if (!iconv_enabled(true)) {
return (void *)-1;
+ }
#endif
fd = iconv_open((char *)enc_skip(to), (char *)enc_skip(from));
@@ -2162,7 +2168,7 @@ static HINSTANCE hMsvcrtDLL = 0;
# ifndef DYNAMIC_ICONV_DLL
# define DYNAMIC_ICONV_DLL "iconv.dll"
-# define DYNAMIC_ICONV_DLL_ALT "libiconv.dll"
+# define DYNAMIC_ICONV_DLL_ALT "libiconv-2.dll"
# endif
# ifndef DYNAMIC_MSVCRT_DLL
# define DYNAMIC_MSVCRT_DLL "msvcrt.dll"
@@ -2208,6 +2214,35 @@ static void * get_iconv_import_func(HINSTANCE hInst,
return NULL;
}
+// Load library "name".
+HINSTANCE vimLoadLib(char *name)
+{
+ HINSTANCE dll = NULL;
+
+ // NOTE: Do not use mch_dirname() and mch_chdir() here, they may call
+ // vimLoadLib() recursively, which causes a stack overflow.
+ WCHAR old_dirw[MAXPATHL];
+
+ // Path to exe dir.
+ char *buf = xstrdup((char *)get_vim_var_str(VV_PROGPATH));
+ // ptrdiff_t len = ;
+ // assert(len > 0);
+ buf[path_tail_with_sep(buf) - buf] = '\0';
+
+ if (GetCurrentDirectoryW(MAXPATHL, old_dirw) != 0) {
+ // Change directory to where the executable is, both to make
+ // sure we find a .dll there and to avoid looking for a .dll
+ // in the current directory.
+ SetCurrentDirectory((LPCSTR)buf);
+ // TODO(justinmk): use uv_dlopen instead. see os_libcall
+ dll = LoadLibrary(name);
+ SetCurrentDirectoryW(old_dirw);
+ }
+
+ return dll;
+}
+
+
/*
* Try opening the iconv.dll and return TRUE if iconv() can be used.
*/
@@ -2255,10 +2290,13 @@ bool iconv_enabled(bool verbose)
void iconv_end(void)
{
- if (hIconvDLL != 0)
+ if (hIconvDLL != 0) {
+ // TODO(justinmk): use uv_dlclose instead.
FreeLibrary(hIconvDLL);
- if (hMsvcrtDLL != 0)
+ }
+ if (hMsvcrtDLL != 0) {
FreeLibrary(hMsvcrtDLL);
+ }
hIconvDLL = 0;
hMsvcrtDLL = 0;
}
diff --git a/src/nvim/os/win_defs.h b/src/nvim/os/win_defs.h
index db93f016bf..356094baa1 100644
--- a/src/nvim/os/win_defs.h
+++ b/src/nvim/os/win_defs.h
@@ -59,7 +59,6 @@
#define BACKSLASH_IN_FILENAME
#ifdef _MSC_VER
-typedef SSIZE_T ssize_t;
typedef int mode_t;
#endif
diff --git a/src/nvim/po/CMakeLists.txt b/src/nvim/po/CMakeLists.txt
index 94cc63baea..a7b910f0eb 100644
--- a/src/nvim/po/CMakeLists.txt
+++ b/src/nvim/po/CMakeLists.txt
@@ -1,4 +1,4 @@
-find_package(Gettext)
+find_package(Gettext REQUIRED)
find_program(XGETTEXT_PRG xgettext)
find_program(ICONV_PRG iconv)
diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt
index d3843e302d..adb3d73293 100644
--- a/third-party/CMakeLists.txt
+++ b/third-party/CMakeLists.txt
@@ -157,16 +157,22 @@ set(WINGUI_SHA256 260efc686423e2529360b6a45c8e241fbbf276c8de6b04d44f45ab5b6fe8df
set(WIN32YANK_X86_URL https://github.com/equalsraf/win32yank/releases/download/v0.0.4/win32yank-x86.zip)
set(WIN32YANK_X86_SHA256 62f34e5a46c5d4a7b3f3b512e1ff7b77fedd432f42581cbe825233a996eed62c)
-
set(WIN32YANK_X86_64_URL https://github.com/equalsraf/win32yank/releases/download/v0.0.4/win32yank-x64.zip)
set(WIN32YANK_X86_64_SHA256 33a747a92da60fb65e668edbf7661d3d902411a2d545fe9dc08623cecd142a20)
set(WINPTY_URL https://github.com/rprichard/winpty/releases/download/0.4.3/winpty-0.4.3-msvc2015.zip)
set(WINPTY_SHA256 35a48ece2ff4acdcbc8299d4920de53eb86b1fb41e64d2fe5ae7898931bcee89)
+# gettext source (for building/linking, does NOT provide tools like msgmerge.exe)
set(GETTEXT_URL https://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.8.1.tar.gz)
set(GETTEXT_SHA256 ff942af0e438ced4a8b0ea4b0b6e0d6d657157c5e2364de57baa279c1c125c43)
+# gettext binary (for tools like msgmerge.exe)
+set(GETTEXT_X86_URL https://github.com/mlocati/gettext-iconv-windows/releases/download/v0.19.8.1-v1.15/gettext0.19.8.1-iconv1.15-shared-32.zip)
+set(GETTEXT_X86_SHA256 b7d8fe2d038950bc0447d664db614ebfc3100a1ba962a959d78e41bc708a2140)
+set(GETTEXT_X86_64_URL https://github.com/mlocati/gettext-iconv-windows/releases/download/v0.19.8.1-v1.15/gettext0.19.8.1-iconv1.15-shared-64.zip)
+set(GETTEXT_X86_64_SHA256 c8ed2897438efc0a511892c2b38b623ef0c9092aced2acbd3f3daf2f12ba70b4)
+
if(USE_BUNDLED_UNIBILIUM)
include(BuildUnibilium)
endif()
@@ -229,6 +235,9 @@ if(WIN32)
GetBinaryDep(TARGET "win32yank_${TARGET_ARCH}"
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy win32yank.exe ${DEPS_INSTALL_DIR}/bin)
+ GetBinaryDep(TARGET "gettext_${TARGET_ARCH}"
+ INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory bin ${DEPS_INSTALL_DIR}/bin)
+
if("${TARGET_ARCH}" STREQUAL "X86_64")
set(TARGET_ARCH x64)
elseif(TARGET_ARCH STREQUAL "X86")