Skip to content

Commit 978255e

Browse files
Merge pull request #1 from Awesome-Embedded-Learning-Studio/develop
feat: Desktop backbone initial setups, still in WIP
2 parents 24cf44d + 4bc2e2b commit 978255e

75 files changed

Lines changed: 9972 additions & 242 deletions

File tree

Some content is hidden

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

.clangd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
CompileFlags:
2+
Remove:
3+
- -mno-direct-extern-access
24
Add:
35
- -Wno-builtin-declaration-mismatch
46
- -Wno-incompatible-library-redeclaration

CMakeLists.txt

Lines changed: 17 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -10,119 +10,27 @@ message("Including Requested CMake Dependencies OK")
1010
# cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain.cmake -S . -B out/build
1111
# cmake -DUSE_TOOLCHAIN=windows/llvm -S . -B out/build
1212
include(cmake/check_toolchain.cmake)
13-
project(CFDesktop VERSION 0.11.0 LANGUAGES CXX C)
1413

15-
# ------ Build Type Configuration ------
16-
# Validate and set build type
17-
if(NOT CMAKE_BUILD_TYPE)
18-
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (Debug Release RelWithDebInfo)" FORCE)
19-
message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to: ${CMAKE_BUILD_TYPE}")
20-
endif()
21-
22-
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo")
23-
24-
# Set compiler flags for each build type (use CACHE FORCE to override CMake defaults)
25-
# Debug: No optimization (-O0), full debug info (-g)
26-
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -D_CFDESKTOPDEBUG" CACHE STRING "Flags used by the C++ compiler during Debug builds" FORCE)
27-
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "" CACHE STRING "Linker flags used during Debug builds" FORCE)
28-
# For Static Library Relocatable
29-
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
30-
# Release: Maximum optimization (-O3), no debug info
31-
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "Flags used by the C++ compiler during Release builds" FORCE)
32-
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" CACHE STRING "Linker flags used during Release builds" FORCE)
33-
34-
# RelWithDebInfo: Optimization (-O2) + full debug info
35-
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "Flags used by the C++ compiler during RelWithDebInfo builds" FORCE)
36-
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "" CACHE STRING "Linker flags used during RelWithDebInfo builds" FORCE)
37-
38-
string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type_upper)
39-
40-
# Log build type and compiler flags (use variable indirection for nested expansion)
41-
set(_cxx_flags_var "CMAKE_CXX_FLAGS_${_build_type_upper}")
42-
set(_link_flags_var "CMAKE_EXE_LINKER_FLAGS_${_build_type_upper}")
43-
44-
log_info("BuildSettings" "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
45-
log_info("BuildSettings" "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
46-
log_info("BuildSettings" "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}: ${${_cxx_flags_var}}")
47-
log_info("BuildSettings" "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
48-
log_info("BuildSettings" "CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE}: ${${_link_flags_var}}")
49-
50-
# ------ Build Settings ------
51-
# Set output directories for all targets to ensure DLLs and executables are together
52-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
53-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
54-
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
55-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
56-
# Disable response files in compile_commands.json for better clangd compatibility
57-
set(CMAKE_CXX_RESPONSE_FILE_FLAG "@")
58-
set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@")
59-
set(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 0)
60-
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 0)
61-
set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES 0)
62-
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 0)
63-
set(CMAKE_CXX_STANDARD 23)
64-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
65-
set(CMAKE_AUTOMOC ON)
66-
set(CMAKE_AUTORCC ON)
67-
set(CMAKE_AUTOUIC ON)
68-
69-
# ------ Build Settings ------
70-
71-
log_info("BuildSettings" "CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD}")
72-
log_info("BuildSettings" "CMAKE_CXX_STANDARD_REQUIRED: ${CMAKE_CXX_STANDARD_REQUIRED}")
73-
log_info("BuildSettings" "CMAKE_AUTOMOC: ${CMAKE_AUTOMOC}")
74-
log_info("BuildSettings" "CMAKE_AUTORCC: ${CMAKE_AUTORCC}")
75-
log_info("BuildSettings" "CMAKE_AUTOUIC: ${CMAKE_AUTOUIC}")
76-
log_info("BuildSettings" "CMAKE_EXPORT_COMPILE_COMMANDS: ${CMAKE_EXPORT_COMPILE_COMMANDS}")
77-
78-
# find Qt6, As Requested
79-
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Network)
80-
log_info("Post Qt Setups" "Run Post Qt Dependencies check")
81-
include(cmake/custom_target_helper.cmake)
82-
log_info("Post Qt Setups" "Run Post Qt Dependencies OK")
14+
project(CFDesktop
15+
VERSION 0.11.0
16+
DESCRIPTION "CFDesktop: Given Your Device Portable Desktop Anywhere"
17+
HOMEPAGE_URL "https://github.com/Awesome-Embedded-Learning-Studio/CFDesktop"
18+
LANGUAGES CXX C
19+
)
8320

8421
# ============================================================
85-
# Output Directory Configuration
22+
# Pre-configure Checks and Setup
8623
# ============================================================
87-
# 配置分类输出目录:bin/, examples/, plugins/, runtimes/
88-
log_info("OutputConfig" "Configuring output directories")
89-
include(cmake/OutputDirectoryConfig.cmake)
24+
include(cmake/check_pre_configure.cmake)
9025

9126
# ============================================================
92-
# Example Launcher Generator (Windows)
27+
# Generate Meta Information Headers
9328
# ============================================================
94-
# 为每个 example 生成 Windows 启动脚本
95-
if(WIN32)
96-
log_info("Launcher" "Including Windows launcher generator")
97-
include(cmake/ExampleLauncher.cmake)
98-
endif()
29+
include(cmake/generate_meta_info.cmake)
9930

100-
# ============================================================
101-
# Qt Shared Deployment (Windows)
102-
# ============================================================
103-
# 共享 Qt DLLs 部署到 runtimes/ 目录
104-
if(WIN32)
105-
log_info("QtDeploy" "Including shared Qt deployment utilities")
106-
include(cmake/QtDeployUtils.cmake)
107-
endif()
10831

109-
# Include development helpers generation
110-
include(cmake/generate_develop_helpers.cmake)
111-
112-
# Skip VSCode config generation in CI environment (docker builds)
113-
if(NOT USE_TOOLCHAIN STREQUAL "linux/ci")
114-
log_info("DevHelpers" "Will Generate VSCode clangd configuration")
115-
generate_vscode_clangd()
116-
117-
log_info("DevHelpers" "Will Generate VSCode debug configuration")
118-
generate_vscode_debug_config()
119-
else()
120-
log_info("DevHelpers" "Skipping VSCode config generation in CI mode")
121-
endif()
122-
123-
# Print build configuration
124-
log_config_summary()
125-
log_qt_dir()
32+
# Generate meta info headers after Qt6 is found
33+
cf_generate_meta_info()
12634

12735
# Log base module start
12836
log_module_start("base")
@@ -167,4 +75,9 @@ if(WIN32)
16775
cf_setup_shared_qt_deployment()
16876
endif()
16977

78+
# ============================================================
79+
# Final Configuration Summary
80+
# ============================================================
81+
log_build_summary_table()
82+
17083
log_info("Final" "Configuration Ends! You can try to build now!")
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/**
2+
* @file plain_factory.hpp
3+
* @author Charliechen114514 (chengh1922@mails.jlu.edu.cn)
4+
* @brief Provides plain pointer factory templates for cross-ABI compatibility.
5+
*
6+
* Defines factory templates that create objects using raw pointers. Useful for
7+
* scenarios requiring ABI stability across compilation boundaries.
8+
*
9+
* @version 0.1
10+
* @date 2026-03-27
11+
* @copyright Copyright (c) 2026
12+
* @ingroup none
13+
*/
14+
#pragma once
15+
#include "base/singleton/simple_singleton.hpp"
16+
#include <utility>
17+
namespace cf {
18+
19+
/**
20+
* @brief Factory that creates objects as raw pointers.
21+
*
22+
* Provides a virtual interface for constructing objects with raw pointers.
23+
* Intended for cross-ABI scenarios where smart pointers may not be suitable.
24+
*
25+
* @tparam Result Type of object to create. Must be constructible from Args.
26+
* @tparam Args Argument types forwarded to Result constructor.
27+
*
28+
* @note None
29+
* @warning None
30+
* @since N/A
31+
* @ingroup none
32+
*
33+
* @code
34+
* PlainFactory<MyClass, int, double> factory;
35+
* MyClass* obj = factory.make(42, 3.14);
36+
* @endcode
37+
*/
38+
template <typename Result, typename... Args> struct PlainFactory {
39+
/**
40+
* @brief Destroys the factory instance.
41+
*
42+
* @throws None
43+
* @note None
44+
* @warning None
45+
* @since N/A
46+
* @ingroup none
47+
*/
48+
virtual ~PlainFactory() = default;
49+
50+
/**
51+
* @brief Creates a new Result object using raw pointer.
52+
*
53+
* Constructs a Result instance by forwarding arguments to its constructor.
54+
* Caller owns the returned pointer and is responsible for deletion.
55+
*
56+
* @param[in] args Arguments forwarded to Result constructor.
57+
*
58+
* @return Pointer to newly created Result object. Caller owns.
59+
*
60+
* @throws None
61+
* @note Caller must delete the returned pointer to avoid memory leak.
62+
* @warning Raw pointer ownership; consider smart pointers for new code.
63+
* @since N/A
64+
* @ingroup none
65+
*/
66+
Result* make(Args&&... args) { return new Result(std::forward<Args>(args)...); }
67+
};
68+
69+
/**
70+
* @brief Singleton variant of PlainFactory for static access.
71+
*
72+
* Combines PlainFactory with SimpleSingleton to provide a globally
73+
* accessible factory instance using raw pointers.
74+
*
75+
* @tparam Result Type of object to create. Must be constructible from Args.
76+
* @tparam Args Argument types forwarded to Result constructor.
77+
*
78+
* @note None
79+
* @warning None
80+
* @since N/A
81+
* @ingroup none
82+
*
83+
* @code
84+
* auto& factory = StaticPlainFactory<MyClass, int>::instance();
85+
* MyClass* obj = factory.make(42);
86+
* @endcode
87+
*/
88+
template <typename Result, typename... Args> struct StaticPlainFactory
89+
: public PlainFactory<Result, Args...>,
90+
public SimpleSingleton<StaticPlainFactory<Result, Args...>> {};
91+
92+
} // namespace cf
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/**
2+
* @file smartptr_plain_factory.hpp
3+
* @author Charliechen114514 (chengh1922@mails.jlu.edu.cn)
4+
* @brief Provides smart pointer factory templates for automatic lifetime
5+
* management.
6+
*
7+
* Defines factory templates that create objects using std::unique_ptr and
8+
* std::shared_ptr. Eliminates the need for manual memory management.
9+
*
10+
* @version 0.1
11+
* @date 2026-03-27
12+
* @copyright Copyright (c) 2026
13+
* @ingroup none
14+
*/
15+
#pragma once
16+
17+
#include "base/singleton/simple_singleton.hpp"
18+
#include <memory>
19+
namespace cf {
20+
21+
/**
22+
* @brief Factory that creates objects using smart pointers.
23+
*
24+
* Provides methods for constructing objects with automatic lifetime
25+
* management via std::unique_ptr and std::shared_ptr.
26+
*
27+
* @tparam Result Type of object to create. Must be constructible from Args.
28+
* @tparam Args Argument types forwarded to Result constructor.
29+
*
30+
* @note None
31+
* @warning None
32+
* @since N/A
33+
* @ingroup none
34+
*
35+
* @code
36+
* SmartPtrPlainFactory<MyClass, int> factory;
37+
* auto unique = factory.make_unique(42);
38+
* auto shared = factory.make_shared(42);
39+
* @endcode
40+
*/
41+
template <typename Result, typename... Args> struct SmartPtrPlainFactory {
42+
public:
43+
/**
44+
* @brief Default constructs the factory.
45+
*
46+
* @throws None
47+
* @note None
48+
* @warning None
49+
* @since N/A
50+
* @ingroup none
51+
*/
52+
SmartPtrPlainFactory() = default;
53+
54+
/**
55+
* @brief Destroys the factory instance.
56+
*
57+
* @throws None
58+
* @note None
59+
* @warning None
60+
* @since N/A
61+
* @ingroup none
62+
*/
63+
virtual ~SmartPtrPlainFactory() = default;
64+
65+
/**
66+
* @brief Creates a new Result object as std::unique_ptr.
67+
*
68+
* Constructs a Result instance with unique ownership by forwarding
69+
* arguments to its constructor.
70+
*
71+
* @param[in] args Arguments forwarded to Result constructor.
72+
*
73+
* @return std::unique_ptr<Result> owning the newly created object.
74+
*
75+
* @throws None
76+
* @note None
77+
* @warning None
78+
* @since N/A
79+
* @ingroup none
80+
*/
81+
std::unique_ptr<Result> make_unique(Args&&... args) {
82+
return std::make_unique<Result>(std::forward<Args>(args)...);
83+
}
84+
85+
/**
86+
* @brief Creates a new Result object as std::shared_ptr.
87+
*
88+
* Constructs a Result instance with shared ownership by forwarding
89+
* arguments to its constructor.
90+
*
91+
* @param[in] args Arguments forwarded to Result constructor.
92+
*
93+
* @return std::shared_ptr<Result> sharing ownership of the new object.
94+
*
95+
* @throws None
96+
* @note None
97+
* @warning None
98+
* @since N/A
99+
* @ingroup none
100+
*/
101+
std::shared_ptr<Result> make_shared(Args&&... args) {
102+
return std::make_shared<Result>(std::forward<Args>(args)...);
103+
}
104+
};
105+
106+
/**
107+
* @brief Singleton variant of SmartPtrPlainFactory for static access.
108+
*
109+
* Combines SmartPtrPlainFactory with SimpleSingleton to provide a
110+
* globally accessible factory instance using smart pointers.
111+
*
112+
* @tparam Result Type of object to create. Must be constructible from Args.
113+
* @tparam Args Argument types forwarded to Result constructor.
114+
*
115+
* @note None
116+
* @warning None
117+
* @since N/A
118+
* @ingroup none
119+
*
120+
* @code
121+
* auto& factory = StaticSmartPtrPlainFactory<MyClass, int>::instance();
122+
* auto obj = factory.make_unique(42);
123+
* @endcode
124+
*/
125+
template <typename Result, typename... Args> struct StaticSmartPtrPlainFactory
126+
: public SmartPtrPlainFactory<Result, Args...>,
127+
public SimpleSingleton<StaticSmartPtrPlainFactory<Result, Args...>> {};
128+
129+
} // namespace cf

base/include/base/macro/system_judge.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
# define CFDESKTOP_OS_LINUX
2626
#endif
2727

28+
// WSL Specific (set by CMake when WSL is detected)
29+
#ifdef CFDESKTOP_OS_WSL
30+
# define CFDESKTOP_OS_WSL_ENABLED
31+
#endif
32+
2833
/* ==================== Architecture Detection ==================== */
2934

3035
// x86_64 (AMD64) detection

0 commit comments

Comments
 (0)