mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
build: bundle uncrustify
Uncrustify is sensitive to version changes, which causes friction for contributors that doesn't have that exact version. It's also simpler to download and install the correct version than to have bespoke version checking.
This commit is contained in:
parent
c40872acbd
commit
826b95203a
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -38,7 +38,7 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
./.github/scripts/install_deps.sh
|
||||
brew install stylua uncrustify
|
||||
brew install stylua
|
||||
|
||||
- uses: ./.github/actions/cache
|
||||
|
||||
|
@ -16,6 +16,9 @@ project(nvim C)
|
||||
if(POLICY CMP0075)
|
||||
cmake_policy(SET CMP0075 NEW)
|
||||
endif()
|
||||
if(POLICY CMP0135)
|
||||
cmake_policy(SET CMP0135 NEW)
|
||||
endif()
|
||||
|
||||
# Point CMake at any custom modules we may ship
|
||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||
@ -23,9 +26,11 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||
include(CheckCCompilerFlag)
|
||||
include(CheckCSourceCompiles)
|
||||
include(CheckLibraryExists)
|
||||
include(ExternalProject)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
include(Deps)
|
||||
include(InstallHelpers)
|
||||
include(PreventInTreeBuilds)
|
||||
include(Util)
|
||||
@ -107,6 +112,12 @@ endif()
|
||||
message(STATUS "CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
set_default_buildtype()
|
||||
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if(NOT isMultiConfig)
|
||||
# Unlike build dependencies in cmake.deps, we assume we want dev dependencies
|
||||
# such as Uncrustify to always be built with Release.
|
||||
list(APPEND DEPS_CMAKE_ARGS -D CMAKE_BUILD_TYPE=Release)
|
||||
endif()
|
||||
|
||||
# If not in a git repo (e.g., a tarball) these tokens define the complete
|
||||
# version string, else they are combined with the result of `git describe`.
|
||||
@ -221,7 +232,6 @@ endif()
|
||||
find_program(LUACHECK_PRG luacheck)
|
||||
find_program(SHELLCHECK_PRG shellcheck)
|
||||
find_program(STYLUA_PRG stylua)
|
||||
find_program(UNCRUSTIFY_PRG uncrustify)
|
||||
|
||||
add_glob_target(
|
||||
REQUIRED
|
||||
@ -301,3 +311,13 @@ add_custom_target(uninstall
|
||||
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_subdirectory(cmake.packaging)
|
||||
endif()
|
||||
|
||||
ExternalProject_Add(uncrustify
|
||||
PREFIX ${DEPS_BUILD_DIR}
|
||||
URL https://github.com/uncrustify/uncrustify/archive/uncrustify-0.77.1.tar.gz
|
||||
URL_HASH SHA256=414bbc9f7860eb18a53074f9af14ed04638a633b2216a73f2629291300d37c1b
|
||||
DOWNLOAD_NO_PROGRESS TRUE
|
||||
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/uncrustify
|
||||
CMAKE_ARGS ${DEPS_CMAKE_ARGS}
|
||||
CMAKE_CACHE_ARGS ${DEPS_CMAKE_CACHE_ARGS}
|
||||
EXCLUDE_FROM_ALL TRUE)
|
||||
|
@ -12,19 +12,9 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" "${PROJECT_SOURCE_DI
|
||||
include(ExternalProject)
|
||||
include(CheckCCompilerFlag)
|
||||
|
||||
include(Deps)
|
||||
include(Util)
|
||||
|
||||
set(DEPS_CMAKE_ARGS
|
||||
-D CMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
-D CMAKE_C_STANDARD=99
|
||||
-D CMAKE_GENERATOR=${CMAKE_GENERATOR}
|
||||
-D CMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
||||
-D BUILD_SHARED_LIBS=OFF
|
||||
-D CMAKE_POSITION_INDEPENDENT_CODE=ON
|
||||
-D CMAKE_FIND_FRAMEWORK=${CMAKE_FIND_FRAMEWORK})
|
||||
|
||||
set(DEPS_CMAKE_CACHE_ARGS -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES})
|
||||
|
||||
set_default_buildtype()
|
||||
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if(NOT isMultiConfig)
|
||||
@ -38,15 +28,8 @@ if(HAS_OG_FLAG)
|
||||
set(DEFAULT_MAKE_CFLAGS CFLAGS+=-Og ${DEFAULT_MAKE_CFLAGS})
|
||||
endif()
|
||||
|
||||
set(DEPS_INSTALL_DIR "${CMAKE_BINARY_DIR}/usr")
|
||||
set(DEPS_BIN_DIR "${DEPS_INSTALL_DIR}/bin")
|
||||
set(DEPS_LIB_DIR "${DEPS_INSTALL_DIR}/lib")
|
||||
set(DEPS_BUILD_DIR "${CMAKE_BINARY_DIR}/build")
|
||||
set(DEPS_DOWNLOAD_DIR "${DEPS_BUILD_DIR}/downloads")
|
||||
set(DEPS_INCLUDE_FLAGS "-I${DEPS_INSTALL_DIR}/include -I${DEPS_INSTALL_DIR}/include/luajit-2.1")
|
||||
|
||||
list(APPEND DEPS_CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR})
|
||||
|
||||
option(USE_BUNDLED "Use bundled dependencies." ON)
|
||||
|
||||
option(USE_BUNDLED_UNIBILIUM "Use the bundled unibilium." ${USE_BUNDLED})
|
||||
|
@ -1,13 +0,0 @@
|
||||
if(UNCRUSTIFY_PRG)
|
||||
execute_process(COMMAND uncrustify --version
|
||||
OUTPUT_VARIABLE user_version
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REGEX REPLACE "[A-Za-z_#-]" "" user_version ${user_version})
|
||||
|
||||
file(STRINGS ${CONFIG_FILE} required_version LIMIT_COUNT 1)
|
||||
string(REGEX REPLACE "[A-Za-z_# -]" "" required_version ${required_version})
|
||||
|
||||
if(NOT user_version STREQUAL required_version)
|
||||
message(FATAL_ERROR "Wrong uncrustify version! Required version is ${required_version} but found ${user_version}")
|
||||
endif()
|
||||
endif()
|
20
cmake/Deps.cmake
Normal file
20
cmake/Deps.cmake
Normal file
@ -0,0 +1,20 @@
|
||||
set(DEPS_INSTALL_DIR "${CMAKE_BINARY_DIR}/usr")
|
||||
set(DEPS_BIN_DIR "${DEPS_INSTALL_DIR}/bin")
|
||||
set(DEPS_LIB_DIR "${DEPS_INSTALL_DIR}/lib")
|
||||
|
||||
set(DEPS_BUILD_DIR "${CMAKE_BINARY_DIR}/build")
|
||||
set(DEPS_DOWNLOAD_DIR "${DEPS_BUILD_DIR}/downloads")
|
||||
|
||||
set(DEPS_CMAKE_ARGS
|
||||
-D CMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
-D CMAKE_C_STANDARD=99
|
||||
-D CMAKE_GENERATOR=${CMAKE_GENERATOR}
|
||||
-D CMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
||||
-D BUILD_SHARED_LIBS=OFF
|
||||
-D CMAKE_POSITION_INDEPENDENT_CODE=ON
|
||||
-D CMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR})
|
||||
if(APPLE)
|
||||
list(APPEND DEPS_CMAKE_ARGS -D CMAKE_FIND_FRAMEWORK=${CMAKE_FIND_FRAMEWORK})
|
||||
endif()
|
||||
|
||||
set(DEPS_CMAKE_CACHE_ARGS -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES})
|
@ -888,18 +888,13 @@ add_glob_target(
|
||||
EXCLUDE
|
||||
tui/terminfo_defs.h)
|
||||
|
||||
add_custom_target(uncrustify-version
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D UNCRUSTIFY_PRG=${UNCRUSTIFY_PRG}
|
||||
-D CONFIG_FILE=${PROJECT_SOURCE_DIR}/src/uncrustify.cfg
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/CheckUncrustifyVersion.cmake)
|
||||
|
||||
set(UNCRUSTIFY_PRG ${DEPS_BIN_DIR}/uncrustify)
|
||||
add_glob_target(
|
||||
TARGET lintc-uncrustify
|
||||
COMMAND ${UNCRUSTIFY_PRG}
|
||||
FLAGS -c "${PROJECT_SOURCE_DIR}/src/uncrustify.cfg" -q --check
|
||||
FILES ${LINT_NVIM_SOURCES})
|
||||
add_dependencies(lintc-uncrustify uncrustify-version)
|
||||
add_dependencies(lintc-uncrustify uncrustify)
|
||||
|
||||
add_custom_target(lintc)
|
||||
add_dependencies(lintc lintc-clint lintc-uncrustify)
|
||||
@ -910,7 +905,7 @@ add_custom_target(formatc
|
||||
-D LANG=c
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/Format.cmake
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
|
||||
add_dependencies(formatc uncrustify-version)
|
||||
add_dependencies(formatc uncrustify)
|
||||
|
||||
add_custom_target(generated-sources DEPENDS
|
||||
${NVIM_GENERATED_FOR_SOURCES}
|
||||
|
@ -223,7 +223,7 @@ describe('vim.fs', function()
|
||||
|
||||
describe('find()', function()
|
||||
it('works', function()
|
||||
eq({test_build_dir}, exec_lua([[
|
||||
eq({test_build_dir .. "/build"}, exec_lua([[
|
||||
local dir = ...
|
||||
return vim.fs.find('build', { path = dir, upward = true, type = 'directory' })
|
||||
]], nvim_dir))
|
||||
@ -239,7 +239,7 @@ describe('vim.fs', function()
|
||||
end)
|
||||
|
||||
it('accepts predicate as names', function()
|
||||
eq({test_build_dir}, exec_lua([[
|
||||
eq({test_build_dir .. "/build"}, exec_lua([[
|
||||
local dir = ...
|
||||
local opts = { path = dir, upward = true, type = 'directory' }
|
||||
return vim.fs.find(function(x) return x == 'build' end, opts)
|
||||
|
Loading…
Reference in New Issue
Block a user