diff --git a/QQtExample.pro b/QQtExample.pro index cf7e35ed..2290616f 100644 --- a/QQtExample.pro +++ b/QQtExample.pro @@ -117,5 +117,5 @@ SUBDIRS = #SUBDIRS += test/QQtWidgetClickSoundHelperTest #这是一对,用于测试Multi-link对其他的lib的链接能力 -SUBDIRS += test/QQtBasedLibTest -SUBDIRS += test/QQtMultiLinkTest +#SUBDIRS += test/QQtBasedLibTest +#SUBDIRS += test/QQtMultiLinkTest diff --git a/multi-link/app_deploy.pri b/multi-link/add_deploy.pri similarity index 91% rename from multi-link/app_deploy.pri rename to multi-link/add_deploy.pri index 4421ffd7..96c73b54 100644 --- a/multi-link/app_deploy.pri +++ b/multi-link/add_deploy.pri @@ -202,6 +202,20 @@ defineTest(app_deploy) { #APP_DEPLOY_PWD #APP_DEST_PWD + #如果 配置文件里 没有配置 APP_DEPLOY_ROOT 那么返回,不拷贝发布任何应用 + #不会走到 + isEmpty(APP_DEPLOY_ROOT) { + message("$${TARGET} hasn't deployed any app files") + greaterThan(QT_MAJOR_VERSION, 5):return() + } + + ##4.8 qmake arm32 return() 函数无效 + !isEmpty(APP_DEPLOY_ROOT) { + #这里定义了一个配置开关,但是用户可以忽略 + #CONFIG += app_deploy + message("$${TARGET} has deployed some app files") + } + !isEmpty(QMAKE_POST_LINK):QMAKE_POST_LINK += $$CMD_SEP contains(QSYS_PRIVATE, Win32||Win64) { #发布windows版本 @@ -276,28 +290,4 @@ equals(QMAKE_HOST.os, Windows) { APP_DEPLOY_PWD~=s,/,\\,g } -#如果 配置文件里 没有配置 APP_DEPLOY_ROOT 那么返回,不拷贝发布任何应用 -#不会走到 -isEmpty(APP_DEPLOY_ROOT) { - message("$${TARGET} hasn't deployed any app files") - greaterThan(QT_MAJOR_VERSION, 5):return() -} -##4.8 qmake arm32 return() 函数无效 -!isEmpty(APP_DEPLOY_ROOT) { - CONFIG += app_deploy - message("$${TARGET} has deployed some app files") -} - -########## -#注意,此处强制发布App 不需要用户手动调用。 -#注意,此处强制依赖LibQQt,不需要用户手动发布LibQQt。 -########## -contains(CONFIG, app_deploy) { - app_deploy_lib(QQt) - app_deploy() - #如果用户依赖了其他的lib,便可以用app_deploy_lib进行拷贝依赖到app发布区域。 - #并且这个工作,后续持续收到app_deploy配置开关的控制。 - #note: app_deploy 一个配置开关 一个函数 两个都有效使用 - #注意,用户必须先发布lib 再发布app -} diff --git a/multi-link/app_deploy_config.pri b/multi-link/add_deploy_config.pri similarity index 100% rename from multi-link/app_deploy_config.pri rename to multi-link/add_deploy_config.pri diff --git a/multi-link/app_function.pri b/multi-link/add_function.pri similarity index 100% rename from multi-link/app_function.pri rename to multi-link/add_function.pri diff --git a/multi-link/app_link.pri b/multi-link/add_link.pri similarity index 61% rename from multi-link/app_link.pri rename to multi-link/add_link.pri index 4dc4082a..50de422d 100644 --- a/multi-link/app_link.pri +++ b/multi-link/add_link.pri @@ -1,5 +1,5 @@ #------------------------------------------------------------- -#app_link.pri +#add_link.pri #提供app链接函数,app lib工程通用 #------------------------------------------------------------- @@ -7,11 +7,11 @@ #内部用函数 #获取命令 ################################################################################ -defineReplace(get_app_link) { +defineReplace(get_add_link) { libname = $$1 librealname = $$2 - isEmpty(1): error("get_app_link(libname, librealname) requires at last one argument") - !isEmpty(3): error("get_app_link(libname, librealname) requires at most two argument") + isEmpty(1): error("get_add_link(libname, librealname) requires at last one argument") + !isEmpty(3): error("get_add_link(libname, librealname) requires at most two argument") isEmpty(2): librealname = $${libname} CUR_LIB_PWD = $${LIB_SDK_ROOT}/$${libname}/$${QSYS_STD_DIR}/lib @@ -31,11 +31,11 @@ defineReplace(get_app_link) { return ($${LINK}) } -defineReplace(get_app_include) { +defineReplace(get_add_include) { incname = $$1 increalname = $$2 - isEmpty(1): error("get_app_include(incname, increalname) requires at last one argument") - !isEmpty(3): error("get_app_include(incname, increalname) requires at most two argument") + isEmpty(1): error("get_add_include(incname, increalname) requires at last one argument") + !isEmpty(3): error("get_add_include(incname, increalname) requires at most two argument") INCLUDE = contains(DEFINES, __DARWIN__) { @@ -55,31 +55,6 @@ defineReplace(get_app_include) { return ($${INCLUDE}) } -defineReplace(get_add_deploy) { - #APP_DEPLOY_ROOT - #DESTDIR - incname = $$1 - increalname = $$2 - isEmpty(1): error("get_app_include(incname, increalname) requires at last one argument") - !isEmpty(3): error("get_app_include(incname, increalname) requires at most two argument") - - INCLUDE = - contains(DEFINES, __DARWIN__) { - CUR_INC_PWD = $${LIB_SDK_ROOT}/$${incname}/$${QSYS_STD_DIR}/$${incname}.framework/Headers - !isEmpty(2):CUR_INC_PWD=$${CUR_INC_PWD}/$${increalname} - INCLUDE += $${CUR_INC_PWD} - } else { - CUR_INC_PWD = $${LIB_SDK_ROOT}/$${incname}/$${QSYS_STD_DIR}/include - !isEmpty(2):CUR_INC_PWD=$${CUR_INC_PWD}/$${increalname} - equals(QMAKE_HOST.os, Windows) { - CUR_INC_PWD~=s,/,\\,g - } - - INCLUDE += $${CUR_INC_PWD} - } - - return ($${INCLUDE}) -} ################################################################################ #公开给外部用函数 @@ -90,14 +65,14 @@ defineReplace(get_add_deploy) { #[libname/5.9.2/macOS/Debug/lib/librealname.dll] #[libname/5.9.2/macOS/Debug/lib/lib.so.*] #librealname可以为空 -defineTest(app_link) { +defineTest(add_link) { libname = $$1 librealname = $$2 - isEmpty(1): error("app_link(libname, librealname) requires at last one argument") - !isEmpty(3): error("app_link(libname, librealname) requires at most two argument") + isEmpty(1): error("add_link(libname, librealname) requires at last one argument") + !isEmpty(3): error("add_link(libname, librealname) requires at most two argument") isEmpty(2): librealname = $${libname} - command = $$get_app_link($${libname}, $${librealname}) + command = $$get_add_link($${libname}, $${librealname}) #message ($$command) LIBS += $${command} @@ -109,13 +84,13 @@ defineTest(app_link) { #[incname/5.9.2/macOS/Debug/lib/incname.framework/Headers/increalname] #[incname/5.9.2/macOS/Debug/include/increalname] #increalname可以为空 -defineTest(app_include) { +defineTest(add_include) { incname = $$1 increalname = $$2 - isEmpty(1): error("app_include(incname, increalname) requires at last one argument") - !isEmpty(3): error("app_include(incname, increalname) requires at most two argument") + isEmpty(1): error("add_include(incname, increalname) requires at last one argument") + !isEmpty(3): error("add_include(incname, increalname) requires at most two argument") - command = $$get_app_include($${incname}, $${increalname}) + command = $$get_add_include($${incname}, $${increalname}) #message ($$command) INCLUDEPATH += $${command} diff --git a/multi-link/multi_link_technology.pri b/multi-link/add_multi_link_technology.pri similarity index 94% rename from multi-link/multi_link_technology.pri rename to multi-link/add_multi_link_technology.pri index 73cd26c9..ab23d64e 100644 --- a/multi-link/multi_link_technology.pri +++ b/multi-link/add_multi_link_technology.pri @@ -42,8 +42,8 @@ isEmpty(APP_BUILD_ROOT)|isEmpty(LIB_SDK_ROOT)|isEmpty(APP_DEPLOY_ROOT){ error("please check $$CONFIG_FILE") } -message($${TARGET} build root: $$APP_BUILD_ROOT) -message($${TARGET} deploy root: $$APP_DEPLOY_ROOT) +#message($${TARGET} build root: $$APP_BUILD_ROOT) +#message($${TARGET} deploy root: $$APP_DEPLOY_ROOT) equals(TEMPLATE, app):message($${TARGET} use sdk root: $$LIB_SDK_ROOT) else:message($${TARGET} deploy sdk root: $$LIB_SDK_ROOT) diff --git a/multi-link/app_platform.pri b/multi-link/add_platform.pri similarity index 98% rename from multi-link/app_platform.pri rename to multi-link/add_platform.pri index eee238f8..f7ccb563 100644 --- a/multi-link/app_platform.pri +++ b/multi-link/add_platform.pri @@ -43,7 +43,7 @@ CONFIG(release, debug|profile|release):BUILD=Release QSYS_STD_DIR = $${QT_VERSION}/$${QSYS_PRIVATE}/$${BUILD} -message(base_platform.pri) +message(app_platform.pri) message(Build $${TARGET} to $${QSYS_PRIVATE} \(QSYS=$${QSYS_PRIVATE} is configed in project build page.\) ) message(Build $${TARGET} at $${QSYS_STD_DIR} \(Qt Kit page FileSystem Name=$${QSYS_PRIVATE}\) ) message(Build $${TARGET} on $${QMAKE_HOST.os} \(Operating System=$${QMAKE_HOST.os}\) ) diff --git a/multi-link/add_sdk.pri b/multi-link/add_sdk.pri new file mode 100644 index 00000000..ddbd0d83 --- /dev/null +++ b/multi-link/add_sdk.pri @@ -0,0 +1,310 @@ +################################################ +##add_sdk.pri, making sdk function +##install to SDK path +##把Library按照SDK格式安装到LIB_SDK_ROOT +##发布到sdk是为Multi link准备的。 +##依赖add_version.pri +##please don't modify this pri +################################################ + + +################################################ +##lib install functions +##variable can be private and default inherit +##内部实现 +################################################ +defineReplace(add_sdk_dir_struct) { + #if it's qt library, don't create + command = + !equals(LIB_SDK_PWD , $$[QT_INSTALL_DATA]){ + !contains(QSYS_PRIVATE, macOS) { + command += $$MK_DIR $$LIB_INC_DIR $$CMD_SEP + } + command += $$MK_DIR $$LIB_LIB_DIR $$CMD_SEP + command += $$MK_DIR $$LIB_CMAKE_DIR $$CMD_SEP + command += $$MK_DIR $$LIB_PRI_PATH + } + return ($$command) +} + +defineReplace(add_windows_sdk) { + #need cd sdk root + + command = + #copy header + command += $${COPY_DIR} $${LIB_SRC_PWD}\\*.h* $${LIB_INC_DIR} $$CMD_SEP + #should be *.dll *.lib + command += $${COPY_DIR} $${LIB_BUILD_PWD}\\* $${LIB_LIB_DIR} + + return ($$command) +} + +defineReplace(add_linux_sdk) { + #need cd sdk root + copy_command = $$get_copy_dir_and_file($${LIB_SRC_PWD}, "*.h*", $${LIB_INC_DIR}) + command = + command += $${copy_command} $$CMD_SEP + #should be *.so.* *.a + command += $$COPY_DIR $${LIB_BUILD_PWD}/* $${LIB_LIB_DIR} + + return ($$command) +} + +defineReplace(add_mac_sdk){ + #need cd framework root + #LIB_BUILD_PWD libname libmajorver + libname = $$TARGET + libmajorver = $$APP_MAJOR_VERSION + + LIB_BUNDLE_VER_DIR = Versions/$${libmajorver} + LIB_BUNDLE_CUR_DIR = Versions/Current + LIB_BUNDLE_INC_DIR = $${LIB_BUNDLE_VER_DIR}/Headers + LIB_BUNDLE_RES_DIR = $${LIB_BUNDLE_VER_DIR}/Resources + LIB_BUNDLE_EXE_FILE = $${LIB_BUNDLE_VER_DIR}/$${libname} + + LIB_BUNDLE_CUR_INC_DIR = $${LIB_BUNDLE_CUR_DIR}/Headers + LIB_BUNDLE_CUR_RES_DIR = $${LIB_BUNDLE_CUR_DIR}/Resources + LIB_BUNDLE_CUR_EXE_FILE = $${LIB_BUNDLE_CUR_DIR}/$${libname} + + LIB_BUNDLE_CUR_LINK = Current + LIB_BUNDLE_INC_LINK = Headers + LIB_BUNDLE_RES_LINK = Resources + LIB_BUNDLE_EXE_LINK = $${libname} + + command = + command += $$MK_DIR $$LIB_BUNDLE_VER_DIR $$CMD_SEP + command += $$MK_DIR $$LIB_BUNDLE_INC_DIR $$CMD_SEP + #copy lib + #should be * + command += $$COPY_DIR $${LIB_BUILD_PWD}/$${libname}.framework/$${LIB_BUNDLE_VER_DIR}/* $$LIB_BUNDLE_VER_DIR $$CMD_SEP + #copy header + copy_command = $$get_copy_dir_and_file($${LIB_SRC_PWD}, "*.h*", $${LIB_BUNDLE_INC_DIR}) + command += $${copy_command} $$CMD_SEP + #link header current resources + command += $$CD Versions $$CMD_SEP + command += $$LN $${libmajorver} $${LIB_BUNDLE_CUR_LINK} $$CMD_SEP + command += $$CD .. $$CMD_SEP + command += $$LN $$LIB_BUNDLE_CUR_INC_DIR $${LIB_BUNDLE_INC_LINK} $$CMD_SEP + command += $$LN $$LIB_BUNDLE_CUR_RES_DIR $${LIB_BUNDLE_RES_LINK} $$CMD_SEP + command += $$LN $$LIB_BUNDLE_CUR_EXE_FILE $${LIB_BUNDLE_EXE_LINK} + lessThan(QT_MAJOR_VERSION, 5){ + command += $$CMD_SEP + command += chmod +x $${PWD}/mac_deploy_qt4.sh $$CMD_SEP + command += $${PWD}/mac_deploy_qt4.sh $${LIB_BUNDLE_VER_DIR}/$${libname} + } + return ($$command) +} + +defineReplace(add_Qt_lib_pri){ + #need cd sdk root + #LIB_BASE_DIR libname LIB_VERSION MODULE_CNAME + ##write qt_lib_qqtcore.pri + + command = + command += $$get_empty_file($${LIB_PRI_FILEPATH}) $$CMD_SEP + command += echo "QT.$${libname_lower}.VERSION = $${VERSION}" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + command += echo "QT.$${libname_lower}.name = $${libname}" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + command += echo "QT.$${libname_lower}.module = $${libname}" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + contains(QSYS_PRIVATE, Win32|Win64) { + command += echo "QT.$${libname_lower}.libs = \$$QT_MODULE_LIB_BASE" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + command += echo "QT.$${libname_lower}.bins = \$$QT_MODULE_BIN_BASE" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + } else { + command += echo "QT.$${libname_lower}.libs = '\$$QT_MODULE_LIB_BASE'" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + command += echo "QT.$${libname_lower}.bins = '\$$QT_MODULE_BIN_BASE'" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + } + contains(QSYS_PRIVATE, Win32|Win64) { + command += echo "QT.$${libname_lower}.includes = \$$QT_MODULE_INCLUDE_BASE \$$QT_MODULE_INCLUDE_BASE/$${libname}" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + command += echo "QT.$${libname_lower}.frameworks = " >> $${LIB_PRI_FILEPATH} $$CMD_SEP + command += echo "QT.$${libname_lower}.module_config = v2 " >> $${LIB_PRI_FILEPATH} $$CMD_SEP + }else:equals(QSYS_PRIVATE, macOS) { + command += echo "QT.$${libname_lower}.includes = '\$$QT_MODULE_LIB_BASE/$${libname}.framework/Headers'" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + command += echo "QT.$${libname_lower}.frameworks = '\$$QT_MODULE_LIB_BASE'" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + command += echo "QT.$${libname_lower}.module_config = v2 lib_bundle" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + } else { + command += echo "QT.$${libname_lower}.includes = '\$$QT_MODULE_INCLUDE_BASE \$$QT_MODULE_INCLUDE_BASE/$${libname}'" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + command += echo "QT.$${libname_lower}.frameworks = " >> $${LIB_PRI_FILEPATH} $$CMD_SEP + command += echo "QT.$${libname_lower}.module_config = v2 " >> $${LIB_PRI_FILEPATH} $$CMD_SEP + } + greaterThan(QT_MAJOR_VERSION, 4):{ + command += echo "QT.$${libname_lower}.depends = core sql network gui xml widgets" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + } else { + command += echo "QT.$${libname_lower}.depends = core sql network gui xml" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + } + command += echo "QT.$${libname_lower}.uses =" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + command += echo "QT.$${libname_lower}.DEFINES = LIB_LIBRARY" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + command += echo "QT.$${libname_lower}.enabled_features =" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + command += echo "QT.$${libname_lower}.disabled_features =" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + command += echo "QT_CONFIG +=" >> $${LIB_PRI_FILEPATH} $$CMD_SEP + command += echo "QT_MODULES += $${libname_lower}" >> $${LIB_PRI_FILEPATH} + return ($$command) +} + +################################################ +##Lib deploy sdk workflow +##SDK发布过程 +################################################ +defineReplace(add_sdk_work_flow){ + #need cd sdk root + + libname = $$TARGET + libname_lower = $$lower($${libname}) + libmajorver = $$APP_MAJOR_VERSION + + command = + command += $$RM_DIR $${LIB_SDK_PWD} $$CMD_SEP + command += $$MK_DIR $${LIB_SDK_PWD} $$CMD_SEP + command += $$CD $${LIB_SDK_PWD} $$CMD_SEP + command += $$add_sdk_dir_struct() $$CMD_SEP + + #这里不是目标为Windows才拷贝,而是开发机是Windows就得这么拷贝。 + #Windows下,Win目标、Android目标都走这里。 + #contains(QSYS_PRIVATE, Win32|Win64) { + equals(QMAKE_HOST.os, Windows) { + #message(create QQt windows struct library) + command += $$add_windows_sdk() $$CMD_SEP + command += $$COPY $${LIB_BUILD_PWD}\\*.prl lib $$CMD_SEP + } else { + contains(QSYS_PRIVATE, macOS) { + #message(create QQt mac bundle framework) + command += $$MK_DIR lib/$${libname}.framework $$CMD_SEP + command += $$CD lib/$${libname}.framework $$CMD_SEP + command += $$add_mac_sdk() $$CMD_SEP + command += $$CD ../../ $$CMD_SEP + #create prl + command += $$COPY $${LIB_BUILD_PWD}/$${libname}.framework/$${libname}.prl lib/$${libname}.framework/$${libname}.prl $$CMD_SEP + } else { + #Android在linux开发机下也会走这里,Android目标,LibQQt可以发布Win和Linux两种格式的SDK。 + #message(create QQt linux struct library) + command += $$add_linux_sdk() $$CMD_SEP + command += $$COPY $${LIB_BUILD_PWD}/*.prl lib $$CMD_SEP + } + } + + command += $$add_Qt_lib_pri() + return ($$command) +} + +################################################ +##Lib deploy sdk work flow +##初始化SDK发布过程需要的变量 +################################################ +defineReplace(add_sdk_private){ + libname = $$TARGET + libname_lower = $$lower($${libname}) + libmajorver = $$APP_MAJOR_VERSION + + #qqt defined these dir struct, used from qt library + LIB_INC_DIR = include/$${libname} + LIB_LIB_DIR = lib + LIB_CMAKE_DIR=lib/cmake/$${libname} + LIB_PRI_PATH=mkspecs/modules + LIB_PRI_FILEPATH=$${LIB_PRI_PATH}/qt_lib_$${libname_lower}.pri + + #不仅仅发布目标为Windows的时候需要改变, + #开发Host是Windows的时候都要改变。路径问题是两种操作系统固有的痛。 + #contains(QSYS_PRIVATE, Win32|Win64) { + equals(QMAKE_HOST.os, Windows) { + #on windows every path must use \ sep. + LIB_SRC_PWD~=s,/,\\,g + LIB_BUILD_PWD~=s,/,\\,g + LIB_SDK_PWD~=s,/,\\,g + + LIB_INC_DIR~=s,/,\\,g + LIB_LIB_DIR = lib + LIB_CMAKE_DIR~=s,/,\\,g + LIB_PRI_PATH~=s,/,\\,g + LIB_PRI_FILEPATH~=s,/,\\,g + + #ignored + HEADERS_WIN=$${HEADERS} + HEADERS_WIN~=s,/,\\,g + #on windows, copy all *.h*, include closed feature header. + #qmake regexp use perl grammer + #HEADERS_WIN~=s/[d ]+/h+/g how to mod space to + + } + #create library struct + #create platform sdk + #create mkspec module pri + command = $$add_sdk_work_flow() + + #message ($$command) + return ($${command}) +} + +################################################ +##用户调用的函数 +################################################ +#依赖 libname libsrcdir libdstdir libmajorversion +defineTest(add_sdk){ + #isEmpty(1):error(add_sdk(libname, libsrcdir, libdstdir) need at last one argument) + + contains(QSYS_PRIVATE, macOS) { + equals(APP_MAJOR_VERSION, 0):message(add_sdk(libname, libsrcdir, libdstdir) macos app major version is "0," have you setted it?) + } + + libname = $$TARGET + libname_lower = $$lower($${libname}) + + #LIB std dir is not same to app std dir + LIB_STD_DIR = $${libname}/$${QSYS_STD_DIR} + + #编译目标位置 + LIB_DST_DIR=$$3 + isEmpty($$3):LIB_DST_DIR = $$DESTDIR + + #create platform sdk need this + #源代码目录 + LIB_SRC_PWD=$$2 + isEmpty($$2):LIB_SRC_PWD=$${PWD} + + #lib major version + libmajorver = $$APP_MAJOR_VERSION + + #need use qqt subdir proj + LIB_BUILD_PWD=$${APP_BUILD_ROOT}/$${LIB_STD_DIR} + !isEmpty(LIB_DST_DIR):LIB_BUILD_PWD=$${LIB_BUILD_PWD}/$${LIB_DST_DIR} + + #sdk path + LIB_SDK_PWD = $${LIB_SDK_ROOT}/$${LIB_STD_DIR} + #message(QQt sdk install here:$${LIB_SDK_PWD}) + + contains(CONFIG, link_from_sdk) { + LIB_LIB_PWD = $${LIB_SDK_ROOT}/$${LIB_STD_DIR}/lib + } else: contains(CONFIG, link_from_build) { + LIB_LIB_PWD = $${APP_BUILD_ROOT}/$${LIB_STD_DIR}/$${LIB_DST_DIR} + } + + #这里不仅仅目标为windows的时候,才会转换, + #开发Host为Windows的时候,都要转换。 + #contains(QSYS_PRIVATE, WIN32||WIN64) { + equals(QMAKE_HOST.os, Windows) { + APP_BUILD_ROOT~=s,/,\\,g + LIB_SDK_ROOT~=s,/,\\,g + APP_DEPLOY_ROOT~=s,/,\\,g + + QSYS_STD_DIR~=s,/,\\,g + LIB_STD_DIR~=s,/,\\,g + LIB_DST_DIR~=s,/,\\,g + LIB_BUILD_PWD~=s,/,\\,g + LIB_SDK_PWD~=s,/,\\,g + LIB_LIB_PWD~=s,/,\\,g + } + + command += $$add_sdk_private() + message($$command) + QMAKE_POST_LINK += $$command + + export(QMAKE_POST_LINK) + + return (1) +} + +#if you want to use QQt with QT += QQt please open this feature +#unimplete: CONFIG += add_sdk_to_Qt +defineTest(add_sdk_to_Qt){ + libname=QQt + #LIB_BUILD_PWD + LIB_SDK_PWD=$$[QT_INSTALL_DATA] + message(QQt sdk install here:$${LIB_SDK_PWD}) + return (1) +} diff --git a/multi-link/add_version.pri b/multi-link/add_version.pri new file mode 100644 index 00000000..bb91d4b1 --- /dev/null +++ b/multi-link/add_version.pri @@ -0,0 +1,85 @@ +################################################################# +##project $${TARGET} version pri +################################################################# +#拷贝到用户用户工程目录里使用用 +##add_sdk need this pri + +defineReplace(get_version_string_1) { + major_version = $$1 + !isEmpty(2): error("get_version_string_1(major) requires one arguments") + isEmpty(1): error("get_version_string_1(major) requires one arguments") + command = $${major_version} + return ($$command) +} +defineReplace(get_version_string_2) { + major_version = $$1 + minor_version = $$2 + !isEmpty(3): error("get_version_string_2(major, minor) requires two arguments") + isEmpty(2): error("get_version_string_2(major, minor) requires two arguments") + command = $${major_version}.$${minor_version} + return ($$command) +} +defineReplace(get_version_string_3) { + major_version = $$1 + minor_version = $$2 + patch_version = $$3 + !isEmpty(4): error("get_version_string_3(major, minor, patch) requires three arguments") + isEmpty(3): error("get_version_string_3(major, minor, patch) requires three arguments") + command = $${major_version}.$${minor_version}.$${patch_version} + return ($$command) +} +defineReplace(get_version_string_4) { + major_version = $$1 + minor_version = $$2 + patch_version = $$3 + build_version = $$4 + !isEmpty(5): error("get_version_string_4(major, minor, patch, build) requires four arguments") + isEmpty(4): error("get_version_string_4(major, minor, patch, build) requires four arguments") + command = $${major_version}.$${minor_version}.$${patch_version}.$${build_version} + return ($$command) +} + +#------------------------------------------------------------------------------- +#User Make Version Flow +#------------------------------------------------------------------------------- +defineTest(add_version) { + isEmpty(4):error(add_version(major, minor, patch, build) need four arguments.) + + APP_MAJOR_VERSION = $$1 + APP_MINOR_VERSION = $$2 + APP_PATCH_VERSION = $$3 + APP_BUILD_VERSION = $$4 + + APP_VERSION1 = $$get_version_string_1( $${APP_MAJOR_VERSION} ) + APP_VERSION2 = $$get_version_string_2( $${APP_MAJOR_VERSION}, $${APP_MINOR_VERSION} ) + APP_VERSION3 = $$get_version_string_3( $${APP_MAJOR_VERSION}, $${APP_MINOR_VERSION}, $${APP_PATCH_VERSION} ) + APP_VERSION4 = $$get_version_string_4( $${APP_MAJOR_VERSION}, $${APP_MINOR_VERSION}, $${APP_PATCH_VERSION}, $${APP_BUILD_VERSION} ) + + message ($${TARGET} version: V$$APP_VERSION4) + + #这两个变量赋值是什么关系? + #qmake 域变量 + APP_VERSION = $${APP_VERSION3} + #源代码 域宏 + DEFINES += VERSION=$${APP_VERSION} + DEFINES += LIB_VERSION=$${APP_VERSION} + DEFINES += APP_VERSION=$${APP_VERSION} + + #工程版本设置 + VERSION = $${APP_VERSION} + VER_MAJ = $$APP_MAJOR_VERSION + VER_MIN = $$APP_MINOR_VERSION + VER_PAT = $$APP_PATCH_VERSION + + export(DEFINES) + export(VERSION) + export(VER_MAJ) + export(VER_MIN) + export(VER_PAT) + export(APP_MAJOR_VERSION) + export(APP_MINOR_VERSION) + export(APP_PATCH_VERSION) + export(APP_BUILD_VERSION) + + return (1) +} diff --git a/multi-link/app_base_manager.pri b/multi-link/app_base_manager.pri index c812a324..07a92a1b 100644 --- a/multi-link/app_base_manager.pri +++ b/multi-link/app_base_manager.pri @@ -7,31 +7,38 @@ ################################################################################ #包含这个pri依赖的pri ################################################################################ -include ($${PWD}/app_platform.pri) -include ($${PWD}/app_function.pri) +include ($${PWD}/add_platform.pri) +include ($${PWD}/add_function.pri) ################################################################################ #多链接技术入口 ################################################################################ -include($${PWD}/multi_link_technology.pri) +include($${PWD}/add_multi_link_technology.pri) ################################################################################ #这里的pri提供multi link的全部函数 ################################################################################ #app发布所需要的函数 -include ($${PWD}/app_deploy.pri) +include ($${PWD}/add_deploy.pri) #app发布配置项需要的函数 -include ($${PWD}/app_deploy_config.pri) +include ($${PWD}/add_deploy_config.pri) #app链接所需要的函数 -include ($${PWD}/app_link.pri) +include ($${PWD}/add_link.pri) #################################################################################### #app base manager 都做了一下这些事情 #################################################################################### #发布app和libQQt -#这个在app_deploy.pri里强制发布,这里不必调用 +#注意,此处强制发布App 不需要用户手动调用。 +#注意,此处强制依赖LibQQt,不需要用户手动发布LibQQt。 +app_deploy() +app_deploy_lib(QQt) +#如果用户依赖了其他的lib,便可以用app_deploy_lib进行拷贝依赖到app发布区域。 +#并且这个工作,后续持续收到app_deploy配置开关的控制。 +#note: app_deploy 一个配置开关 一个函数 两个都有效使用 +#注意,用户必须先发布lib 再发布app #发布配置 #用户手动调用app_deploy_config(源配置文件所在位置) diff --git a/multi-link/app_version.pri b/multi-link/app_version.pri deleted file mode 100644 index a790aba3..00000000 --- a/multi-link/app_version.pri +++ /dev/null @@ -1,15 +0,0 @@ -################################################################# -##project $${TARGET} version pri -################################################################# -#拷贝到用户app工程目录里使用用 - -APP_MAJOR_VERSION = 0 -APP_MINOR_VERSION = 0 -APP_PATCH_VERSION = 0 -APP_BUILD_VERSION = 0 - -APP_VERSION = $${APP_MAJOR_VERSION}.$${APP_MINOR_VERSION}.$${APP_PATCH_VERSION} -APP_VERSION4 = $${APP_MAJOR_VERSION}.$${APP_MINOR_VERSION}.$${APP_PATCH_VERSION}.$${APP_BUILD_VERSION} -DEFINES += APP_VERSION=$${APP_VERSION} -message (Build $${TARGET} version: $$APP_VERSION4) -unix:VERSION = $${APP_VERSION} diff --git a/multi-link/lib_base_manager.pri b/multi-link/lib_base_manager.pri new file mode 100644 index 00000000..aba08bd5 --- /dev/null +++ b/multi-link/lib_base_manager.pri @@ -0,0 +1,196 @@ +#--------------------------------------------------------------------------------- +#app_base_manager.pri +#应用程序和Library的基础管理器,统一使用这个管理器。 +# +#--------------------------------------------------------------------------------- + +################################################################################ +#包含这个pri依赖的pri +################################################################################ +include ($${PWD}/add_platform.pri) +include ($${PWD}/add_function.pri) + +################################################################################ +#多链接技术入口 +################################################################################ +include($${PWD}/add_multi_link_technology.pri) + +################################################################################ +#这里的pri提供multi link的全部函数 +################################################################################ +#app发布所需要的函数 +#include ($${PWD}/add_deploy.pri) + +#app发布配置项需要的函数 +#include ($${PWD}/add_deploy_config.pri) + +#链接lib所需要的函数 +include ($${PWD}/add_link.pri) + +#lib version +include ($${PWD}/add_version.pri) + +#lib发布sdk所需要的函数 +include ($${PWD}/add_sdk.pri) + +#################################################################################### +#lib base manager 都做了一下这些事情 +#################################################################################### + +################################################################# +##definition and configration +##need QSYS +################################################################# +##Qt version +QT += core sql network gui xml +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +# release open debug output +CONFIG(debug, debug|release) { +} else { + DEFINES -= QT_NO_DEBUG_OUTPUT +} + +#mingw要加速编译,make -j20,-j参数是最好的解决办法。 + +#close win32 no using fopen_s warning +win32:DEFINES += _CRT_SECURE_NO_WARNINGS #fopen fopen_s + +#msvc支持设置 +msvc { + MSVC_CCFLAGS = + #this three pragma cause mingw errors + msvc:MSVC_CCFLAGS += /wd"4819" /wd"4244" /wd"4100" + + #UTF8编码 + DEFINES += __MSVC_UTF8_SUPPORT__ + msvc:MSVC_CCFLAGS += /execution-charset:utf-8 + msvc:MSVC_CCFLAGS += /source-charset:utf-8 + #msvc:MSVC_CCFLAGS += /utf-8 #这一个是快捷方式,顶上边两个。 + + #指定/mp编译选项,编译器将使用并行编译,同时起多个编译进程并行编译不同的cpp + msvc:MSVC_CCFLAGS += /MP + #指出:这个FLAG只能用于MSVC + + msvc:QMAKE_CFLAGS += $${MSVC_CCFLAGS} + msvc:QMAKE_CXXFLAGS += $${MSVC_CCFLAGS} + + #指定stable.h这个头文件作为编译预处理文件,MFC里这个文件一般叫stdafx.h 然后在 stable.h里 包含你所用到的所有 Qt 头文件 + #在.pro 文件中加入一行, 加在这里,加速编译。 + #msvc:PRECOMPILED_HEADER = $${PWD}/qqt-qt.h + #指出:precompiler header只能用于MSVC + #这个功能可用,可是编译问题比较多,不方便,所以默认不开开。 +} + +CONFIG += create_prl +################################################################# +##build qqt or link qqt +################################################################# +##different target: +##----------------------------------------------- +##win platform: +##build qqt dll + QQT_LIBRARY +##build qqt lib + QQT_STATIC_LIBRARY +##link qqt lib + QQT_STATIC_LIBRARY +##link qqt dll + ~~ +##- - - - - - - - - - - - - - - - - - - - - +##*nix platform: +##build and link qqt dll or lib + ~~ +##----------------------------------------------- +#link QQt static library in some occation on windows +#when link QQt static library, if no this macro, headers can't be linked on windows. +contains(QSYS_PRIVATE, Win32|Win64 || iOS|iOSSimulator) { + #Qt is static by mingw32 building + mingw|ios{ + #on my computer, Qt library are all static library? + DEFINES += LIB_STATIC_LIBRARY + message(Build $${TARGET} LIB_STATIC_LIBRARY is defined. build and link) + } + + #link and build all need this macro + contains(DEFINES, QQT_STATIC_LIBRARY) { + } +} + +################################################################ +##build cache (此处为中间目标目录,对用户并不重要) +##此处加以干涉,使目录清晰。 +##此处关于DESTDIR的设置,导致用户必须把这个文件的包含,提前到最前边的位置,才能进行App里的目录操作。 +##删除干涉? +##用户注意:(done in app_base_manager), 首先include(app_link_qqt_library.pri),然后做app的工作,和include其他pri,包括LibQQt提供的其他pri,保证这个顺序就不会出错了。 +##对编译目标目录进行干涉管理,显得更加细腻。 +##用户注意:这里相当于给编译中间目录加了一个自动校准,属于校正范畴。 +################################################################ +isEmpty(OBJECTS_DIR):OBJECTS_DIR = obj +isEmpty(MOC_DIR):MOC_DIR = obj/moc.cpp +isEmpty(UI_DIR):UI_DIR = obj/ui.h +isEmpty(RCC_DIR):RCC_DIR = qrc +#这样做保持了App工程和LibQQt工程中间目录的一致性,但是并不必要。 +isEmpty(DESTDIR):DESTDIR = bin + +################################################################ +##QQt Functions Macro +################################################################ +#You need switch these more macro according to your needs when you build this library +#You can tailor QQt with these macro. +#Default: macroes is configed, some open, some close, compatibled to special accotation. +##App希望裁剪LibQQt,开关这个文件里的组件宏,用户有必要读懂这个头文件。up to so. + +##################C++11 Module############################### +#if you use C++11, open this annotation. suggest: ignore +#DEFINES += __CPP11__ +contains (DEFINES, __CPP11__) { + #macOS gcc Qt4.8.7 + #qobject.h fatal error: 'initializer_list' file not found, + #Qt4.8.7 can't support c++11 features + #QMAKE_CXXFLAGS += "-std=c++11" + #QMAKE_CXXFLAGS += "-std=c++0x" + + #below: gcc version > 4.6.3 + #Open this Config, Why in Qt4 works? see qmake config auto ignored this feature. + #In Qt5? don't need open this config, qmake auto add c++11 support on linux plat. + #on windows mingw32? need test + #CONFIG += c++11 + + #compile period + #LibQQt need c++11 support. Please ensure your compiler version. + #LibQQt used override identifier + #lambda also need c++11 +} + +################################################################# +##library +################################################################## +equals (QKIT_PRIVATE, iOSSimulator):{ + #error need + #QMAKE_CXXFLAGS +=-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk +} + +win32 { + LIBS += -luser32 +}else: unix { + equals(QSYS_PRIVATE, macOS) { + #min macosx target + QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9 + #deperated + #QMAKE_MAC_SDK=macosx10.12 + #MACOSXSDK = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$${QMAKE_MACOSX_DEPLOYMENT_TARGET}.sdk + #QMAKE_LIBDIR = $${MACOSXSDK} + #LIBS += -F$${MACOSXSDK}/System/Library/Frameworks + #LIBS += -L$${MACOSXSDK}/usr/lib + LIBS += -framework DiskArbitration -framework Cocoa -framework IOKit + }else:contains(QSYS_PRIVATE, iOS|iOSSimulator){ + QMAKE_LFLAGS += -ObjC -lsqlite3 -lz + QMAKE_IOS_DEPLOYMENT_TARGET = 8 + } +} + + +#用户有必要设置APP_VERSION +#add_version(1,0,0,0) + +#用户有必要发布SDK 给其他APP用 +#add_sdk() + +#add_link(QQt) +#add_include(QQt) diff --git a/test/QQtBasedLibTest/QQtBasedLibTest.pro b/test/QQtBasedLibTest/QQtBasedLibTest.pro index f7722465..8259ce62 100644 --- a/test/QQtBasedLibTest/QQtBasedLibTest.pro +++ b/test/QQtBasedLibTest/QQtBasedLibTest.pro @@ -42,5 +42,16 @@ unix { #INSTALLS += target } +#touch 启动post link system(touch qqtbasedlibtest.cpp) -include (../../lib/lib_base_manager.pri) +#包含基础管理者 +include (../../multi-link/lib_base_manager.pri) + +contains(QSYS_PRIVATE, macOS){ + CONFIG += lib_bundle +} + +#设置版本 必要 +add_version(1,0,0,0) +#发布SDK 必要 +add_sdk() diff --git a/test/QQtBasedLibTest/qqtbasedlibtest.cpp b/test/QQtBasedLibTest/qqtbasedlibtest.cpp index 4bfd6729..415a07d6 100644 --- a/test/QQtBasedLibTest/qqtbasedlibtest.cpp +++ b/test/QQtBasedLibTest/qqtbasedlibtest.cpp @@ -3,5 +3,6 @@ QQtBasedLibTest::QQtBasedLibTest() { - pline() << res ( "xxx.png" ); + //pline() << res ( "xxx.png" ); } + diff --git a/test/QQtBasedLibTest/qqtbasedlibtest.h b/test/QQtBasedLibTest/qqtbasedlibtest.h index add85795..07525808 100644 --- a/test/QQtBasedLibTest/qqtbasedlibtest.h +++ b/test/QQtBasedLibTest/qqtbasedlibtest.h @@ -3,8 +3,8 @@ #include "qqtbasedlibtest_global.h" -#include -#include +//#include +//#include class QQTBASEDLIBTESTSHARED_EXPORT QQtBasedLibTest {