Skip to content

Commit 71868d4

Browse files
committed
Modularization
1 parent d19b86a commit 71868d4

66 files changed

Lines changed: 149 additions & 2913 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
[submodule "third-party/cpprestsdk"]
2-
path = third-party/cpprestsdk
3-
url = https://github.com/microsoft/cpprestsdk.git
41
[submodule "third-party/zlib-ng"]
52
path = third-party/zlib-ng
63
url = https://github.com/zlib-ng/zlib-ng.git
74
[submodule "third-party/openssl"]
85
path = third-party/openssl
96
url = https://github.com/openssl/openssl.git
10-
[submodule "third-party/boost-archive-for-cpprestsdk"]
11-
path = third-party/boost-archive-for-cpprestsdk
12-
url = https://github.com/refvalue/boost-archive-for-cpprestsdk.git
137
[submodule "third-party/zstd"]
148
path = third-party/zstd
159
url = https://github.com/facebook/zstd.git

CMakeLists.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# CMakeList.txt : Top-level CMake project file, do global configuration
22
# and include sub-projects here.
33
#
4-
cmake_minimum_required(VERSION 3.30)
4+
cmake_minimum_required(VERSION 4.0.0)
55

66
# Set experimental flag to enable `import std` support from CMake.
77
# This must be enabled before C++ language support.
8-
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "0e5b6991-d74f-4b3d-a41c-cf096e0b2508")
8+
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "d0edc3af-4c50-42ea-a356-e2862fe7a444")
99
set(CMAKE_CXX_MODULE_STD ON)
1010

11-
project(cpp-essence CXX)
11+
project(cpp-essence C CXX)
1212

13-
option(ES_WITH_NET "Whether to include the net support." ON)
1413
option(ES_WITH_JNI "Whether to include JNI support." ON)
1514
option(ES_WITH_TESTS "Whether to compile tests." ON)
1615
option(ES_WITH_LANG_COMPILER "Whether to compile the language compiler for globalization." ON)
@@ -19,10 +18,6 @@ option(ES_STATIC_RUNTIME "Whether to statically link to the C++ standard library
1918

2019
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
2120

22-
if(ES_WITH_NET AND EMSCRIPTEN)
23-
message(FATAL_ERROR "The net support has not been implemented on WebAssembly.")
24-
endif()
25-
2621
if(ANDROID)
2722
set(ES_WITH_JNI OFF)
2823
set(ES_STATIC_RUNTIME OFF) # Dynamically linking to libc++.

Dependencies.cmake

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
include_guard()
22
include(ESUtil)
3-
include(ESBoost)
43
include(ESOpenSSL)
54
include(ESEmscripten)
65
include(ESLangCompiler)
@@ -52,15 +51,13 @@ if(ES_WITH_TESTS)
5251
endif()
5352

5453
set(extra_cmake_args
55-
-DCMAKE_CXX_STANDARD=20
54+
-DCMAKE_CXX_STANDARD=23
5655
-DCMAKE_CXX_STANDARD_REQUIRED=ON
5756
)
5857

5958
set(extra_openssl_args no-tests no-afalgeng no-aria no-async no-autoload-config no-blake2 no-bf no-camellia no-cast no-chacha no-cmac no-cms no-cmp no-comp no-ct no-des no-dgram no-dh no-dsa no-dtls no-ec2m no-engine no-filenames no-gost no-idea no-ktls no-mdc2 no-md4 no-multiblock no-nextprotoneg no-ocsp no-ocb no-poly1305 no-psk no-rc2 no-rc4 no-rmd160 no-seed no-siphash no-siv no-srp no-srtp no-ssl3 no-ssl3-method no-ts no-ui-console no-whirlpool)
6059

6160
if(CMAKE_CROSSCOMPILING AND NOT EMSCRIPTEN)
62-
# The Boost library is unnecessary if the websocketpp library is excluded
63-
# when compiling the cpprestsdk on Windows.
6461
message(STATUS "======== CROSS-COMPILING ========")
6562
list(
6663
APPEND extra_cmake_args
@@ -168,64 +165,3 @@ es_make_install_third_party_library(
168165
${extra_cmake_args}
169166
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/third-party/zstd/build/cmake
170167
)
171-
172-
# The cpprestsdk library uses Ninja as the build system when cross-compiling.
173-
if(ES_WITH_NET)
174-
if(WIN32)
175-
set(cpprestsdk_extra_cmake_args "")
176-
else()
177-
# Unix/Linux needs Boost.
178-
set(
179-
make_boost_extra_args
180-
TOOLSET ${CMAKE_CXX_COMPILER}
181-
TARGET_OS linux
182-
)
183-
184-
es_make_boost(
185-
REQUIRED
186-
STATIC
187-
${runtime_args}
188-
PARALLEL_BUILD
189-
SYNC_BUILD_TYPE
190-
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/third-party/boost-archive-for-cpprestsdk
191-
${make_boost_extra_args}
192-
)
193-
194-
set(
195-
cpprestsdk_extra_cmake_args
196-
-DBOOST_ROOT=${BOOST_ROOT}
197-
-DBoost_USE_STATIC_LIBS=ON
198-
-DBoost_USE_STATIC_RUNTIME=${ES_STATIC_RUNTIME}
199-
)
200-
endif()
201-
202-
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
203-
list(APPEND cpprestsdk_extra_cmake_args -DCMAKE_CXX_FLAGS=-Wno-format-truncation)
204-
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
205-
list(APPEND cpprestsdk_extra_cmake_args -DCMAKE_CXX_FLAGS=-Wno-enum-constexpr-conversion)
206-
endif()
207-
208-
# Boost is excluded without compiling websocketpp as a dependency.
209-
es_make_install_third_party_library(
210-
cpprestsdk
211-
REQUIRED
212-
${runtime_args}
213-
#PARALLEL_BUILD
214-
SYNC_BUILD_TYPE
215-
GENERATOR ${CMAKE_GENERATOR}
216-
CMAKE_ARGS
217-
-G Ninja
218-
-DWERROR=OFF
219-
-DBUILD_TESTS=OFF
220-
-DBUILD_SAMPLES=OFF
221-
-DBUILD_SHARED_LIBS=OFF
222-
-DCPPREST_EXCLUDE_WEBSOCKETS=ON
223-
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
224-
-DZLIB_ROOT=${ZLIB_ROOT}
225-
-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}
226-
-DOPENSSL_USE_STATIC_LIBS=TRUE
227-
${extra_cmake_args}
228-
${cpprestsdk_extra_cmake_args}
229-
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/third-party/cpprestsdk
230-
)
231-
endif()

cmake/ESLangCompiler.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function(es_add_lang_resources target_name)
107107

108108
if("${target_type}" STREQUAL "EXECUTABLE")
109109
set(cxx_modules_access PRIVATE)
110-
elseif()
110+
else()
111111
set(cxx_modules_access PUBLIC)
112112
endif()
113113

src/CMakeLists.txt

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,6 @@ if(EMSCRIPTEN)
5757
es_filter_sources([=[^((.*(thread|delegate|interruptable_timer|atomic_readable_buffer)|.*/params/.*|.*/crypto/.*(asymm|pubkey).*))(.ixx|.cxx|.cpp)$]=])
5858
endif()
5959

60-
if(NOT ES_WITH_NET)
61-
es_filter_sources([=[^.*/net/.*(.ixx|.cxx|.cpp)$]=])
62-
endif()
63-
64-
if(NOT ANDROID OR NOT ES_WITH_NET)
65-
list(
66-
FILTER private_sources
67-
EXCLUDE REGEX "^.*jni_entry.cpp$"
68-
)
69-
endif()
70-
7160
include(ESUtil)
7261
es_dump_list(miu_sources)
7362
es_dump_list(internal_piu_sources)
@@ -140,28 +129,6 @@ if(NOT EMSCRIPTEN)
140129
)
141130
endif()
142131

143-
if(ES_WITH_NET)
144-
target_link_libraries(
145-
${target_name}
146-
PRIVATE
147-
cpprestsdk::cpprest
148-
)
149-
150-
if(CMAKE_CROSSCOMPILING)
151-
target_link_libraries(
152-
${target_name}
153-
PRIVATE
154-
Boost::boost
155-
)
156-
endif()
157-
158-
target_compile_definitions(
159-
${target_name}
160-
PUBLIC
161-
CPP_ESSENCE_HAS_NET=1
162-
)
163-
endif()
164-
165132
if(ANDROID)
166133
target_link_libraries(
167134
${target_name}

src/basic.ixx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export import :functional;
4646
export import :generator;
4747
export import :hashing;
4848
export import :interruptable_timer;
49-
export import :library_state;
5049
export import :managed_handle;
5150
export import :math;
5251
export import :memory;

src/cli/abstract/option.ixx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
module;
2424

25+
#include <essence/compat.hpp>
26+
2527
export module essence.cli:abstract.option;
2628
import :common_types;
2729
import :validation_result;
@@ -40,77 +42,77 @@ export namespace essence::cli::abstract {
4042
requires(!std::same_as<std::decay_t<T>, option>)
4143
explicit option(T&& value) : wrapper_{std::make_shared<wrapper<T>>(std::forward<T>(value))} {}
4244

43-
[[nodiscard]] abi::string bound_name() const {
45+
ES_API(CPPESSENCE) [[nodiscard]] abi::string bound_name() const {
4446
return wrapper_->bound_name();
4547
}
4648

47-
const option& set_bound_name(std::string_view name) const { // NOLINT(*-use-nodiscard)
49+
ES_API(CPPESSENCE) const option& set_bound_name(std::string_view name) const { // NOLINT(*-use-nodiscard)
4850
wrapper_->set_bound_name(name);
4951

5052
return *this;
5153
}
5254

53-
[[nodiscard]] abi::string description() const {
55+
ES_API(CPPESSENCE) [[nodiscard]] abi::string description() const {
5456
return wrapper_->description();
5557
}
5658

57-
[[nodiscard]] const option& set_description(std::string_view description) const {
59+
ES_API(CPPESSENCE) [[nodiscard]] const option& set_description(std::string_view description) const {
5860
wrapper_->set_description(description);
5961

6062
return *this;
6163
}
6264

63-
[[nodiscard]] std::span<const abi::string> aliases() const {
65+
ES_API(CPPESSENCE) [[nodiscard]] std::span<const abi::string> aliases() const {
6466
return wrapper_->aliases();
6567
}
6668

67-
const option& add_aliases(std::span<const abi::string> aliases) const { // NOLINT(*-use-nodiscard)
69+
ES_API(CPPESSENCE) const option& add_aliases(std::span<const abi::string> aliases) const { // NOLINT(*-use-nodiscard)
6870
wrapper_->add_aliases(aliases);
6971

7072
return *this;
7173
}
7274

73-
[[nodiscard]] std::optional<abi::string> default_value_str() const {
75+
ES_API(CPPESSENCE) [[nodiscard]] std::optional<abi::string> default_value_str() const {
7476
return wrapper_->default_value_str();
7577
}
7678

77-
[[nodiscard]] std::span<const abi::string> valid_value_strs() const {
79+
ES_API(CPPESSENCE) [[nodiscard]] std::span<const abi::string> valid_value_strs() const {
7880
return wrapper_->valid_value_strs();
7981
}
8082

81-
[[nodiscard]] abi::string name_hints() const {
83+
ES_API(CPPESSENCE) [[nodiscard]] abi::string name_hints() const {
8284
return wrapper_->name_hints();
8385
}
8486

85-
[[nodiscard]] abi::string value_hints() const {
87+
ES_API(CPPESSENCE) [[nodiscard]] abi::string value_hints() const {
8688
return wrapper_->value_hints();
8789
}
8890

89-
[[nodiscard]] bool check_target_type(meta::fingerprint id) const {
91+
ES_API(CPPESSENCE) [[nodiscard]] bool check_target_type(meta::fingerprint id) const {
9092
return wrapper_->check_target_type(id);
9193
}
9294

93-
[[nodiscard]] bool parse_value_and_cache(std::string_view value) const {
95+
ES_API(CPPESSENCE) [[nodiscard]] bool parse_value_and_cache(std::string_view value) const {
9496
return wrapper_->parse_value_and_cache(value);
9597
}
9698

97-
void validate(std::string_view value, validation_result& result) const {
99+
ES_API(CPPESSENCE) void validate(std::string_view value, validation_result& result) const {
98100
wrapper_->validate(value, result);
99101
}
100102

101-
void raise_error(std::string_view message) const {
103+
ES_API(CPPESSENCE) void raise_error(std::string_view message) const {
102104
wrapper_->raise_error(message);
103105
}
104106

105-
[[nodiscard]] void* underlying_ptr() const noexcept {
107+
ES_API(CPPESSENCE) [[nodiscard]] void* underlying_ptr() const noexcept {
106108
return wrapper_.get();
107109
}
108110

109-
void on_validation(const validation_handler& handler) const {
111+
ES_API(CPPESSENCE) void on_validation(const validation_handler& handler) const {
110112
wrapper_->on_validation(handler);
111113
}
112114

113-
void on_error(const output_handler& handler) const {
115+
ES_API(CPPESSENCE) void on_error(const output_handler& handler) const {
114116
wrapper_->on_error(handler);
115117
}
116118

src/i18n/abstract/compiler.ixx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
* THE SOFTWARE.
2121
*/
2222

23+
module;
24+
25+
#include <essence/compat.hpp>
26+
2327
export module essence.i18n:abstract.compiler;
2428
import essence.basic;
2529
import essence.serialization;
@@ -39,7 +43,7 @@ export namespace essence::i18n::abstract {
3943
* Gets the version of the compiler.
4044
* @return The version.
4145
*/
42-
[[nodiscard]] std::uint32_t version() const {
46+
ES_API(CPPESSENCE) [[nodiscard]] std::uint32_t version() const {
4347
return wrapper_->version();
4448
}
4549

@@ -48,7 +52,7 @@ export namespace essence::i18n::abstract {
4852
* @param json The JSON value.
4953
* @param path The path of the file.
5054
*/
51-
void to_file(const abi::json& json, std::string_view path) const {
55+
ES_API(CPPESSENCE) void to_file(const abi::json& json, std::string_view path) const {
5256
wrapper_->to_file(json, path);
5357
}
5458

@@ -57,7 +61,7 @@ export namespace essence::i18n::abstract {
5761
* @param json The JSON value.
5862
* @return The byte array.
5963
*/
60-
[[nodiscard]] abi::vector<std::byte> to_bytes(const abi::json& json) const {
64+
ES_API(CPPESSENCE) [[nodiscard]] abi::vector<std::byte> to_bytes(const abi::json& json) const {
6165
return wrapper_->to_bytes(json);
6266
}
6367

@@ -66,7 +70,7 @@ export namespace essence::i18n::abstract {
6670
* @param json The JSON value.
6771
* @return The base64 string.
6872
*/
69-
[[nodiscard]] abi::string to_base64(const abi::json& json) const {
73+
ES_API(CPPESSENCE) [[nodiscard]] abi::string to_base64(const abi::json& json) const {
7074
return wrapper_->to_base64(json);
7175
}
7276

0 commit comments

Comments
 (0)