mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-01 21:21:15 -03:00
cmake: install fish_{indent,key_reader} as hardlinks to fish
As mentioned in https://github.com/fish-shell/fish-shell/issues/11921#issuecomment-3540587001, binaries duplicate a lot of information unnecessarily. $ cargo b --release $ du -h target/release/fish{,_indent,_key_reader} 15M target/release/fish 15M target/release/fish_indent 4.1M target/release/fish_key_reader 34M total Remove the duplication in CMake-installed builds by creating hard links. I'm not sure how to do that for Cargo binaries yet (can we write a portable wrapper script)? This is still a bit weird because hardlinks are rarely used like this; but symlinks may cause issues on MSYS2. Maybe we should write a /bin/sh wrapper script instead.
This commit is contained in:
@@ -13,6 +13,7 @@ Interactive improvements
|
|||||||
|
|
||||||
For distributors and developers
|
For distributors and developers
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
- ``fish_key_reader`` and ``fish_indent`` are now hardlinks to ``fish``.
|
||||||
|
|
||||||
fish 4.2.1 (released November 13, 2025)
|
fish 4.2.1 (released November 13, 2025)
|
||||||
=======================================
|
=======================================
|
||||||
|
|||||||
@@ -58,37 +58,40 @@ if(NOT "${CMAKE_BUILD_TYPE}" IN_LIST build_types)
|
|||||||
message(WARNING "Unsupported build type ${CMAKE_BUILD_TYPE}. If this doesn't build, try one of Release, RelWithDebInfo or Debug")
|
message(WARNING "Unsupported build type ${CMAKE_BUILD_TYPE}. If this doesn't build, try one of Release, RelWithDebInfo or Debug")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Define a function to build and link dependencies.
|
add_custom_target(
|
||||||
function(CREATE_TARGET target)
|
fish ALL
|
||||||
|
COMMAND
|
||||||
|
"${CMAKE_COMMAND}" -E
|
||||||
|
env ${VARS_FOR_CARGO}
|
||||||
|
${Rust_CARGO}
|
||||||
|
build --bin fish
|
||||||
|
$<$<CONFIG:Release>:--release>
|
||||||
|
$<$<CONFIG:RelWithDebInfo>:--profile=release-with-debug>
|
||||||
|
--target ${Rust_CARGO_TARGET}
|
||||||
|
--no-default-features
|
||||||
|
--features=${FISH_CARGO_FEATURES}
|
||||||
|
${CARGO_FLAGS}
|
||||||
|
&&
|
||||||
|
"${CMAKE_COMMAND}" -E
|
||||||
|
copy "${rust_target_dir}/${rust_profile}/fish" "${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
USES_TERMINAL
|
||||||
|
)
|
||||||
|
|
||||||
|
function(CREATE_LINK target)
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
${target} ALL
|
${target} ALL
|
||||||
COMMAND
|
DEPENDS fish
|
||||||
"${CMAKE_COMMAND}" -E
|
COMMAND ln -f fish ${target}
|
||||||
env ${VARS_FOR_CARGO}
|
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
${Rust_CARGO}
|
|
||||||
build --bin ${target}
|
|
||||||
$<$<CONFIG:Release>:--release>
|
|
||||||
$<$<CONFIG:RelWithDebInfo>:--profile=release-with-debug>
|
|
||||||
--target ${Rust_CARGO_TARGET}
|
|
||||||
--no-default-features
|
|
||||||
--features=${FISH_CARGO_FEATURES}
|
|
||||||
${CARGO_FLAGS}
|
|
||||||
&&
|
|
||||||
"${CMAKE_COMMAND}" -E
|
|
||||||
copy "${rust_target_dir}/${rust_profile}/${target}" "${CMAKE_CURRENT_BINARY_DIR}"
|
|
||||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
||||||
USES_TERMINAL
|
|
||||||
)
|
)
|
||||||
endfunction(CREATE_TARGET)
|
endfunction(CREATE_LINK)
|
||||||
|
|
||||||
# Define fish.
|
|
||||||
create_target(fish)
|
|
||||||
|
|
||||||
# Define fish_indent.
|
# Define fish_indent.
|
||||||
create_target(fish_indent)
|
create_link(fish_indent)
|
||||||
|
|
||||||
# Define fish_key_reader.
|
# Define fish_key_reader.
|
||||||
create_target(fish_key_reader)
|
create_link(fish_key_reader)
|
||||||
|
|
||||||
# Set up tests.
|
# Set up tests.
|
||||||
include(cmake/Tests.cmake)
|
include(cmake/Tests.cmake)
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
set(CMAKE_INSTALL_MESSAGE NEVER)
|
set(CMAKE_INSTALL_MESSAGE NEVER)
|
||||||
|
|
||||||
set(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fish ${CMAKE_CURRENT_BINARY_DIR}/fish_indent ${CMAKE_CURRENT_BINARY_DIR}/fish_key_reader)
|
|
||||||
|
|
||||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||||
set(bindir ${CMAKE_INSTALL_BINDIR})
|
set(bindir ${CMAKE_INSTALL_BINDIR})
|
||||||
set(sysconfdir ${CMAKE_INSTALL_SYSCONFDIR})
|
set(sysconfdir ${CMAKE_INSTALL_SYSCONFDIR})
|
||||||
@@ -75,11 +73,19 @@ function(FISH_TRY_CREATE_DIRS)
|
|||||||
endforeach()
|
endforeach()
|
||||||
endfunction(FISH_TRY_CREATE_DIRS)
|
endfunction(FISH_TRY_CREATE_DIRS)
|
||||||
|
|
||||||
install(PROGRAMS ${PROGRAMS}
|
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fish
|
||||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
|
||||||
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||||
DESTINATION ${bindir})
|
DESTINATION ${bindir})
|
||||||
|
|
||||||
|
if(NOT IS_ABSOLUTE ${bindir})
|
||||||
|
set(abs_bindir "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${bindir}")
|
||||||
|
else()
|
||||||
|
set(abs_bindir "\$ENV{DESTDIR}${bindir}")
|
||||||
|
endif()
|
||||||
|
install(CODE "file(CREATE_LINK ${abs_bindir}/fish ${abs_bindir}/fish_indent)")
|
||||||
|
install(CODE "file(CREATE_LINK ${abs_bindir}/fish ${abs_bindir}/fish_key_reader)")
|
||||||
|
|
||||||
fish_create_dirs(${sysconfdir}/fish/conf.d ${sysconfdir}/fish/completions
|
fish_create_dirs(${sysconfdir}/fish/conf.d ${sysconfdir}/fish/completions
|
||||||
${sysconfdir}/fish/functions)
|
${sysconfdir}/fish/functions)
|
||||||
install(FILES etc/config.fish DESTINATION ${sysconfdir}/fish/)
|
install(FILES etc/config.fish DESTINATION ${sysconfdir}/fish/)
|
||||||
|
|||||||
Reference in New Issue
Block a user