update:进度更新。
This commit is contained in:
parent
155629c127
commit
4c45249d0d
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@ -20,9 +20,9 @@
|
|||||||
"/f", "mfile", "/i", "mico", "/c", "mc", "/m", "mm"
|
"/f", "mfile", "/i", "mico", "/c", "mc", "/m", "mm"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"cmake.configureSettings": {
|
// "cmake.configureSettings": {
|
||||||
"CMAKE_TOOLCHAIN_FILE": "${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
// "CMAKE_TOOLCHAIN_FILE": "${env:VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||||
},
|
// },
|
||||||
"cmake.options.statusBarVisibility": "visible",
|
"cmake.options.statusBarVisibility": "visible",
|
||||||
"cmake.generator": "Ninja",
|
"cmake.generator": "Ninja",
|
||||||
"C_Cpp.default.compileCommands": "${workspaceRoot}/build/compile_commands.json",
|
"C_Cpp.default.compileCommands": "${workspaceRoot}/build/compile_commands.json",
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "cmd_parse.h"
|
#include "cmd_parse.h"
|
||||||
#include "logic.h"
|
#include "logic.h"
|
||||||
|
#include <Poco/File.h>
|
||||||
|
|
||||||
void CPackBinaryCmd::initialize(Poco::Util::Application& self)
|
void CPackBinaryCmd::initialize(Poco::Util::Application& self)
|
||||||
{
|
{
|
||||||
@ -40,6 +41,13 @@ void CPackBinaryCmd::defineOptions(Poco::Util::OptionSet& options)
|
|||||||
.argument("category name")
|
.argument("category name")
|
||||||
.callback(Poco::Util::OptionCallback<CPackBinaryCmd>(
|
.callback(Poco::Util::OptionCallback<CPackBinaryCmd>(
|
||||||
this, &CPackBinaryCmd::handleInput)));
|
this, &CPackBinaryCmd::handleInput)));
|
||||||
|
|
||||||
|
options.addOption(Poco::Util::Option("purpose", "p", "purpose dir")
|
||||||
|
.required(false)
|
||||||
|
.repeatable(false)
|
||||||
|
.argument("purpose dir")
|
||||||
|
.callback(Poco::Util::OptionCallback<CPackBinaryCmd>(
|
||||||
|
this, &CPackBinaryCmd::handleInput)));
|
||||||
options.addOption(Poco::Util::Option("mode", "m", "mode name")
|
options.addOption(Poco::Util::Option("mode", "m", "mode name")
|
||||||
.required(false)
|
.required(false)
|
||||||
.repeatable(false)
|
.repeatable(false)
|
||||||
@ -80,6 +88,10 @@ void CPackBinaryCmd::handleInput(const std::string& name,
|
|||||||
result_.binary = value;
|
result_.binary = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (name == "purpose") {
|
||||||
|
result_.purpose_dir = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (name == "ext") {
|
if (name == "ext") {
|
||||||
result_.lib_dirs.push_back(value);
|
result_.lib_dirs.push_back(value);
|
||||||
return;
|
return;
|
||||||
@ -113,10 +125,26 @@ bool CPackBinaryCmd::validCheck()
|
|||||||
std::cout << "file:" << result_.binary << std::endl;
|
std::cout << "file:" << result_.binary << std::endl;
|
||||||
std::cout << "mode:" << result_.mode << std::endl;
|
std::cout << "mode:" << result_.mode << std::endl;
|
||||||
std::cout << "category:" << result_.category << std::endl;
|
std::cout << "category:" << result_.category << std::endl;
|
||||||
std::cout << "include:" << std::endl;
|
std::cout << "include, size = " << result_.lib_dirs.size() << std::endl;
|
||||||
|
|
||||||
for (const auto& item : result_.lib_dirs) {
|
for (const auto& item : result_.lib_dirs) {
|
||||||
std::cout << " " << item << std::endl;
|
std::cout << ">>" << item << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (result_.mode) {
|
||||||
|
case 0: {
|
||||||
|
Poco::File file(result_.binary);
|
||||||
|
if (!file.exists()) {
|
||||||
|
std::cout << "binary file not exist." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
std::cout << "不合法的mode内容。" << std::endl;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
46
pack.cpp
46
pack.cpp
@ -1,6 +1,50 @@
|
|||||||
#include "pack.h"
|
#include "pack.h"
|
||||||
|
#include <Poco/StringTokenizer.h>
|
||||||
|
|
||||||
bool CPackBinary::startPack(const CmdResult& result)
|
bool CPackBinary::startPack(const CmdResult& result)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string>
|
||||||
|
CPackBinary::getDepends(const std::string& path,
|
||||||
|
const std::vector<std::string>& dirs)
|
||||||
|
{
|
||||||
|
std::vector<std::string> result;
|
||||||
|
std::string cmds;
|
||||||
|
cmds.append("export LD_LIBRARY_PATH=$LD_LIBRARY_PATH");
|
||||||
|
for (const auto& item : dirs) {
|
||||||
|
cmds.append(":" + item);
|
||||||
|
}
|
||||||
|
cmds.append(" && ldd " + path);
|
||||||
|
|
||||||
|
auto* pf = popen(cmds.c_str(), "r");
|
||||||
|
if (pf != nullptr) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
char buffer[1024]{};
|
||||||
|
std::string output{};
|
||||||
|
while (std::fgets(buffer, sizeof(buffer), pf)) {
|
||||||
|
output.append(buffer);
|
||||||
|
}
|
||||||
|
fclose(pf);
|
||||||
|
|
||||||
|
Poco::StringTokenizer token(output, "\t");
|
||||||
|
for (const auto& item : token) {
|
||||||
|
std::cout << item << std::endl;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::list<std::string>
|
||||||
|
CPackBinary::parseResult(const std::vector<std::string>& result)
|
||||||
|
{
|
||||||
|
std::list<std::string> ret;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CPackBinary::handleAndCopy(const std::list<std::string>& libs)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
11
pack.h
11
pack.h
@ -2,14 +2,23 @@
|
|||||||
#define PACK_HEADER
|
#define PACK_HEADER
|
||||||
|
|
||||||
#include "public.hpp"
|
#include "public.hpp"
|
||||||
|
#include <Poco/String.h>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
class CPackBinary
|
class CPackBinary
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CPackBinary() = default;
|
CPackBinary() = default;
|
||||||
~CPackBinary() = default;
|
~CPackBinary() = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool startPack(const CmdResult& result);
|
bool startPack(const CmdResult& result);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<std::string> getDepends(const std::string& path,
|
||||||
|
const std::vector<std::string>& dirs);
|
||||||
|
std::list<std::string> parseResult(const std::vector<std::string>& result);
|
||||||
|
bool handleAndCopy(const std::list<std::string>& libs);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
struct CmdResult {
|
struct CmdResult {
|
||||||
std::string binary;
|
std::string binary;
|
||||||
|
std::string purpose_dir;
|
||||||
std::string ico;
|
std::string ico;
|
||||||
std::string category;
|
std::string category;
|
||||||
std::vector<std::string> lib_dirs;
|
std::vector<std::string> lib_dirs;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user