1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00

update qqt function

This commit is contained in:
tianduanrui 2017-12-02 17:25:00 +08:00
parent 116a3050cd
commit 31adde3112
3 changed files with 102 additions and 36 deletions

View File

@ -63,19 +63,32 @@ QQT_DST_DIR = src/bin
#user can modify this path
#create_qqt_sdk and link_from_sdk will need this.
#different in every operate system
CONFIG_FILE = $${PWD}/.config.ini
CONFIG_PATH =
CONFIG_FILE =
win32 {
CONFIG_PATH = $$user_config_path()\\QQt
CONFIG_FILE = $${CONFIG_PATH}\\config.ini
} else {
CONFIG_PATH = $$user_config_path()/.QQt
CONFIG_FILE = $${CONFIG_PATH}/config.ini
}
message(config path: $$CONFIG_PATH config file: $${CONFIG_FILE})
!exists($${CONFIG_FILE}) {
$$system(echo [ROOT] > $${CONFIG_FILE})
$$system(echo QQT_BUILD_ROOT = >> $${CONFIG_FILE})
$$system(echo QQT_SDK_ROOT = >> $${CONFIG_FILE})
mkdir("$${CONFIG_PATH}")
empty_file($${CONFIG_FILE})
#qt4 need this ret, why?
ret = $$system(echo [ROOT] >> $${CONFIG_FILE})
ret = $$system(echo QQT_SDK_ROOT = >> $${CONFIG_FILE})
ret = $$system(echo QQT_BUILD_ROOT = >> $${CONFIG_FILE})
}
isEmpty(QQT_BUILD_ROOT): QQT_BUILD_ROOT = $$read_ini("$${CONFIG_FILE}", "ROOT", "QQT_BUILD_ROOT")
isEmpty(QQT_SDK_ROOT): QQT_SDK_ROOT = $$read_ini($${CONFIG_FILE}, ROOT, QQT_SDK_ROOT)
message(QQt build root: $$QQT_BUILD_ROOT)
message(QQt sdk root: $$QQT_SDK_ROOT)
isEmpty(QQT_BUILD_ROOT):error(QQT_BUILD_ROOT required please check .config.ini at $$PWD)
isEmpty(QQT_SDK_ROOT):error(QQT_SDK_ROOT required please check .config.ini at $$PWD)
isEmpty(QQT_BUILD_ROOT)|isEmpty(QQT_SDK_ROOT):error(QQT_BUILD_ROOT and QQT_SDK_ROOT required please check config.ini at $$CONFIG_PATH)
}
#-------------------------------------------------------------

View File

@ -33,33 +33,38 @@ contains(QMAKE_HOST.os,Windows) {
defineReplace(get_mkdir) {
filepath = $$1
isEmpty(1): error("get_mkdir(filepath) requires one argument")
command = $${MKDIR} $${filepath}
return ($$command)
command = $${MK_DIR} $${filepath}
#message($${command})
return ($${command})
}
defineReplace(get_errcode) {
command = $$1
cmd_exec = $$1
isEmpty(1): error("get_errcode(command) requires one argument")
contains(QMAKE_HOST.os,Windows) {
command = $${command} >nul & echo %errorlevel%
command = $${cmd_exec} >nul & echo %errorlevel%
} else {
command = $${command} >/dev/null; echo $?
command = "$${cmd_exec}" 2>/dev/null; echo $?
}
#message($$command)
return ($$command)
}
defineReplace(get_empty_file) {
filename = $$1
isEmpty(1): error("get_empty_file(filename) requires one argument")
command = echo . 2> $${filename}
command =
win32 {
command = echo . 2> $${filename}
} else {
command = echo 2> $${filename}
}
return ($$command)
}
defineReplace(get_write_file) {
filename = $$1
variable = $$2
!isEmpty(3): error("get_write_file(name, [content]) requires one or two arguments.")
isEmpty(2) {
return ( $$get_empty_file($$filename) )
}
command = echo $$variable >> $$filename
!isEmpty(3): error("get_write_file(name, content) requires two arguments.")
isEmpty(2): error("get_write_file(name, content) requires two arguments.")
command = echo $${variable} >> $${filename}
return ($$command)
}
@ -70,8 +75,13 @@ defineReplace(get_copy_dir_and_file) {
target = $$3
!isEmpty(4): error("get_copy_dir_and_file(source, pattern, target) requires three arguments.")
isEmpty(3) : error("get_copy_dir_and_file(source, pattern, target) requires three arguments.")
command = chmod +x $${LINUX_CP_FILES} $${CMD_SEP}
command += $${LINUX_CP_FILES} $${source} $${pattern} $${target}
command =
win32{
command = $${COPY_DIR} $${source}\\$${pattern} $${target}
} else {
command = chmod +x $${LINUX_CP_FILES} $${CMD_SEP}
command += $${LINUX_CP_FILES} $${source} $${pattern} $${target}
}
return ($$command)
}
@ -94,6 +104,26 @@ defineReplace(get_read_ini_command) {
#message ($$command)
return ($$command)
}
defineReplace(get_user_home) {
command =
win32{
command = echo %HOMEPATH%
} else {
command = echo $HOME
}
#message ($$command)
return ($$command)
}
defineReplace(get_user_config_path) {
command =
win32{
command = echo %APPDATA%
} else {
command = echo $HOME
}
#message ($$command)
return ($$command)
}
################################################
##custom functions
@ -110,30 +140,35 @@ defineTest(system_errcode) {
command = $$get_errcode($$command)
#the command is only return ret(0,1) wrappered by get_errcode
ret = $$system("$${command}")
#message($$command)
#message($$ret)
#if eval configed ...
#error: if(ret) : return (false)
#erro : eval(ret = 0): return (false)
#succ: equals(ret, 0):return (false)
return ($$ret)
return ($${ret})
}
#can be used in condition
#test function and replace function can be same name
defineTest(mkdir) {
filename = $$1
isEmpty(1): error("mkdir(name) requires one argument")
command = $$get_mkdir($$filename)
system_errcode($${command}): return (true)
command = $$get_mkdir($${filename})
#message ($$command)
system_errcode("$${command}"): return (true)
return (false)
}
#can be used in condition or values
#can be used in values
#must $$ !
#return values. true is 'true', false is 'false', xx0, xx1 is list
defineReplace(mkdir) {
filename = $$1
isEmpty(1): error("mkdir(name) requires one argument")
command = $$get_mkdir($$filename)
result = $$system($${command})
return ($$result)
command = $$get_mkdir($${filename})
result = $$system("$${command}")
return ($${result})
}
@ -144,20 +179,21 @@ defineTest(empty_file) {
filename = $$1
isEmpty(1): error("empty_file(filename) requires one argument")
command = $$get_empty_file($$filename)
#message($$command)
system_errcode($${command}) : return (true)
return(false)
}
## but system write_file where ?
defineTest(write_file) {
## but qt4 write twice... when file exist, if empty_file first, write once....
defineTest(write_line) {
filename = $$1
variable = $$2
!isEmpty(3): error("write_file(name, [content]) requires one or two arguments.")
isEmpty(2) {
empty_file($$filename)
}
command = $$get_write_file($$filename, $$variable)
system_errcode($$command) : return(true)
!isEmpty(3): error("write_line(name, content) requires two arguments.")
isEmpty(2): error("write_line(name, content) requires two arguments.")
command = $$get_write_file($${filename}, $${variable})
#message($$command)
system_errcode($$command): return(true)
return (false)
}
@ -181,6 +217,23 @@ defineReplace(read_ini) {
isEmpty(3) : error("read_ini(file, section, key) requires three arguments.")
command = $$get_read_ini_command($${file_name}, $${sect_name}, $${key_name})
echo = $$system("$${command}")
#message($$command $$echo)
#message($$command)
#message($$echo)
return ($${echo})
}
defineReplace(user_home) {
command = $$get_user_home()
echo = $$system("$${command}")
#message($$command)
#message($$echo)
return ($${echo})
}
defineReplace(user_config_path) {
command = $$get_user_config_path()
echo = $$system("$${command}")
#message($$command)
#message($$echo)
return ($${echo})
}

View File

@ -33,9 +33,9 @@ defineReplace(create_windows_sdk) {
command =
#copy header
command += $${COPY_DIR} $${QQT_SRC_PWD}\*.h* $${QQT_INC_DIR} $$CMD_SEP
command += $${COPY_DIR} $${QQT_SRC_PWD}\\*.h* $${QQT_INC_DIR} $$CMD_SEP
#should be *.dll *.lib
command += $${COPY_DIR} $${QQT_BUILD_PWD}\* $${QQT_LIB_DIR}
command += $${COPY_DIR} $${QQT_BUILD_PWD}\\* $${QQT_LIB_DIR}
return ($$command)
}