revert 'parallelize using libdispatch'(a121fb7
) due to only minor improvement in execution time
This commit is contained in:
parent
bbcbaa4da4
commit
a459e157b4
|
@ -24,5 +24,4 @@ add_executable(dylibbundler
|
|||
src/Settings.h
|
||||
src/Utils.cpp
|
||||
src/Utils.h
|
||||
src/ParallelForEach.h
|
||||
)
|
||||
|
|
|
@ -126,6 +126,13 @@ bool Dependency::MergeIfIdentical(Dependency* dependency)
|
|||
return false;
|
||||
}
|
||||
|
||||
void Dependency::Print() const
|
||||
{
|
||||
std::cout << "\n* " << filename << " from " << prefix << std::endl;
|
||||
for (const auto& symlink : symlinks)
|
||||
std::cout << " symlink --> " << symlink << std::endl;
|
||||
}
|
||||
|
||||
void Dependency::CopyToBundle() const
|
||||
{
|
||||
std::string original_path = OriginalPath();
|
||||
|
@ -161,22 +168,12 @@ void Dependency::CopyToBundle() const
|
|||
void Dependency::FixDependentFile(const std::string& dependent_file) const
|
||||
{
|
||||
db->changeInstallName(dependent_file, OriginalPath(), InnerPath());
|
||||
for (const auto& symlink : symlinks) {
|
||||
for (const auto& symlink : symlinks)
|
||||
db->changeInstallName(dependent_file, symlink, InnerPath());
|
||||
}
|
||||
|
||||
if (db->missingPrefixes()) {
|
||||
db->changeInstallName(dependent_file, filename, InnerPath());
|
||||
for (const auto& symlink : symlinks) {
|
||||
db->changeInstallName(dependent_file, symlink, InnerPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!db->missingPrefixes()) return;
|
||||
|
||||
void Dependency::Print() const
|
||||
{
|
||||
std::cout << "\n* " << filename << " from " << prefix << std::endl;
|
||||
for (const auto& symlink : symlinks) {
|
||||
std::cout << " symlink --> " << symlink << std::endl;
|
||||
}
|
||||
db->changeInstallName(dependent_file, filename, InnerPath());
|
||||
for (const auto& symlink : symlinks)
|
||||
db->changeInstallName(dependent_file, symlink, InnerPath());
|
||||
}
|
||||
|
|
|
@ -22,16 +22,13 @@ public:
|
|||
[[nodiscard]] std::string InstallPath() const;
|
||||
|
||||
void AddSymlink(const std::string& path);
|
||||
|
||||
// Compare the given dependency with this one. If both refer to the same file,
|
||||
// merge both entries into one and return true.
|
||||
// Compare the |dependency| with |this|. Merge entries if both refer to the same file.
|
||||
bool MergeIfIdentical(Dependency* dependency);
|
||||
void Print() const;
|
||||
|
||||
void CopyToBundle() const;
|
||||
void FixDependentFile(const std::string& dependent_file) const;
|
||||
|
||||
void Print() const;
|
||||
|
||||
private:
|
||||
bool is_framework;
|
||||
|
||||
|
|
|
@ -12,12 +12,10 @@
|
|||
#include <linux/limits.h>
|
||||
#endif
|
||||
|
||||
#include "ParallelForEach.h"
|
||||
#include "Dependency.h"
|
||||
#include "Utils.h"
|
||||
|
||||
DylibBundler::DylibBundler() : qt_plugins_called(false) {}
|
||||
|
||||
DylibBundler::~DylibBundler() = default;
|
||||
|
||||
void DylibBundler::addDependency(const std::string& path, const std::string& dependent_file)
|
||||
|
@ -139,9 +137,8 @@ void DylibBundler::fixRpathsOnFile(const std::string& original_file, const std::
|
|||
|
||||
rpaths_to_fix = getRpathsForFile(original_file);
|
||||
for (const auto& rpath_to_fix : rpaths_to_fix) {
|
||||
std::string command = std::string("/usr/bin/install_name_tool -rpath ");
|
||||
command.append(rpath_to_fix).append(" ").append(insideLibPath());
|
||||
command.append(" ").append(file_to_fix);
|
||||
std::string command = std::string("/usr/bin/install_name_tool -rpath ").append(rpath_to_fix);
|
||||
command += std::string(" ").append(insideLibPath()).append(" ").append(file_to_fix);
|
||||
if (systemp(command) != 0) {
|
||||
std::cerr << "\n\n/!\\ ERROR: An error occured while trying to fix rpath " << rpath_to_fix << " of " << file_to_fix << std::endl;
|
||||
exit(1);
|
||||
|
@ -163,18 +160,18 @@ void DylibBundler::bundleDependencies()
|
|||
// copy & fix up dependencies
|
||||
if (bundleLibs()) {
|
||||
createDestDir();
|
||||
parallel_for_each(deps.begin(), deps.end(), [&](Dependency* dep) {
|
||||
for (const auto& dep : deps) {
|
||||
dep->CopyToBundle();
|
||||
changeLibPathsOnFile(dep->InstallPath());
|
||||
fixRpathsOnFile(dep->OriginalPath(), dep->InstallPath());
|
||||
});
|
||||
}
|
||||
}
|
||||
// fix up input files
|
||||
const auto files = filesToFix();
|
||||
parallel_for_each(files.begin(), files.end(), [&](const std::string& file) {
|
||||
for (const auto& file : files) {
|
||||
changeLibPathsOnFile(file);
|
||||
fixRpathsOnFile(file, file);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void DylibBundler::bundleQtPlugins()
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef DYLIBBUNDLER_PARALLELFOREACH_H
|
||||
#define DYLIBBUNDLER_PARALLELFOREACH_H
|
||||
|
||||
#include <iterator>
|
||||
#include <dispatch/dispatch.h>
|
||||
|
||||
template<typename It, typename F>
|
||||
inline void parallel_for_each(It a, It b, F&& f)
|
||||
{
|
||||
size_t count = std::distance(a,b);
|
||||
using data_t = std::pair<It, F>;
|
||||
data_t helper = data_t(a, std::forward<F>(f));
|
||||
dispatch_apply_f(count,
|
||||
dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0),
|
||||
&helper,
|
||||
[](void* ctx, size_t cnt) {
|
||||
auto* d = static_cast<data_t*>(ctx);
|
||||
auto elem_it = std::next(d->first, cnt);
|
||||
(*d).second(*(elem_it));
|
||||
});
|
||||
}
|
||||
|
||||
#endif //DYLIBBUNDLER_PARALLELFOREACH_H
|
|
@ -134,7 +134,7 @@ std::string systemOutput(const std::string& cmd)
|
|||
|
||||
void otool(const std::string& flags, const std::string& file, std::vector<std::string>& lines)
|
||||
{
|
||||
std::string command = std::string("/bin/otool ").append(flags).append(" ").append(file);
|
||||
std::string command = std::string("/usr/bin/otool ").append(flags).append(" ").append(file);
|
||||
std::string output = systemOutput(command);
|
||||
|
||||
if (output.find("can't open file") != std::string::npos
|
||||
|
|
Loading…
Reference in New Issue