diff --git a/.editorconfig b/.editorconfig index b08a27f2a2..ac902ecec5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,6 +7,10 @@ end_of_line = lf insert_final_newline = true charset = utf_8 +[runtime/doc/*.txt] +indent_style = tab +indent_size = 8 + [Makefile] indent_style = tab tab_width = 4 diff --git a/.gitignore b/.gitignore index fb506305b6..ddbcc9c60d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,10 @@ # Build/deps dir /build/ +/cmake-build-debug/ /dist/ /.deps/ /tmp/ -*.orig *.mo .*.sw? *~ @@ -17,6 +17,9 @@ tags /src/nvim/po/vim.pot /src/nvim/po/*.ck +# generated by tests with $NVIM_LOG_FILE set. +/.nvimlog + # Files generated by scripts/vim-patch.sh /.vim-src/ diff --git a/.travis.yml b/.travis.yml index 45c2dcb832..3cd21170b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,8 @@ language: c env: global: - # To force rebuilding of third-party dependencies, set this to 'true'. - - BUILD_NVIM_DEPS=false - # Travis has 1.5 virtual cores according to - # http://docs.travis-ci.com/user/speeding-up-the-build/#Paralellizing-your-build-on-one-VM - - MAKE_CMD="make -j2" - # Update PATH for pip. - - PATH="$(python2.7 -c 'import site; print(site.getuserbase())')/bin:/usr/lib/llvm-symbolizer-4.0/bin:$PATH" + # Set "false" to force rebuild of third-party dependencies. + - CACHE_ENABLE=true # Build directory for Neovim. - BUILD_DIR="$TRAVIS_BUILD_DIR/build" # Build directory for third-party dependencies. @@ -41,9 +36,7 @@ env: - UBSAN_OPTIONS="print_stacktrace=1 log_path=$LOG_DIR/ubsan" # Environment variables for Valgrind. - VALGRIND_LOG="$LOG_DIR/valgrind-%p.log" - # Cache marker for third-party dependencies cache. - # If this file exists, we know that the cache contains compiled - # dependencies and we can use it. + # If this file exists, the cache is valid (compile was successful). - CACHE_MARKER="$HOME/.cache/nvim-deps/.travis_cache_marker" # default target name for functional tests - FUNCTIONALTEST=functionaltest @@ -51,40 +44,42 @@ env: jobs: include: - - stage: sanitizers + - stage: normal builds os: linux - compiler: clang-4.0 + compiler: clang env: > CLANG_SANITIZER=ASAN_UBSAN CMAKE_FLAGS="$CMAKE_FLAGS -DPREFER_LUA=ON" + sudo: true - os: linux - compiler: clang-4.0 - env: CLANG_SANITIZER=TSAN - - stage: normal builds - os: linux - compiler: gcc-5 - env: FUNCTIONALTEST=functionaltest-lua + compiler: gcc + env: > + FUNCTIONALTEST=functionaltest-lua + CMAKE_FLAGS="$CMAKE_FLAGS -DPREFER_LUA=ON" + DEPS_CMAKE_FLAGS="$DEPS_CMAKE_FLAGS -DUSE_BUNDLED_LUAJIT=OFF" - os: linux - # Travis creates a cache per compiler. - # Set a different value here to store 32-bit - # dependencies in a separate cache. - compiler: gcc-5 -m32 + # Travis creates a cache per compiler. Set a different value here to + # store 32-bit dependencies in a separate cache. + compiler: gcc -m32 env: BUILD_32BIT=ON - os: osx compiler: clang osx_image: xcode7.3 # macOS 10.11 - os: osx - compiler: gcc-4.9 + compiler: gcc osx_image: xcode7.3 # macOS 10.11 - - stage: lint - os: linux + - os: linux env: CI_TARGET=lint - - stage: coverage + - stage: Flaky builds os: linux - compiler: gcc-5 - env: GCOV=gcov-5 CMAKE_FLAGS="$CMAKE_FLAGS -DUSE_GCOV=ON" + compiler: gcc + env: GCOV=gcov CMAKE_FLAGS="$CMAKE_FLAGS -DUSE_GCOV=ON" + - os: linux + compiler: clang + env: CLANG_SANITIZER=TSAN allow_failures: - - env: GCOV=gcov-5 CMAKE_FLAGS="$CMAKE_FLAGS -DUSE_GCOV=ON" + - env: GCOV=gcov CMAKE_FLAGS="$CMAKE_FLAGS -DUSE_GCOV=ON" + - env: CLANG_SANITIZER=TSAN fast_finish: true before_install: ci/before_install.sh @@ -96,27 +91,22 @@ after_success: ci/after_success.sh addons: apt: - sources: - - ubuntu-toolchain-r-test - - llvm-toolchain-trusty-4.0 packages: - autoconf - automake - apport - build-essential - - clang-4.0 + - clang - cmake - cscope - - g++-5-multilib - g++-multilib - - gcc-5-multilib - gcc-multilib - gdb - language-pack-tr - libc6-dev-i386 - libtool - - llvm-4.0-dev - locales + - ninja-build - pkg-config - unzip - valgrind @@ -131,6 +121,7 @@ cache: directories: - "$HOME/.cache/pip" - "$HOME/.cache/nvim-deps" + - "$HOME/.cache/nvim-deps-downloads" notifications: webhooks: diff --git a/BSDmakefile b/BSDmakefile new file mode 100644 index 0000000000..93b7dc7f3d --- /dev/null +++ b/BSDmakefile @@ -0,0 +1,4 @@ +.DONE: + @echo "Please use GNU Make (gmake) to build neovim" +.DEFAULT: + @echo "Please use GNU Make (gmake) to build neovim" diff --git a/CMakeLists.txt b/CMakeLists.txt index 1699ffa8fa..4b021ad6e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,11 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") 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") +else() 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}) list(INSERT CMAKE_PREFIX_PATH 0 ${DEPS_PREFIX}/../host/bin) @@ -51,24 +55,24 @@ endif() # Set default build type. if(NOT CMAKE_BUILD_TYPE) - message(STATUS "CMAKE_BUILD_TYPE not given, defaulting to 'Dev'.") - set(CMAKE_BUILD_TYPE "Dev" CACHE STRING "Choose the type of build." FORCE) + message(STATUS "CMAKE_BUILD_TYPE not given, defaulting to 'Debug'.") + set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE) endif() # Set available build types for CMake GUIs. # A different build type can still be set by -DCMAKE_BUILD_TYPE=... set_property(CACHE CMAKE_BUILD_TYPE PROPERTY - STRINGS "Debug" "Dev" "Release" "MinSizeRel" "RelWithDebInfo") + STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") # 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`. set(NVIM_VERSION_MAJOR 0) set(NVIM_VERSION_MINOR 2) -set(NVIM_VERSION_PATCH 1) +set(NVIM_VERSION_PATCH 3) set(NVIM_VERSION_PRERELEASE "-dev") # for package maintainers # API level -set(NVIM_API_LEVEL 3) # Bump this after any API change. +set(NVIM_API_LEVEL 4) # Bump this after any API change. set(NVIM_API_LEVEL_COMPAT 0) # Adjust this after a _breaking_ API change. set(NVIM_API_PRERELEASE true) @@ -107,46 +111,23 @@ if(NOT CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DMIN_LOG_LEVEL) set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DMIN_LOG_LEVEL=3") endif() -# Enable assertions for RelWithDebInfo. +if(CMAKE_COMPILER_IS_GNUCC) + check_c_compiler_flag(-Og HAS_OG_FLAG) +else() + set(HAS_OG_FLAG 0) +endif() + +# +# Build-type: RelWithDebInfo +# +if(HAS_OG_FLAG) + set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -Og -g") +endif() +# We _want_ assertions in RelWithDebInfo build-type. if(CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DNDEBUG) string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") endif() -# Set build flags for custom Dev build type. -# -DNDEBUG purposely omitted because we want assertions. -if(MSVC) - SET(CMAKE_C_FLAGS_DEV "" - CACHE STRING "Flags used by the compiler during development (optimized, but with debug info and logging) builds." - FORCE) -else() - if(CMAKE_COMPILER_IS_GNUCC) - check_c_compiler_flag(-Og HAS_OG_FLAG) - else() - set(HAS_OG_FLAG 0) - endif() - - if(HAS_OG_FLAG) - set(CMAKE_C_FLAGS_DEV "-Og -g" - CACHE STRING "Flags used by the compiler during development (optimized, but with debug info and logging) builds." - FORCE) - else() - set(CMAKE_C_FLAGS_DEV "-O2 -g" - CACHE STRING "Flags used by the compiler during development (optimized, but with debug info and logging) builds." - FORCE) - endif() -endif() -SET(CMAKE_EXE_LINKER_FLAGS_DEV "" - CACHE STRING "Flags used for linking binaries during development (optimized, but with debug info and logging) builds." - FORCE) -SET(CMAKE_SHARED_LINKER_FLAGS_DEV "" - CACHE STRING "Flags used by the shared libraries linker during development (optimized, but with debug info and logging) builds." - FORCE) - -MARK_AS_ADVANCED( - CMAKE_C_FLAGS_DEV - CMAKE_EXE_LINKER_FLAGS_DEV - CMAKE_SHARED_LINKER_FLAGS_DEV) - # Enable -Wconversion. if(NOT MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion") @@ -214,9 +195,20 @@ if(CMAKE_EXE_LINKER_FLAGS MATCHES "--sort-common" OR string(REGEX REPLACE "-Wl($| )" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}") endif() +check_c_source_compiles(" +#include +int main(void) +{ + void *trace[1]; + int trace_size = backtrace(trace, 1); + return 0; +} +" HAVE_EXECINFO_BACKTRACE) + if(MSVC) # XXX: /W4 gives too many warnings. #3241 add_definitions(/W3 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) + add_definitions(-DWIN32) else() add_definitions(-Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99) @@ -236,6 +228,9 @@ endif() if(MINGW) # Use POSIX compatible stdio in Mingw add_definitions(-D__USE_MINGW_ANSI_STDIO) +endif() +if(WIN32) + # Windows Vista is the minimum supported version add_definitions(-D_WIN32_WINNT=0x0600) endif() @@ -262,6 +257,18 @@ if(HAS_DIAG_COLOR_FLAG) add_definitions(-fdiagnostics-color=auto) endif() +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # 1. Array-bounds testing is broken in some GCC versions before 4.8.5. + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273 + # 2. But _Pragma("...ignored") is broken (unresolved) in GCC 5+: + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66099 + # So we must disable -Warray-bounds globally for GCC (for kbtree.h, #7083). + check_c_compiler_flag(-Wno-array-bounds HAS_NO_ARRAY_BOUNDS_FLAG) + if(HAS_NO_ARRAY_BOUNDS_FLAG) + add_definitions(-Wno-array-bounds) + endif() +endif() + option(TRAVIS_CI_BUILD "Travis/QuickBuild CI. Extra flags will be set." OFF) if(TRAVIS_CI_BUILD) @@ -279,6 +286,8 @@ else() set(DEBUG 0) endif() +option(LOG_LIST_ACTIONS "Add list actions logging" OFF) + add_definitions(-DINCLUDE_GENERATED_DECLARATIONS) if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_NAME STREQUAL "Linux") @@ -338,7 +347,6 @@ main(void) return MSGPACK_OBJECT_FLOAT32; } " MSGPACK_HAS_FLOAT32) - if(MSGPACK_HAS_FLOAT32) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNVIM_MSGPACK_HAS_FLOAT32") endif() @@ -349,6 +357,21 @@ if(FEAT_TUI) find_package(Unibilium REQUIRED) include_directories(SYSTEM ${UNIBILIUM_INCLUDE_DIRS}) + list(APPEND CMAKE_REQUIRED_INCLUDES "${UNIBILIUM_INCLUDE_DIRS}") + list(APPEND CMAKE_REQUIRED_LIBRARIES "${UNIBILIUM_LIBRARIES}") + check_c_source_compiles(" + #include + + int + main(void) + { + return unibi_num_from_var(unibi_var_from_num(0)); + } + " UNIBI_HAS_VAR_FROM) + if(UNIBI_HAS_VAR_FROM) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNVIM_UNIBI_HAS_VAR_FROM") + endif() + find_package(LibTermkey REQUIRED) include_directories(SYSTEM ${LIBTERMKEY_INCLUDE_DIRS}) endif() @@ -356,6 +379,11 @@ endif() find_package(LibVterm REQUIRED) include_directories(SYSTEM ${LIBVTERM_INCLUDE_DIRS}) +if(WIN32) + find_package(Winpty REQUIRED) + include_directories(SYSTEM ${WINPTY_INCLUDE_DIRS}) +endif() + option(CLANG_ASAN_UBSAN "Enable Clang address & undefined behavior sanitizer for nvim binary." OFF) option(CLANG_MSAN "Enable Clang memory sanitizer for nvim binary." OFF) option(CLANG_TSAN "Enable Clang thread sanitizer for nvim binary." OFF) @@ -461,20 +489,19 @@ install_helper( DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) # MIN_LOG_LEVEL for log.h -if(DEFINED MIN_LOG_LEVEL) +if("${MIN_LOG_LEVEL}" MATCHES "^$") + message(STATUS "MIN_LOG_LEVEL not specified") +else() if(NOT MIN_LOG_LEVEL MATCHES "^[0-3]$") message(FATAL_ERROR "invalid MIN_LOG_LEVEL: " ${MIN_LOG_LEVEL}) endif() message(STATUS "MIN_LOG_LEVEL set to ${MIN_LOG_LEVEL}") -else() - message(STATUS "MIN_LOG_LEVEL not specified, defaulting to 1 (INFO)") endif() # Go down the tree. add_subdirectory(src/nvim) -# Read compilation flags from src/nvim, -# used in config subdirectory below. +# Read compilation flags from src/nvim, used in config subdirectory below. include(GetCompileFlags) get_compile_flags(NVIM_VERSION_CFLAGS) @@ -489,17 +516,6 @@ if(BUSTED_PRG) get_property(TEST_INCLUDE_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) - # Set policy CMP0026 to OLD so we avoid CMake warnings on newer - # versions of cmake. - if(POLICY CMP0026) - cmake_policy(SET CMP0026 OLD) - endif() - if(CMAKE_GENERATOR MATCHES "Visual Studio") - set(TEST_LIBNVIM_PATH ${CMAKE_BINARY_DIR}/lib/nvim-test.dll) - else() - get_target_property(TEST_LIBNVIM_PATH nvim-test LOCATION) - endif() - # When running tests from 'ninja' we need to use the # console pool: to do so we need to use the USES_TERMINAL # option, but this is only available in CMake 3.2 @@ -508,10 +524,6 @@ if(BUSTED_PRG) list(APPEND TEST_TARGET_ARGS "USES_TERMINAL") endif() - configure_file( - test/config/paths.lua.in - ${CMAKE_BINARY_DIR}/test/config/paths.lua) - set(UNITTEST_PREREQS nvim-test unittest-headers) set(FUNCTIONALTEST_PREREQS nvim printargs-test shell-test) if(NOT WIN32) @@ -548,6 +560,32 @@ if(BUSTED_PRG) message(WARNING "disabling unit tests: no Luajit FFI in ${LUA_PRG}") endif() + if(${CMAKE_VERSION} VERSION_LESS 2.8.12) + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(TEST_LIBNVIM_PATH ${CMAKE_BINARY_DIR}/lib/nvim-test.dll) + else() + get_target_property(TEST_LIBNVIM_PATH nvim-test LOCATION) + endif() + configure_file( + ${CMAKE_SOURCE_DIR}/test/config/paths.lua.in + ${CMAKE_BINARY_DIR}/test/config/paths.lua) + else() + # To avoid duplicating paths.lua.in while we still support CMake < 2.8.12, + # use configure_file() to add the generator expression and then generate + # the final file + if(LUA_HAS_FFI) + set(TEST_LIBNVIM_PATH $) + else() + set(TEST_LIBNVIM_PATH "") + endif() + configure_file( + ${CMAKE_SOURCE_DIR}/test/config/paths.lua.in + ${CMAKE_BINARY_DIR}/test/config/paths.lua.gen) + file(GENERATE + OUTPUT ${CMAKE_BINARY_DIR}/test/config/paths.lua + INPUT ${CMAKE_BINARY_DIR}/test/config/paths.lua.gen) + endif() + add_custom_target(functionaltest COMMAND ${CMAKE_COMMAND} -DBUSTED_PRG=${BUSTED_PRG} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8580e8ef39..05a97ebf18 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -14,7 +14,7 @@ low-risk/isolated tasks: Developer guidelines -------------------- -- Nvim developers should read `:help dev-help`. +- Nvim developers should read `:help dev`. - External UI developers should read `:help dev-ui`. Reporting problems @@ -24,9 +24,10 @@ Reporting problems - Search [existing issues][github-issues] (including closed!) - Update Neovim to the latest version to see if your problem persists. - Disable plugins incrementally, to narrow down the cause of the issue. -- When reporting a crash, include a stacktrace. +- When reporting a crash, [include a stacktrace](https://github.com/neovim/neovim/wiki/Development-tips#backtrace-linux). - [Bisect][git-bisect] to the cause of a regression, if you are able. This is _extremely_ helpful. - Check `$NVIM_LOG_FILE`, if it exists. +- Include `cmake --system-information` for **build** issues. Pull requests ("PRs") --------------------- @@ -91,11 +92,12 @@ and [AppVeyor]. - CI builds are compiled with [`-Werror`][gcc-warnings], so compiler warnings will fail the build. - If any tests fail, the build will fail. - See [Building Neovim#running-tests][wiki-run-tests] to run tests locally. + See [test/README.md#running-tests][run-tests] to run tests locally. Passing locally doesn't guarantee passing the CI build, because of the different compilers and platforms tested against. -- CI runs [ASan] and other analyzers. To run valgrind locally: - `VALGRIND=1 make test` +- CI runs [ASan] and other analyzers. + - To run valgrind locally: `VALGRIND=1 make test` + - To run Clang ASan/UBSan locally: `CC=clang make CMAKE_FLAGS="-DCLANG_ASAN_UBSAN=ON"` - The `lint` build ([#3174][3174]) checks modified lines _and their immediate neighbors_. This is to encourage incrementally updating the legacy style to meet our style guidelines. @@ -166,7 +168,7 @@ as context, use the `-W` argument as well. [hygiene]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html [style-guide]: http://neovim.io/develop/style-guide.xml [ASan]: http://clang.llvm.org/docs/AddressSanitizer.html -[wiki-run-tests]: https://github.com/neovim/neovim/wiki/Building-Neovim#running-tests +[run-tests]: https://github.com/neovim/neovim/blob/master/test/README.md#running-tests [wiki-faq]: https://github.com/neovim/neovim/wiki/FAQ [review-checklist]: https://github.com/neovim/neovim/wiki/Code-review-checklist [3174]: https://github.com/neovim/neovim/issues/3174 diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index 011739396d..1a7268a51e 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,16 +1,19 @@ + + - `nvim --version`: - Vim (version: ) behaves differently? - Operating system/version: - Terminal name/version: - `$TERM`: -### Actual behaviour - -### Expected behaviour - ### Steps to reproduce using `nvim -u NORC` ``` nvim -u NORC ``` + +### Actual behaviour + +### Expected behaviour + diff --git a/Makefile b/Makefile index e349cc4d0f..72db67a0d9 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +THIS_DIR = $(shell pwd) filter-false = $(strip $(filter-out 0 off OFF false FALSE,$1)) filter-true = $(strip $(filter-out 1 on ON true TRUE,$1)) @@ -8,11 +9,14 @@ CMAKE_PRG ?= $(shell (command -v cmake3 || echo cmake)) CMAKE_BUILD_TYPE ?= Debug CMAKE_FLAGS := -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) -DOC_DOWNLOAD_URL_BASE := https://raw.githubusercontent.com/neovim/doc/gh-pages -CLINT_ERRORS_FILE_PATH := /reports/clint/errors.json BUILD_TYPE ?= $(shell (type ninja > /dev/null 2>&1 && echo "Ninja") || \ echo "Unix Makefiles") +DEPS_BUILD_DIR ?= .deps + +ifneq (1,$(words [$(DEPS_BUILD_DIR)])) + $(error DEPS_BUILD_DIR must not contain whitespace) +endif ifeq (,$(BUILD_TOOL)) ifeq (Ninja,$(BUILD_TYPE)) @@ -48,7 +52,7 @@ endif ifneq (,$(findstring functionaltest-lua,$(MAKECMDGOALS))) BUNDLED_LUA_CMAKE_FLAG := -DUSE_BUNDLED_LUA=ON - $(shell [ -x .deps/usr/bin/lua ] || rm build/.ran-*) + $(shell [ -x $(DEPS_BUILD_DIR)/usr/bin/lua ] || rm build/.ran-*) endif # For use where we want to make sure only a single job is run. This does issue @@ -68,20 +72,20 @@ cmake: $(MAKE) build/.ran-cmake build/.ran-cmake: | deps - cd build && $(CMAKE_PRG) -G '$(BUILD_TYPE)' $(CMAKE_FLAGS) $(CMAKE_EXTRA_FLAGS) .. + cd build && $(CMAKE_PRG) -G '$(BUILD_TYPE)' $(CMAKE_FLAGS) $(CMAKE_EXTRA_FLAGS) $(THIS_DIR) touch $@ deps: | build/.ran-third-party-cmake ifeq ($(call filter-true,$(USE_BUNDLED_DEPS)),) - +$(BUILD_CMD) -C .deps + +$(BUILD_CMD) -C $(DEPS_BUILD_DIR) endif build/.ran-third-party-cmake: ifeq ($(call filter-true,$(USE_BUNDLED_DEPS)),) - mkdir -p .deps - cd .deps && \ + mkdir -p $(DEPS_BUILD_DIR) + cd $(DEPS_BUILD_DIR) && \ $(CMAKE_PRG) -G '$(BUILD_TYPE)' $(BUNDLED_CMAKE_FLAG) $(BUNDLED_LUA_CMAKE_FLAG) \ - $(DEPS_CMAKE_FLAGS) ../third-party + $(DEPS_CMAKE_FLAGS) $(THIS_DIR)/third-party endif mkdir -p build touch $@ @@ -124,7 +128,7 @@ clean: $(MAKE) -C runtime/doc clean distclean: clean - rm -rf .deps build + rm -rf $(DEPS_BUILD_DIR) build install: | nvim +$(BUILD_CMD) -C build install @@ -141,6 +145,11 @@ check-single-includes: build/.ran-cmake appimage: bash scripts/genappimage.sh +# Build an appimage with embedded update information appimage-nightly for +# nightly builds or appimage-latest for a release +appimage-%: + bash scripts/genappimage.sh $* + lint: check-single-includes clint testlint lualint .PHONY: test testlint lualint functionaltest unittest lint clint clean distclean nvim libnvim cmake deps install appimage diff --git a/README.md b/README.md index cb3ac46a24..20026f4578 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,13 @@ [![Travis Build Status](https://travis-ci.org/neovim/neovim.svg?branch=master)](https://travis-ci.org/neovim/neovim) [![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/urdqjrik5u521fac/branch/master?svg=true)](https://ci.appveyor.com/project/neovim/neovim/branch/master) -[![Coverage Status](https://img.shields.io/coveralls/neovim/neovim.svg)](https://coveralls.io/r/neovim/neovim) +[![codecov](https://img.shields.io/codecov/c/github/neovim/neovim.svg)](https://codecov.io/gh/neovim/neovim) [![Coverity Scan Build](https://scan.coverity.com/projects/2227/badge.svg)](https://scan.coverity.com/projects/2227) [![Clang Scan Build](https://neovim.io/doc/reports/clang/badge.svg)](https://neovim.io/doc/reports/clang) [![PVS-studio Check](https://neovim.io/doc/reports/pvs/badge.svg)](https://neovim.io/doc/reports/pvs) -Debian -[![Downloads](https://img.shields.io/github/downloads/neovim/neovim/total.svg?maxAge=2592000)](https://github.com/neovim/neovim/releases/) +[![Debian CI](https://badges.debian.net/badges/debian/testing/neovim/version.svg)](https://buildd.debian.org/neovim) +[![Downloads](https://img.shields.io/github/downloads/neovim/neovim/total.svg?maxAge=2592001)](https://github.com/neovim/neovim/releases/) Neovim is a project that seeks to aggressively refactor Vim in order to: @@ -34,6 +34,15 @@ Install from source make CMAKE_BUILD_TYPE=RelWithDebInfo sudo make install +To install to a non-default location, set `CMAKE_INSTALL_PREFIX`: + + make CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=/full/path/" + make install + +To list all targets: + + cmake --build build --target help + See [the wiki](https://github.com/neovim/neovim/wiki/Building-Neovim) for details. Install from package @@ -48,17 +57,24 @@ and [more](https://github.com/neovim/neovim/wiki/Installing-Neovim)! Project layout -------------- - ├─ ci/ Build server scripts - ├─ cmake/ Build scripts - ├─ runtime/ User plugins/docs - ├─ src/ Source code - ├─ third-party/ CMake subproject to build dependencies - └─ test/ Test code + ├─ ci/ build automation + ├─ cmake/ build scripts + ├─ runtime/ user plugins/docs + ├─ src/ application source code (see src/nvim/README.md) + │ ├─ api/ API subsystem + │ ├─ eval/ VimL subsystem + │ ├─ event/ event-loop subsystem + │ ├─ generators/ code generation (pre-compilation) + │ ├─ lib/ generic data structures + │ ├─ lua/ lua subsystem + │ ├─ msgpack_rpc/ RPC subsystem + │ ├─ os/ low-level platform code + │ └─ tui/ built-in UI + ├─ third-party/ cmake subproject to build dependencies + └─ test/ tests (see test/README.md) -- `third-party/` is activated if `USE_BUNDLED_DEPS` is undefined or the - `USE_BUNDLED` CMake option is true. -- [Source README](src/nvim/README.md) -- [Test README](test/README.md) +- To disable `third-party/` specify `USE_BUNDLED_DEPS=NO` or `USE_BUNDLED=NO` + (CMake option). Features -------- diff --git a/appveyor.yml b/appveyor.yml index edb679d223..75ca74d0d5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,12 +1,23 @@ version: '{build}' +environment: + APPVEYOR_CACHE_ENTRY_ZIP_ARGS: "-t7z -m0=lzma -mx=9" +image: Visual Studio 2017 configuration: +- MSVC_64 +- MSVC_32 - MINGW_64 - MINGW_32 +- MINGW_64-gcov +matrix: + allow_failures: + - configuration: MINGW_64-gcov install: [] +before_build: +- ps: Install-Product node 8 build_script: -- call ci\build.bat +- powershell ci\build.ps1 cache: -- C:\msys64\var\cache\pacman\pkg -> ci\build.bat +- C:\msys64\var\cache\pacman\pkg -> ci\build.ps1 - .deps -> third-party\** artifacts: - path: build/Neovim.zip diff --git a/busted/outputHandlers/TAP.lua b/busted/outputHandlers/TAP.lua new file mode 100644 index 0000000000..ff93a7cc75 --- /dev/null +++ b/busted/outputHandlers/TAP.lua @@ -0,0 +1,92 @@ +-- TODO(jkeyes): remove this and use the upstream version as soon as it is +-- available in a release of busted. + +local pretty = require 'pl.pretty' + +return function(options) + local busted = require 'busted' + local handler = require 'busted.outputHandlers.base'() + + local success = 'ok %u - %s' + local failure = 'not ' .. success + local skip = 'ok %u - # SKIP %s' + local counter = 0 + + handler.suiteReset = function() + counter = 0 + return nil, true + end + + handler.suiteEnd = function() + print('1..' .. counter) + io.flush() + return nil, true + end + + local function showFailure(t) + local message = t.message + local trace = t.trace or {} + + if message == nil then + message = 'Nil error' + elseif type(message) ~= 'string' then + message = pretty.write(message) + end + + print(failure:format(counter, t.name)) + print('# ' .. t.element.trace.short_src .. ' @ ' .. t.element.trace.currentline) + if t.randomseed then print('# Random seed: ' .. t.randomseed) end + print('# Failure message: ' .. message:gsub('\n', '\n# ')) + if options.verbose and trace.traceback then + print('# ' .. trace.traceback:gsub('^\n', '', 1):gsub('\n', '\n# ')) + end + end + + handler.testStart = function(element, parent) + local trace = element.trace + if options.verbose and trace and trace.short_src then + local fileline = trace.short_src .. ' @ ' .. trace.currentline .. ': ' + local testName = fileline .. handler.getFullName(element) + print('# ' .. testName) + end + io.flush() + + return nil, true + end + + handler.testEnd = function(element, parent, status, trace) + counter = counter + 1 + if status == 'success' then + local t = handler.successes[#handler.successes] + print(success:format(counter, t.name)) + elseif status == 'pending' then + local t = handler.pendings[#handler.pendings] + print(skip:format(counter, (t.message or t.name))) + elseif status == 'failure' then + showFailure(handler.failures[#handler.failures]) + elseif status == 'error' then + showFailure(handler.errors[#handler.errors]) + end + io.flush() + + return nil, true + end + + handler.error = function(element, parent, message, debug) + if element.descriptor ~= 'it' then + counter = counter + 1 + showFailure(handler.errors[#handler.errors]) + end + io.flush() + + return nil, true + end + + busted.subscribe({ 'suite', 'reset' }, handler.suiteReset) + busted.subscribe({ 'suite', 'end' }, handler.suiteEnd) + busted.subscribe({ 'test', 'start' }, handler.testStart, { predicate = handler.cancelOnPending }) + busted.subscribe({ 'test', 'end' }, handler.testEnd, { predicate = handler.cancelOnPending }) + busted.subscribe({ 'error' }, handler.error) + + return handler +end diff --git a/ci/after_success.sh b/ci/after_success.sh deleted file mode 100755 index 0215eb139b..0000000000 --- a/ci/after_success.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -e -set -o pipefail - -if [[ -n "${GCOV}" ]]; then - coveralls --gcov "$(which "${GCOV}")" --encoding iso-8859-1 || echo 'coveralls upload failed.' -fi diff --git a/ci/before_cache.sh b/ci/before_cache.sh index 3d7cc0ec5a..d99b8e68c6 100755 --- a/ci/before_cache.sh +++ b/ci/before_cache.sh @@ -4,16 +4,24 @@ set -e set -o pipefail CI_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${CI_DIR}/common/build.sh" source "${CI_DIR}/common/suite.sh" # Don't cache pip's log and selfcheck. rm -rf "${HOME}/.cache/pip/log" rm -f "${HOME}/.cache/pip/selfcheck.json" +echo "before_cache.sh: cache size" +du -d 2 "${HOME}/.cache" | sort -n + # Update the third-party dependency cache only if the build was successful. if ended_successfully; then rm -rf "${HOME}/.cache/nvim-deps" mv "${DEPS_BUILD_DIR}" "${HOME}/.cache/nvim-deps" + + rm -rf "${HOME}/.cache/nvim-deps-downloads" + mv "${DEPS_DOWNLOAD_DIR}" "${HOME}/.cache/nvim-deps-downloads" + touch "${CACHE_MARKER}" - echo "Updated third-party dependencies (timestamp: $(stat -c '%y' "${CACHE_MARKER}"))." + echo "Updated third-party dependencies (timestamp: $(_stat "${CACHE_MARKER}"))." fi diff --git a/ci/before_install.sh b/ci/before_install.sh index 5b36adaef2..9a3e192536 100755 --- a/ci/before_install.sh +++ b/ci/before_install.sh @@ -11,15 +11,38 @@ if [[ "${TRAVIS_OS_NAME}" == osx ]]; then brew update fi -echo "Upgrade Python 2 pip." -pip2.7 -q install --user --upgrade pip +echo 'python info:' +( + 2>&1 python --version || true + 2>&1 python2 --version || true + 2>&1 python3 --version || true + 2>&1 pip --version || true + 2>&1 pip2 --version || true + 2>&1 pip3 --version || true + echo 'pyenv versions:' + 2>&1 pyenv versions || true +) | sed 's/^/ /' if [[ "${TRAVIS_OS_NAME}" == osx ]]; then - echo "Install Python 3." - brew install python3 + echo "Upgrade Python 3." + brew upgrade python echo "Upgrade Python 3 pip." pip3 -q install --user --upgrade pip else + echo "Upgrade Python 2 pip." + pip2.7 -q install --user --upgrade pip echo "Upgrade Python 3 pip." - pip3 -q install --user --upgrade pip + # Allow failure. pyenv pip3 on travis is broken: + # https://github.com/travis-ci/travis-ci/issues/8363 + pip3 -q install --user --upgrade pip || true fi + +echo "Install node (LTS)" + +if [[ "${TRAVIS_OS_NAME}" == osx ]] || [ ! -f ~/.nvm/nvm.sh ]; then + curl -o ~/.nvm/nvm.sh https://raw.githubusercontent.com/creationix/nvm/master/nvm.sh +fi + +source ~/.nvm/nvm.sh +nvm install --lts +nvm use --lts diff --git a/ci/build.bat b/ci/build.bat deleted file mode 100644 index c871c6b849..0000000000 --- a/ci/build.bat +++ /dev/null @@ -1,54 +0,0 @@ -:: These are native MinGW builds, but they use the toolchain inside -:: MSYS2, this allows using all the dependencies and tools available -:: in MSYS2, but we cannot build inside the MSYS2 shell. -echo on -if "%CONFIGURATION%" == "MINGW_32" ( - set ARCH=i686 - set BITS=32 -) else ( - set ARCH=x86_64 - set BITS=64 -) -:: We cannot have sh.exe in the PATH (MinGW) -set PATH=%PATH:C:\Program Files\Git\usr\bin;=% -set PATH=C:\msys64\mingw%BITS%\bin;C:\Windows\System32;C:\Windows;%PATH% -:: The default cpack in the PATH is not CMake -set PATH=C:\Program Files (x86)\CMake\bin\cpack.exe;%PATH% - -:: Build third-party dependencies -C:\msys64\usr\bin\bash -lc "pacman --verbose --noconfirm -Su" || goto :error -C:\msys64\usr\bin\bash -lc "pacman --verbose --noconfirm --needed -S mingw-w64-%ARCH%-cmake mingw-w64-%ARCH%-perl mingw-w64-%ARCH%-diffutils mingw-w64-%ARCH%-unibilium gperf" || goto :error - -:: Setup python (use AppVeyor system python) -C:\Python27\python.exe -m pip install neovim || goto :error -C:\Python35\python.exe -m pip install neovim || goto :error -:: Disambiguate python3 -move c:\Python35\python.exe c:\Python35\python3.exe -set PATH=C:\Python35;C:\Python27;%PATH% -:: Sanity check -python -c "import neovim; print(str(neovim))" || goto :error -python3 -c "import neovim; print(str(neovim))" || goto :error - -mkdir .deps -cd .deps -cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo ..\third-party\ || goto :error -mingw32-make VERBOSE=1 || goto :error -cd .. - -:: Build Neovim -mkdir build -cd build -cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUSTED_OUTPUT_TYPE=nvim -DGPERF_PRG="C:\msys64\usr\bin\gperf.exe" .. || goto :error -mingw32-make VERBOSE=1 || goto :error -bin\nvim --version || goto :error - -:: Functional tests -mingw32-make functionaltest VERBOSE=1 || goto :error - -:: Build artifacts -cpack -G ZIP -C RelWithDebInfo -if defined APPVEYOR_REPO_TAG_NAME cpack -G NSIS -C RelWithDebInfo - -goto :EOF -:error -exit /b %errorlevel% diff --git a/ci/build.ps1 b/ci/build.ps1 new file mode 100644 index 0000000000..df70b44458 --- /dev/null +++ b/ci/build.ps1 @@ -0,0 +1,123 @@ +Set-PSDebug -Trace 1 + +$env:CONFIGURATION -match '^(?\w+)_(?32|64)(?:-(?