mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
version: Add compilation info.
This commit is contained in:
parent
dcccc1a50d
commit
176930fa56
@ -32,6 +32,17 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
endif()
|
||||
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" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
|
||||
# Set default build type.
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
message(STATUS "CMAKE_BUILD_TYPE not given; setting to 'RelWithDebInfo'.")
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE)
|
||||
endif()
|
||||
|
||||
# Version tokens
|
||||
include(GetGitRevisionDescription)
|
||||
get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT)
|
||||
@ -48,6 +59,8 @@ git_timestamp(GIT_TIMESTAMP)
|
||||
if(GIT_TIMESTAMP)
|
||||
set(NVIM_VERSION_BUILD "+${GIT_TIMESTAMP}")
|
||||
endif()
|
||||
set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
|
||||
# NVIM_VERSION_CFLAGS set further below.
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
@ -249,9 +262,14 @@ install(SCRIPT ${CMAKE_MODULE_PATH}/GenerateHelptags.cmake)
|
||||
|
||||
# Go down the tree.
|
||||
|
||||
add_subdirectory(config)
|
||||
add_subdirectory(src/nvim)
|
||||
# Read compilation flags from src/nvim,
|
||||
# used in config subdirectory below.
|
||||
include(GetCompileFlags)
|
||||
get_compile_flags(NVIM_VERSION_CFLAGS)
|
||||
|
||||
add_subdirectory(test/includes)
|
||||
add_subdirectory(config)
|
||||
|
||||
# Setup some test-related bits. We do this after going down the tree because we
|
||||
# need some of the targets.
|
||||
|
58
cmake/GetCompileFlags.cmake
Normal file
58
cmake/GetCompileFlags.cmake
Normal file
@ -0,0 +1,58 @@
|
||||
function(get_compile_flags _compile_flags)
|
||||
# Create template akin to CMAKE_C_COMPILE_OBJECT.
|
||||
set(compile_flags "<CMAKE_C_COMPILER> <CFLAGS> <BUILD_TYPE_CFLAGS> <DEFINITIONS> <INCLUDES>")
|
||||
|
||||
# Get C compiler.
|
||||
string(REPLACE
|
||||
"<CMAKE_C_COMPILER>"
|
||||
"${CMAKE_C_COMPILER}"
|
||||
compile_flags
|
||||
"${compile_flags}")
|
||||
|
||||
# Get flags set by add_definition().
|
||||
get_directory_property(definitions
|
||||
DIRECTORY "src/nvim"
|
||||
DEFINITIONS)
|
||||
string(REPLACE
|
||||
"<DEFINITIONS>"
|
||||
"${definitions}"
|
||||
compile_flags
|
||||
"${compile_flags}")
|
||||
|
||||
# Get general C flags.
|
||||
string(REPLACE
|
||||
"<CFLAGS>"
|
||||
"${CMAKE_C_FLAGS}"
|
||||
compile_flags
|
||||
"${compile_flags}")
|
||||
|
||||
# Get C flags specific to build type.
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
|
||||
string(REPLACE
|
||||
"<BUILD_TYPE_CFLAGS>"
|
||||
"${CMAKE_C_FLAGS_${build_type}}"
|
||||
compile_flags
|
||||
"${compile_flags}")
|
||||
|
||||
# Get include directories.
|
||||
get_directory_property(include_directories_list
|
||||
DIRECTORY "src/nvim"
|
||||
INCLUDE_DIRECTORIES)
|
||||
foreach(include_directory ${include_directories_list})
|
||||
set(include_directories "${include_directories} -I${include_directory}")
|
||||
endforeach()
|
||||
string(REPLACE
|
||||
"<INCLUDES>"
|
||||
"${include_directories}"
|
||||
compile_flags
|
||||
"${compile_flags}")
|
||||
|
||||
# Clean duplicate whitespace.
|
||||
string(REPLACE
|
||||
" "
|
||||
" "
|
||||
compile_flags
|
||||
"${compile_flags}")
|
||||
|
||||
set(${_compile_flags} "${compile_flags}" PARENT_SCOPE)
|
||||
endfunction()
|
@ -4,6 +4,8 @@
|
||||
#define NVIM_VERSION_PRERELEASE "@NVIM_VERSION_PRERELEASE@"
|
||||
#define NVIM_VERSION_BUILD "@NVIM_VERSION_BUILD@"
|
||||
#define NVIM_VERSION_COMMIT "@NVIM_VERSION_COMMIT@"
|
||||
#define NVIM_VERSION_CFLAGS "@NVIM_VERSION_CFLAGS@"
|
||||
#define NVIM_VERSION_BUILD_TYPE "@NVIM_VERSION_BUILD_TYPE@"
|
||||
|
||||
#cmakedefine DEBUG
|
||||
|
||||
|
@ -89,8 +89,8 @@ get_directory_property(gen_includes INCLUDE_DIRECTORIES)
|
||||
foreach(gen_include ${gen_includes})
|
||||
set(gen_cflags "${gen_cflags} -I${gen_include}")
|
||||
endforeach()
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type)
|
||||
set(gen_cflags "${gen_cflags} ${CMAKE_C_FLAGS_${_build_type}} ${CMAKE_C_FLAGS}")
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
|
||||
set(gen_cflags "${gen_cflags} ${CMAKE_C_FLAGS_${build_type}} ${CMAKE_C_FLAGS}")
|
||||
|
||||
foreach(sfile ${NEOVIM_SOURCES}
|
||||
"${PROJECT_SOURCE_DIR}/src/nvim/regexp_nfa.c")
|
||||
|
@ -21,6 +21,8 @@
|
||||
char *Version = VIM_VERSION_SHORT;
|
||||
char *longVersion = NVIM_VERSION_LONG " (compiled " __DATE__ " " __TIME__ ")";
|
||||
char *version_commit = "Commit: " NVIM_VERSION_COMMIT;
|
||||
char *version_buildtype = "Build type: " NVIM_VERSION_BUILD_TYPE;
|
||||
char *version_cflags = "Compilation: " NVIM_VERSION_CFLAGS;
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "version.c.generated.h"
|
||||
@ -778,6 +780,8 @@ void list_version(void)
|
||||
// internal variables in eval.c!
|
||||
MSG(longVersion);
|
||||
MSG(version_commit);
|
||||
MSG(version_buildtype);
|
||||
MSG(version_cflags);
|
||||
|
||||
// Print the list of extra patch descriptions if there is at least one.
|
||||
char *s = "";
|
||||
@ -857,10 +861,6 @@ void list_version(void)
|
||||
version_msg("\"\n");
|
||||
}
|
||||
#endif // ifdef HAVE_PATHDEF
|
||||
#ifdef DEBUG
|
||||
version_msg("\n");
|
||||
version_msg(_(" DEBUG BUILD"));
|
||||
#endif // ifdef DEBUG
|
||||
}
|
||||
|
||||
/// Output a string for the version message. If it's going to wrap, output a
|
||||
|
@ -22,13 +22,19 @@
|
||||
#define NVIM_VERSION_PATCH 0
|
||||
#endif
|
||||
#ifndef NVIM_VERSION_PRERELEASE
|
||||
#define NVIM_VERSION_PRERELEASE
|
||||
#define NVIM_VERSION_PRERELEASE "?"
|
||||
#endif
|
||||
#ifndef NVIM_VERSION_BUILD
|
||||
#define NVIM_VERSION_BUILD
|
||||
#define NVIM_VERSION_BUILD "?"
|
||||
#endif
|
||||
#ifndef NVIM_VERSION_COMMIT
|
||||
#define NVIM_VERSION_COMMIT
|
||||
#define NVIM_VERSION_COMMIT "?"
|
||||
#endif
|
||||
#ifndef NVIM_VERSION_CFLAGS
|
||||
#define NVIM_VERSION_CFLAGS "?"
|
||||
#endif
|
||||
#ifndef NVIM_VERSION_BUILD_TYPE
|
||||
#define NVIM_VERSION_BUILD_TYPE "?"
|
||||
#endif
|
||||
// for the startup-screen
|
||||
#define NVIM_VERSION_MEDIUM STR(NVIM_VERSION_MAJOR) "." STR(NVIM_VERSION_MINOR)
|
||||
|
Loading…
Reference in New Issue
Block a user