Skip to content

Commit

Permalink
Use packaged ftxui for the static binary build
Browse files Browse the repository at this point in the history
  • Loading branch information
tobim committed May 30, 2023
1 parent 4ee45fc commit 9e00e11
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 9 deletions.
11 changes: 11 additions & 0 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ in {
# spdlog in nixpkgs uses `fmt_8` directly, but we want version 9, so we use a
# little hack here.
fmt_8 = prev.fmt;
ftxui =
if !isStatic
then prev.ftxui
else
prev.ftxui.overrideAttrs (orig: {
cmakeFlags = [
"-DFTXUI_BUILD_EXAMPLES=OFF"
"-DFTXUI_BUILD_DOCS=OFF"
"-DFTXUI_BUILD_TESTS=OFF"
];
});
# We need boost 1.8.1 at minimum for URL.
boost = prev.boost18x;
rapidjson = prev.rapidjson.overrideAttrs (_: {
Expand Down
3 changes: 3 additions & 0 deletions nix/vast/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
arrow-cpp,
fast_float,
flatbuffers,
ftxui,
spdlog,
libyamlcpp,
simdjson,
Expand Down Expand Up @@ -60,6 +61,7 @@
"plugins/parquet"
"plugins/pcap"
"plugins/sigma"
"plugins/tui"
"plugins/web"
]
++ extraPlugins';
Expand Down Expand Up @@ -90,6 +92,7 @@
buildInputs = [
boost
fast_float
ftxui
libpcap
libunwind
libyamlcpp
Expand Down
60 changes: 51 additions & 9 deletions plugins/tui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,57 @@ VASTRegisterPlugin(
SOURCES ${tui_sources}
INCLUDE_DIRECTORIES include)

if (NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/aux/ftxui/.git")
message(
FATAL_ERROR
"submodule '${CMAKE_CURRENT_LIST_DIR}/aux/ftxui' is not initialized")
#macro(VASTAddDependency name visibility path)
# string(TOUPPER name upper_name)
# option(VAST_ENABLE_BUNDLED_${upper_name} "Always use the bundled ${name}" OFF)
# add_feature_info("VAST_ENABLE_BUNDLED_${upper_name}" VAST_ENABLE_BUNDLED_${upper_name}
# "always use the bundled ${name}.")
# if (NOT VAST_ENABLE_BUNDLED_${upper_name})
# find_package(${name} QUIET)
# if (${name}_FOUND)
# string(APPEND VAST_FIND_DEPENDENCY_LIST
# "\nfind_package(${name} REQUIRED)")
# dependency_summary("${name}" ${target} "Dependencies")
# endif ()
# endif ()
# if (NOT ${name})
# if (NOT VAST_ENABLE_BUNDLED_${upper_name})
# message(
# STATUS
# "Cannot find installed ${name}; falling back to bundled version")
# endif ()
# set(CMAKE_CXX_STANDARD 20)
# add_subdirectory(${pah})
# unset(CMAKE_CXX_STANDARD)
# dependency_summary("${name}" "${CMAKE_CURRENT_SOURCE_DIR}/${path}"
# "Dependencies")
# endif ()
#endmacro()
#
#VASTAddDependency(ftxui PRIVATE aux/ftxui)
option(VAST_ENABLE_BUNDLED_FTXUI "Always use the bundled ftxui" OFF)
add_feature_info("VAST_ENABLE_BUNDLED_FTXUI" VAST_ENABLE_BUNDLED_FTXUI
"always use the bundled ftxui.")
if (NOT VAST_ENABLE_BUNDLED_FTXUI)
find_package(ftxui QUIET)
if (ftxui_FOUND)
string(APPEND VAST_FIND_DEPENDENCY_LIST
"\nfind_package(ftxui REQUIRED)")
dependency_summary("ftxui" ftxui::screen "Dependencies")
endif ()
endif ()

set(CMAKE_CXX_STANDARD 20)
add_subdirectory(aux/ftxui)
unset(CMAKE_CXX_STANDARD)

if (NOT ftxui_FOUND)
if (NOT VAST_ENABLE_BUNDLED_FTXUI)
message(
STATUS
"Cannot find installed ftxui; falling back to bundled version")
endif ()
set(CMAKE_CXX_STANDARD 20)
add_subdirectory(aux/ftxui)
unset(CMAKE_CXX_STANDARD)
dependency_summary("ftxui" "${CMAKE_CURRENT_SOURCE_DIR}/aux/ftxui"
"Dependencies")
endif ()

target_link_libraries(tui PUBLIC vast::libvast vast::internal)
target_link_libraries(tui PUBLIC ftxui::screen ftxui::dom ftxui::component)

0 comments on commit 9e00e11

Please sign in to comment.