Browse Source

Z991239-342 #comment 应该所有模块在Linux下能编译得过,能够通过 spshell 启动 sphost

gifur 5 năm trước cách đây
mục cha
commit
c86a44c3ec

+ 14 - 6
CMakeLists.txt

@@ -32,6 +32,8 @@ set(CMAKE_CXX_STANDARD 11)
 option(BUILD_TESTING "Build the project test case." OFF)
 option(INSTALL_INCLUDE_FILES "Enable installation of include header file or third_party" ON)
 
+set(SIMULATE_DEV_AND_TEST_TEMP ON)
+
 # 
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/addin/cmake/ )
 include(CheckStructHasMember)
@@ -82,24 +84,30 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
 
+if(MSVC)
+set(LIB_PREFIX "")
+set(LIB_SUFFIX ".dll")
+set(ROOT_INI_NAME "root.ini.win32")
+else()
+set(LIB_PREFIX "lib")
+set(LIB_SUFFIX ".so")
+set(ROOT_INI_NAME "root.ini.unix")
+endif(MSVC)
 
+if(SIMULATE_DEV_AND_TEST_TEMP)
 # simulate the real executive path environment, for debug easily.
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/run/version/1.2.3.4/bin")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 file(MAKE_DIRECTORY  ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 file(MAKE_DIRECTORY  "${CMAKE_BINARY_DIR}/run/hardwarecfg")
 file(MAKE_DIRECTORY  "${CMAKE_BINARY_DIR}/run/version/1.2.3.4/cfg")
 file(MAKE_DIRECTORY  "${CMAKE_BINARY_DIR}/run/version/1.2.3.4/mod")
-if(MSVC)
-	set(ROOT_INI_NAME "root.ini.win32")
-else()
-	set(ROOT_INI_NAME "root.ini.unix")
-endif(MSVC)
 file(COPY "${CMAKE_SOURCE_DIR}/addin/hardwarecfg/${ROOT_INI_NAME}" DESTINATION "${CMAKE_BINARY_DIR}/run/hardwarecfg")
 file(RENAME "${CMAKE_BINARY_DIR}/run/hardwarecfg/${ROOT_INI_NAME}" "${CMAKE_BINARY_DIR}/run/hardwarecfg/root.ini")
 file(GLOB SIMU_CONFIG_FILE "${CMAKE_SOURCE_DIR}/addin/cfg/*.ini")
 file(COPY ${SIMU_CONFIG_FILE} DESTINATION "${CMAKE_BINARY_DIR}/run/version/1.2.3.4/cfg")
 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/addin/cfg/shell.ini.in" "${CMAKE_BINARY_DIR}/run/version/1.2.3.4/cfg/shell.ini" @ONLY)
-#end simulate
+endif(SIMULATE_DEV_AND_TEST_TEMP)#end simulate
 
 if(BUILD_TESTING)
 	include(CTest)

+ 1 - 0
Common/AutoArray.h

@@ -1,6 +1,7 @@
 #pragma once
 
 #ifndef _WIN32
+#include <assert.h>
 #define _ASSERT assert
 #include <winpr/interlocked.h>
 #else

+ 1 - 1
Common/SpBase.h

@@ -39,7 +39,7 @@
 #ifdef _WIN32
 #include<wtypes.h>
 #else
-#include <winpr/wtypes.h>
+#include <winpr/library.h>
 #include <winpr/synch.h>
 #endif // _WIN32
 

+ 3 - 3
Common/SpSecureClient.h

@@ -20,11 +20,11 @@ struct ENTITY_CONNECT_INFO;
 
 enum RvcCommStateEnum : DWORD
 {
-	CS_Stop = 0,		// 停止状态
-	CS_Connectting,	// 连接中
+	CS_Stop = 0,		    // 停止状态
+	CS_Connectting,	    // 连接中
 	CS_Fail,					// 连接失败
 	CS_Connected,		// 连接建立
-	CS_Break,				// 异常中断
+	CS_Break,				    // 异常中断
 };
 
 class SPBASE_API SpSecureClient : public CSecureClientBase

+ 1 - 1
RVCComm/CMakeLists.txt

@@ -45,7 +45,7 @@ target_compile_definitions(${MODULE_NAME} PRIVATE "-DRVCCOMM_EXPORTS=1")
 
 if (BUILD_TESTING)
 	add_library(${MODULE_NAME}_a STATIC ${${MODULE_PREFIX}_SRCS})
-	target_link_libraries(${MODULE_NAME}_a ssl)
+	target_link_libraries(${MODULE_NAME}_a ssl winpr)
 	target_compile_definitions(${MODULE_NAME}_a PRIVATE "-DRVCCOMM_LINKED_AS_STATIC_LIBRARY")
 	add_subdirectory(test)
 endif()

+ 2 - 2
addin/cfg/shell.ini.in

@@ -4,8 +4,8 @@ SoftwareVersion=@RVC_FRAMEWORK_VERSION@
 [Entity]
 
 ;ÆäËû
-HelloClient=0,mod_helloclient.dll,0x901
-HelloService=0,mod_helloservice.dll,0x902
+HelloClient=0,@LIB_PREFIX@mod_helloclient@LIB_SUFFIX@,0x901
+HelloService=0,@LIB_PREFIX@mod_helloservice@LIB_SUFFIX@,0x902
 
 [Startup]
 Number=2

+ 4 - 2
libtoolkit/fileutil.c

@@ -17,6 +17,8 @@
 #include "fileutil.h"
 #include "strutil.h"
 
+#include <winpr/wlog.h>
+#define TAG TOOLKIT_TAG("fileutil")
 
 TOOLKIT_API BOOL CreateDirA(LPCSTR lpDirPath, BOOL bRecursive)
 {
@@ -689,11 +691,11 @@ void _splitpath(const char* path, char* drive, char* dir, char* fname, char* ext
 	}
 	
 	if (realpath(path, resolved_path) == NULL) {
-		fprintf(stderr, "realpath failed: %s\n", strerror(errno));
+		WLog_ERR(TAG, "realpath failed: %s", strerror(errno));
 		strcpy(resolved_path, path);
 	}
 	else {
-		printf("resolved_path: %s\n", resolved_path);
+		WLog_DBG(TAG, "resolved_path: %s", resolved_path);
 	}
 	len = strlen(resolved_path);
 	if (resolved_path[0] == '/') {

+ 1 - 1
libtoolkit/process.c

@@ -95,7 +95,7 @@ TOOLKIT_API int process_spawn(const tk_process_option_t* option, tk_process_t**
 		new_process->handle = pi.hProcess;
 	}
 	else {
-		WLog_ERR(TAG, "create process  failed.");
+		WLog_ERR(TAG, "create process  failed, GetLastError(%d).", GetLastError());
 		FREE(new_process);
 		ret = -1;
 	}

+ 22 - 0
libtoolkit/test/test_process.cpp

@@ -3,6 +3,7 @@
 #include <cstring>
 #include <gtest/gtest.h>
 #include "process_monitor.h"
+#include "toolkit.h"
 #include "list.h"
 #ifndef _WIN32
 #include <winpr/thread.h>
@@ -60,9 +61,30 @@ static int create_process_test(tk_process_t* new_process)
 		std::cerr << "create process failed, error: " << GetLastError() << std::endl;
 		return -1;
 	}
+
 	return 0;
 }
 
+//TEST(TestProcessCreate, CreateProcessTest)
+//{
+//	char path[MAX_PATH];
+//	char app[MAX_PATH] = { '\0' };
+//	char tmp[32];
+//	tk_process_t* process1 = NULL;
+//	tk_process_option_t option;
+//#ifdef _WIN32
+//	sprintf(app, ".\\bin\\sphost.exe 254");
+//#else
+//	sprintf(app, "./bin/sphost  254");
+//#endif //_WIN32
+//	option.exit_cb = NULL;
+//	option.file = NULL;
+//	option.flags = 0;
+//	option.params = app;
+//	EXPECT_TRUE(process_spawn(&option, &process1) == 0);
+//	EXPECT_TRUE(process1 != NULL);
+//}
+
 TEST(TestProcessMonitor, TestProcess)
 {
 	char* pt = NULL;

+ 13 - 10
spbase/sp_cfg.cpp

@@ -26,6 +26,11 @@
 #include <winpr/string.h>
 
 #define MAX_ENTITY_LEN	33
+#ifdef _WIN32
+#define MOD_LIB_SUFFIX ".dll"
+#else
+#define MOD_LIB_SUFFIX ".so"
+#endif //_WIN32
 
 #define T_MALLOC_T(type, shm) \
 	shm ? (type*)shm_malloc(sizeof(type)) : (type*)malloc(sizeof(type))
@@ -579,7 +584,8 @@ static int load_shell_ini(sp_dir_t *dir, sp_cfg_shell_ini_t *shell, sp_cfg_root_
 		mod->company = shm_strdup(shellVerInfo.strCompanyName);
 		mod->name = shm_strdup("SpShell");
 		mod->mem_trace = inifile_read_int(file, "MemTrace", mod->name, 0);
-		mod->idx = shell->arr_module->nelts;
+		mod->idx = shell->arr_module->nelts; //the first mod id is spshell
+		/*increment netls at the same time*/
 		SHM_ARRAY_PUSH(shell->arr_module, sp_cfg_shell_module_t*) = mod;
 		ent = (sp_cfg_shell_entity_t *)shm_malloc(sizeof(sp_cfg_shell_entity_t));
 		memset(ent, 0, sizeof(sp_cfg_shell_entity_t));
@@ -617,20 +623,17 @@ static int load_shell_ini(sp_dir_t *dir, sp_cfg_shell_ini_t *shell, sp_cfg_root_
 			ret = inifile_format_read(file, sectionName, entity->name, "%d,%[^,],%x", &entity->privilege, tmp, &entity->devel_id);
 			if (ret == 3) {
 				sp_cfg_shell_module_t *mod;
-#ifdef _WIN32
-				if (str_has_suffix(tmp, ".dll")) {
-#else
-				if (str_has_suffix(tmp, ".so")) {
-#endif //_WIN32
-				int len = strlen(tmp);
-				tmp[len-4] = 0;
-			}
+				if (str_has_suffix(tmp, MOD_LIB_SUFFIX)) {
+					int len = strlen(tmp);
+					tmp[len-strlen(MOD_LIB_SUFFIX)] = 0;
+				}
 				mod = find_module(shell, tmp);
 				if (!mod) {
 					char sal_tmp[MAX_PATH];
+					int len = (strstr(tmp, "lib") == tmp) ? 3 : 0;
 					mod = (sp_cfg_shell_module_t *)shm_malloc(sizeof(sp_cfg_shell_module_t));
 					memset(mod, 0, sizeof(sp_cfg_shell_module_t));
-					mod->name = shm_strdup(tmp);
+					mod->name = shm_strdup(tmp + len);
 					tmp[strlen(tmp)] = '.';
 					sprintf(sal_tmp, "%s" SPLIT_SLASH_STR "%s", dir->mod_path, tmp);
 				mod->group = curGroup;

+ 17 - 52
spbase/sp_dir.c

@@ -168,68 +168,46 @@ static int __dir_get_path(char *base_dir, int flag, const char *cat_name, char *
 	else if (flag == SP_DIR_RUNINFO_INI)
 	{
 		strcpy(buf, base_dir);
-#ifdef _WIN32
-		strcat(buf, "\\runcfg\\");
-#else
-		strcat(buf, "/runcfg/");
-#endif //_WIN32
+		strcat(buf, SPLIT_SLASH_STR "runcfg" SPLIT_SLASH_STR);
 		strcat(buf, cat_name);
 		strcat(buf, ".ini");
 	}	
 	else if (flag == SP_DIR_RUNINFO_BOOT_LOG) {
 		strcpy(buf, base_dir);
-#ifdef _WIN32
-		strcat(buf, "\\bootrec\\");
-#else
-		strcat(buf, "/bootrec/");
-#endif //_WIN32
+		strcat(buf, SPLIT_SLASH_STR "bootrec" SPLIT_SLASH_STR);
 		strcat(buf, cat_name);
 		strcat(buf, ".log");
 	}else if (flag == SP_DIR_SHELLVAR_INI){
 		strcpy(buf, base_dir);
-#ifdef _WIN32
-		strcat(buf, "\\runcfg\\shellVar.ini");
-#else
-		strcat(buf, "/runcfg/shellVar.ini");
-#endif //_WIN32
+		strcat(buf, SPLIT_SLASH_STR "runcfg" SPLIT_SLASH_STR "shellVar.ini");
 	}else if (flag == SP_DIR_SHELL_INI) {
 		strcpy(buf, base_dir);
-#ifdef _WIN32
-		strcat(buf, "\\shell.ini");
-#else
-		strcat(buf, "/shell.ini");
-#endif //_WIN32
+		strcat(buf, SPLIT_SLASH_STR "shell.ini");
 	} else if (flag == SP_DIR_MODULE_BIN) {
 		strcpy(buf, base_dir);
 		strcat(buf, SPLIT_SLASH_STR);
+#ifdef _WIN32
 		strcat(buf, cat_name);
 		strcat(buf, ".dll");
-	} else if (flag == SP_DIR_ROOT_INI) {
-		strcpy(buf, base_dir);
-#ifdef _WIN32
-		strcat(buf, "\\root.ini");
 #else
-		strcat(buf, "/root.ini");
+		strcat(buf, "lib");
+		strcat(buf, cat_name);
+		strcat(buf, ".so");
 #endif //_WIN32
+
+	} else if (flag == SP_DIR_ROOT_INI) {
+		strcpy(buf, base_dir);
+		strcat(buf, SPLIT_SLASH_STR "root.ini");
 	} else if (flag == SP_DIR_INSTALL_INI) {
 		strcpy(buf, base_dir);
-#ifdef _WIN32
-		strcat(buf, "\\install.ini");
-#else
-		strcat(buf, "/install.ini");
-#endif //_WIN32
+		strcat(buf, SPLIT_SLASH_STR "install.ini");
 	}
 	else if (flag == SP_DIR_CENTER_SETTING_INI)
 	{
 		// 为了兼容旧版本实体,此处仍返回原有配置名
 		strcpy(buf, base_dir);
-#ifdef _WIN32
-		strcat(buf, "\\CenterSetting.ini");
-#else
-		strcat(buf, "/CenterSetting.ini");
-#endif //_WIN32
+		strcat(buf, SPLIT_SLASH_STR  "CenterSetting.ini");
 	}
-
 	return rc;
 }
 
@@ -399,30 +377,17 @@ int sp_dir_get_path_version(sp_dir_t* dir, int major, int minor, int revision, i
 	} else if (flag == SP_DIR_RUNINFO_INI || flag == SP_DIR_RUNINFO_BOOT_LOG) {
 		base_path = dir->root_runinfo_path;
 	} else if (flag == SP_DIR_SHELL_INI || flag == SP_DIR_ENTITY_INI) {
-#ifdef _WIN32
-		sprintf(tmp, "%s\\%d.%d.%d.%d\\cfg", dir->root_ver_path, major, minor, revision, build);
-#else
-		sprintf(tmp, "%s/%d.%d.%d.%d/cfg", dir->root_ver_path, major, minor, revision, build);
-#endif //_WIN32
+		sprintf(tmp, "%s" SPLIT_SLASH_STR "%d.%d.%d.%d" SPLIT_SLASH_STR "cfg", dir->root_ver_path, major, minor, revision, build);
 		base_path = tmp;
 	} else if (flag == SP_DIR_MODULE_BIN) {
-#ifdef _WIN32
-		sprintf(tmp, "%s\\%d.%d.%d.%d\\mod", dir->root_ver_path, major, minor, revision, build);
-#else
-		sprintf(tmp, "%s/%d.%d.%d.%d/mod", dir->root_ver_path, major, minor, revision, build);
-#endif //_WIN32
+		sprintf(tmp, "%s" SPLIT_SLASH_STR "%d.%d.%d.%d" SPLIT_SLASH_STR "mod", dir->root_ver_path, major, minor, revision, build);
 		base_path = tmp;
 	} else if (flag == SP_DIR_INSTALL_INI) {
-#ifdef _WIN32
-		sprintf(tmp, "%s\\%d.%d.%d.%d", dir->root_ver_path, major, minor, revision, build);
-#else
-		sprintf(tmp, "%s/%d.%d.%d.%d", dir->root_ver_path, major, minor, revision, build);
-#endif //_WIN32
+		sprintf(tmp, "%s" SPLIT_SLASH_STR "%d.%d.%d.%d", dir->root_ver_path, major, minor, revision, build);
 		base_path = tmp;
 	} else {
 		return Error_Param;
 	}
-	
 	return __dir_get_path(base_path, flag, cat_name, buf, len, NULL);
 }
 

+ 8 - 0
spbase/sp_iom.c

@@ -373,6 +373,8 @@ static int sp_iom_poll(sp_iom_t *iom, int *timeout)
 int sp_iom_run(sp_iom_t *iom)
 {
 	int timeout = POLL_INTERVAL;
+	
+	sp_dbg_debug("iom stop %d", iom->stop);
 	while (InterlockedExchangeAdd((LONG*)&iom->stop, 0) == 0 || timer_queue_get_count(iom->tm_queue) > 0) {
 		int rc = sp_iom_poll(iom, &timeout);
 		if (rc >= 0) {
@@ -380,6 +382,12 @@ int sp_iom_run(sp_iom_t *iom)
 				timeout = POLL_INTERVAL;
 		} else {
 			sp_dbg_debug("iom poll failed!");
+#ifndef _WIN32
+			/*add true For Debug !!!!!  [3/28/2020 Gifur] */
+			while (true) {
+				Sleep(3000);
+			}
+#endif //NOT _WIN32
 			ExitProcess(-1);
 			return rc;
 		}

+ 1 - 1
spbase/sp_mod.c

@@ -818,7 +818,7 @@ static int create_module_process(const char *mod_name, int epid, int range, int
 #else
 	tk_process_t* process = NULL;
 	tk_process_option_t option;
-	sprintf(app, "./bin/sphost.out %d %s %d", range, mod_name, epid);
+	sprintf(app, "./bin/sphost %d %s %d", range, mod_name, epid);
 	option.exit_cb = NULL;
 	option.file = NULL;
 	option.flags = 0;

+ 4 - 1
spbase/test/SpBaseMiscTest.cpp

@@ -1,7 +1,9 @@
 #include "precompile.h"
-#include "CodeSignVerify.h"
+
 #include <gtest/gtest.h>
 
+#ifdef _WIN32
+#include "CodeSignVerify.h"
 TEST(SpBaseMisc, FileVersionTest)
 {
 	CCodeSignVerify ver;
@@ -9,6 +11,7 @@ TEST(SpBaseMisc, FileVersionTest)
 	EXPECT_TRUE(ver.GetVersionInfo("Spshell.exe", verInfo));
 	EXPECT_TRUE(verInfo.FileVersion.IsValid());
 }
+#endif //_WIN32
 
 #include "sp_dir.h"
 TEST(SpBaseMisc, DirTest)

+ 6 - 0
spbase/test/SpCommTest.cpp

@@ -79,6 +79,9 @@ TEST(SimpleStringTest, CharTypeTest)
 	ASSERT_TRUE(str5.Compare(str7, true) == 0);
 }
 
+#ifdef _WIN32
+
+
 TEST(SimpleStringTest, WideCharTypeTest)
 {
 	CSimpleStringW s1(L"123456 7890");
@@ -163,3 +166,6 @@ TEST(SimpleStringTest, WideCharTransferTest)
 	CSimpleStringW wstr = CSimpleStringA2W(str);
 	ASSERT_TRUE(wstr.Compare(L"testString") == 0);
 }
+
+
+#endif //_WIN32

+ 4 - 4
spbase/test/SpModTest.cpp

@@ -28,9 +28,9 @@ TEST(SpModTest, LoadModuleTest)
 	memset(mod, 0, sizeof(sp_cfg_shell_module_t));
 	sp_version_t ver = { 1, 0, 1, 0 };
 	sp_version_copy(&mod->version, &ver);
-	mod->author = _strdup("tester");
-	mod->company = _strdup("tester");
-	mod->name = _strdup("test_mod_name");
+	mod->author = strdup("tester");
+	mod->company = strdup("tester");
+	mod->name = strdup("test_mod_name");
 	mod->mem_trace = 0;
 	mod->idx = 1;
 	
@@ -38,7 +38,7 @@ TEST(SpModTest, LoadModuleTest)
 	ASSERT_TRUE(ent != NULL);
 	memset(ent, 0, sizeof(sp_cfg_shell_entity_t));
 	ent->mod = mod;
-	ent->name = _strdup("test_entity_name");
+	ent->name = strdup("test_entity_name");
 	ent->idx = 1;
 	ent->privilege = 1;
 	ent->debug_level = 0;

+ 5 - 3
spbase/test/SpRunTaskTest.cpp

@@ -6,8 +6,10 @@
 #include "sp_runTask.h"
 #include <gtest/gtest.h>
 
+#ifdef _WIN32
 TEST(SpRunTask, ControlProcessTest)
 {
-    EXPECT_TRUE(sp_runtask_killprocess() == 0);
-    EXPECT_TRUE(sp_runtask_startprocess() == 0);
-}
+	EXPECT_TRUE(sp_runtask_killprocess() == 0);
+	EXPECT_TRUE(sp_runtask_startprocess() == 0);
+}
+#endif //_WIN32

+ 0 - 0
spbase/test/SpSecureClientTest.cpp → spbase/test/SpSecureClientTest.cxx


+ 1 - 3
spshell/app.cpp

@@ -112,6 +112,7 @@ static int kickoff_startlist()
 	}
 	return Error_Resource;
 }
+
 #include "sp_runTask.h"
 int  RenameLightPacks(const char *pszAdPath)
 {
@@ -313,9 +314,6 @@ int app_init()
 	// 检查轻量更新包是否有.new文件
 	RenameLightPacks(env->cfg->root_ini->ref_addata_path);
 
-	// reg dbg log handler
-	//sp_dbg_reg_handler(log_on_dbg_log_callback);
-
 	rc = sp_var_daemon_create(g_app.svc, &g_app.var_daemon);	// add workitem daemon_on_pkt and daemon_on_sys
 	if (rc != 0) {
 		sp_dbg_error("var daemon create failed!");

+ 12 - 1
test/module/CMakeLists.txt

@@ -1,3 +1,5 @@
+
+#设置实体名称 ${MODULE_NAME},和实体前缀定义 ${MODULE_PREFIX}
 macro(define_moudle _module_name)
 	set(MODULE_NAME "mod_${_module_name}")
 	string(TOUPPER "MOD_${MODULE_NAME}" MODULE_PREFIX)
@@ -6,6 +8,8 @@ endmacro(define_moudle)
 #macro(add_module _module_prefix _module_name)
 #endmacro(add_module)
 
+#对于 Windows 设置实体的版本信息
+#定义共享库输出
 macro(add_module_libraries _module_prefix _module_name)
 	if(WIN32)
 	    set (RC_VERSION_MAJOR ${RVC_VERSION_MAJOR})
@@ -21,9 +25,14 @@ macro(add_module_libraries _module_prefix _module_name)
     endif(WIN32)
     add_library(${_module_name} SHARED ${${_module_prefix}_SRCS})
     # 设置工程输出路径
-    # set_target_properties(${_module_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${RVC_MODULE_LIBRARY_PATH}")
+    if(SIMULATE_DEV_AND_TEST_TEMP)
+        set_target_properties(${_module_name} 
+        PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/run/version/1.2.3.4/mod")
+    endif(SIMULATE_DEV_AND_TEST_TEMP)
 endmacro(add_module_libraries)
 
+# 设置实体的安装拷贝路径
+# 对于 Windows 设置实体项目工程在解决方案的节点
 macro(deploy_module _module_prefix _module_name)
     install(TARGETS ${_module_name} 
     RUNTIME DESTINATION "${RVC_MODULE_PATH}"
@@ -37,7 +46,9 @@ endmacro(deploy_module)
 #set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp)
 #set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} msimg32)
 #target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
+set(MODULE_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 
+# 遍历实体
 file(GLOB module_dirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/*")
 set(module_list "")
 foreach(module_dir ${module_dirs})

+ 7 - 0
test/module/mod_helloclient/CMakeLists.txt

@@ -1,8 +1,15 @@
+# 定义实体名称
 define_moudle("helloclient")
+
 set(${MODULE_PREFIX}_SRCS
 	mod_helloclient.cpp)
 
 add_module_libraries(${MODULE_PREFIX} ${MODULE_NAME})
+target_include_directories(${MODULE_NAME}
+	PRIVATE ${MODULE_BASE_DIR}/mod_helloservice
+)
+
+# 添加实体需要依赖的其他共享库(包括系统库)
 set(${MODULE_PREFIX}_LIBS spbase)
 target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
 

+ 1 - 1
test/module/mod_helloclient/mod_helloclient.cpp

@@ -1,7 +1,7 @@
 #include "stdafx.h"
 #include "SpBase.h"
 
-#include "..\mod_helloservice\HelloService_client_g.h"
+#include "HelloService_client_g.h"
 
 using namespace HelloService;
 

+ 1 - 1
test/module/mod_helloservice/HelloService_def_g.h

@@ -5,7 +5,7 @@
 
 // This code is generated by spgen tool!
 
-#include "spHelper.h"
+#include "SpHelper.h"
 
 namespace HelloService {
 //

+ 1 - 1
test/module/mod_helloservice/HelloService_msg_g.h

@@ -6,7 +6,7 @@
 
 // This code is generated by spgen tool!
 
-#include "spHelper.h"
+#include "SpHelper.h"
 
 namespace HelloService {
 #define eMsg_TestEvent 0

+ 1 - 22
winpr/libwinpr/library/library.c

@@ -107,34 +107,13 @@ BOOL SetDefaultDllDirectories(DWORD DirectoryFlags)
 
 HMODULE LoadLibraryA(LPCSTR lpLibFileName)
 {
-#if defined(_UWP)
-	int status;
-	HMODULE hModule = NULL;
-	WCHAR* filenameW = NULL;
-
-	if (!lpLibFileName)
-		return NULL;
-
-	status = ConvertToUnicode(CP_UTF8, 0, lpLibFileName, -1, &filenameW, 0);
-
-	if (status < 1)
-		return NULL;
-
-	hModule = LoadLibraryW(filenameW);
-	free(filenameW);
-	return hModule;
-#else
 	HMODULE library;
 	library = dlopen(lpLibFileName, RTLD_LOCAL | RTLD_LAZY);
-
-	if (!library)
-	{
+	if (!library) {
 		WLog_ERR(TAG, "%s failed with %s", __FUNCTION__, dlerror());
 		return NULL;
 	}
-
 	return library;
-#endif
 }
 
 HMODULE LoadLibraryW(LPCWSTR lpLibFileName)

+ 20 - 31
winpr/libwinpr/thread/process.c

@@ -61,6 +61,8 @@
 #include <stdarg.h>
 #include <sys/wait.h>
 #include <signal.h>
+#include "../log.h"
+#define TAG WINPR_TAG("process")
 
 #include "thread.h"
 
@@ -100,43 +102,35 @@ static char* FindApplicationPath(char* application)
 
 	if (!application)
 		return NULL;
-
-	if (application[0] == '/')
+	if (application[0] == '/') {
 		return _strdup(application);
-
+	}
+	else if (PathFileExistsA(application)) {
+		return _strdup(application);
+	}
 	nSize = GetEnvironmentVariableA(pathName, NULL, 0);
-
 	if (!nSize)
 		return _strdup(application);
-
 	lpSystemPath = (LPSTR)malloc(nSize);
-
 	if (!lpSystemPath)
 		return NULL;
-
 	if (GetEnvironmentVariableA(pathName, lpSystemPath, nSize) != nSize - 1)
 	{
 		free(lpSystemPath);
 		return NULL;
 	}
-
 	save = NULL;
 	path = strtok_s(lpSystemPath, ":", &save);
-
 	while (path)
 	{
 		filename = GetCombinedPath(path, application);
-
-		if (PathFileExistsA(filename))
-		{
+		if (PathFileExistsA(filename)) {
 			break;
 		}
-
 		free(filename);
 		filename = NULL;
 		path = strtok_s(NULL, ":", &save);
 	}
-
 	free(lpSystemPath);
 	return filename;
 }
@@ -169,11 +163,11 @@ static BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplic
 	lpszEnvironmentBlock = NULL;
 	pArgs = CommandLineToArgvA(lpCommandLine, &numArgs);
 
-	if (!pArgs)
+	if (!pArgs) {
+		WLog_ERR(TAG, "CommandLineToArgvA failed.");
 		return FALSE;
-
+	}
 	token = (WINPR_ACCESS_TOKEN*)hToken;
-
 	if (lpEnvironment)
 	{
 		envp = EnvironmentBlockToEnvpA(lpEnvironment);
@@ -181,19 +175,17 @@ static BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplic
 	else
 	{
 		lpszEnvironmentBlock = GetEnvironmentStrings();
-
 		if (!lpszEnvironmentBlock)
 			goto finish;
-
 		envp = EnvironmentBlockToEnvpA(lpszEnvironmentBlock);
 	}
-
 	if (!envp)
 		goto finish;
 	if(lpApplicationName == NULL)
 	{
 		filename = FindApplicationPath(pArgs[0]);
-	} else
+	} 
+	else
 	{
 		lpszAppName = _strdup(lpApplicationName);
 		//lpszAppName = (char*)malloc(strlen(lpApplicationName)+1);
@@ -205,8 +197,11 @@ static BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplic
 			free(lpszAppName);
 		}
 	}
-	if (NULL == filename)
+	if (NULL == filename) {
+		WLog_WARN(TAG, "filename is needed");
+		SetLastError(ERROR_PATH_NOT_FOUND);
 		goto finish;
+	}
 
 	/* block all signals so that the child can safely reset the caller's handlers */
 	sigfillset(&newSigMask);
@@ -217,15 +212,14 @@ static BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplic
 	if (pid < 0)
 	{
 		/* fork failure */
+		WLog_ERR(TAG, "fork failed: %s", strerror(errno));
 		goto finish;
 	}
 
 	if (pid == 0)
 	{
 		/* child process */
-#ifndef __sun
 		int maxfd;
-#endif
 		int fd;
 		int sig;
 		sigset_t set;
@@ -261,10 +255,6 @@ static BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplic
 			if (handle_fd != -1)
 				dup2(handle_fd, STDIN_FILENO);
 		}
-
-#ifdef __sun
-		closefrom(3);
-#else
 #ifdef F_MAXFD // on some BSD derivates
 		maxfd = fcntl(0, F_MAXFD);
 #else
@@ -273,9 +263,6 @@ static BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplic
 
 		for (fd = 3; fd < maxfd; fd++)
 			close(fd);
-
-#endif // __sun
-
 		if (token)
 		{
 			if (token->GroupId)
@@ -314,6 +301,7 @@ static BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplic
 
 	if (!process)
 	{
+		WLog_ERR(TAG, "CreateProcessHandle failed: %s", strerror(errno));
 		goto finish;
 	}
 
@@ -321,6 +309,7 @@ static BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplic
 
 	if (!thread)
 	{
+		WLog_ERR(TAG, "CreateNoneHandle failed");
 		ProcessHandleCloseHandle(process);
 		goto finish;
 	}