Skip to content

Commit 6d3adc5

Browse files
committed
update platform macro
1 parent fae6d4b commit 6d3adc5

22 files changed

+58
-54
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11

2+
## [2025.04.08] - v1.1.3.0
3+
### [Optimize] update platform macro
4+
25
## [2025.04.08] - v1.1.2.0
36
### [Windows] optimize binary output
47

app/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set(PROJ_ROOT ${CMAKE_CURRENT_LIST_DIR})
88

99
if(WIN)
1010
# set(CMAKE_INSTALL_PREFIX "${PROJ_ROOT}")
11-
# set(EXECUTABLE_OUTPUT_PATH "${PROJ_ROOT}")
11+
set(EXECUTABLE_OUTPUT_PATH "${PROJ_ROOT}")
1212
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJ_ROOT}")
1313
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${PROJ_ROOT}/bin64")
1414
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${PROJ_ROOT}/bin64")
@@ -32,7 +32,7 @@ message("CMAKE_TOOLCHAIN_ROOT = ${CMAKE_TOOLCHAIN_ROOT} ")
3232
message("include(${CMAKE_TOOLCHAIN_ROOT}/cmake-core/global.cmake) ")
3333

3434

35-
project(${PROJECT_NAME} VERSION 1.1.2.0)
35+
project(${PROJECT_NAME} VERSION 1.1.3.0)
3636
# set(CMAKE_DEBUG_POSTFIX d)
3737
set(LIB_TYPE SHARED) # SHARED STATIC
3838
# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
@@ -54,15 +54,15 @@ if(WIN)
5454
set(WIN32 ON)
5555
set(OS_TYPE "win")
5656
set(OS_BUNDLE WIN32)
57-
add_definitions(-DWIN)
57+
add_definitions(-DWIN=1)
5858

5959
include(${CMAKE_TOOLCHAIN_ROOT}/cmake-win/win_func.cmake)
6060
WIN_ADD_META(META_FILES) # Add Resource To Project - eg. AppIcon.ico
6161
APP_ADD_RES("${CMAKE_TOOLCHAIN_ROOT}/cmake-win/res/*.*" "data/Resource")
6262

6363
elseif(LINUX)
6464
set(OS_TYPE "linux")
65-
add_definitions(-DLINUX)
65+
add_definitions(-DLINUX=1)
6666

6767
if("${LINUX_OS}" STREQUAL "CentOS")
6868
set(CMAKE_PREFIX_PATH "/usr/lib64/cmake/Qt5")
@@ -85,7 +85,7 @@ elseif(OSX)
8585
set(XCODE_DEVELOPMENT_TEAM "")
8686
set(XCODE_CODE_SIGN_IDENTITY "")
8787
set(XCODE_PROVISIONING_PROFILE "")
88-
add_definitions(-DOSX )
88+
add_definitions(-DOSX=1)
8989

9090
# set OSX Libs
9191
set(LIB_FMWKs)
@@ -104,7 +104,7 @@ elseif(IOS)
104104
set(XCODE_DEVELOPMENT_TEAM "XXXXXXXXXX")
105105
set(XCODE_CODE_SIGN_IDENTITY "Apple Development")
106106
set(XCODE_PROVISIONING_PROFILE "")
107-
add_definitions(-DIOS )
107+
add_definitions(-DIOS=1)
108108

109109
# set iOS Libs
110110
set(LIB_FMWKs)
@@ -116,7 +116,7 @@ elseif(IOS)
116116

117117
elseif(ANDROID)
118118
set(OS_TYPE "linux")
119-
add_definitions(-DANDROID )
119+
add_definitions(-DANDROID=1)
120120

121121
endif()
122122

app/pkg-win-nsis.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ start /wait %QT_HOME%\bin\windeployqt.exe -qmldir %QT_HOME%/qml %BIN_DIR%\%PROJ_
2121

2222
call %SCRIPT_DIR%\vs-env.bat
2323

24-
set VERSION="1.1.2.0"
24+
set VERSION="1.1.3.0"
2525
echo packaging %VERSION% for "x64"
2626
makensis /INPUTCHARSET UTF8 /DPRODUCT_NAME=%PROJ_NAME% /DPRODUCT_VERSION=%VERSION% /DOS_ARCH="x64" %SCRIPT_DIR%/pkg-win-nsis.nsi
2727
echo packaging %VERSION% for "x86"

app/src/app/DevAssistant/AppLoader.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,21 @@ void InitAppConfig(const char *bin_path) {
1919
std::string app_path, app_dir, root_dir;
2020
CE::AppLoader::GetAppPath(bin_path, app_path);
2121
CE::AppLoader::GetAppDirPath(bin_path, app_dir);
22-
#if OSX
23-
CKAppConf::GetInstance()->SetRootDir(app_path + "/Contents");
24-
#elif WIN
22+
#if WIN
2523
CU::String::LastNCharSubStr(app_path, '\\', 2, root_dir);
2624
CKAppConf::GetInstance()->SetRootDir(root_dir);
2725
CKAppConf::GetInstance()->SetRelativePath("app_icon", "data/Resource/AppIcon.ico");
26+
#elif OSX
27+
CKAppConf::GetInstance()->SetRootDir(app_path + "/Contents");
2828
#else // LINUX
29+
CU::String::LastNCharSubStr(app_path, '/', 2, root_dir);
2930
CKAppConf::GetInstance()->SetRootDir(root_dir);
3031
#endif
3132
LOGI("root_dir = %s, app_dir = %s, app_path = %s", root_dir.c_str(), app_dir.c_str(), app_path.c_str());
3233
}
3334

3435
int SetInitStart(const char * bin_path) {
35-
#ifdef WIN
36+
#if WIN
3637
std::string app_bin_abs = std::string(bin_path) + " %1";
3738
std::string app_icon_abs = CKAppConf::GetInstance()->GetRelativePath("app_icon");
3839
LOGI("app_bin_abs = %s", app_bin_abs.c_str());

app/src/app/DevAssistant/QDAMainWindow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <QMessageBox>
88

99
#include <iostream>
10-
#ifdef WIN
10+
#if WIN
1111
#include <windows.h>
1212
#endif // WIN
1313

@@ -104,7 +104,7 @@ void QDAMainWindow::LoadWelcome()
104104

105105
bool QDAMainWindow::nativeEvent(const QByteArray& eventType, void* message, long* result)
106106
{
107-
#ifdef WIN
107+
#if WIN
108108
MSG* msg = (MSG*)message;
109109
if (msg->message == WM_TO_TRAY) {
110110
LOGI("eventType = %s", QString(eventType).toStdString().c_str());

app/src/app/DevAssistant/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ std::string GetBinRelativePath(const std::string& bin_path) {
3838
}
3939

4040
auto bin_path_tmp = bin_path;
41-
#ifdef WIN
41+
#if WIN
4242
std::replace(bin_path_tmp.begin(), bin_path_tmp.end(), '\\', '/');
4343
#endif // WIN
4444
auto pos_l = bin_path_tmp.find_last_not_of('/');

app/src/kits/CApp/CAppConf.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bool CKAppConf::SetRootDir(const std::string &root)
2626

2727
std::string CKAppConf::GetRootDir() {
2828
auto ret = root_dir_;
29-
#ifdef WIN
29+
#if WIN
3030
std::replace(ret.begin(), ret.end(), '/', '\\');
3131
#endif // WIN
3232
return ret;
@@ -51,7 +51,7 @@ std::string CKAppConf::GetRelativePath(const std::string& key)
5151

5252
auto ret = root_dir_ + "/" + iter->second;
5353

54-
#ifdef WIN
54+
#if WIN
5555
std::replace(ret.begin(), ret.end(), '/', '\\');
5656
#endif // WIN
5757

app/src/kits/COSEnv/CEAppLoader.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <iostream>
99
#include <algorithm>
1010

11-
#ifdef WIN
11+
#if WIN
1212
# include <windows.h>
1313
#endif
1414

@@ -45,7 +45,7 @@ bool AppLoader::GetAppDirPath(const std::string &bin_path, std::string &output)
4545
}
4646
auto bin_path_tmp = bin_path;
4747
std::string::size_type pos;
48-
#ifdef WIN
48+
#if WIN
4949
std::replace(bin_path_tmp.begin(), bin_path_tmp.end(), '\\', '/');
5050
#elif defined(OSX)
5151
pos = bin_path_tmp.rfind(".app");
@@ -95,7 +95,7 @@ static int RunCmdByPopen(const std::string &cmd_str, std::vector<std::string> &o
9595
// Match priority: full equal > first same prefix > only one > other(failed)
9696
bool AppLoader::GetAppInstallPath(const std::string &app_name, std::string &output)
9797
{
98-
#ifdef WIN
98+
#if WIN
9999
return false;
100100
#else // OSX or Linux
101101
//#if _HAS_CXX17
@@ -170,7 +170,7 @@ bool AppLoader::GetAppInstallPath(const std::string &app_name, std::string &outp
170170

171171
bool AppLoader::RunAsRoot(const std::string& bin_path)
172172
{
173-
#ifdef WIN
173+
#if WIN
174174
HINSTANCE hResult = ShellExecute(NULL, "runas", bin_path.c_str(), NULL, NULL, SW_SHOWNORMAL);
175175
return true;
176176
#else // OSX OR Linux
@@ -180,14 +180,14 @@ bool AppLoader::RunAsRoot(const std::string& bin_path)
180180

181181
bool AppLoader::RunAsOSStart(const std::string& app_key, const std::string& bin_path)
182182
{
183-
#ifdef WIN
183+
#if WIN
184184
std::string regkey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\";
185185
auto tmp_path = bin_path;
186186
std::replace(tmp_path.begin(), tmp_path.end(), '/', '\\');
187187
//CE::Regedit::DelRegValue(regkey + app_key);
188188
return CE::Regedit::SetRegValue(regkey + app_key, tmp_path, "REG_SZ", true);
189189

190-
#elif defined(OSX)
190+
#elif OSX
191191
// plist 关键字:
192192
// Label - 标识符,用来表示该任务的唯一性
193193
// Program - 程序名称,用来说明运行哪个程序、脚本

app/src/kits/COSEnv/CERegedit.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#include <iostream>
66

7-
#ifdef WIN
7+
#if WIN
88
# include <windows.h>
99
#endif
1010

@@ -14,7 +14,7 @@
1414

1515
NS_CE_BEGIN
1616

17-
#ifdef WIN
17+
#if WIN
1818
static HKEY GetRegHKeyRootHandle(const std::string &key)
1919
{
2020
HKEY hkey = HKEY_LOCAL_MACHINE;

app/src/kits/COSEnv/CERightAction.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <iostream>
66
#include <map>
77

8-
#ifdef WIN
8+
#if WIN
99
# include <windows.h>
1010
#endif
1111

@@ -44,7 +44,7 @@ int RightAction::AddAction(const std::string& key, const std::string& action,
4444
return 1;
4545
}
4646

47-
#ifdef WIN
47+
#if WIN
4848
std::string reg_path = GetRegPrefix(mode);
4949
if (reg_path.empty()) {
5050
LOGE("Invalid Mode ! mode = %d", (int)mode);
@@ -82,12 +82,12 @@ int RightAction::DelAction(const std::string& key, RightAction::Mode mode, const
8282
return 1;
8383
}
8484

85-
#ifdef WIN
85+
#if WIN
8686
std::string reg_path = GetRegPrefix(mode);
8787
if (reg_path.empty()) {
8888
LOGE("Invalid Mode ! mode = %d", (int)mode);
8989
return 2;
90-
}
90+
}
9191

9292
if (mode == CE::RightAction::Mode::FIX_SUFFIX) {
9393
reg_path.append(suffix + "\\shell\\" + key + "\\");

app/src/kits/COSEnv/CESystemEnv.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616

1717
#define LOG_TAG "TAG_COSEnv"
1818

19-
#ifdef WIN
19+
#if WIN
2020
# include <windows.h>
2121
#endif // WIN
2222

2323
NS_CE_BEGIN
2424

25-
#ifdef WIN
25+
#if WIN
2626
const std::string OS_NAME = "Windows";
2727
const std::string ENV_PATH_SPLIT = ";";
2828
#elif defined(MAC) || defined(OSX)
@@ -36,7 +36,7 @@ const std::string ENV_PATH_SPLIT = ":";
3636
/// @param name upper-case is required!
3737
std::string SystemEnv::GetEnv(const char* name)
3838
{
39-
#ifdef WIN
39+
#if WIN
4040
// https://www.orcode.com/question/1012464_k5c59b.html
4141
const DWORD buf_size = 4096;
4242
LPTSTR lp_buf = new TCHAR[buf_size];
@@ -149,7 +149,7 @@ bool SystemEnv::SetEnv(const std::string& key, const std::string& value)
149149
// Key-Value Not Exist, add or update
150150
std::string old_val = GetEnv(key.c_str());
151151
const std::string new_val = old_val.empty() ? value : old_val.append(";").append(value);
152-
#ifdef WIN
152+
#if WIN
153153
std::string cmd = "SETX " + key + " " + "\"" + new_val;
154154
int ret = system(cmd.c_str());
155155
if (ret != 0) {

app/src/kits/COSEnv/CETrayIcon.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
#include <iostream>
66

7-
#ifdef WIN
7+
#if WIN
88
# include <windows.h>
99
#endif
1010

1111
NS_CE_BEGIN
1212

1313
void TrayIcon::SetIcon(int winid, const std::string& icon_name, const std::string& tips, unsigned long mode)
1414
{
15-
#ifdef WIN
15+
#if WIN
1616
NOTIFYICONDATA tray_icon;
1717
HWND hwnd = HWND(winid);
1818
CreateSemaphore(NULL, 1, 1, tips.c_str());
@@ -60,7 +60,7 @@ void TrayIcon::SetIcon(int winid, const std::string& icon_name, const std::strin
6060

6161
void TrayIcon::ShowWindow(int winid, bool show)
6262
{
63-
#ifdef WIN
63+
#if WIN
6464
ShowWindow(HWND(winid), show ? SW_SHOWNORMAL : SW_HIDE);
6565
#else
6666

@@ -69,7 +69,7 @@ void TrayIcon::ShowWindow(int winid, bool show)
6969

7070
void TrayIcon::DelIcon(int winid)
7171
{
72-
#ifdef WIN
72+
#if WIN
7373
NOTIFYICONDATA tray_icon;
7474
HWND hwnd = HWND(winid);
7575
memset(&tray_icon, 0, sizeof(NOTIFYICONDATA));

app/src/kits/CUtils/def_build.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869)
22

3-
#ifdef WIN
3+
#if WIN
44
// 无警告编号
55
#pragma warning(disable: 4619)
66

app/src/kits/CUtils/def_macro.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869)
22

3-
#ifdef WIN
3+
#if WIN
44
# define API_EXPORT _declspec(dllexport)
55
# define API_IMPORT _declspec(dllimport)
66
#else // Linux
@@ -15,7 +15,7 @@
1515
#define RET_OK 0
1616
#define RET_ERROR 1
1717

18-
//#ifdef WIN
18+
//#if WIN
1919
//const char* PATH_SPLIT_TAG = "\\";
2020
//#else // Linux
2121
//const char* PATH_SPLIT_TAG = "/";

app/src/kits/CUtils/logger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <filesystem> // C++17
1313
#endif
1414

15-
#ifdef WIN
15+
#if WIN
1616
#include <direct.h>
1717
#endif // WIN
1818

app/src/kits/CUtils/path_util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace utils::path {
1010

1111
std::string absolute_path(const std::string &relative_path) {
1212
std::filesystem::path tmp_path = relative_path;
13-
#ifdef WIN
13+
#if WIN
1414
char abs_path[MAX_PATH] = {0};
1515
_fullpath(abs_path, relative_path.c_str(), MAX_PATH);
1616
return abs_path;

app/src/kits/CUtils/unused/log.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
#include <sys/timeb.h>
1111
#include <time.h>
1212

13-
#ifdef WIN
13+
#if WIN
1414
#include <direct.h>
1515
#endif // WIN
1616

1717
static std::ofstream g_log;
1818
static bool g_log_open = false;
1919

2020
static void log_open() {
21-
#ifdef WIN
21+
#if WIN
2222
_mkdir("logs");
2323
#else
2424
// TDDO :: Linux mkdir

app/src/qtmodules/QtEnvKit/DABuildScript.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <COSEnv/CERegedit.h>
88
#include <COSEnv/CESystemEnv.h>
99

10-
#ifdef WIN
10+
#if WIN
1111
# include <windows.h>
1212
#endif
1313

0 commit comments

Comments
 (0)