build: various fixes

- simplify lua interpreter search
- fix incorrect variable name in BuildLua.cmake
- build PUC Lua with -O2
- silence non-mandatory find_package search for libuv
- simplify Find modules
- Prefer using the explicitly set CI_BUILD over relying on the
  environment variable "CI".
This commit is contained in:
dundargoc 2023-09-04 00:00:26 +02:00 committed by GitHub
parent af899971b9
commit c50951a4d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 12 additions and 47 deletions

View File

@ -173,23 +173,10 @@ foreach(CFGNAME ${CMAKE_CONFIGURATION_TYPES})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFGNAME} ${CMAKE_BINARY_DIR}/lib)
endforeach()
if(NOT LUA_PRG)
foreach(CURRENT_LUA_PRG luajit lua5.1 lua5.2 lua)
unset(_CHECK_LUA_PRG CACHE)
find_program(_CHECK_LUA_PRG ${CURRENT_LUA_PRG})
if(_CHECK_LUA_PRG)
set(LUA_PRG "${_CHECK_LUA_PRG}" CACHE FILEPATH "Path to a program.")
break()
endif()
endforeach()
unset(_CHECK_LUA_PRG CACHE)
endif()
find_program(LUA_PRG NAMES luajit lua5.1 lua5.2 lua)
if(NOT LUA_PRG)
message(FATAL_ERROR "Failed to find a Lua 5.1-compatible interpreter")
endif()
message(STATUS "Using Lua interpreter: ${LUA_PRG}")
# Some of the code generation still relies on stable table ordering in order to
@ -200,11 +187,9 @@ message(STATUS "Using Lua interpreter: ${LUA_PRG}")
if(NOT LUA_GEN_PRG)
set(LUA_GEN_PRG "${LUA_PRG}" CACHE FILEPATH "Path to the lua used for code generation.")
endif()
message(STATUS "Using Lua interpreter for code generation: ${LUA_GEN_PRG}")
option(COMPILE_LUA "Pre-compile Lua sources into bytecode (for sources that are included in the binary)" ON)
if(COMPILE_LUA AND NOT WIN32)
if(PREFER_LUA)
foreach(CURRENT_LUAC_PRG luac5.1 luac)
@ -221,14 +206,11 @@ if(COMPILE_LUA AND NOT WIN32)
endif()
endif()
endif()
if(LUAC_PRG)
message(STATUS "Using Lua compiler: ${LUAC_PRG}")
endif()
#
# Lint
#
option(CI_LINT "Abort if lint programs not found" OFF)
if(CI_LINT)
set(LINT_REQUIRED "REQUIRED")
@ -277,9 +259,7 @@ add_dependencies(lintcommit nvim)
add_custom_target(lint)
add_dependencies(lint clang-tidy lintc lintlua lintsh lintcommit)
#
# Format
#
add_custom_target(formatlua
COMMAND ${CMAKE_COMMAND}
-D FORMAT_PRG=${STYLUA_PRG}

View File

@ -5,9 +5,9 @@ elseif(APPLE)
elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(LUA_TARGET freebsd)
elseif(CMAKE_SYSTEM_NAME MATCHES "BSD")
set(CMAKE_LUA_TARGET bsd)
set(LUA_TARGET bsd)
elseif(CMAKE_SYSTEM_NAME MATCHES "^MINGW")
set(CMAKE_LUA_TARGET mingw)
set(LUA_TARGET mingw)
else()
if(UNIX)
set(LUA_TARGET posix)
@ -16,7 +16,7 @@ else()
endif()
endif()
set(LUA_CFLAGS "-O0 -g3 -fPIC")
set(LUA_CFLAGS "-O2 -g3 -fPIC")
set(LUA_LDFLAGS "")
if(ENABLE_ASAN_UBSAN)

View File

@ -1,11 +1,4 @@
find_library(LPEG_LIBRARY NAMES lpeg_a lpeg liblpeg_a)
# Ubuntu-specific workaround to find system paths
function(ubuntu)
set(CMAKE_FIND_LIBRARY_PREFIXES "")
find_library(LPEG_LIBRARY NAMES lpeg PATH_SUFFIXES lua/5.1)
endfunction()
ubuntu()
find_library(LPEG_LIBRARY NAMES lpeg_a lpeg liblpeg_a lpeg${CMAKE_SHARED_LIBRARY_SUFFIX} PATH_SUFFIXES lua/5.1)
find_package_handle_standard_args(Lpeg DEFAULT_MSG LPEG_LIBRARY)
mark_as_advanced(LPEG_LIBRARY)

View File

@ -1,5 +1,5 @@
find_path(LUAJIT_INCLUDE_DIR luajit.h
PATH_SUFFIXES luajit-2.0 luajit-2.1)
PATH_SUFFIXES luajit-2.1)
if(MSVC)
list(APPEND LUAJIT_NAMES lua51)

View File

@ -1,13 +1,5 @@
find_path(LUV_INCLUDE_DIR luv/luv.h)
find_library(LUV_LIBRARY NAMES luv_a luv libluv_a)
# Ubuntu-specific workaround to find system paths
function(ubuntu)
set(CMAKE_FIND_LIBRARY_PREFIXES "")
find_path(LUV_INCLUDE_DIR luv/luv.h PATH_SUFFIXES lua5.1)
find_library(LUV_LIBRARY NAMES luv PATH_SUFFIXES lua/5.1)
endfunction()
ubuntu()
find_path(LUV_INCLUDE_DIR luv/luv.h PATH_SUFFIXES lua5.1)
find_library(LUV_LIBRARY NAMES luv_a luv libluv_a luv${CMAKE_SHARED_LIBRARY_SUFFIX} PATH_SUFFIXES lua/5.1)
find_package_handle_standard_args(Luv DEFAULT_MSG
LUV_LIBRARY LUV_INCLUDE_DIR)

View File

@ -7,7 +7,6 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
RESULT_VARIABLE RES)
if(RES)
message(STATUS "Using NVIM_VERSION: ${NVIM_VERSION}")
file(WRITE "${OUTPUT}" "")

View File

@ -23,7 +23,7 @@ foreach(DLL_NAME ${DLLS})
message(FATAL_ERROR "Unable to find dependency ${DLL_NAME}")
endif()
if($ENV{CI} MATCHES "true")
if(CI_BUILD)
message("Copying ${DLL_NAME} to ${DST}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${DLL_PATH} ${DST})

View File

@ -2,7 +2,7 @@ add_library(main_lib INTERFACE)
add_executable(nvim main.c)
add_library(libuv INTERFACE)
find_package(libuv CONFIG)
find_package(libuv CONFIG QUIET)
if(TARGET libuv::uv_a)
target_link_libraries(libuv INTERFACE libuv::uv_a)
mark_as_advanced(libuv_DIR)
@ -392,7 +392,7 @@ else()
endif()
# Log level (NVIM_LOG_DEBUG in log.h)
if($ENV{CI})
if(CI_BUILD)
# Don't debug log on CI, it gets too verbose in the main build log.
# TODO(bfredl): debug log level also exposes some errors with EXITFREE in ASAN build.
else()
@ -703,6 +703,7 @@ if(WIN32)
-D CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
-D BINARY="${PROJECT_BINARY_DIR}/bin/nvim${CMAKE_EXECUTABLE_SUFFIX}"
-D DST=${PROJECT_BINARY_DIR}/windows_runtime_deps
-D CI_BUILD=${CI_BUILD}
-P ${PROJECT_SOURCE_DIR}/cmake/WindowsDllCopy.cmake)
add_dependencies(nvim_runtime_deps nvim_dll_deps)