add:去除boost依赖,修正编译。
This commit is contained in:
parent
b5b11a6056
commit
489f4fff58
@ -1,34 +1,17 @@
|
||||
# .clang-format
|
||||
|
||||
# 风格格式化
|
||||
BasedOnStyle: LLVM
|
||||
# 4 空格缩进
|
||||
IndentWidth: 4
|
||||
# 连续对齐变量的声明
|
||||
AlignConsecutiveDeclarations: true
|
||||
# 指针左侧对齐
|
||||
PointerAlignment: Left
|
||||
# 访问说明符(public、private等)的偏移
|
||||
AccessModifierOffset: -4
|
||||
# 大括号
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
# 函数定义后面大括号在新行
|
||||
AfterFunction: true
|
||||
# class定义后面
|
||||
AfterClass: true
|
||||
|
||||
# 去除C++11的列表初始化的大括号{后和}前的空格
|
||||
Cpp11BracedListStyle: true
|
||||
# 允许重新排版注释
|
||||
ReflowComments: true
|
||||
# 允许排序#include
|
||||
SortIncludes: true
|
||||
# 在尾随的评论前添加的空格数(只适用于//)
|
||||
SpacesBeforeTrailingComments: 3
|
||||
# tab宽度
|
||||
TabWidth: 4
|
||||
# 构造函数的初始化列表要么都在同一行,要么都各自一行
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
# 每行字符的限制,0表示没有限制
|
||||
ColumnLimit: 150
|
||||
ColumnLimit: 110
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "ofen"]
|
||||
path = ofen
|
||||
url = https://www.sinxmiao.cn/taynpg/ofen
|
117
.vscode/settings.json
vendored
117
.vscode/settings.json
vendored
@ -1,8 +1,9 @@
|
||||
{
|
||||
"files.autoSave": "onFocusChange",
|
||||
"editor.fontSize": 16,
|
||||
"editor.fontFamily": "'Operator Mono Lig', 'Operator Mono Lig', 'Operator Mono Lig'",
|
||||
"editor.fontSize": 13,
|
||||
"editor.fontFamily": "'Source Code Pro', 'Source Code Pro', 'Source Code Pro'",
|
||||
"cmake.configureOnOpen": true,
|
||||
"terminal.integrated.fontFamily": "Source Code Pro",
|
||||
"cmake.debugConfig": {
|
||||
"console": "integratedTerminal",
|
||||
"setupCommands": [
|
||||
@ -19,29 +20,109 @@
|
||||
"visualizerFile": "${workspaceRoot}/.vscode/qt6.natvis"
|
||||
},
|
||||
"cmake.environment": {
|
||||
"PATH": "${env:PATH};/home/typ/Qt5.14.2/5.14.2/gcc_64/bin"
|
||||
"PATH": "${env:PATH};C:/Qt/6.7.2/bin;C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/bin;D:/Qt/Qt5.14.2/5.14.2/msvc2017_64/bin"
|
||||
},
|
||||
"cmake.options.statusBarVisibility": "visible",
|
||||
"cmake.generator": "Ninja",
|
||||
"C_Cpp.intelliSenseEngine": "disabled",
|
||||
"clangd.arguments": [
|
||||
"--header-insertion=never",
|
||||
"--all-scopes-completion",
|
||||
"--completion-style=detailed",
|
||||
"--clang-tidy",
|
||||
"-j=4",
|
||||
"--pch-storage=memory",
|
||||
"--compile-commands-dir=build",
|
||||
"--background-index",
|
||||
"--ranking-model=heuristics",
|
||||
"--function-arg-placeholders=false",
|
||||
"--query-driver=/usr/bin/g++"
|
||||
],
|
||||
"C_Cpp.default.compileCommands": "${workspaceRoot}/build/compile_commands.json",
|
||||
"C_Cpp.default.cppStandard": "c++14",
|
||||
"editor.inlayHints.enabled": "off",
|
||||
"editor.unicodeHighlight.allowedLocales": {
|
||||
"ja": true,
|
||||
"zh-hant": true,
|
||||
"zh-hans": true
|
||||
},
|
||||
"files.associations": {
|
||||
"algorithm": "cpp",
|
||||
"atomic": "cpp",
|
||||
"cctype": "cpp",
|
||||
"chrono": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"exception": "cpp",
|
||||
"filesystem": "cpp",
|
||||
"functional": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"ios": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"iterator": "cpp",
|
||||
"limits": "cpp",
|
||||
"list": "cpp",
|
||||
"locale": "cpp",
|
||||
"map": "cpp",
|
||||
"memory": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"numeric": "cpp",
|
||||
"ostream": "cpp",
|
||||
"ratio": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"string": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"thread": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"utility": "cpp",
|
||||
"variant": "cpp",
|
||||
"vector": "cpp",
|
||||
"xfacet": "cpp",
|
||||
"xhash": "cpp",
|
||||
"xiosbase": "cpp",
|
||||
"xlocale": "cpp",
|
||||
"xlocbuf": "cpp",
|
||||
"xlocinfo": "cpp",
|
||||
"xlocmes": "cpp",
|
||||
"xlocmon": "cpp",
|
||||
"xlocnum": "cpp",
|
||||
"xloctime": "cpp",
|
||||
"xmemory": "cpp",
|
||||
"xmemory0": "cpp",
|
||||
"xstddef": "cpp",
|
||||
"xstring": "cpp",
|
||||
"xtr1common": "cpp",
|
||||
"xtree": "cpp",
|
||||
"xutility": "cpp",
|
||||
"qtablewidget": "cpp",
|
||||
"qmenu": "cpp",
|
||||
"qmessagebox": "cpp",
|
||||
"qaction": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"qregexp": "cpp",
|
||||
"qregularexpression": "cpp",
|
||||
"array": "cpp",
|
||||
"bit": "cpp",
|
||||
"charconv": "cpp",
|
||||
"clocale": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"format": "cpp",
|
||||
"forward_list": "cpp",
|
||||
"future": "cpp",
|
||||
"optional": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"regex": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"deque": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"random": "cpp",
|
||||
"fstream": "cpp",
|
||||
"cinttypes": "cpp"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,24 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(packqt VERSION 0.1 LANGUAGES CXX)
|
||||
|
||||
# 获取环境变量 HOME
|
||||
if (UNIX)
|
||||
set(USER_HOME $ENV{HOME})
|
||||
else()
|
||||
set(USER_HOME "C:/Qt")
|
||||
endif()
|
||||
|
||||
# 打印用户目录
|
||||
message(STATUS "User home directory: ${USER_HOME}")
|
||||
|
||||
set(CMAKE_PREFIX_PATH
|
||||
"/home/typ/Qt5.14.2/5.14.2/gcc_64"
|
||||
"/home/typ/Dev/Boost"
|
||||
"/home/yun/Qt5.14.2/5.14.2/gcc_64"
|
||||
"/home/yun/Dev/Boost"
|
||||
${CMAKE_PREFIX_PATH}
|
||||
"${USER_HOME}/Qt5.14.2/5.14.2/gcc_64/"
|
||||
"${USER_HOME}/Qt5.14.2/5.14.2/msvc2017_64/"
|
||||
"D:/Qt/Qt5.14.2/5.14.2/msvc2017_64/"
|
||||
"C:/Qt/6.7.2"
|
||||
"/opt/homebrew/Cellar/qt/6.7.0_2/"
|
||||
)
|
||||
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
@ -27,9 +39,7 @@ if (MSVC)
|
||||
add_compile_options(-D_CRT_SECURE_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
find_package(Boost REQUIRED filesystem)
|
||||
include_directories(${Boost_INCLUDE_DIR})
|
||||
add_subdirectory(ofen)
|
||||
|
||||
set(PROJECT_SOURCES
|
||||
main.cpp
|
||||
@ -65,7 +75,7 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(packqt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets ${Boost_LIBRARIES})
|
||||
target_link_libraries(packqt PRIVATE Qt${QT_VERSION_MAJOR}::Widgets ofen)
|
||||
|
||||
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
|
||||
# If you are developing for iOS or macOS you should consider setting an
|
||||
|
@ -3,7 +3,10 @@
|
||||
#include "adddesktop.h"
|
||||
#include <QTextStream>
|
||||
#include <fstream>
|
||||
#include <of_path.h>
|
||||
#include <of_str.h>
|
||||
|
||||
using namespace ofen;
|
||||
MainWidget::MainWidget(QWidget* parent) : QWidget(parent), ui(new Ui::MainWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@ -12,11 +15,15 @@ MainWidget::MainWidget(QWidget* parent) : QWidget(parent), ui(new Ui::MainWidget
|
||||
control_init();
|
||||
}
|
||||
|
||||
MainWidget::~MainWidget() { delete ui; }
|
||||
MainWidget::~MainWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWidget::connect_operator()
|
||||
{
|
||||
connect(ui->btnSelcetBinary, &QPushButton::clicked, this, [=]() { SelectFile(this, ui->edBinary, "请选择Qt二进制文件", "所有文件 (*)"); });
|
||||
connect(ui->btnSelcetBinary, &QPushButton::clicked, this,
|
||||
[=]() { SelectFile(this, ui->edBinary, "请选择Qt二进制文件", "所有文件 (*)"); });
|
||||
connect(ui->btnSelectOut, &QPushButton::clicked, this, [=]() { SelectDirectory(this, ui->edOutDir); });
|
||||
connect(ui->btnSelectQt, &QPushButton::clicked, this, [=]() { SelectDirectory(this, ui->edQtDir); });
|
||||
connect(ui->btnAddEnv, &QPushButton::clicked, this, [=]() { add_env_btn(); });
|
||||
@ -73,7 +80,7 @@ bool MainWidget::copy_dir(const std::string& source_dir, const std::string& des_
|
||||
return false;
|
||||
}
|
||||
|
||||
fs::path des_parent_dir = fs::path(des_dir).append(fs::path(source_dir).filename());
|
||||
fs::path des_parent_dir = fs::path(des_dir).append(fs::path(source_dir).filename().string());
|
||||
if (!fs::exists(des_parent_dir)) {
|
||||
fs::create_directories(des_parent_dir);
|
||||
}
|
||||
@ -86,7 +93,7 @@ bool MainWidget::copy_dir(const std::string& source_dir, const std::string& des_
|
||||
fs::path path = paths.front();
|
||||
paths.pop_front();
|
||||
|
||||
fs::path destination(boost::replace_all_copy(path.string(), source_dir, des_parent_dir.string()));
|
||||
fs::path destination(COfStr::replace(path.string(), source_dir, des_parent_dir.string()));
|
||||
if (fs::is_directory(path)) {
|
||||
if (!fs::exists(destination)) {
|
||||
fs::create_directories(destination);
|
||||
@ -101,7 +108,8 @@ bool MainWidget::copy_dir(const std::string& source_dir, const std::string& des_
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::string> MainWidget::get_depend_on(const std::string& name, const std::vector<std::string>& env)
|
||||
std::vector<std::string> MainWidget::get_depend_on(const std::string& name,
|
||||
const std::vector<std::string>& env)
|
||||
{
|
||||
std::vector<std::string> vec;
|
||||
std::string cmd{};
|
||||
@ -123,7 +131,7 @@ std::vector<std::string> MainWidget::get_depend_on(const std::string& name, cons
|
||||
result.append(buffer);
|
||||
}
|
||||
|
||||
boost::split(vec, result, boost::is_any_of("\t"));
|
||||
vec = COfStr::split(result, "\t");
|
||||
return vec;
|
||||
}
|
||||
|
||||
@ -135,20 +143,19 @@ std::list<std::string> MainWidget::handle_result(const std::vector<std::string>&
|
||||
continue;
|
||||
}
|
||||
|
||||
if (boost::contains(data, "not found")) {
|
||||
if (data.find("not found") == 0) {
|
||||
simple_log(QString::fromStdString("未找到依赖:" + data), false);
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string tdata = boost::replace_all_copy(data, "=>", "");
|
||||
std::vector<std::string> vt;
|
||||
boost::split(vt, tdata, boost::is_any_of(" "));
|
||||
std::string tdata = COfStr::replace(data, "=>", "");
|
||||
std::vector<std::string> vt = COfStr::split(tdata, " ");
|
||||
if (vt.size() != 4) {
|
||||
// QString info = "原始数据:" + QString::fromStdString(data);
|
||||
// simple_log(info, false);
|
||||
continue;
|
||||
}
|
||||
if (boost::starts_with(vt[2], "/lib")) {
|
||||
if (vt[2].find("/lib") == 0) {
|
||||
continue;
|
||||
}
|
||||
ret.push_back(vt[2]);
|
||||
@ -209,7 +216,10 @@ bool MainWidget::isOk(QWidget* parent, const QString& title, const QString& cont
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::message(QWidget* parent, const QString& content) { QMessageBox::information(parent, "提示", content); }
|
||||
void MainWidget::message(QWidget* parent, const QString& content)
|
||||
{
|
||||
QMessageBox::information(parent, "提示", content);
|
||||
}
|
||||
|
||||
void MainWidget::cmd_exec(const std::string& cmd)
|
||||
{
|
||||
@ -269,7 +279,7 @@ void MainWidget::generate()
|
||||
}
|
||||
|
||||
for (const auto& data : dynamic_so) {
|
||||
std::string purpose = fs::path(out_dir).append(fs::path(data).filename()).string();
|
||||
std::string purpose = fs::path(out_dir).append(fs::path(data).filename().string()).string();
|
||||
fs::copy_file(data, purpose, fs::copy_options::overwrite_existing);
|
||||
}
|
||||
|
||||
@ -277,7 +287,7 @@ void MainWidget::generate()
|
||||
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().string());
|
||||
fs::copy_file(binary_.toStdString(), out_binary, fs::copy_options::overwrite_existing);
|
||||
if (!add_run_sh(out_dir.string(), filename)) {
|
||||
return;
|
||||
@ -285,7 +295,6 @@ void MainWidget::generate()
|
||||
message(this, "完成");
|
||||
}
|
||||
|
||||
|
||||
bool MainWidget::add_run_sh(const std::string& out_dir, const std::string& exe_name)
|
||||
{
|
||||
// 生成一个启动文件夹
|
||||
@ -299,7 +308,8 @@ bool MainWidget::add_run_sh(const std::string& out_dir, const std::string& exe_n
|
||||
file.close();
|
||||
|
||||
std::string run_sh = content.toStdString();
|
||||
boost::replace_all(run_sh, "replace_string", exe_name);
|
||||
|
||||
run_sh = COfStr::replace(run_sh, "replace_string", exe_name);
|
||||
|
||||
std::string out_sh = fs::path(out_dir).append(exe_name + ".sh").string();
|
||||
std::ofstream out(out_sh, std::ios::out);
|
||||
|
@ -6,12 +6,11 @@
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
#include <QWidget>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
|
@ -2,6 +2,9 @@
|
||||
#include "ui_adddesktop.h"
|
||||
#include <QTextStream>
|
||||
#include <fstream>
|
||||
#include <of_str.h>
|
||||
|
||||
using namespace ofen;
|
||||
|
||||
AddDesktop::AddDesktop(QWidget* parent) : QDialog(parent), ui(new Ui::AddDesktop)
|
||||
{
|
||||
@ -36,8 +39,10 @@ AddDesktop::AddDesktop(QWidget* parent) : QDialog(parent), ui(new Ui::AddDesktop
|
||||
connect(ui->ckUseDefault, &QCheckBox::toggled, this, &AddDesktop::checkchange);
|
||||
connect(ui->btnSelectBinary, &QPushButton::clicked, this,
|
||||
[=]() { MainWidget::SelectFile(this, ui->edBinary, "请选择二进制文件", "所有文件 (*)"); });
|
||||
connect(ui->btnSelectIco, &QPushButton::clicked, this,
|
||||
[=]() { MainWidget::SelectFile(this, ui->edIco, "请选择ico图标文件", "png图标(*.png);;ico图标(*.ico);;svg图标(*.svg);;所有文件 (*)"); });
|
||||
connect(ui->btnSelectIco, &QPushButton::clicked, this, [=]() {
|
||||
MainWidget::SelectFile(this, ui->edIco, "请选择ico图标文件",
|
||||
"png图标(*.png);;ico图标(*.ico);;svg图标(*.svg);;所有文件 (*)");
|
||||
});
|
||||
connect(ui->btnInstall, &QPushButton::clicked, this, &AddDesktop::install_to_desktop);
|
||||
}
|
||||
|
||||
@ -84,9 +89,9 @@ void AddDesktop::install_to_desktop()
|
||||
QString content = stream.readAll();
|
||||
file.close();
|
||||
std::string ct = content.toStdString();
|
||||
boost::replace_all(ct, "re_name", binaryName);
|
||||
boost::replace_all(ct, "re_describe", binaryName);
|
||||
boost::replace_all(ct, "re_path", "sh " + sh_path.string());
|
||||
ct = COfStr::replace(ct, "re_name", binaryName);
|
||||
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");
|
||||
if (!fs::exists(default_ico_path)) {
|
||||
@ -95,7 +100,7 @@ void AddDesktop::install_to_desktop()
|
||||
if (ui->ckUseDefault->isChecked()) {
|
||||
default_ico_path.append("Tools.svg");
|
||||
QFile::copy("://resource/Tools.svg", QString::fromStdString(default_ico_path.string()));
|
||||
boost::replace_all(ct, "re_icon", default_ico_path.string());
|
||||
ct = COfStr::replace(ct, "re_icon", default_ico_path.string());
|
||||
|
||||
} else {
|
||||
std::string icn = ui->edIco->text().trimmed().toStdString();
|
||||
@ -103,12 +108,12 @@ void AddDesktop::install_to_desktop()
|
||||
MainWidget::message(this, "图标路径为空");
|
||||
return;
|
||||
}
|
||||
default_ico_path.append(fs::path(icn).filename());
|
||||
boost::replace_all(ct, "re_icon", default_ico_path.string());
|
||||
default_ico_path.append(fs::path(icn).filename().string());
|
||||
ct = COfStr::replace(ct, "re_icon", default_ico_path.string());
|
||||
fs::copy_file(icn, default_ico_path, fs::copy_options::overwrite_existing);
|
||||
}
|
||||
|
||||
boost::replace_all(ct, "re_category", ui->cbCategories->currentText().toStdString());
|
||||
ct = COfStr::replace(ct, "re_category", ui->cbCategories->currentText().toStdString());
|
||||
tmp.append(binaryName + ".desktop");
|
||||
;
|
||||
std::ofstream out(tmp.string(), std::ios::out);
|
||||
@ -123,4 +128,7 @@ void AddDesktop::install_to_desktop()
|
||||
MainWidget::message(this, "完成");
|
||||
}
|
||||
|
||||
AddDesktop::~AddDesktop() { delete ui; }
|
||||
AddDesktop::~AddDesktop()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
1
ofen
Submodule
1
ofen
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 71948320b735e33db511f756b5df83ef3ddcf2c7
|
Loading…
x
Reference in New Issue
Block a user