Skip to content

Commit 8b6c740

Browse files
Export internal symbols for shared library builds (#1283)
These symbols are internal to FTXUI (located in src/), but they must be exported when building as shared libraries because of internal dependencies between the screen, dom, and component libraries. - SCREEN symbols in string_internal.hpp are used by COMPONENT. - DOM symbols in node_decorator.hpp are used by COMPONENT. Also: - Bump minor version to 6.2.0 due to ABI changes. - Update tools/abi_fingerprint.txt. - Fix Meson build for Windows and shared library mode by setting necessary export definitions.
1 parent da2491b commit 8b6c740

6 files changed

Lines changed: 61 additions & 11 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Shared Library Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build-shared:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Configure CMake
19+
env:
20+
CC: clang
21+
CXX: clang++
22+
run: |
23+
cmake -B build \
24+
-DBUILD_SHARED_LIBS=ON \
25+
-DFTXUI_BUILD_EXAMPLES=ON \
26+
-DFTXUI_BUILD_TESTS=OFF \
27+
-DFTXUI_BUILD_DOCS=OFF
28+
29+
- name: Build one example
30+
run: |
31+
cmake --build build --target ftxui_example_text

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ if (FTXUI_BUILD_MODULES)
1515
else()
1616
cmake_minimum_required(VERSION 3.12)
1717
endif()
18-
1918
project(ftxui
2019
LANGUAGES CXX
21-
VERSION 6.1.9
20+
VERSION 6.2.0
2221
DESCRIPTION "C++ Functional Terminal User Interface."
2322
)
2423

meson.build

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project('ftxui', 'cpp',
2-
version: run_command('python3', '-c', 'import re; print(re.search(r"project\(ftxui\s+.*?VERSION\s+([0-9.]+)", open("CMakeLists.txt").read(), re.DOTALL).group(1))', check: true).stdout().strip(),
2+
version: run_command(import('python').find_installation(), '-c', 'import re; print(re.search(r"project\(ftxui\s+.*?VERSION\s+([0-9.]+)", open("CMakeLists.txt").read(), re.DOTALL).group(1))', check: true).stdout().strip(),
33
license: 'MIT',
44
default_options: [
55
'cpp_std=c++17',
@@ -27,6 +27,12 @@ ftxui_build_tests = get_option('tests')
2727
ftxui_public_inc = include_directories('include')
2828
ftxui_private_inc = include_directories('src', 'include')
2929

30+
# Export definitions for shared libraries
31+
ftxui_args = []
32+
if get_option('default_library') != 'static'
33+
ftxui_args += '-DCOMPONENT_BUILD'
34+
endif
35+
3036
# Subdirectories for sources
3137
subdir('src/ftxui/screen')
3238
subdir('src/ftxui/dom')
@@ -36,6 +42,7 @@ subdir('src/ftxui/component')
3642
ftxui_screen = library('ftxui-screen',
3743
screen_sources,
3844
include_directories: ftxui_private_inc,
45+
cpp_args: ftxui_args + ['-DIS_FTXUI_SCREEN_IMPL=1'],
3946
install: true,
4047
)
4148

@@ -48,6 +55,7 @@ ftxui_screen_dep = declare_dependency(
4855
ftxui_dom = library('ftxui-dom',
4956
dom_sources,
5057
include_directories: ftxui_private_inc,
58+
cpp_args: ftxui_args + ['-DIS_FTXUI_DOM_IMPL=1'],
5159
link_with: ftxui_screen,
5260
install: true,
5361
)
@@ -61,6 +69,7 @@ ftxui_dom_dep = declare_dependency(
6169
ftxui_component = library('ftxui-component',
6270
component_sources,
6371
include_directories: ftxui_private_inc,
72+
cpp_args: ftxui_args + ['-DIS_FTXUI_COMPONENT_IMPL=1'],
6473
link_with: [ftxui_dom, ftxui_screen],
6574
install: true,
6675
)

src/ftxui/dom/node_decorator.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88

99
#include "ftxui/dom/elements.hpp" // for Element, unpack
1010
#include "ftxui/dom/node.hpp" // for Node
11+
#include "ftxui/util/export.hpp" // for FTXUI_EXPORT
1112

1213
namespace ftxui {
1314
struct Box;
1415

1516
// Helper class.
16-
class NodeDecorator : public Node {
17+
// Internal class exported for the 'component' library.
18+
class FTXUI_EXPORT(DOM) NodeDecorator : public Node {
1719
public:
1820
explicit NodeDecorator(Element child) : Node(unpack(std::move(child))) {}
1921
void ComputeRequirement() override;

src/ftxui/screen/string_internal.hpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,36 @@
88
#include <string>
99
#include <vector>
1010

11+
#include "ftxui/util/export.hpp"
12+
1113
namespace ftxui {
1214

15+
// Internal functions exported for the 'component' library.
16+
FTXUI_EXPORT(SCREEN)
1317
bool EatCodePoint(std::string_view input,
1418
size_t start,
1519
size_t* end,
1620
uint32_t* ucs);
21+
FTXUI_EXPORT(SCREEN)
1722
bool EatCodePoint(std::wstring_view input,
1823
size_t start,
1924
size_t* end,
2025
uint32_t* ucs);
2126

22-
bool IsCombining(uint32_t ucs);
23-
bool IsFullWidth(uint32_t ucs);
24-
bool IsControl(uint32_t ucs);
27+
FTXUI_EXPORT(SCREEN) bool IsCombining(uint32_t ucs);
28+
FTXUI_EXPORT(SCREEN) bool IsFullWidth(uint32_t ucs);
29+
FTXUI_EXPORT(SCREEN) bool IsControl(uint32_t ucs);
2530

26-
size_t GlyphPrevious(std::string_view input, size_t start);
27-
size_t GlyphNext(std::string_view input, size_t start);
31+
FTXUI_EXPORT(SCREEN) size_t GlyphPrevious(std::string_view input, size_t start);
32+
FTXUI_EXPORT(SCREEN) size_t GlyphNext(std::string_view input, size_t start);
2833

2934
// Return the index in the |input| string of the glyph at |glyph_offset|,
3035
// starting at |start|
36+
FTXUI_EXPORT(SCREEN)
3137
size_t GlyphIterate(std::string_view input, int glyph_offset, size_t start = 0);
3238

3339
// Returns the number of glyphs in |input|.
34-
int GlyphCount(std::string_view input);
40+
FTXUI_EXPORT(SCREEN) int GlyphCount(std::string_view input);
3541

3642
// Properties from:
3743
// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/WordBreakProperty.txt
@@ -55,9 +61,12 @@ enum class WordBreakProperty : int8_t {
5561
WSegSpace,
5662
ZWJ,
5763
};
64+
FTXUI_EXPORT(SCREEN)
5865
WordBreakProperty CodepointToWordBreakProperty(uint32_t codepoint);
66+
FTXUI_EXPORT(SCREEN)
5967
std::vector<WordBreakProperty> Utf8ToWordBreakProperty(std::string_view input);
6068

69+
FTXUI_EXPORT(SCREEN)
6170
bool IsWordBreakingCharacter(std::string_view input, size_t glyph_index);
6271
} // namespace ftxui
6372

tools/abi_fingerprint.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
396e5a0e8a1982216fe0c4caadecddd7e19ad609aaff274c118c87d385978fad
1+
62348ac12fb57551cd70e9ef4d96c7418976591f5963ef5d98702eda511ab08b

0 commit comments

Comments
 (0)