基本可用版本
This commit is contained in:
parent
f29fbb9825
commit
f0120af7de
@ -34,6 +34,7 @@ set(PROJECT_SOURCES
|
|||||||
MainWidget.cpp
|
MainWidget.cpp
|
||||||
MainWidget.h
|
MainWidget.h
|
||||||
MainWidget.ui
|
MainWidget.ui
|
||||||
|
packqt.qrc
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#include "MainWidget.h"
|
#include "MainWidget.h"
|
||||||
#include "./ui_MainWidget.h"
|
#include "./ui_MainWidget.h"
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
MainWidget::MainWidget(QWidget* parent) : QWidget(parent), ui(new Ui::MainWidget)
|
MainWidget::MainWidget(QWidget* parent) : QWidget(parent), ui(new Ui::MainWidget)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setWindowTitle("打包Qt工具");
|
setWindowTitle("打包Qt工具 v0.9");
|
||||||
connect_operator();
|
connect_operator();
|
||||||
control_init();
|
control_init();
|
||||||
}
|
}
|
||||||
@ -251,11 +253,31 @@ void MainWidget::generate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 复制platform文件夹
|
// 复制platform文件夹
|
||||||
// fs::path qt_platform(ui->edQtDir->text().trimmed().toStdString());
|
copy_dir(qt_platform.string(), out_dir.string());
|
||||||
// qt_platform.append("plugins/platforms");
|
|
||||||
// copy_dir(qt_platform.string(), out_dir.string());
|
|
||||||
|
|
||||||
// 复制主体文件
|
// 复制主体文件
|
||||||
fs::path out_binary = fs::path(out_dir).append(fs::path(binary_.toStdString()).filename());
|
fs::path out_binary = fs::path(out_dir).append(fs::path(binary_.toStdString()).filename());
|
||||||
fs::copy_file(binary_.toStdString(), out_binary, fs::copy_options::overwrite_existing);
|
fs::copy_file(binary_.toStdString(), out_binary, fs::copy_options::overwrite_existing);
|
||||||
|
|
||||||
|
// 生成一个启动文件夹
|
||||||
|
QFile file("://resource/run.sh");
|
||||||
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QTextStream in(&file);
|
||||||
|
// 读取文件内容
|
||||||
|
QString content = in.readAll();
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
std::string run_sh = content.toStdString();
|
||||||
|
boost::replace_all(run_sh, "replace_string", fs::path(binary_.toStdString()).filename().string());
|
||||||
|
|
||||||
|
std::string out_sh = fs::path(out_dir).append("run.sh").string();
|
||||||
|
std::ofstream out(out_sh, std::ios::out);
|
||||||
|
if (!out.is_open()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
out << run_sh;
|
||||||
|
out.close();
|
||||||
|
system(std::string("chmod +x " + out_sh).c_str());
|
||||||
}
|
}
|
5
packqt.qrc
Normal file
5
packqt.qrc
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>resource/run.sh</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
10
resource/run.sh
Normal file
10
resource/run.sh
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 获取脚本所在目录的绝对路径
|
||||||
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||||
|
|
||||||
|
# 将脚本所在目录添加到 LD_LIBRARY_PATH 环境变量
|
||||||
|
export LD_LIBRARY_PATH="$SCRIPT_DIR"
|
||||||
|
|
||||||
|
# 执行其他操作
|
||||||
|
./replace_string
|
Loading…
x
Reference in New Issue
Block a user