diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2023-05-18 16:27:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-18 16:27:47 +0200 |
commit | 826b95203ac9c8decf02e332fbb55cf4ebf73aef (patch) | |
tree | 222fd6410b7010759575c54d9317c5df0ac47738 | |
parent | c40872acbddb61fd084203af60a86c7ec404d716 (diff) | |
download | rneovim-826b95203ac9c8decf02e332fbb55cf4ebf73aef.tar.gz rneovim-826b95203ac9c8decf02e332fbb55cf4ebf73aef.tar.bz2 rneovim-826b95203ac9c8decf02e332fbb55cf4ebf73aef.zip |
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.
-rw-r--r-- | .github/workflows/test.yml | 2 | ||||
-rw-r--r-- | CMakeLists.txt | 22 | ||||
-rw-r--r-- | cmake.deps/CMakeLists.txt | 19 | ||||
-rw-r--r-- | cmake/CheckUncrustifyVersion.cmake | 13 | ||||
-rw-r--r-- | cmake/Deps.cmake | 20 | ||||
-rw-r--r-- | src/nvim/CMakeLists.txt | 11 | ||||
-rw-r--r-- | test/functional/lua/fs_spec.lua | 4 |
7 files changed, 48 insertions, 43 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ba696ad85a..2790994377 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index f1b17f66a9..f7dbc6b6d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake.deps/CMakeLists.txt b/cmake.deps/CMakeLists.txt index 2de4160176..b046b2b54a 100644 --- a/cmake.deps/CMakeLists.txt +++ b/cmake.deps/CMakeLists.txt @@ -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}) diff --git a/cmake/CheckUncrustifyVersion.cmake b/cmake/CheckUncrustifyVersion.cmake deleted file mode 100644 index 4812c24ace..0000000000 --- a/cmake/CheckUncrustifyVersion.cmake +++ /dev/null @@ -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() diff --git a/cmake/Deps.cmake b/cmake/Deps.cmake new file mode 100644 index 0000000000..a375270f61 --- /dev/null +++ b/cmake/Deps.cmake @@ -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}) diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 070cea3b59..47f32abc07 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -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} diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua index 2fcbc9450f..f646e676c6 100644 --- a/test/functional/lua/fs_spec.lua +++ b/test/functional/lua/fs_spec.lua @@ -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) |