Skip to content

Commit

Permalink
Restore local plugins paths for local builds (#2)
Browse files Browse the repository at this point in the history
* Restore local plugins paths for local builds

* fixup! Restore local plugins paths for local builds

rewrite paths only when sending compile command

* fixup! Restore local plugins paths for local builds

fix for multiple plugins on command line

* fixup! Restore local plugins paths for local builds

usr/local/lib -> usr/lib

* fixup! Restore local plugins paths for local builds

usr/lib ->
  • Loading branch information
pr0t4zy authored and avl7771 committed Feb 13, 2018
1 parent 983a1c5 commit 8c0be0b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
2 changes: 2 additions & 0 deletions client/local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ static void handle_user_break(int sig)
**/
int build_local(CompileJob &job, MsgChannel *local_daemon, struct rusage *used)
{
job.rewritePluginPaths(false);

list<string> arguments;

string compiler_name = find_compiler(job);
Expand Down
4 changes: 2 additions & 2 deletions client/remote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ static int build_remote_int(CompileJob &job, UseCSMsg *usecs, MsgChannel *local_
job.appendFlag( job.language() == CompileJob::Lang_OBJC ? "objective-c" : "objective-c++", Arg_Remote );
}

job.rewritePluginPaths(true);
CompileFileMsg compile_file(&job);
{
log_block b("send compile_file");
Expand All @@ -497,6 +498,7 @@ static int build_remote_int(CompileJob &job, UseCSMsg *usecs, MsgChannel *local_
throw client_error(9, "Error 9 - error sending file to remote");
}
}
job.rewritePluginPaths(false);

if (!preproc_file) {
int sockets[2];
Expand Down Expand Up @@ -750,8 +752,6 @@ static int minimalRemoteVersion( const CompileJob& job)

int build_remote(CompileJob &job, MsgChannel *local_daemon, const Environments &_envs, int permill)
{
job.rewritePluginPathsForRemoteJob();

srand(time(0) + getpid());

int torepeat = 1;
Expand Down
31 changes: 21 additions & 10 deletions services/job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ list<string> CompileJob::flags(Argument_Type argumentType) const
return args;
}

void CompileJob::rewritePluginPathsForRemoteJob() {
void CompileJob::rewritePluginPaths(bool remote) {
enum ArgState { NONE, XCLANG, XLOAD, XPLUGIN };
ArgState state = NONE;
for (ArgumentsList::iterator it = m_flags.begin(); it != m_flags.end(); ++it) {
Expand All @@ -58,18 +58,29 @@ void CompileJob::rewritePluginPathsForRemoteJob() {
continue;
}
if (state == XPLUGIN) {
std::string filename = it->first;
size_t index = filename.find_last_of('/');
if (index != string::npos) {
filename = filename.substr(index + 1);
}
filename = "/usr/local/lib/" + filename;
log_info() << "Rewritten path:" << it->first << " -> "
<< filename << std::endl;
it->first = filename;
if (remote) {
std::string filename = it->first;
size_t index = filename.find_last_of('/');
if (index != string::npos) {
filename = filename.substr(index + 1);
}
log_info() << "Rewritten path:" << it->first << " -> "
<< filename << std::endl;
m_plugins[filename] = it->first;
it->first = filename;
} else {
PluginsT::const_iterator found = m_plugins.find(it->first);
if (found != m_plugins.end()) {
log_info() << "Rewritten path:" << it->first << " -> "
<< found->second << std::endl;
it->first = found->second;
}
}
}
state = NONE;
}
if (!remote)
m_plugins.clear();
}

list<string> CompileJob::localFlags() const
Expand Down
5 changes: 4 additions & 1 deletion services/job.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define ICECREAM_COMPILE_JOB_H

#include <list>
#include <map>
#include <string>
#include <iostream>
#include <sstream>
Expand Down Expand Up @@ -120,7 +121,7 @@ class CompileJob
m_flags = flags;
}

void rewritePluginPathsForRemoteJob();
void rewritePluginPaths(bool remote);

std::list<std::string> localFlags() const;
std::list<std::string> remoteFlags() const;
Expand Down Expand Up @@ -205,6 +206,7 @@ class CompileJob
}

private:
typedef std::map<std::string, std::string> PluginsT;
std::list<std::string> flags(Argument_Type argumentType) const;
void setTargetPlatform();

Expand All @@ -219,6 +221,7 @@ class CompileJob
std::string m_target_platform;
bool m_dwarf_fission;
bool m_block_rewrite_includes;
PluginsT m_plugins;
};

inline void appendList(std::list<std::string> &list, const std::list<std::string> &toadd)
Expand Down

0 comments on commit 8c0be0b

Please sign in to comment.