2019-01-26 07:54:56 +03:00
/*
2021-01-05 13:17:11 +03:00
* Copyright ( C ) 2018 - 2021 QuasarApp .
2019-01-26 07:54:56 +03:00
* Distributed under the lgplv3 software license , see the accompanying
* Everyone is permitted to copy and distribute verbatim copies
* of this license document , but changing it is not allowed .
*/
2019-09-08 13:37:33 +03:00
# include "extracter.h"
2019-09-03 18:15:05 +03:00
# include "deploycore.h"
2019-11-01 19:43:54 +03:00
# include "pathutils.h"
2020-07-04 23:08:41 +03:00
# include "pluginsparser.h"
2018-12-09 17:35:07 +03:00
2018-12-15 20:51:25 +03:00
# include <QDebug>
# include <QDir>
2018-12-09 17:35:07 +03:00
# include <QFileInfo>
2019-08-12 18:05:28 +03:00
# include <QLibraryInfo>
2020-07-28 23:56:34 +03:00
# include <QProcess>
2019-09-14 13:59:11 +03:00
# include <configparser.h>
2020-04-04 15:43:46 +03:00
# include <iostream>
2018-12-09 17:35:07 +03:00
2019-09-07 12:01:20 +03:00
//QString DeployCore::qtDir = "";
//QStringList DeployCore::extraPaths = QStringList();
2018-12-09 17:35:07 +03:00
2019-03-25 20:13:30 +03:00
2019-09-08 13:37:33 +03:00
const DeployConfig * DeployCore : : _config = nullptr ;
2019-09-03 18:15:05 +03:00
QtModuleEntry DeployCore : : qtModuleEntries [ ] = {
2020-11-28 20:02:51 +03:00
{ QtBluetoothModule , " bluetooth " , " QtXBluetooth " , nullptr } ,
{ QtConcurrentModule , " concurrent " , " QtXConcurrent " , " qtbase " } ,
{ QtCoreModule , " core " , " QtXCore " , " qtbase " } ,
{ QtDeclarativeModule , " declarative " , " QtXDeclarative " , " qtquick1 " } ,
{ QtDesignerModule , " designer " , " QtXDesigner " , nullptr } ,
{ QtDesignerComponents , " designercomponents " , " QtXDesignerComponents " , nullptr } ,
2019-01-27 15:37:19 +03:00
{ QtEnginioModule , " enginio " , " Enginio " , nullptr } ,
2020-11-28 20:02:51 +03:00
{ QtGamePadModule , " gamepad " , " QtXGamepad " , nullptr } ,
{ QtGuiModule , " gui " , " QtXGui " , " qtbase " } ,
{ QtHelpModule , " qthelp " , " QtXHelp " , " qt_help " } ,
{ QtMultimediaModule , " multimedia " , " QtXMultimedia " , " qtmultimedia " } ,
{ QtMultimediaWidgetsModule , " multimediawidgets " , " QtXMultimediaWidgets " , " qtmultimedia " } ,
{ QtMultimediaQuickModule , " multimediaquick " , " QtXMultimediaQuick_p " , " qtmultimedia " } ,
{ QtNetworkModule , " network " , " QtXNetwork " , " qtbase " } ,
{ QtNfcModule , " nfc " , " QtXNfc " , nullptr } ,
{ QtOpenGLModule , " opengl " , " QtXOpenGL " , nullptr } ,
{ QtOpenGLWidgetsModule , " openglwidgets " , " QtXOpenGLWidgets " , nullptr } ,
{ QtPositioningModule , " positioning " , " QtXPositioning " , nullptr } ,
{ QtPrintSupportModule , " printsupport " , " QtXPrintSupport " , nullptr } ,
{ QtQmlModule , " qml " , " QtXQml " , " qtdeclarative " } ,
2019-01-27 15:37:19 +03:00
{ QtQmlToolingModule , " qmltooling " , " qmltooling " , nullptr } ,
2020-11-28 20:02:51 +03:00
{ QtQuickModule , " quick " , " QtXQuick " , " qtdeclarative " } ,
{ QtQuickParticlesModule , " quickparticles " , " QtXQuickParticles " , nullptr } ,
{ QtQuickWidgetsModule , " quickwidgets " , " QtXQuickWidgets " , nullptr } ,
{ QtScriptModule , " script " , " QtXScript " , " qtscript " } ,
{ QtScriptToolsModule , " scripttools " , " QtXScriptTools " , " qtscript " } ,
{ QtSensorsModule , " sensors " , " QtXSensors " , nullptr } ,
{ QtSerialPortModule , " serialport " , " QtXSerialPort " , " qtserialport " } ,
{ QtSqlModule , " sql " , " QtXSql " , " qtbase " } ,
{ QtSvgWidgetsModule , " svgwidgets " , " QtXSvgWidgets " , nullptr } ,
{ QtSvgModule , " svg " , " QtXSvg " , nullptr } ,
{ QtTestModule , " test " , " QtXTest " , " qtbase " } ,
{ QtWebKitModule , " webkit " , " QtXWebKit " , nullptr } ,
{ QtWebKitWidgetsModule , " webkitwidgets " , " QtXWebKitWidgets " , nullptr } ,
{ QtWebSocketsModule , " websockets " , " QtXWebSockets " , nullptr } ,
{ QtWidgetsModule , " widgets " , " QtXWidgets " , " qtbase " } ,
{ QtWinExtrasModule , " winextras " , " QtXWinExtras " , nullptr } ,
{ QtXmlModule , " xml " , " QtXXml " , " qtbase " } ,
{ QtXmlPatternsModule , " xmlpatterns " , " QtXXmlPatterns " , " qtxmlpatterns " } ,
{ QtWebEngineCoreModule , " webenginecore " , " QtXWebEngineCore " , nullptr } ,
{ QtWebEngineModule , " webengine " , " QtXWebEngine " , " qtwebengine " } ,
{ QtWebEngineWidgetsModule , " webenginewidgets " , " QtXWebEngineWidgets " , nullptr } ,
{ Qt3DCoreModule , " 3dcore " , " QtX3DCore " , nullptr } ,
{ Qt3DRendererModule , " 3drenderer " , " QtX3DRender " , nullptr } ,
{ Qt3DQuickModule , " 3dquick " , " QtX3DQuick " , nullptr } ,
{ Qt3DQuickRendererModule , " 3dquickrenderer " , " QtX3DQuickRender " , nullptr } ,
{ Qt3DInputModule , " 3dinput " , " QtX3DInput " , nullptr } ,
{ Qt3DAnimationModule , " 3danimation " , " QtX3DAnimation " , nullptr } ,
{ Qt3DExtrasModule , " 3dextras " , " QtX3DExtras " , nullptr } ,
{ QtLocationModule , " geoservices " , " QtXLocation " , nullptr } ,
{ QtWebChannelModule , " webchannel " , " QtXWebChannel " , nullptr } ,
{ QtTextToSpeechModule , " texttospeech " , " QtXTextToSpeech " , nullptr } ,
{ QtSerialBusModule , " serialbus " , " QtXSerialBus " , nullptr } ,
2021-03-03 14:10:53 +03:00
{ QtWebViewModule , " webview " , " QtXWebView " , nullptr } ,
{ QtVirtualKeyboard , " virtualkeyboard " , " QtXVirtualKeyboard " , nullptr }
2019-01-27 15:37:19 +03:00
} ;
2019-09-03 18:15:05 +03:00
DeployCore : : QtModule DeployCore : : getQtModule ( const QString & path ) {
2020-11-17 18:15:58 +03:00
auto Qt = DeployCore : : isQtLib ( path ) ;
2019-08-31 22:22:26 +03:00
2020-11-17 18:15:58 +03:00
if ( ! Qt ) {
2019-09-03 18:15:05 +03:00
return DeployCore : : QtModule : : NONE ;
2019-08-31 22:22:26 +03:00
}
int modulesCount = sizeof ( qtModuleEntries ) / sizeof ( QtModuleEntry ) ;
auto lIbName = QFileInfo ( path ) . fileName ( ) ;
for ( int i = 0 ; i < modulesCount ; + + i ) {
2020-11-28 20:02:51 +03:00
if ( containsModule ( qtModuleEntries [ i ] . libraryName , lIbName ) ) {
2019-09-03 18:15:05 +03:00
return static_cast < DeployCore : : QtModule > ( qtModuleEntries [ i ] . module ) ;
2019-08-31 22:22:26 +03:00
}
}
2019-09-03 18:15:05 +03:00
return DeployCore : : QtModule : : NONE ;
2019-08-31 22:22:26 +03:00
}
2019-09-03 18:15:05 +03:00
void DeployCore : : addQtModule ( DeployCore : : QtModule & module , const QString & path ) {
2019-09-04 16:06:28 +03:00
2021-05-01 00:31:15 +03:00
QuasarAppUtils : : Params : : log ( " Current module " + QString : : number ( module ) ,
2020-07-29 18:12:55 +03:00
QuasarAppUtils : : Debug ) ;
2019-09-04 16:37:31 +03:00
2019-09-04 16:06:28 +03:00
auto mod = getQtModule ( path ) ;
2021-05-01 00:31:15 +03:00
QuasarAppUtils : : Params : : log ( " Add new module from path " + path +
2019-09-04 16:06:28 +03:00
" module value " + QString : : number ( mod ) ,
2020-07-29 18:12:55 +03:00
QuasarAppUtils : : Debug ) ;
2019-09-04 16:06:28 +03:00
2019-09-03 18:15:05 +03:00
module = static_cast < DeployCore : : QtModule > (
2019-09-04 16:06:28 +03:00
static_cast < quint64 > ( module ) | static_cast < quint64 > ( mod ) ) ;
2019-08-31 22:22:26 +03:00
}
2021-04-22 11:14:33 +03:00
bool DeployCore : : isGui ( DeployCore : : QtModule module ) {
DeployCore : : QtModule guiModules =
static_cast < DeployCore : : QtModule > ( DeployCore : : QtGuiModule |
DeployCore : : QtOpenGLModule |
DeployCore : : QtQmlModule |
DeployCore : : QtQuickModule ) ;
return guiModules & module ;
}
2019-09-03 18:15:05 +03:00
LibPriority DeployCore : : getLibPriority ( const QString & lib ) {
2018-12-09 17:35:07 +03:00
if ( ! QFileInfo ( lib ) . isFile ( ) ) {
2019-03-25 21:27:26 +03:00
return NotFile ;
2018-12-09 17:35:07 +03:00
}
if ( isQtLib ( lib ) ) {
2019-03-25 21:27:26 +03:00
return QtLib ;
2018-12-09 17:35:07 +03:00
}
if ( isExtraLib ( lib ) ) {
2019-03-25 21:27:26 +03:00
return ExtraLib ;
2018-12-09 17:35:07 +03:00
}
2020-02-25 15:18:14 +03:00
if ( isAlienLib ( lib ) ) {
return AlienLib ;
}
2020-10-14 20:32:38 +03:00
if ( isAllowedLib ( lib ) ) {
return AllowedLib ;
}
2019-04-04 18:11:38 +03:00
return SystemLib ;
2018-12-09 17:35:07 +03:00
}
2020-11-28 20:02:51 +03:00
bool DeployCore : : containsModule ( const QString & moduleLibrary , const QString & lib ) {
QRegExp erfexp ( QString ( moduleLibrary ) . replace ( " QtX " , " Qt[4,5,6] " ) ) ;
return lib . contains ( erfexp ) ;
}
2019-08-24 17:56:42 +03:00
# define C(X) QuasarAppUtils::Params::isEndable(X)
2019-09-03 18:15:05 +03:00
RunMode DeployCore : : getMode ( ) {
2019-08-24 17:56:42 +03:00
if ( C ( " help " ) | | C ( " h " ) | | C ( " v " ) | | C ( " version " ) ) {
return RunMode : : Info ;
}
2020-01-24 13:57:55 +03:00
if ( C ( " init " ) ) {
return RunMode : : Init ;
}
2021-01-10 20:25:22 +03:00
if ( C ( " getDefaultTemplate " ) ) {
return RunMode : : Template ;
}
2020-12-04 17:13:12 +03:00
if ( C ( " bin " ) | | C ( " extraData " ) ) {
2019-08-24 17:56:42 +03:00
return RunMode : : Deploy ;
}
if ( C ( " clear " ) | | C ( " force-clear " ) ) {
return RunMode : : Clear ;
}
return RunMode : : Info ;
}
2021-07-28 12:39:25 +03:00
QuasarAppUtils : : OptionsDataList DeployCore : : avilableOptions ( ) {
2021-07-27 18:00:52 +03:00
QString group = " Part 1 Boolean options " ;
2021-07-28 12:39:25 +03:00
QuasarAppUtils : : OptionsDataList help = { } ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " init " } , " " ,
2021-07-27 18:00:52 +03:00
" will initialize cqtdeployer.json file (configuration file). " ,
" 'cqtdeployer init' - for initialize base package configuration. "
" 'cqtdeployer -init multi' - for initialize multi package configuration "
" 'cqtdeployer -init single' - for initialize singel package configuration "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " clear " } , " " ,
" Deletes deployable files of the previous session. "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " force-clear " } , " " ,
" Deletes the destination directory before deployment. "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " noStrip " } , " " ,
" Skips strip step "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " noTranslations " } , " " ,
" Skips the translations files. It doesn't work without qmake. "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " noOverwrite " } , " " ,
" Prevents replacing existing files. "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " noCheckRPATH " } , " " ,
" Disables automatic search of paths to qmake in executable files. "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " noCheckPATH " } , " " ,
" Disables automatic search of paths to qmake in system PATH. "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " noRecursiveiIgnoreEnv " } , " " ,
" Disables recursive ignore for ignoreEnv option. "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " v " , " version " } , " " ,
2021-07-27 18:00:52 +03:00
" Shows compiled version "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " h " , " help " } , " " ,
" Show all help or help of the selected options. "
" You can add any another option to a command line for show help about using options "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " qif " , " -qif " } , " " ,
" Create the QIF installer for deployment programm "
" You can specify the path to your own installer template. " ,
" Examples: cqtdeployer -qif path/to/myCustom/qif. "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " qifFromSystem " } , " " ,
" force use system binarycreator tool of qif from path or qt "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " zip " } , " " ,
" Create the ZIP arhive for deployment programm "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " deb " , " -deb " } , " " ,
" Create the deb package for deployment programm "
" You can specify the path to your own debian template. " ,
" cqtdeployer -deb path/to/myCustom/DEBIAN. "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " deploySystem " } , " " ,
" Deploys all libraries. "
" Not recomendet because there may be conflicts with system libraries "
" (on snap version you need to turn on permission) "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " noQt " } , " " ,
" Ignors the error of initialize of a qmake. Use only if your application does not use the qt framework. "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " allowEmptyPackages " } , " " ,
" Allows configure the empty packages. "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " getDefaultTemplate " } , " " ,
" Extracts defaults deb or qif templates. "
" All templates extract into targetDirectory. "
" For change target directory use the targetDir option. " ,
" cqtdeployer -bin myExecutable getDefaultTemplate qif deb. "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " noHashSum " } , " " ,
" This option disable computation of a packages hash sum "
} } ) ;
group = " Part 2 Deploy options " ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " -bin " } , " {list,params} " ,
" Files to deploy or folders that contain files to deploy. " ,
" -bin ~/my/project/bin/,~/my/project/bin.exe,~/my/project/runtimeLinking/lib.dll. "
" For files: These files will be unconditional copied to the destination directory, "
" regardless of their format or suffix. "
" For folders: "
" CCQtDeployer will enter these folders and non-recursively copy all executable files to the destination directory. "
" Then, CQtDeployer will extract all dependencies of the copied files and search dependencies in system environments and libDir paths. "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " -binPrefix " } , " {prefixPath} " ,
" Sets prefix path for bin option. " ,
" -bin path/MyExecutable is some as -bin MyExecutable -binPrefix path "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " -confFile " } , " {params} " ,
" The path to the json file with all deployment configurations. Using this file, "
" you can add the necessary options, thereby simplifying the command invocation in the console. "
" However, the parameters in Kansol have a higher priority than in the file. "
" For more info about this flag see https://github.com/QuasarApp/CQtDeployer/wiki/DeployConfigFileEn "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " -qmlDir " } , " {params} " ,
" Sets path to Qml data dir " ,
" -qmlDir ~/my/project/qml "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " -qmake " } , " {params} " ,
" Sets path to the qmake executable. " ,
" -qmake ~/Qt/bin/qmake or -qmake ~/Qt/bin/qmake.exe "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " -ignore " } , " {list,params} " ,
" Sets the list of libs to ignore. " ,
" -ignore libicudata.so.56,libicudata2.so.56 "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " -ignoreEnv " } , " {list,params} " ,
" Sets the list of the environment to ignore. " ,
" -ignoreEnv /bad/dir,/my/bad/Dir "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " -libDir " } , " {list,params} " ,
" Sets additional paths for extra libs of an app. " ,
" -libDir ~/myLib,~/newLibs "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " -extraLibs " } , " {list,params} " ,
" Sets the mask of the library name for forced copying. " ,
" \" -extraLib mySql \" - forces to copy all libraries whose names contain mySql to the project folder. "
" This option is case-insensitive on Windows and case-sensitive on other platforms. "
" This option will only search libraries in system environments similar to **deploySystem**. "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " -customScript " } , " {scriptCode} " ,
" Insert extra code inTo All run script. " ,
" " ,
" This option will be removed into next release cqtdeployer. "
" Please use the runScript option "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " -recursiveDepth " } , " {params} " ,
" Sets the Depth of recursive search of libs and depth for ignoreEnv option (default 0) "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " -targetDir " } , " {params} " ,
" Sets target directory(by default it is the path to the first deployable file) "
} } ) ;
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
2021-07-27 18:00:52 +03:00
{ " -runScript " } , " {list,parems} " ,
" forces cqtdeployer swap default run script to new from the arguments of option. "
" This option copy all content from input file and insert all code into runScript.sh or .bat " ,
" cqtdeployer -runScript \" myTargetMame;path/to/my/myCustomLaunchScript.sh,myTargetSecondMame;path/to/my/mySecondCustomLaunchScript.sh \" "
} } ) ;
2020-02-19 19:26:46 +03:00
2021-07-28 12:39:25 +03:00
group = " Part 3 Control of packages options " ;
2021-02-12 16:10:22 +03:00
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -targetPackage " } , " {package;tar1,package;tar2} " ,
" Creates a new package and adds 'tar1 and tar2' to it. "
" If you want configure the package that do not have any targets use the allowEmptyPackages option. "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -qmlOut " } , " {package;path,path} " ,
" Sets path to qml out directory "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -libOut " } , " {package;path,path} " ,
" Sets path to libraries out directory "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -trOut " } , " {package;path,path} " ,
" Sets path to Sets path to translations out directory "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -pluginOut " } , " {package;path,path} " ,
" Sets path to plugins out directory "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -binOut " } , " {package;path,path} " ,
" Sets path to binary out directory "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -recOut " } , " {package;path,path} " ,
" Sets path to recurses out directory "
} } ) ;
2020-11-10 14:07:54 +03:00
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -extraDataOut " } , " {package;path,path} " ,
" Sets path to extra data files out directory. By Default it is root dir of the distribution. "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -name " } , " {package;val,val} " ,
" Sets name for a package. "
" If this if you do not specify a package, the value will be assigned to the default package ( " " ) "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -description " } , " {package;val,val} " ,
" Sets description for a package "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -deployVersion " } , " {package;val,val} " ,
" Sets version for a package "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -releaseDate " } , " {package;val,val} " ,
" Sets release date for a package "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -publisher " } , " {package;val,val} " ,
" Sets publisher for a package "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -homePage " } , " {package;val,val} " ,
" Sets the home page url for a package "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -prefix " } , " {package;val,val} " ,
" Sets the prefix for the package relatively a target directory "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -extraData " } , " {package;val,val} " ,
" Adds the extra files or directories like a target. The selected directory will be copy to the extraDataOut location with save own structure. "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -tr " } , " {package;val,val} " ,
" Adds qm files into the translations folder. "
} } ) ;
2020-03-04 18:08:05 +03:00
2021-07-28 12:39:25 +03:00
group = " Part 4 Control of packages options " ;
2021-06-09 14:22:03 +03:00
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -icon " } , " {target;val,val} " ,
" Sets path to icon for a targets "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -disableRunScript " } , " {package;val,val} " ,
" Disables a generation of run script for selected targets "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -disableShortCut " } , " {package;val,val} " ,
" Disables a generation of shortcut for selected targets "
} } ) ;
2021-02-26 20:24:06 +03:00
2021-07-28 12:39:25 +03:00
group = " Part 5 Plugins Control Options " ;
2020-02-20 10:35:00 +03:00
2021-07-28 12:39:25 +03:00
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -extraPlugin " } , " {package;val1;val2,SingeleVal} " ,
" Sets an additional path to third-party application plug-in "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -enablePlugins " } , " {package;val1;val2,SingeleVa} " ,
" Enables additional plugins for distribution. "
" By default disabled next plugins: " + PluginsParser : : defaultForbidenPlugins ( ) . join ( ' , ' ) + " if you want enable "
" it then use '-enablePlugins " + PluginsParser : : defaultForbidenPlugins ( ) . join ( ' , ' ) + " ' option "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -disablePlugins " } , " {package;val1;val2,SingeleVal} " ,
" Disables plugins for distribution. "
" You can disable any plugin of your Qt build, just see the yourQtFolder/plugins forlder for available plugins. "
" Example if you want disable qxcb plugin: -disablePlugins qxcb. "
" Note that the name of the plugin is indicated without its extension "
} } ) ;
group = " Part 6 QtInstallFramework options " ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -qifStyle " } , " {path/to/style.css} " ,
" Sets the path to the CSS style file or sets the default style. "
" Available styles: quasar, quasarDark "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -qifBanner " } , " {path/to/banner.png} " ,
" Sets path to the banner png file. "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -qifLogo " } , " {path/to/logo.png} " ,
" Sets path to the logo png file. "
} } ) ;
help . insert ( group , { QuasarAppUtils : : OptionData {
{ " -qifOut " } , " {nameOfOutputInstallerFile} " ,
" Sets name of output qifw installer. Note: on Windows, the exe suffix will be added to the installer automatically. "
} } ) ;
return help ;
}
void DeployCore : : help ( ) {
auto localHelp = QuasarAppUtils : : Params : : getHelpOfInputOptions ( ) ;
if ( ! localHelp . isEmpty ( ) ) {
QuasarAppUtils : : Help : : print ( localHelp ) ;
return ;
}
// help extra data;
QuasarAppUtils : : Help : : Charters help = {
2020-03-04 18:08:05 +03:00
{
2021-07-28 12:39:25 +03:00
" Part 0 General " , {
{ " CQtDeployer version " , getAppVersion ( ) } ,
{ " Usage " , " cqtdeployer <-bin [params]> [options] " } ,
2020-03-04 18:08:05 +03:00
}
2020-08-27 18:57:33 +03:00
} ,
{
" Support " , {
{ " Support for you " , " If you have any questions or problems with cqtdeployer you can write to us about the problem on the GitHub page: https://github.com/QuasarApp/CQtDeployer/issues " } ,
{ " Support for us " , " If you liked cqtdeployer, then you can join any patreon plan of your choice for support us: https://www.patreon.com/QuasarApp " } ,
}
2020-02-19 19:26:46 +03:00
}
} ;
2021-07-28 12:39:25 +03:00
help + = QuasarAppUtils : : Params : : getHelp ( ) ;
2020-02-19 19:26:46 +03:00
2021-04-30 12:40:33 +03:00
QuasarAppUtils : : Help : : print ( help ) ;
2020-02-19 19:26:46 +03:00
2020-02-20 11:02:01 +03:00
return ;
2018-12-15 20:51:25 +03:00
}
2019-12-15 18:30:24 +03:00
QStringList DeployCore : : extractTranslation ( const QSet < QString > & libs ) {
2019-01-27 15:37:19 +03:00
QSet < QString > res ;
const size_t qtModulesCount = sizeof ( qtModuleEntries ) / sizeof ( QtModuleEntry ) ;
2020-01-12 16:43:03 +03:00
for ( const auto & lib : libs ) {
2019-01-27 15:37:19 +03:00
for ( size_t i = 0 ; i < qtModulesCount ; + + i ) {
2020-11-28 20:02:51 +03:00
if ( containsModule ( qtModuleEntries [ i ] . libraryName , lib ) & & qtModuleEntries [ i ] . translation ) {
2019-01-27 15:37:19 +03:00
res . insert ( qtModuleEntries [ i ] . translation ) ;
}
}
}
2020-02-20 10:35:00 +03:00
return res . values ( ) ;
2019-01-27 15:37:19 +03:00
}
2019-09-03 18:15:05 +03:00
QString DeployCore : : getAppVersion ( ) {
2019-08-12 18:05:28 +03:00
return APP_VERSION ;
}
2020-03-22 11:52:08 +03:00
QString DeployCore : : getAppVersionName ( ) {
2020-03-24 15:38:34 +03:00
return " *** Binary Box *** " ;
2020-03-22 11:52:08 +03:00
}
2019-09-03 18:15:05 +03:00
QString DeployCore : : getQtVersion ( ) {
2019-08-12 18:05:28 +03:00
# ifdef QT_VERSION_STR
return QT_VERSION_STR ;
# else
return " without qt " ;
# endif
}
2019-09-03 18:15:05 +03:00
void DeployCore : : printVersion ( ) {
2020-04-04 15:43:46 +03:00
std : : cout < < QString { " CQtDeployer: " + getAppVersion ( ) + " " + getAppVersionName ( ) } . toStdString ( ) < < std : : endl ;
std : : cout < < QString { " Qt: " + getQtVersion ( ) } . toStdString ( ) < < std : : endl ;
2019-08-12 18:05:28 +03:00
}
2019-09-15 11:31:31 +03:00
bool DeployCore : : isExecutable ( const QFileInfo & file ) {
2019-08-28 17:23:49 +03:00
auto sufix = file . completeSuffix ( ) ;
return sufix . contains ( " exe " , Qt : : CaseInsensitive ) | | sufix . contains ( " run " , Qt : : CaseInsensitive ) | | sufix . isEmpty ( ) ;
}
2020-01-02 19:27:40 +03:00
bool DeployCore : : isContainsArraySeparators ( const QString & val , int lastLvl ) {
while ( lastLvl ) {
if ( val . contains ( getSeparator ( - - lastLvl ) ) )
return true ;
}
return false ;
}
2020-01-28 13:51:00 +03:00
QString DeployCore : : findProcess ( const QString & env , const QString & proc ) {
auto list = env . split ( DeployCore : : getEnvSeparator ( ) ) ;
for ( const auto & path : list ) {
auto files = QDir ( path ) . entryInfoList ( QDir : : NoDotAndDotDot | QDir : : Files ) ;
for ( const auto & bin : files ) {
2020-02-07 17:33:36 +03:00
if ( bin . baseName ( ) . compare ( proc , ONLY_WIN_CASE_INSENSIATIVE ) = = 0 ) {
2020-01-28 13:51:00 +03:00
return bin . absoluteFilePath ( ) ;
}
}
}
return " " ;
}
2020-11-18 09:51:10 +03:00
QStringList DeployCore : : debugExtensions ( ) {
return { " .debug " , " d.dll " , " .pdb " } ;
}
bool DeployCore : : isDebugFile ( const QString & file ) {
auto debug = debugExtensions ( ) ;
for ( const auto & debugEx : debug ) {
if ( file . contains ( debugEx , ONLY_WIN_CASE_INSENSIATIVE ) ) {
return true ;
}
}
return false ;
}
2019-09-08 13:37:33 +03:00
int DeployCore : : find ( const QString & str , const QStringList & list ) {
for ( int i = 0 ; i < list . size ( ) ; + + i ) {
if ( list [ i ] . contains ( str ) )
return i ;
}
return - 1 ;
}
bool DeployCore : : isLib ( const QFileInfo & file ) {
return file . completeSuffix ( ) . contains ( " so " , Qt : : CaseInsensitive )
| | file . completeSuffix ( ) . contains ( " dll " , Qt : : CaseInsensitive ) ;
}
2019-11-01 15:12:03 +03:00
MSVCVersion DeployCore : : getMSVC ( const QString & _qtBin ) {
2019-03-28 10:32:46 +03:00
int res = MSVCVersion : : MSVC_Unknown ;
2019-11-01 15:12:03 +03:00
QDir dir = QFileInfo ( _qtBin ) . absoluteFilePath ( ) ;
2019-03-28 10:32:46 +03:00
if ( ! dir . cdUp ( ) ) {
2021-05-02 12:19:16 +03:00
QuasarAppUtils : : Params : : log ( " is not a standard qt repo " , QuasarAppUtils : : Debug ) ;
2019-03-28 10:32:46 +03:00
return static_cast < MSVCVersion > ( res ) ;
}
auto msvcPath = dir . absolutePath ( ) ;
if ( ! ( dir . cdUp ( ) & & dir . cdUp ( ) ) ) {
2021-05-02 12:19:16 +03:00
QuasarAppUtils : : Params : : log ( " is not a standard qt repo " , QuasarAppUtils : : Debug ) ;
2019-03-28 10:32:46 +03:00
return static_cast < MSVCVersion > ( res ) ;
}
if ( ! msvcPath . contains ( " msvc " ) ) {
2021-05-02 12:19:16 +03:00
QuasarAppUtils : : Params : : log ( " vcredist not defined " , QuasarAppUtils : : Debug ) ;
2019-03-28 10:32:46 +03:00
return static_cast < MSVCVersion > ( res ) ;
}
auto base = msvcPath . mid ( msvcPath . indexOf ( " msvc " ) , 11 ) ;
auto version = base . mid ( 4 , 4 ) ;
auto type = base . right ( 2 ) ;
if ( version = = " 2013 " ) {
res | = MSVC_13 ;
}
else if ( version = = " 2015 " ) {
res | = MSVC_15 ;
}
else if ( version = = " 2017 " ) {
res | = MSVC_17 ;
}
else if ( version = = " 2019 " ) {
res | = MSVC_19 ;
}
if ( type = = " 32 " ) {
res | = MSVC_x32 ;
}
else if ( type = = " 64 " ) {
res | = MSVC_x64 ;
}
return static_cast < MSVCVersion > ( res ) ;
}
2019-11-01 15:12:03 +03:00
QString DeployCore : : getVCredist ( const QString & _qtbinDir ) {
auto msvc = getMSVC ( _qtbinDir ) ;
2019-03-28 12:36:21 +03:00
2019-11-01 15:12:03 +03:00
QDir dir = _qtbinDir ;
2019-03-28 12:36:21 +03:00
if ( ! ( dir . cdUp ( ) & & dir . cdUp ( ) & & dir . cdUp ( ) & & dir . cd ( " vcredist " ) ) ) {
2021-05-01 00:31:15 +03:00
QuasarAppUtils : : Params : : log ( " vcredist not found! " ) ;
2019-03-28 12:36:21 +03:00
return " " ;
}
auto infoList = dir . entryInfoList ( QDir : : Files | QDir : : NoDotAndDotDot ) ;
auto name = getMSVCName ( msvc ) ;
auto version = getMSVCVersion ( msvc ) ;
2020-01-12 16:43:03 +03:00
for ( const auto & info : infoList ) {
2019-11-01 15:12:03 +03:00
auto file = info . fileName ( ) ;
if ( file . contains ( name , Qt : : CaseInsensitive ) & &
file . contains ( version , Qt : : CaseInsensitive ) ) {
2019-03-28 12:36:21 +03:00
return info . absoluteFilePath ( ) ;
}
}
return " " ;
}
2019-09-03 18:15:05 +03:00
QString DeployCore : : getMSVCName ( MSVCVersion msvc ) {
2019-03-28 12:36:21 +03:00
if ( msvc | MSVCVersion : : MSVC_13 ) {
return " msvc2013 " ;
} else if ( msvc | MSVCVersion : : MSVC_15 ) {
return " msvc2015 " ;
} else if ( msvc | MSVCVersion : : MSVC_17 ) {
return " msvc2017 " ;
} else if ( msvc | MSVCVersion : : MSVC_19 ) {
return " msvc2019 " ;
}
return " " ;
}
2019-09-03 18:15:05 +03:00
QString DeployCore : : getMSVCVersion ( MSVCVersion msvc ) {
2019-03-28 12:36:21 +03:00
if ( msvc | MSVCVersion : : MSVC_x32 ) {
return " x86 " ;
} else if ( msvc | MSVCVersion : : MSVC_x64 ) {
return " x64 " ;
}
2019-03-28 10:32:46 +03:00
return " " ;
}
2020-11-05 12:57:41 +03:00
QtMajorVersion DeployCore : : isQtLib ( const QString & lib ) {
2020-10-14 13:17:26 +03:00
QFileInfo info ( lib ) ;
2021-05-24 18:35:22 +03:00
QtMajorVersion isQt = isQtLibName ( lib ) ;
if ( _config & & ! _config - > qtDir . isQt ( info . absoluteFilePath ( ) ) ) {
return QtMajorVersion : : NoQt ;
}
return isQt ;
}
QtMajorVersion DeployCore : : isQtLibName ( const QString & lib ) {
QFileInfo info ( lib ) ;
/*
* Task https : //github.com/QuasarApp/CQtDeployer/issues/422
* All qt libs need to contains the Qt label .
*/
2020-11-05 12:57:41 +03:00
QtMajorVersion isQt = QtMajorVersion : : NoQt ;
2020-10-13 22:38:16 +03:00
2020-11-05 12:57:41 +03:00
if ( ! isLib ( info ) ) {
return isQt ;
}
QString fileName = info . fileName ( ) ;
if ( fileName . contains ( " Qt4 " , ONLY_WIN_CASE_INSENSIATIVE ) ) {
isQt = QtMajorVersion : : Qt4 ;
} else if ( fileName . contains ( " Qt5 " , ONLY_WIN_CASE_INSENSIATIVE ) ) {
isQt = QtMajorVersion : : Qt5 ;
} else if ( fileName . contains ( " Qt6 " , ONLY_WIN_CASE_INSENSIATIVE ) ) {
isQt = QtMajorVersion : : Qt6 ;
}
2020-01-28 15:25:35 +03:00
2020-10-13 22:38:16 +03:00
if ( isQt & & QuasarAppUtils : : Params : : isEndable ( " noQt " ) & &
! QuasarAppUtils : : Params : : isEndable ( " qmake " ) ) {
2020-11-05 12:57:41 +03:00
return QtMajorVersion : : NoQt ;
2020-01-28 14:48:53 +03:00
}
2020-10-13 22:38:16 +03:00
return isQt ;
2018-12-09 17:35:07 +03:00
}
2019-09-03 18:15:05 +03:00
bool DeployCore : : isExtraLib ( const QString & lib ) {
2018-12-09 17:35:07 +03:00
QFileInfo info ( lib ) ;
2019-11-05 13:17:52 +03:00
return _config - > extraPaths . contains ( info . absoluteFilePath ( ) ) ;
2018-12-09 17:35:07 +03:00
}
2019-12-12 18:16:31 +03:00
2020-02-25 15:18:14 +03:00
bool DeployCore : : isAlienLib ( const QString & lib ) {
return lib . contains ( " /opt/ " , ONLY_WIN_CASE_INSENSIATIVE ) | |
2020-10-12 22:23:36 +03:00
lib . contains ( " /PROGRAM FILES " , ONLY_WIN_CASE_INSENSIATIVE ) ;
}
2020-10-14 20:32:38 +03:00
bool DeployCore : : isAllowedLib ( const QString & lib ) {
QFileInfo info ( lib ) ;
return _config - > allowedPaths . contains ( info . absoluteFilePath ( ) ) ;
}
2020-10-12 22:23:36 +03:00
QStringList DeployCore : : Qt3rdpartyLibs ( Platform platform ) {
QStringList result ;
result < < QStringList {
2021-06-11 11:47:48 +03:00
// SQL LIBS
2020-10-12 22:23:36 +03:00
// See task https://github.com/QuasarApp/CQtDeployer/issues/367
" libpq " ,
2021-06-11 11:47:48 +03:00
" mysqlclient " ,
// SLL Libs
// See task https://github.com/QuasarApp/CQtDeployer/issues/620
" libcrypto " ,
" libssl " ,
" libeay32 " ,
" ssleay32 " ,
2020-10-12 22:23:36 +03:00
} ;
if ( platform & Platform : : Win ) {
result < < QStringList {
// Qml Gl driver wraper
" d3dcompiler_47 " ,
" libEGL " ,
" libGLESv2 " ,
// gcc runtime libs ow mingw
" libgcc_s_seh " ,
2021-04-30 13:53:12 +08:00
" libgcc_s_dw2 " ,
2020-10-12 22:23:36 +03:00
" libstdc++ " ,
" libwinpthread " ,
// OpenglES libs
" opengl32sw " ,
} ;
}
if ( platform & Platform : : Unix ) {
result < < QStringList {
// Begin Unicode libs
" libicudata " ,
" libicui18n " ,
" libicuio " ,
" libicule " ,
" libiculx " ,
" libicutest " ,
" libicutu " ,
" libicuuc " ,
// End Unicode libs
2020-11-05 14:51:37 +03:00
// xcb plugin
" libxcb-xinerama " ,
2020-11-15 21:23:14 +03:00
// qt GUI
" libpng " ,
" libjpeg "
2020-10-12 22:23:36 +03:00
} ;
}
return result ;
2020-02-25 15:18:14 +03:00
}
2019-12-12 18:16:31 +03:00
QChar DeployCore : : getSeparator ( int lvl ) {
switch ( lvl ) {
case 0 : return ' , ' ;
case 1 : return ' ; ' ;
default :
return ' \0 ' ;
}
}
2020-01-16 11:10:16 +03:00
char DeployCore : : getEnvSeparator ( ) {
# ifdef Q_OS_UNIX
return ' : ' ;
# else
return ' ; ' ;
# endif
}
2020-01-18 16:38:40 +03:00
2020-07-28 23:56:34 +03:00
bool DeployCore : : isSnap ( ) {
return QProcessEnvironment : : systemEnvironment ( ) . value ( " SNAP " ) . size ( ) ;
}
QString DeployCore : : snapRootFS ( ) {
return " /var/lib/snapd/hostfs " ;
}
QString DeployCore : : transportPathToSnapRoot ( const QString & path ) {
2020-07-30 10:39:13 +03:00
if ( isSnap ( ) & & checkSystemBakupSnapInterface ( ) ) {
2020-07-28 23:56:34 +03:00
2020-10-15 09:49:52 +03:00
if ( QFileInfo ( path ) . isWritable ( ) ) {
return path ;
}
2020-07-28 23:56:34 +03:00
if ( path . size ( ) & & path [ 0 ] ! = " / " ) {
auto absalutPath = QProcessEnvironment : : systemEnvironment ( ) . value ( " PWD " ) + " / " + path ;
if ( ! absalutPath . contains ( DeployCore : : snapRootFS ( ) ) ) {
return snapRootFS ( ) + " / " + absalutPath ;
}
}
if ( ! path . contains ( DeployCore : : snapRootFS ( ) ) ) {
return snapRootFS ( ) + " / " + path ;
}
}
return path ;
}
2020-07-30 10:39:13 +03:00
bool DeployCore : : checkSystemBakupSnapInterface ( ) {
return QDir ( DeployCore : : snapRootFS ( ) ) . entryList ( QDir : : AllEntries | QDir : : NoDotAndDotDot ) . size ( ) ;
}
2021-03-01 09:44:59 +03:00
void DeployCore : : printInternalError ( const char * function , const char * file , int line ) {
QuasarAppUtils : : Params : : log ( QString ( " Internal error ocurred in %0 (%1:%2). " ) . arg ( function , file ) . arg ( line ) ,
QuasarAppUtils : : Error ) ;
QuasarAppUtils : : Params : : log ( QString ( " If you see this message please create a new issue "
" about this problem on the official github page "
" https://github.com/QuasarApp/CQtDeployer/issues/new/choose. " ) ,
QuasarAppUtils : : Error ) ;
2021-07-01 17:07:14 +03:00
}
2021-07-02 16:59:45 +03:00
QFileInfo DeployCore : : findItem ( const QString & bin ) {
2021-07-01 17:07:14 +03:00
auto prefixes = QuasarAppUtils : : Params : : getArg ( " binPrefix " ) .
split ( DeployCore : : getSeparator ( 0 ) , splitbehavior ) ;
for ( const QString & prefix : qAsConst ( prefixes ) ) {
QFileInfo info ( prefix + " / " + bin ) ;
2021-07-02 16:59:45 +03:00
if ( info . exists ( ) ) {
2021-07-01 17:07:14 +03:00
return info ;
}
}
return QFileInfo ( bin ) ;
2021-03-01 09:44:59 +03:00
} ;
2021-01-11 19:15:50 +03:00
QString DeployCore : : systemLibsFolderName ( ) {
return " systemLibs " ;
}
2021-03-03 14:10:53 +03:00
QString DeployCore : : getLibCoreName ( const QFileInfo & info ) {
auto baseName = info . baseName ( ) ;
QString result ; if ( baseName . left ( 3 ) = = " lib " ) {
result = baseName . mid ( 3 ) ;
} else {
result = baseName ;
}
return result ;
}
2019-12-24 11:46:11 +03:00
uint qHash ( WinAPI i ) {
return static_cast < uint > ( i ) ;
}