apro:优化。
This commit is contained in:
parent
40466ed3b4
commit
b5e518e887
@ -276,13 +276,13 @@ void MainWidget::generate()
|
||||
// 复制主体文件
|
||||
fs::path out_binary = fs::path(out_dir).append(fs::path(binary_.toStdString()).filename().string());
|
||||
fs::copy_file(binary_.toStdString(), out_binary, fs::copy_options::overwrite_existing);
|
||||
if (!add_run_sh(out_dir.string(), filename)) {
|
||||
if (!add_run_sh(out_dir.string(), filename, std::vector<std::string>())) {
|
||||
return;
|
||||
}
|
||||
message(this, "完成");
|
||||
}
|
||||
|
||||
bool MainWidget::add_run_sh(const std::string& out_dir, const std::string& exe_name)
|
||||
bool MainWidget::add_run_sh(const std::string& out_dir, const std::string& exe_name, const std::vector<std::string>& exports)
|
||||
{
|
||||
// 生成一个启动文件夹
|
||||
QFile file("://resource/run.sh");
|
||||
@ -295,9 +295,14 @@ bool MainWidget::add_run_sh(const std::string& out_dir, const std::string& exe_n
|
||||
file.close();
|
||||
|
||||
std::string run_sh = content.toStdString();
|
||||
|
||||
run_sh = COfStr::replace(run_sh, "replace_string", exe_name);
|
||||
// REPLACE_EXPORT
|
||||
|
||||
std::string outs{};
|
||||
for (const auto& item : exports) {
|
||||
outs = outs + "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:" + item + "\n";
|
||||
}
|
||||
run_sh = COfStr::replace(run_sh, "REPLACE_EXPORT", outs);
|
||||
std::string out_sh = fs::path(out_dir).append(exe_name + ".sh").string();
|
||||
std::ofstream out(out_sh, std::ios::out);
|
||||
if (!out.is_open()) {
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
static bool isOk(QWidget* parent, const QString& title, const QString& content);
|
||||
static void message(QWidget* parent, const QString& content);
|
||||
static void cmd_exec(const std::string& cmd);
|
||||
static bool add_run_sh(const std::string& out_dir, const std::string& exe_name);
|
||||
static bool add_run_sh(const std::string& out_dir, const std::string& exe_name, const std::vector<std::string>& exports);
|
||||
|
||||
private:
|
||||
Ui::MainWidget* ui;
|
||||
|
@ -79,8 +79,14 @@ void AddDesktop::install_to_desktop()
|
||||
MainWidget::cmd_exec(cmodBin);
|
||||
MainWidget::cmd_exec(cmodSh);
|
||||
|
||||
std::vector<std::string> evs{};
|
||||
int env_cnt = ui->listWidget->count();
|
||||
for (int i = 0; i < env_cnt; ++i) {
|
||||
evs.push_back(ui->listWidget->item(i)->text().toStdString());
|
||||
}
|
||||
|
||||
if (!fs::exists(sh_path)) {
|
||||
MainWidget::add_run_sh(sh_path.parent_path().string(), binaryName);
|
||||
MainWidget::add_run_sh(sh_path.parent_path().string(), binaryName, evs);
|
||||
}
|
||||
fs::path tmp = fs::path(QDir::homePath().toStdString()).append(".config");
|
||||
if (!fs::exists(tmp)) {
|
||||
@ -95,7 +101,7 @@ void AddDesktop::install_to_desktop()
|
||||
ct = COfStr::replace(ct, "re_describe", binaryName);
|
||||
ct = COfStr::replace(ct, "re_path", "sh " + sh_path.string());
|
||||
|
||||
fs::path default_ico_path = fs::path(tmp).append("packqt");
|
||||
fs::path default_ico_path = fs::path(tmp).append("binpack");
|
||||
if (!fs::exists(default_ico_path)) {
|
||||
fs::create_directories(default_ico_path);
|
||||
}
|
||||
|
BIN
img/show.png
BIN
img/show.png
Binary file not shown.
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 33 KiB |
BIN
img/show2.png
BIN
img/show2.png
Binary file not shown.
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 26 KiB |
BIN
resource/binpack.png
Normal file
BIN
resource/binpack.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
@ -10,7 +10,8 @@ cd "$SCRIPT_DIR" || exit
|
||||
echo "当前目录是:$SCRIPT_DIR"
|
||||
|
||||
# 将脚本所在目录添加到 LD_LIBRARY_PATH 环境变量
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$SCRIPT_DIR":REPLACE
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$SCRIPT_DIR"
|
||||
REPLACE_EXPORT
|
||||
|
||||
# 定义 replace_string 脚本的绝对路径
|
||||
REPLACE_STRING_SCRIPT="$SCRIPT_DIR/replace_string"
|
||||
|
Loading…
x
Reference in New Issue
Block a user