mirror of
https://github.com/neovim/neovim.git
synced 2025-09-30 06:58:35 +00:00
Merge #8128 'build/windows: Simplify build requirements'
This commit is contained in:
@@ -34,11 +34,15 @@ Install from source
|
|||||||
make CMAKE_BUILD_TYPE=RelWithDebInfo
|
make CMAKE_BUILD_TYPE=RelWithDebInfo
|
||||||
sudo make install
|
sudo make install
|
||||||
|
|
||||||
To install to a non-default location, specify `CMAKE_INSTALL_PREFIX`:
|
To install to a non-default location, set `CMAKE_INSTALL_PREFIX`:
|
||||||
|
|
||||||
make CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=/full/path/"
|
make CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=/full/path/"
|
||||||
make install
|
make install
|
||||||
|
|
||||||
|
To list all targets:
|
||||||
|
|
||||||
|
cmake --build build --target help
|
||||||
|
|
||||||
See [the wiki](https://github.com/neovim/neovim/wiki/Building-Neovim) for details.
|
See [the wiki](https://github.com/neovim/neovim/wiki/Building-Neovim) for details.
|
||||||
|
|
||||||
Install from package
|
Install from package
|
||||||
|
@@ -42,6 +42,7 @@ foreach(PACKAGE ${PACKAGES})
|
|||||||
nvim
|
nvim
|
||||||
WORKING_DIRECTORY "${GENERATED_PACKAGE_DIR}/${PACKNAME}"
|
WORKING_DIRECTORY "${GENERATED_PACKAGE_DIR}/${PACKNAME}"
|
||||||
)
|
)
|
||||||
|
add_dependencies(${PACKNAME}-tags nvim_runtime_deps)
|
||||||
|
|
||||||
add_custom_command(OUTPUT "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags"
|
add_custom_command(OUTPUT "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags"
|
||||||
DEPENDS
|
DEPENDS
|
||||||
@@ -80,6 +81,7 @@ add_custom_target(helptags
|
|||||||
nvim
|
nvim
|
||||||
WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}"
|
WORKING_DIRECTORY "${GENERATED_RUNTIME_DIR}"
|
||||||
)
|
)
|
||||||
|
add_dependencies(helptags nvim_runtime_deps)
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${GENERATED_HELP_TAGS}
|
add_custom_command(OUTPUT ${GENERATED_HELP_TAGS}
|
||||||
DEPENDS
|
DEPENDS
|
||||||
|
@@ -455,6 +455,8 @@ if(WIN32)
|
|||||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/platforms/qwindows.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/platforms/
|
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)
|
add_dependencies(nvim_runtime_deps external_blobs)
|
||||||
|
else()
|
||||||
|
add_custom_target(nvim_runtime_deps) # Stub target to avoid CMP0046.
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(
|
add_library(
|
||||||
|
7
third-party/CMakeLists.txt
vendored
7
third-party/CMakeLists.txt
vendored
@@ -29,6 +29,7 @@ set(DEPS_DOWNLOAD_DIR "${DEPS_BUILD_DIR}/downloads" CACHE PATH "Dependencies dow
|
|||||||
|
|
||||||
option(USE_BUNDLED "Use bundled dependencies." ON)
|
option(USE_BUNDLED "Use bundled dependencies." ON)
|
||||||
|
|
||||||
|
option(USE_BUNDLED_GPERF "Use the bundled version of gperf." ${USE_BUNDLED})
|
||||||
option(USE_BUNDLED_JEMALLOC "Use the bundled jemalloc." ${USE_BUNDLED})
|
option(USE_BUNDLED_JEMALLOC "Use the bundled jemalloc." ${USE_BUNDLED})
|
||||||
option(USE_BUNDLED_UNIBILIUM "Use the bundled unibilium." ${USE_BUNDLED})
|
option(USE_BUNDLED_UNIBILIUM "Use the bundled unibilium." ${USE_BUNDLED})
|
||||||
option(USE_BUNDLED_LIBTERMKEY "Use the bundled libtermkey." ${USE_BUNDLED})
|
option(USE_BUNDLED_LIBTERMKEY "Use the bundled libtermkey." ${USE_BUNDLED})
|
||||||
@@ -42,12 +43,6 @@ option(USE_BUNDLED_LUV "Use the bundled version of luv." ${USE_BUNDLED})
|
|||||||
# build it unless explicitly requested
|
# build it unless explicitly requested
|
||||||
option(USE_BUNDLED_LUA "Use the bundled version of lua." OFF)
|
option(USE_BUNDLED_LUA "Use the bundled version of lua." OFF)
|
||||||
|
|
||||||
if(USE_BUNDLED AND (NOT WIN32))
|
|
||||||
option(USE_BUNDLED_GPERF "Use the bundled version of gperf." ON)
|
|
||||||
else()
|
|
||||||
option(USE_BUNDLED_GPERF "Use the bundled version of gperf." OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(USE_EXISTING_SRC_DIR "Skip download of deps sources in case of existing source directory." OFF)
|
option(USE_EXISTING_SRC_DIR "Skip download of deps sources in case of existing source directory." OFF)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
17
third-party/cmake/BuildGperf.cmake
vendored
17
third-party/cmake/BuildGperf.cmake
vendored
@@ -36,8 +36,6 @@ function(BuildGperf)
|
|||||||
INSTALL_COMMAND "${_gperf_INSTALL_COMMAND}")
|
INSTALL_COMMAND "${_gperf_INSTALL_COMMAND}")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
set(GPERF_BUILDARGS CC=${HOSTDEPS_C_COMPILER} LD=${HOSTDEPS_C_COMPILER})
|
|
||||||
|
|
||||||
if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING))
|
if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING))
|
||||||
|
|
||||||
BuildGperf(
|
BuildGperf(
|
||||||
@@ -45,6 +43,21 @@ if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING))
|
|||||||
--prefix=${HOSTDEPS_INSTALL_DIR}
|
--prefix=${HOSTDEPS_INSTALL_DIR}
|
||||||
INSTALL_COMMAND ${MAKE_PRG} install)
|
INSTALL_COMMAND ${MAKE_PRG} install)
|
||||||
|
|
||||||
|
elseif(MSVC OR MINGW)
|
||||||
|
|
||||||
|
BuildGperf(
|
||||||
|
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/GperfCMakeLists.txt
|
||||||
|
${DEPS_BUILD_DIR}/src/gperf/CMakeLists.txt
|
||||||
|
COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/gperf/CMakeLists.txt
|
||||||
|
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||||
|
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||||
|
-DCMAKE_GENERATOR=${CMAKE_GENERATOR}
|
||||||
|
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||||
|
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
|
||||||
|
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE}
|
||||||
|
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE})
|
||||||
|
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Trying to build gperf in an unsupported system ${CMAKE_SYSTEM_NAME}/${CMAKE_C_COMPILER_ID}")
|
message(FATAL_ERROR "Trying to build gperf in an unsupported system ${CMAKE_SYSTEM_NAME}/${CMAKE_C_COMPILER_ID}")
|
||||||
endif()
|
endif()
|
||||||
|
35
third-party/cmake/BuildLibuv.cmake
vendored
35
third-party/cmake/BuildLibuv.cmake
vendored
@@ -70,28 +70,19 @@ elseif(MINGW)
|
|||||||
|
|
||||||
elseif(WIN32 AND MSVC)
|
elseif(WIN32 AND MSVC)
|
||||||
|
|
||||||
find_package(PythonInterp 2.6 REQUIRED)
|
set(UV_OUTPUT_DIR ${DEPS_BUILD_DIR}/src/libuv/${CMAKE_BUILD_TYPE})
|
||||||
if(NOT PYTHONINTERP_FOUND OR PYTHON_VERSION_MAJOR GREATER 2)
|
BuildLibUv(BUILD_IN_SOURCE
|
||||||
message(FATAL_ERROR "Python2 is required to build libuv on windows, use -DPYTHON_EXECUTABLE to set a python interpreter")
|
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
endif()
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/LibuvCMakeLists.txt
|
||||||
|
${DEPS_BUILD_DIR}/src/libuv/CMakeLists.txt
|
||||||
include(TargetArch)
|
COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/libuv/CMakeLists.txt
|
||||||
if(TARGET_ARCH STREQUAL "X86_64")
|
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||||
set(TARGET_ARCH x64)
|
-DCMAKE_GENERATOR=${CMAKE_GENERATOR}
|
||||||
elseif(TARGET_ARCH STREQUAL "X86")
|
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||||
set(TARGET_ARCH x86)
|
-DBUILD_SHARED_LIBS=ON
|
||||||
endif()
|
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE}
|
||||||
set(TARGET_CONFIG debug)
|
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE}
|
||||||
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 ${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
|
|
||||||
# Some applications (lua-client/luarocks) look for uv.lib instead of libuv.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.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/
|
||||||
|
11
third-party/cmake/BuildLibvterm.cmake
vendored
11
third-party/cmake/BuildLibvterm.cmake
vendored
@@ -38,13 +38,16 @@ if(WIN32)
|
|||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(LIBVTERM_PATCH_COMMAND
|
set(LIBVTERM_PATCH_COMMAND
|
||||||
${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/libvterm init
|
${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/libvterm init
|
||||||
COMMAND ${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/libvterm apply
|
COMMAND ${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/libvterm apply --ignore-whitespace
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/patches/libvterm-Remove-VLAs-for-MSVC.patch)
|
${CMAKE_CURRENT_SOURCE_DIR}/patches/libvterm-Remove-VLAs-for-MSVC.patch)
|
||||||
endif()
|
endif()
|
||||||
set(LIBVTERM_CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy
|
set(LIBVTERM_CONFIGURE_COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/LibvtermCMakeLists.txt
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/LibvtermCMakeLists.txt
|
||||||
${DEPS_BUILD_DIR}/src/libvterm/CMakeLists.txt
|
${DEPS_BUILD_DIR}/src/libvterm/CMakeLists.txt
|
||||||
COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/libvterm
|
COMMAND ${CMAKE_COMMAND} -E copy
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Libvterm-tbl2inc_c.cmake
|
||||||
|
${DEPS_BUILD_DIR}/src/libvterm/tbl2inc_c.cmake
|
||||||
|
COMMAND ${CMAKE_COMMAND} ${DEPS_BUILD_DIR}/src/libvterm
|
||||||
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
|
-DCMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR}
|
||||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||||
"-DCMAKE_C_FLAGS:STRING=${CMAKE_C_COMPILER_ARG1} -fPIC"
|
"-DCMAKE_C_FLAGS:STRING=${CMAKE_C_COMPILER_ARG1} -fPIC"
|
||||||
|
2
third-party/cmake/BuildLuarocks.cmake
vendored
2
third-party/cmake/BuildLuarocks.cmake
vendored
@@ -85,7 +85,7 @@ elseif(MSVC OR MINGW)
|
|||||||
BuildLuarocks(
|
BuildLuarocks(
|
||||||
PATCH_COMMAND
|
PATCH_COMMAND
|
||||||
${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/luarocks init
|
${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/luarocks init
|
||||||
COMMAND ${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/luarocks apply
|
COMMAND ${GIT_EXECUTABLE} -C ${DEPS_BUILD_DIR}/src/luarocks apply --ignore-whitespace
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/patches/luarocks-Change-default-downloader-to-curl.patch
|
${CMAKE_CURRENT_SOURCE_DIR}/patches/luarocks-Change-default-downloader-to-curl.patch
|
||||||
INSTALL_COMMAND install.bat /FORCECONFIG /NOREG /NOADMIN /Q /F
|
INSTALL_COMMAND install.bat /FORCECONFIG /NOREG /NOADMIN /Q /F
|
||||||
/LUA ${DEPS_INSTALL_DIR}
|
/LUA ${DEPS_INSTALL_DIR}
|
||||||
|
30
third-party/cmake/GperfCMakeLists.txt
vendored
Normal file
30
third-party/cmake/GperfCMakeLists.txt
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8.7)
|
||||||
|
project(gperf LANGUAGES C CXX)
|
||||||
|
|
||||||
|
add_executable(gperf
|
||||||
|
lib/getline.cc
|
||||||
|
lib/hash.cc
|
||||||
|
lib/getopt.c
|
||||||
|
lib/getopt1.c
|
||||||
|
src/version.cc
|
||||||
|
src/positions.cc
|
||||||
|
src/options.cc
|
||||||
|
src/keyword.cc
|
||||||
|
src/keyword-list.cc
|
||||||
|
src/input.cc
|
||||||
|
src/bool-array.cc
|
||||||
|
src/hash-table.cc
|
||||||
|
src/search.cc
|
||||||
|
src/output.cc
|
||||||
|
src/main.cc)
|
||||||
|
|
||||||
|
include_directories(lib)
|
||||||
|
|
||||||
|
# Copy the config.h template without modifying it
|
||||||
|
# because none of the definitions are necessary
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/src/config.h.in ${CMAKE_BINARY_DIR}/config/config.h)
|
||||||
|
include_directories(${CMAKE_BINARY_DIR}/config)
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
install(TARGETS gperf
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
27
third-party/cmake/LibuvCMakeLists.txt
vendored
Normal file
27
third-party/cmake/LibuvCMakeLists.txt
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8.7)
|
||||||
|
project(libuv LANGUAGES C)
|
||||||
|
|
||||||
|
file(GLOB UV_SOURCES_COMMON src/*.c)
|
||||||
|
file(GLOB UV_SOURCES_WIN src/win/*.c)
|
||||||
|
|
||||||
|
add_library(libuv ${UV_SOURCES_COMMON} ${UV_SOURCES_WIN})
|
||||||
|
target_compile_definitions(libuv PRIVATE WIN32_LEAN_AND_MEAN "_WIN32_WINNT=0x0600")
|
||||||
|
target_link_libraries(libuv iphlpapi psapi shell32 userenv ws2_32)
|
||||||
|
target_include_directories(libuv PUBLIC ./include PRIVATE ./src)
|
||||||
|
set_target_properties(libuv PROPERTIES DEFINE_SYMBOL BUILDING_UV_SHARED)
|
||||||
|
|
||||||
|
install(FILES
|
||||||
|
include/tree.h
|
||||||
|
include/uv.h
|
||||||
|
include/uv-version.h
|
||||||
|
include/uv-errno.h
|
||||||
|
include/uv-threadpool.h
|
||||||
|
include/uv-win.h
|
||||||
|
DESTINATION include)
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
install(TARGETS libuv
|
||||||
|
PUBLIC_HEADER
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
163
third-party/cmake/Libvterm-tbl2inc_c.cmake
vendored
Normal file
163
third-party/cmake/Libvterm-tbl2inc_c.cmake
vendored
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8.7)
|
||||||
|
|
||||||
|
set(HEX_ALPHABET "0123456789abcdef")
|
||||||
|
|
||||||
|
function(ConvertToHex dec hex)
|
||||||
|
while(dec GREATER 0)
|
||||||
|
math(EXPR _val "${dec} % 16")
|
||||||
|
math(EXPR dec "${dec} / 16")
|
||||||
|
string(SUBSTRING ${HEX_ALPHABET} ${_val} 1 _val)
|
||||||
|
set(_res "${_val}${_res}")
|
||||||
|
endwhile()
|
||||||
|
# Pad the result with the number of zeros
|
||||||
|
# specified by the optional third argument
|
||||||
|
if(${ARGC} EQUAL 3)
|
||||||
|
set(padding ${ARGV2})
|
||||||
|
string(LENGTH ${_res} _resLen)
|
||||||
|
if(_resLen LESS ${padding})
|
||||||
|
math(EXPR _neededPadding "${padding} - ${_resLen}")
|
||||||
|
foreach(i RANGE 1 ${_neededPadding})
|
||||||
|
set(_res "0${_res}")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
set(${hex} "0x${_res}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(ConvertFromHex hex dec)
|
||||||
|
string(TOLOWER ${hex} hex)
|
||||||
|
string(LENGTH "${hex}" _strlen)
|
||||||
|
set(_res 0)
|
||||||
|
while(_strlen GREATER 0)
|
||||||
|
math(EXPR _res "${_res} * 16")
|
||||||
|
string(SUBSTRING "${hex}" 0 1 NIBBLE)
|
||||||
|
string(SUBSTRING "${hex}" 1 -1 hex)
|
||||||
|
string(FIND ${HEX_ALPHABET} ${NIBBLE} value)
|
||||||
|
if(value EQUAL -1)
|
||||||
|
message(FATAL_ERROR "Invalid hex character '${NIBBLE}'")
|
||||||
|
endif()
|
||||||
|
math(EXPR _res "${_res} + ${value}")
|
||||||
|
string(LENGTH "${hex}" _strlen)
|
||||||
|
endwhile()
|
||||||
|
set(${dec} ${_res} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Based on http://www.json.org/JSON_checker/utf8_decode.c
|
||||||
|
function(DecodeUtf8 hexBytes codePoint)
|
||||||
|
string(SUBSTRING ${hexBytes} 0 2 hexByte1)
|
||||||
|
ConvertFromHex(${hexByte1} byte1)
|
||||||
|
# Zero continuations (0 to 127)
|
||||||
|
math(EXPR out "${byte1} & 128")
|
||||||
|
if(out EQUAL 0)
|
||||||
|
set(${codePoint} ${byte1} PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
# One continuation (128 to 2047)
|
||||||
|
math(EXPR out "${byte1} & 224")
|
||||||
|
if(out EQUAL 192)
|
||||||
|
string(SUBSTRING ${hexBytes} 2 2 hexByte2)
|
||||||
|
ConvertFromHex(${hexByte2} byte2)
|
||||||
|
math(EXPR result "((${byte1} & 31) << 6) | ${byte2}")
|
||||||
|
if(result GREATER 127)
|
||||||
|
set(${codePoint} ${result} PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
# Two continuations (2048 to 55295 and 57344 to 65535)
|
||||||
|
math(EXPR result "${byte1} & 240")
|
||||||
|
if(result EQUAL 224)
|
||||||
|
string(SUBSTRING ${hexBytes} 2 2 hexByte2)
|
||||||
|
string(SUBSTRING ${hexBytes} 4 2 hexByte3)
|
||||||
|
ConvertFromHex(${hexByte2} byte2)
|
||||||
|
ConvertFromHex(${hexByte3} byte3)
|
||||||
|
math(EXPR result "${byte2} | ${byte3}")
|
||||||
|
if(result GREATER -1)
|
||||||
|
math(EXPR result "((${byte1} & 15) << 12) | (${byte2} << 6) | ${byte3}")
|
||||||
|
if((result GREATER 2047) AND (result LESS 55296 OR result GREATER 57343))
|
||||||
|
set(${codePoint} ${result} PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
# Three continuations (65536 to 1114111)
|
||||||
|
math(EXPR result "${byte1} & 248")
|
||||||
|
if(result EQUAL 224)
|
||||||
|
string(SUBSTRING ${hexBytes} 2 2 hexByte2)
|
||||||
|
string(SUBSTRING ${hexBytes} 4 2 hexByte3)
|
||||||
|
string(SUBSTRING ${hexBytes} 6 2 hexByte4)
|
||||||
|
ConvertFromHex(${hexByte2} byte2)
|
||||||
|
ConvertFromHex(${hexByte3} byte3)
|
||||||
|
ConvertFromHex(${hexByte4} byte4)
|
||||||
|
math(EXPR result "${byte2} | ${byte3} | ${byte4}")
|
||||||
|
if(result GREATER -1)
|
||||||
|
math(EXPR result "((c & 7) << 18) | (c1 << 12) | (c2 << 6) | c3")
|
||||||
|
if((result GREATER 65535) AND (result LESS 1114112))
|
||||||
|
set(${codePoint} ${result} PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
message(FATAL_ERROR "Invalid UTF-8 encoding")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
set(inputFile ${CMAKE_ARGV3})
|
||||||
|
set(outputFile ${CMAKE_ARGV4})
|
||||||
|
# Get the file contents in text and hex-encoded format because
|
||||||
|
# CMake doesn't provide functions for converting between the two
|
||||||
|
file(READ "${inputFile}" contents)
|
||||||
|
file(READ "${inputFile}" hexContents HEX)
|
||||||
|
|
||||||
|
# Convert the text contents into a list of lines by escaping
|
||||||
|
# the list separator ';' and then replacing new line characters
|
||||||
|
# with the list separator
|
||||||
|
string(REGEX REPLACE ";" "\\\\;" contents ${contents})
|
||||||
|
string(REGEX REPLACE "\n" ";" contents ${contents})
|
||||||
|
|
||||||
|
get_filename_component(encname ${inputFile} NAME_WE)
|
||||||
|
set(output
|
||||||
|
"static const struct StaticTableEncoding encoding_${encname} = {\n"
|
||||||
|
" { .decode = &decode_table },\n"
|
||||||
|
" {")
|
||||||
|
set(hexIndex 0)
|
||||||
|
foreach(line ${contents})
|
||||||
|
string(LENGTH ${line} lineLength)
|
||||||
|
# Convert "A" to 0x41
|
||||||
|
string(FIND ${line} "\"" beginQuote)
|
||||||
|
if(NOT ${beginQuote} EQUAL -1)
|
||||||
|
string(FIND ${line} "\"" endQuote REVERSE)
|
||||||
|
if(${beginQuote} EQUAL ${endQuote})
|
||||||
|
message(FATAL_ERROR "Line contains only one quote")
|
||||||
|
endif()
|
||||||
|
math(EXPR beginHexQuote "${hexIndex} + (${beginQuote} + 1)*2")
|
||||||
|
math(EXPR endHexQuote "${hexIndex} + (${endQuote} + 1)*2")
|
||||||
|
math(EXPR quoteLen "${endHexQuote} - ${beginHexQuote} - 1")
|
||||||
|
string(SUBSTRING ${hexContents} ${beginHexQuote} ${quoteLen} hexQuote)
|
||||||
|
DecodeUtf8(${hexQuote} codePoint)
|
||||||
|
ConvertToHex(${codePoint} hexCodePoint 4)
|
||||||
|
STRING(REGEX REPLACE "\"(.+)\"" ${hexCodePoint} line ${line})
|
||||||
|
endif()
|
||||||
|
# Strip comment
|
||||||
|
string(REGEX REPLACE "[ \t\n]*#.*" "" line ${line})
|
||||||
|
# Convert 3/1 to [0x31]
|
||||||
|
string(REGEX REPLACE "^([0-9]+)/([0-9]+).*" "\\1;\\2" numbers ${line})
|
||||||
|
list(GET numbers 0 upperBits)
|
||||||
|
list(GET numbers 1 lowerBits)
|
||||||
|
math(EXPR res "${upperBits}*16 + ${lowerBits}")
|
||||||
|
ConvertToHex(${res} hex 2)
|
||||||
|
string(REGEX REPLACE "^([0-9]+)/([0-9]+)" "[${hex}]" line ${line})
|
||||||
|
# Convert U+0041 to 0x0041
|
||||||
|
string(REPLACE "U+" "0x" line ${line})
|
||||||
|
# Indent and append a comma
|
||||||
|
set(line " ${line},")
|
||||||
|
set(output "${output}\n${line}")
|
||||||
|
# Increment the index by the number of characters in the line,
|
||||||
|
# plus one for the new line character then multiple by two for the hex digit index
|
||||||
|
math(EXPR hexIndex "${hexIndex} + 2*(${lineLength} + 1)")
|
||||||
|
endforeach()
|
||||||
|
set(output "${output}\n"
|
||||||
|
" }\n"
|
||||||
|
"}\;\n")
|
||||||
|
|
||||||
|
file(WRITE ${outputFile} ${output})
|
43
third-party/cmake/LibvtermCMakeLists.txt
vendored
43
third-party/cmake/LibvtermCMakeLists.txt
vendored
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.11)
|
|||||||
project(libvterm LANGUAGES C)
|
project(libvterm LANGUAGES C)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
find_package(Perl REQUIRED)
|
find_package(Perl)
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
add_definitions(/W3 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
|
add_definitions(/W3 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
|
||||||
@@ -18,11 +18,19 @@ foreach(file ${TBL_FILES})
|
|||||||
set(tname encoding/${basename}.inc)
|
set(tname encoding/${basename}.inc)
|
||||||
add_custom_command(OUTPUT
|
add_custom_command(OUTPUT
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/encoding/
|
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}
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/tbl2inc_c.cmake ${file} ${CMAKE_BINARY_DIR}/${tname}
|
||||||
COMMENT "Generating ${tname}"
|
COMMENT "Generating ${tname}"
|
||||||
OUTPUT ${CMAKE_BINARY_DIR}/${tname}
|
OUTPUT ${CMAKE_BINARY_DIR}/${tname}
|
||||||
)
|
)
|
||||||
list(APPEND TBL_FILES_HEADERS ${tname})
|
list(APPEND TBL_FILES_HEADERS ${tname})
|
||||||
|
# Only used for verifying that the output of tbl2inc_c.cmake is correct
|
||||||
|
set(tname encoding-test/${basename}.inc)
|
||||||
|
add_custom_command(OUTPUT
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/encoding-test/
|
||||||
|
COMMAND ${PERL_EXECUTABLE} -CSD ${CMAKE_SOURCE_DIR}/tbl2inc_c.pl ${file} > ${CMAKE_BINARY_DIR}/${tname}
|
||||||
|
COMMENT "Generating ${tname}"
|
||||||
|
OUTPUT ${CMAKE_BINARY_DIR}/${tname}
|
||||||
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/include)
|
include_directories(${CMAKE_SOURCE_DIR}/include)
|
||||||
@@ -60,13 +68,24 @@ set_target_properties(harness PROPERTIES
|
|||||||
# run-test.pl expects to find the harness in t/.libs/
|
# run-test.pl expects to find the harness in t/.libs/
|
||||||
RUNTIME_OUTPUT_DIRECTORY t/.libs)
|
RUNTIME_OUTPUT_DIRECTORY t/.libs)
|
||||||
|
|
||||||
file(GLOB TESTFILES ${CMAKE_SOURCE_DIR}/t/*.test)
|
if(Perl_FOUND)
|
||||||
add_custom_target(check)
|
file(GLOB TESTFILES ${CMAKE_SOURCE_DIR}/t/*.test)
|
||||||
foreach(testfile ${TESTFILES})
|
add_custom_target(check)
|
||||||
get_filename_component(target_name ${testfile} NAME_WE)
|
foreach(testfile ${TESTFILES})
|
||||||
add_custom_target(${target_name}
|
get_filename_component(target_name ${testfile} NAME_WE)
|
||||||
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/t/run-test.pl ${testfile}
|
add_custom_target(${target_name}
|
||||||
COMMENT "**${target_name} **"
|
COMMAND ${PERL_EXECUTABLE} ${CMAKE_SOURCE_DIR}/t/run-test.pl ${testfile}
|
||||||
DEPENDS harness)
|
COMMENT "**${target_name} **"
|
||||||
add_dependencies(check ${target_name})
|
DEPENDS harness)
|
||||||
endforeach()
|
add_dependencies(check ${target_name})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
foreach(header_path ${TBL_FILES_HEADERS})
|
||||||
|
get_filename_component(header_name ${header_path} NAME)
|
||||||
|
set(perl_header_path ${CMAKE_BINARY_DIR}/encoding-test/${header_name})
|
||||||
|
add_custom_target(test-${header_name}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E compare_files
|
||||||
|
${header_path} ${perl_header_path}
|
||||||
|
DEPENDS ${header_path} ${perl_header_path})
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
Reference in New Issue
Block a user