mirror of
https://github.com/neovim/neovim.git
synced 2025-12-11 09:02:40 +00:00
backport: build(windows): vendor xxd.c (#36755)
backport https://github.com/neovim/neovim/pull/36746 Problem: Currently we fetch a prebuilt xxd.exe from neovim/deps for Windows, which is not ideal in terms of obviousness, misses updates, and is clumsy to update. Solution: Similar to tee.c (#36363), vendor xxd.c from Vim and build it as part of the Neovim build process. This makes the source obvious, enables analyzer checks, and simplifies updates. Fixes #36664 Co-authored-by: benarcher2691 <ben.archer2691@gmail.com>
This commit is contained in:
@@ -289,6 +289,7 @@ add_dependencies(nvim nvim_bin nvim_runtime_deps nvim_runtime)
|
|||||||
|
|
||||||
add_subdirectory(src/nvim)
|
add_subdirectory(src/nvim)
|
||||||
add_subdirectory(src/tee)
|
add_subdirectory(src/tee)
|
||||||
|
add_subdirectory(src/xxd)
|
||||||
add_subdirectory(cmake.config)
|
add_subdirectory(cmake.config)
|
||||||
add_subdirectory(runtime)
|
add_subdirectory(runtime)
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
|
|||||||
@@ -450,7 +450,10 @@ foreach(hfile ${NVIM_HEADERS})
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
list(APPEND LINT_NVIM_SOURCES ${NVIM_SOURCES} ${NVIM_HEADERS})
|
list(APPEND LINT_NVIM_SOURCES ${NVIM_SOURCES} ${NVIM_HEADERS})
|
||||||
list(APPEND LINT_NVIM_SOURCES ${PROJECT_SOURCE_DIR}/src/tee/tee.c)
|
list(APPEND LINT_NVIM_SOURCES
|
||||||
|
${PROJECT_SOURCE_DIR}/src/tee/tee.c
|
||||||
|
${PROJECT_SOURCE_DIR}/src/xxd/xxd.c
|
||||||
|
)
|
||||||
|
|
||||||
# Log level (NVIM_LOG_DEBUG in log.h)
|
# Log level (NVIM_LOG_DEBUG in log.h)
|
||||||
if(CI_BUILD)
|
if(CI_BUILD)
|
||||||
@@ -850,7 +853,7 @@ target_link_libraries(libnvim PRIVATE main_lib PUBLIC libuv)
|
|||||||
|
|
||||||
find_program(CLANG_TIDY_PRG clang-tidy)
|
find_program(CLANG_TIDY_PRG clang-tidy)
|
||||||
mark_as_advanced(CLANG_TIDY_PRG)
|
mark_as_advanced(CLANG_TIDY_PRG)
|
||||||
set(EXCLUDE_CLANG_TIDY typval_encode.c.h ui_events.in.h)
|
set(EXCLUDE_CLANG_TIDY typval_encode.c.h ui_events.in.h xxd/xxd.c)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND EXCLUDE_CLANG_TIDY
|
list(APPEND EXCLUDE_CLANG_TIDY
|
||||||
os/pty_proc_unix.h
|
os/pty_proc_unix.h
|
||||||
@@ -912,7 +915,8 @@ add_glob_target(
|
|||||||
FLAGS --output=${LINT_OUTPUT_FORMAT}
|
FLAGS --output=${LINT_OUTPUT_FORMAT}
|
||||||
FILES ${LINT_NVIM_SOURCES}
|
FILES ${LINT_NVIM_SOURCES}
|
||||||
EXCLUDE
|
EXCLUDE
|
||||||
tui/terminfo_defs.h)
|
tui/terminfo_defs.h
|
||||||
|
xxd/xxd.c)
|
||||||
|
|
||||||
set(UNCRUSTIFY_PRG ${DEPS_BIN_DIR}/uncrustify)
|
set(UNCRUSTIFY_PRG ${DEPS_BIN_DIR}/uncrustify)
|
||||||
set(UNCRUSTIFY_CONFIG ${PROJECT_SOURCE_DIR}/src/uncrustify.cfg)
|
set(UNCRUSTIFY_CONFIG ${PROJECT_SOURCE_DIR}/src/uncrustify.cfg)
|
||||||
|
|||||||
12
src/xxd/CMakeLists.txt
Normal file
12
src/xxd/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
add_executable(xxd xxd.c)
|
||||||
|
|
||||||
|
# xxd has to be in the same directory as the nvim executable
|
||||||
|
set_target_properties(xxd PROPERTIES
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
|
||||||
|
)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
install(TARGETS xxd
|
||||||
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
1218
src/xxd/xxd.c
Normal file
1218
src/xxd/xxd.c
Normal file
File diff suppressed because it is too large
Load Diff
19
test/functional/editor/xxd_spec.lua
Normal file
19
test/functional/editor/xxd_spec.lua
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
local t = require('test.testutil')
|
||||||
|
local n = require('test.functional.testnvim')()
|
||||||
|
|
||||||
|
local eq = t.eq
|
||||||
|
local clear = n.clear
|
||||||
|
local fn = n.fn
|
||||||
|
local testprg = n.testprg
|
||||||
|
|
||||||
|
describe('xxd', function()
|
||||||
|
before_each(clear)
|
||||||
|
|
||||||
|
it('works', function()
|
||||||
|
-- Round-trip test: encode then decode should return original
|
||||||
|
local input = 'hello'
|
||||||
|
local encoded = fn.system({ testprg('xxd') }, input)
|
||||||
|
local decoded = fn.system({ testprg('xxd'), '-r' }, encoded)
|
||||||
|
eq(input, decoded)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
Reference in New Issue
Block a user