Skip to content

Commit 527cc5f

Browse files
committed
app: fix scripts issue and add notes
1 parent c11567f commit 527cc5f

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

app/src/kits/COSEnv/CEAppLoader.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// MIT License
1+
// MIT License
22
//
33
// Copyright (c) 2021~2024 [coder4869](https://github.com/coder4869)
44
//
@@ -208,6 +208,14 @@ bool AppLoader::RunAsOSStart(const std::string& app_key, const std::string& bin_
208208
return CE::Regedit::SetRegValue(regkey + app_key, tmp_path, "REG_SZ", true);
209209

210210
#elif defined(OSX)
211+
// TODO:: fix run as root issue
212+
return true;
213+
// plist 关键字:
214+
// Label - 标识符,用来表示该任务的唯一性
215+
// Program - 程序名称,用来说明运行哪个程序、脚本
216+
// ProgramArguments - 数组程序名,同上,只是可以运行多个程序
217+
// WatchPaths - 监控路径,当路径文件有变化是运行程序,也是数组
218+
// RunAtLoad - 是否在加载的同时
211219
std::string start_plist = R"(
212220
<?xml version="1.0" encoding="UTF-8"?>
213221
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@@ -230,6 +238,19 @@ bool AppLoader::RunAsOSStart(const std::string& app_key, const std::string& bin_
230238
start_plist.replace(start_plist.find("bundle—id"), strlen("bundle—id"), bundle_id);
231239

232240
// gen plist_path
241+
// https://zhuanlan.zhihu.com/p/25049770
242+
// https://www.cnblogs.com/gaocy/p/12567156.html
243+
// /System/Library/LaunchDaemons/ (System-wide daemons provided by OS X)
244+
// 比如:apache 的 httpd 程序启动配置文件 org.apache.httpd.plist
245+
// /System/Library/LaunchAgents/ (Mac OS X 为用户定义的任务项)
246+
// /Library/LaunchDaemons (管理员定义的守护进程任务项)
247+
// /Library/LaunchAgents (管理员为用户定义的任务项,开机启动项)
248+
// ~/Library/LaunchAgents(用户自己定义的任务项,用户登录项)
249+
// 区别:
250+
// /System/Library 目录下存放的是系统文件
251+
// /Library 、~/Library/ 目录是用户存放的第三方软件
252+
// LaunchDaemons 是用户未登陆前就启动的服务
253+
// LaunchAgents 是用户登陆后启动的服务
233254
auto agents_path = utils::path::absolute_path("~/Library/LaunchAgents/");
234255
auto plist_path = agents_path.append("/" + bundle_id + ".plist");
235256

app/src/kits/COSEnv/CESystemEnv.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <iostream>
2626
#include <fstream>
2727
#include <stdlib.h>
28+
#include <sys/types.h>
29+
#include <unistd.h>
2830

2931
#include <CUtils/logger.h>
3032
#include <CUtils/CUString.h>
@@ -85,9 +87,13 @@ std::string SystemEnv::GetEnv(const char* name)
8587
}
8688
return std::string(lp_buf, var_size);
8789
#else
90+
char* uname = getlogin();
91+
uid_t uid = geteuid();
92+
8893
const char* val = std::getenv(name);
8994
std::string env_var(val == NULL ? "" : std::string(val));
90-
LOGI("name = %s, env_var = %s", name, env_var.c_str());
95+
LOGI("current user = %s, uid = %d, env_name = %s, env_var = %s",
96+
uname, uid, name, env_var.c_str());
9197
return env_var;
9298
#endif
9399
}

plugins/project/module/template/cmake/bin-deps-qt.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ target_link_libraries(${BIN_NAME} PUBLIC ${LIB_FMWKs} ${LIB_DEPS}
101101
# APP_ADD_RES("${PROJ_ROOT}/conf/project.json" "conf/")
102102
APP_ADD_RES_RECURSE("${CONF_DIR}/" "conf/" "${CONF_DIR}/*")
103103
APP_ADD_RES_RECURSE("${DATA_DIR}/" "data/" "${DATA_DIR}/*")
104-
APP_ADD_RES_RECURSE("${PLUGIN_DIR}/" "data/plugins/" "${PLUGIN_DIR}/*")
104+
# APP_ADD_RES_RECURSE("${PLUGIN_DIR}/" "data/plugins/" "${PLUGIN_DIR}/*")
105105
APP_ADD_RES_RECURSE("${TOOL_DIR}/" "tools/" "${TOOL_DIR}/*")
106106

107107
if(WITH_QT)

plugins/project/module/template/cmake/bin-deps.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ target_link_libraries(${BIN_NAME} PUBLIC ${LIB_FMWKs} ${LIB_DEPS}
7272
# APP_ADD_RES("${PROJ_ROOT}/conf/project.json" "conf/")
7373
APP_ADD_RES_RECURSE("${CONF_DIR}/" "conf/" "${CONF_DIR}/*")
7474
APP_ADD_RES_RECURSE("${DATA_DIR}/" "data/" "${DATA_DIR}/*")
75-
APP_ADD_RES_RECURSE("${PLUGIN_DIR}/" "data/plugins/" "${PLUGIN_DIR}/*")
75+
# APP_ADD_RES_RECURSE("${PLUGIN_DIR}/" "data/plugins/" "${PLUGIN_DIR}/*")
7676
APP_ADD_RES_RECURSE("${TOOL_DIR}/" "tools/" "${TOOL_DIR}/*")
7777

7878
if(WITH_PY)

plugins/project/project/project.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
from module import module
3333

3434
PROJECT_BUILD_DIR = PROJECT_BASE_DIR + "/build"
35-
PROJECT_BUILD_LNK_DIR = PROJECT_BASE_DIR + "/build_lnk"
3635
PROJECT_CMAKE_DIR = PROJECT_BASE_DIR + "/cmake"
3736
MODULE_TEMPLATE_DIR = PROJECT_BASE_DIR + "/template"
3837

0 commit comments

Comments
 (0)