本文整理汇总了C++中CompileJob::compilerName方法的典型用法代码示例。如果您正苦于以下问题:C++ CompileJob::compilerName方法的具体用法?C++ CompileJob::compilerName怎么用?C++ CompileJob::compilerName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CompileJob
的用法示例。
在下文中一共展示了CompileJob::compilerName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compiler_is_clang
bool compiler_is_clang( const CompileJob& job )
{
if( job.language() == CompileJob::Lang_Custom )
return false;
assert( job.compilerName().find( '/' ) == string::npos );
return job.compilerName().find("clang") != string::npos;
}
示例2: find_compiler
/*
* Get the name of the compiler depedant on the
* language of the job and the environment
* variable set. This is useful for native cross-compilers.
* (arm-linux-gcc for example)
*/
string find_compiler( const CompileJob& job )
{
if (job.language() == CompileJob::Lang_C) {
if (const char* env = getenv( "ICECC_CC" ))
return env;
}
if (job.language() == CompileJob::Lang_CXX) {
if (const char* env = getenv ("ICECC_CXX"))
return env;
}
return compiler_path_lookup(job.compilerName());
}
示例3: main
//.........这里部分代码省略.........
local_daemon = Service::createChannel("/var/run/icecc/iceccd.socket");
if (!local_daemon) {
local_daemon = Service::createChannel("/var/run/iceccd.socket");
}
if (!local_daemon && getenv("HOME")) {
string path = getenv("HOME");
path += "/.iceccd.socket";
local_daemon = Service::createChannel(path);
}
if (!local_daemon) {
local_daemon = Service::createChannel("127.0.0.1", 10245, 0/*timeout*/);
}
} else {
local_daemon = Service::createChannel(getenv("ICECC_TEST_SOCKET"));
if (!local_daemon) {
log_error() << "test socket error" << endl;
return EXIT_TEST_SOCKET_ERROR;
}
}
if (!local_daemon) {
log_warning() << "no local daemon found" << endl;
return build_local(job, 0);
}
Environments envs;
if (!local) {
if (getenv("ICECC_VERSION")) { // if set, use it, otherwise take default
try {
envs = parse_icecc_version(job.targetPlatform(), find_prefix(job.compilerName()));
} catch (int x) {
// we just build locally
}
} else if (!extrafiles.empty() && !IS_PROTOCOL_32(local_daemon)) {
log_warning() << "Local daemon is too old to handle compiler plugins." << endl;
local = true;
} else {
if (!local_daemon->send_msg(GetNativeEnvMsg(compiler_is_clang(job)
? "clang" : "gcc", extrafiles))) {
log_warning() << "failed to write get native environment" << endl;
goto do_local_error;
}
// the timeout is high because it creates the native version
Msg *umsg = local_daemon->get_msg(4 * 60);
string native;
if (umsg && umsg->type == M_NATIVE_ENV) {
native = static_cast<UseNativeEnvMsg*>(umsg)->nativeVersion;
}
if (native.empty() || ::access(native.c_str(), R_OK)) {
log_warning() << "daemon can't determine native environment. "
"Set $ICECC_VERSION to an icecc environment.\n";
} else {
envs.push_back(make_pair(job.targetPlatform(), native));
log_info() << "native " << native << endl;
}
delete umsg;
}
示例4: build_local
/**
* Invoke a compiler locally. This is, obviously, the alternative to
* dcc_compile_remote().
*
* The server does basically the same thing, but it doesn't call this
* routine because it wants to overlap execution of the compiler with
* copying the input from the network.
*
* This routine used to exec() the compiler in place of distcc. That
* is slightly more efficient, because it avoids the need to create,
* schedule, etc another process. The problem is that in that case we
* can't clean up our temporary files, and (not so important) we can't
* log our resource usage.
*
**/
int build_local(CompileJob &job, MsgChannel *local_daemon, struct rusage *used)
{
list<string> arguments;
string compiler_name = find_compiler(job);
trace() << "invoking: " << compiler_name << endl;
if (compiler_name.empty()) {
log_error() << "could not find " << job.compilerName() << " in PATH." << endl;
return EXIT_NO_SUCH_FILE;
}
arguments.push_back(compiler_name);
appendList(arguments, job.allFlags());
if (!job.inputFile().empty()) {
arguments.push_back(job.inputFile());
}
if (!job.outputFile().empty()) {
arguments.push_back("-o");
arguments.push_back(job.outputFile());
}
char **argv = new char*[arguments.size() + 1];
int argc = 0;
for (list<string>::const_iterator it = arguments.begin(); it != arguments.end(); ++it) {
argv[argc++] = strdup(it->c_str());
}
argv[argc] = 0;
#if CLIENT_DEBUG
trace() << "execing ";
for (int i = 0; argv[i]; i++) {
trace() << argv[i] << " ";
}
trace() << endl;
#endif
if (!local_daemon) {
int fd;
if (!dcc_lock_host(fd)) {
log_error() << "can't lock for local job" << endl;
return EXIT_DISTCC_FAILED;
}
lock_fd = fd;
}
bool color_output = job.language() != CompileJob::Lang_Custom
&& colorify_wanted(job);
int pf[2];
if (color_output && pipe(pf)) {
color_output = false;
}
if (used || color_output) {
flush_debug();
child_pid = fork();
}
if (!child_pid) {
dcc_increment_safeguard();
if (color_output) {
close(pf[0]);
close(2);
dup2(pf[1], 2);
}
int ret = execv(argv[0], argv);
if (lock_fd) {
dcc_unlock(lock_fd);
}
if (ret) {
char buf[256];
snprintf(buf, sizeof(buf), "ICECC[%d]: %s:", getpid(), argv[0]);
//.........这里部分代码省略.........
示例5: build_local
/**
* Invoke a compiler locally. This is, obviously, the alternative to
* dcc_compile_remote().
*
* The server does basically the same thing, but it doesn't call this
* routine because it wants to overlap execution of the compiler with
* copying the input from the network.
*
* This routine used to exec() the compiler in place of distcc. That
* is slightly more efficient, because it avoids the need to create,
* schedule, etc another process. The problem is that in that case we
* can't clean up our temporary files, and (not so important) we can't
* log our resource usage.
*
**/
int build_local(CompileJob &job, MsgChannel *local_daemon, struct rusage *used)
{
list<string> arguments;
string compiler_name = find_compiler(job);
if (compiler_name.empty()) {
log_error() << "could not find " << job.compilerName() << " in PATH." << endl;
return EXIT_NO_SUCH_FILE;
}
arguments.push_back(compiler_name);
appendList(arguments, job.allFlags());
if (job.dwarfFissionEnabled()) {
arguments.push_back("-gsplit-dwarf");
}
if (!job.inputFile().empty()) {
arguments.push_back(job.inputFile());
}
if (!job.outputFile().empty()) {
arguments.push_back("-o");
arguments.push_back(job.outputFile());
}
vector<char*> argv;
string argstxt;
for (list<string>::const_iterator it = arguments.begin(); it != arguments.end(); ++it) {
argv.push_back(strdup(it->c_str()));
argstxt += ' ';
argstxt += *it;
}
argv.push_back(0);
trace() << "invoking:" << argstxt << endl;
if (!local_daemon) {
int fd;
if (!dcc_lock_host(fd)) {
log_error() << "can't lock for local job" << endl;
return EXIT_DISTCC_FAILED;
}
lock_fd = fd;
}
bool color_output = job.language() != CompileJob::Lang_Custom
&& colorify_wanted(job);
int pf[2];
if (color_output && pipe(pf)) {
color_output = false;
}
if (used || color_output) {
flush_debug();
child_pid = fork();
}
if (child_pid == -1){
log_perror("fork failed");
}
if (!child_pid) {
dcc_increment_safeguard(job.language() == CompileJob::Lang_Custom ? SafeguardStepCustom : SafeguardStepCompiler);
if (color_output) {
if ((-1 == close(pf[0])) && (errno != EBADF)){
log_perror("close failed");
}
if ((-1 == close(2)) && (errno != EBADF)){
log_perror("close failed");
}
if (-1 == dup2(pf[1], 2)){
log_perror("dup2 failed");
}
}
execv(argv[0], &argv[0]);
int exitcode = ( errno == ENOENT ? 127 : 126 );
//.........这里部分代码省略.........
示例6: compiler_is_clang
bool compiler_is_clang( const CompileJob& job )
{
return job.compilerName().find("clang") != string::npos;
}
示例7: analyse_argv
bool analyse_argv( const char * const *argv,
CompileJob &job, bool icerun, list<string> *extrafiles )
{
ArgumentsList args;
string ofile;
#if CLIENT_DEBUG > 1
trace() << "scanning arguments ";
for ( int index = 0; argv[index]; index++ )
trace() << argv[index] << " ";
trace() << endl;
#endif
bool had_cc = (job.compilerName().size() > 0);
bool always_local = analyze_program(had_cc ? job.compilerName().c_str() : argv[0], job);
bool seen_c = false;
bool seen_s = false;
bool seen_mf = false;
bool seen_md = false;
bool fno_color_diagnostics = false;
// if rewriting includes and precompiling on remote machine, then cpp args are not local
Argument_Type Arg_Cpp = compiler_only_rewrite_includes( job ) ? Arg_Rest : Arg_Local;
if( icerun ) {
always_local = true;
job.setLanguage( CompileJob::Lang_Custom );
}
for (int i = had_cc ? 2 : 1; argv[i]; i++) {
const char *a = argv[i];
if (icerun) {
args.append(a, Arg_Local);
} else if (a[0] == '-') {
if (!strcmp(a, "-E") || !strncmp(a, "-fdump", 6) || !strcmp(a, "-combine")) {
always_local = true;
args.append(a, Arg_Local);
} else if (!strcmp(a, "-MD") || !strcmp(a, "-MMD")) {
seen_md = true;
args.append(a, Arg_Local);
/* These two generate dependencies as a side effect. They
* should work with the way we call cpp. */
} else if (!strcmp(a, "-MG") || !strcmp(a, "-MP")) {
args.append(a, Arg_Local);
/* These just modify the behaviour of other -M* options and do
* nothing by themselves. */
} else if (!strcmp(a, "-MF")) {
seen_mf = true;
args.append(a, Arg_Local);
args.append( argv[++i], Arg_Local );
/* as above but with extra argument */
} else if (!strcmp(a, "-MT") || !strcmp(a, "-MQ")) {
args.append(a, Arg_Local);
args.append( argv[++i], Arg_Local );
/* as above but with extra argument */
} else if (a[1] == 'M') {
/* -M(anything else) causes the preprocessor to
produce a list of make-style dependencies on
header files, either to stdout or to a local file.
It implies -E, so only the preprocessor is run,
not the compiler. There would be no point trying
to distribute it even if we could. */
always_local = true;
args.append(a, Arg_Local);
} else if ( str_equal( "--param", a ) ) {
args.append( a, Arg_Remote );
/* skip next word, being option argument */
if (argv[i+1])
args.append( argv[++i], Arg_Remote );
} else if ( a[1] == 'B' ) {
/* -B overwrites the path where the compiler finds the assembler.
As we don't use that, better force local job.
*/
always_local = true;
args.append( a, Arg_Local );
if ( str_equal( a, "-B" ) ) {
/* skip next word, being option argument */
if (argv[i+1])
args.append( argv[++i], Arg_Local );
}
} else if (str_startswith("-Wa,", a)) {
/* Options passed through to the assembler. The only one we
* need to handle so far is -al=output, which directs the
* listing to the named file and cannot be remote. There are
* some other options which also refer to local files,
* but most of them make no sense when called via the compiler,
* hence we only look for -a[a-z]*= and localize the job if we
* find it. */
const char *pos = a;
bool local = false;
while ((pos = strstr(pos+1, "-a"))) {
pos += 2;
while (*pos >= 'a' && *pos <= 'z')
pos++;
if (*pos == '=') {
local = true;
break;
}
if (!*pos)
break;
}
//.........这里部分代码省略.........
示例8: work_it
int work_it( CompileJob &j, unsigned int job_stat[], MsgChannel* client,
CompileResultMsg& rmsg, const string &outfilename,
unsigned long int mem_limit, int client_fd, int /*job_in_fd*/ )
{
rmsg.out.erase(rmsg.out.begin(), rmsg.out.end());
rmsg.out.erase(rmsg.out.begin(), rmsg.out.end());
std::list<string> list = j.remoteFlags();
appendList( list, j.restFlags() );
int sock_err[2];
int sock_out[2];
int sock_in[2];
int main_sock[2];
char buffer[4096];
if ( pipe( sock_err ) )
return EXIT_DISTCC_FAILED;
if ( pipe( sock_out ) )
return EXIT_DISTCC_FAILED;
if ( pipe( main_sock ) )
return EXIT_DISTCC_FAILED;
if ( pipe( death_pipe ) )
return EXIT_DISTCC_FAILED;
// We use a socket pair instead of a pipe to get a "slightly" bigger
// output buffer. This saves context switches and latencies.
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock_in) < 0)
return EXIT_DISTCC_FAILED;
int maxsize = 2*1024*2024;
#ifdef SO_SNDBUFFORCE
if (setsockopt(sock_in[1], SOL_SOCKET, SO_SNDBUFFORCE, &maxsize, sizeof(maxsize)) < 0)
#endif
{
setsockopt(sock_in[1], SOL_SOCKET, SO_SNDBUF, &maxsize, sizeof(maxsize));
}
if ( fcntl( sock_in[1], F_SETFL, O_NONBLOCK ) )
return EXIT_DISTCC_FAILED;
/* Testing */
struct sigaction act;
sigemptyset( &act.sa_mask );
act.sa_handler = SIG_IGN;
act.sa_flags = 0;
sigaction( SIGPIPE, &act, 0L );
act.sa_handler = theSigCHLDHandler;
act.sa_flags = SA_NOCLDSTOP;
sigaction( SIGCHLD, &act, 0 );
sigaddset( &act.sa_mask, SIGCHLD );
// Make sure we don't block this signal. gdb tends to do that :-(
sigprocmask( SIG_UNBLOCK, &act.sa_mask, 0 );
flush_debug();
pid_t pid = fork();
if ( pid == -1 ) {
return EXIT_OUT_OF_MEMORY;
} else if ( pid == 0 ) {
setenv( "PATH", "usr/bin", 1 );
#ifndef HAVE_LIBCAP_NG
// Safety check
if (getuid() == 0 || getgid() == 0) {
error_client( client, "UID is 0 - aborting." );
_exit(142);
}
#endif
#ifdef RLIMIT_AS
struct rlimit rlim;
if ( getrlimit( RLIMIT_AS, &rlim ) ) {
error_client( client, "getrlimit failed." );
log_perror( "getrlimit" );
}
rlim.rlim_cur = mem_limit*1024*1024;
rlim.rlim_max = mem_limit*1024*1024;
if ( setrlimit( RLIMIT_AS, &rlim ) ) {
error_client( client, "setrlimit failed." );
log_perror( "setrlimit" );
}
#endif
int argc = list.size();
argc++; // the program
argc += 6; // -x c - -o file.o -fpreprocessed
argc += 4; // gpc parameters
argc += 1; // -pipe
argc += 1; // -no-canonical-prefixes
char **argv = new char*[argc + 1];
int i = 0;
bool clang = false;
if (IS_PROTOCOL_30( client )) {
assert(!j.compilerName().empty());
clang = (j.compilerName().find( "clang" ) != string::npos);
argv[i++] = strdup(( "usr/bin/" + j.compilerName()).c_str());
//.........这里部分代码省略.........