本文整理汇总了C++中CompileJob::language方法的典型用法代码示例。如果您正苦于以下问题:C++ CompileJob::language方法的具体用法?C++ CompileJob::language怎么用?C++ CompileJob::language使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CompileJob
的用法示例。
在下文中一共展示了CompileJob::language方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
示例2: 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;
}
示例3: build_remote
int build_remote(CompileJob &job, MsgChannel *local_daemon, const Environments &_envs, int permill )
{
srand( time( 0 ) + getpid() );
int torepeat = 1;
// older compilers do not support the options we need to make it reproducible
#if defined(__GNUC__) && ( ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 3) ) || (__GNUC__ >=4) )
if (!compiler_is_clang(job)) {
if ( rand() % 1000 < permill)
torepeat = 3;
}
#endif
trace() << job.inputFile() << " compiled " << torepeat << " times on " << job.targetPlatform() << "\n";
map<string, string> versionfile_map, version_map;
Environments envs = rip_out_paths( _envs, version_map, versionfile_map );
if (!envs.size()) {
log_error() << "$ICECC_VERSION needs to point to .tar files\n";
throw(22);
}
const char *preferred_host = getenv("ICECC_PREFERRED_HOST");
if ( torepeat == 1 ) {
string fake_filename;
list<string> args = job.remoteFlags();
for ( list<string>::const_iterator it = args.begin(); it != args.end(); ++it )
fake_filename += "/" + *it;
args = job.restFlags();
for ( list<string>::const_iterator it = args.begin(); it != args.end(); ++it )
fake_filename += "/" + *it;
fake_filename += get_absfilename( job.inputFile() );
GetCSMsg getcs (envs, fake_filename, job.language(), torepeat,
job.targetPlatform(), job.argumentFlags(),
preferred_host ? preferred_host : string(),
ignore_unverified());
if (!local_daemon->send_msg (getcs)) {
log_warning() << "asked for CS\n";
throw( 24 );
}
UseCSMsg *usecs = get_server( local_daemon );
int ret;
if (!maybe_build_local (local_daemon, usecs, job, ret))
ret = build_remote_int( job, usecs, local_daemon,
version_map[usecs->host_platform],
versionfile_map[usecs->host_platform],
0, true );
delete usecs;
return ret;
} else
{
char *preproc = 0;
dcc_make_tmpnam( "icecc", ".ix", &preproc, 0 );
const CharBufferDeleter preproc_holder(preproc);
int cpp_fd = open(preproc, O_WRONLY );
/* When call_cpp returns normally (for the parent) it will have closed
the write fd, i.e. cpp_fd. */
pid_t cpp_pid = call_cpp(job, cpp_fd );
if ( cpp_pid == -1 ) {
::unlink( preproc );
throw( 10 );
}
int status = 255;
waitpid( cpp_pid, &status, 0);
if ( shell_exit_status(status) ) { // failure
::unlink( preproc );
return shell_exit_status( status );
}
char rand_seed[400]; // "designed to be oversized" (Levi's)
sprintf( rand_seed, "-frandom-seed=%d", rand() );
job.appendFlag( rand_seed, Arg_Remote );
GetCSMsg getcs (envs, get_absfilename( job.inputFile() ), job.language(), torepeat,
job.targetPlatform(), job.argumentFlags(), preferred_host ? preferred_host : string(),
ignore_unverified());
if (!local_daemon->send_msg (getcs)) {
log_warning() << "asked for CS\n";
throw( 0 );
}
map<pid_t, int> jobmap;
CompileJob *jobs = new CompileJob[torepeat];
UseCSMsg **umsgs = new UseCSMsg*[torepeat];
bool misc_error = false;
int *exit_codes = new int[torepeat];
for ( int i = 0; i < torepeat; i++ ) // init
exit_codes[i] = 42;
for ( int i = 0; i < torepeat; i++ ) {
jobs[i] = job;
char *buffer = 0;
if ( i ) {
dcc_make_tmpnam( "icecc", ".o", &buffer, 0 );
//.........这里部分代码省略.........
示例4: 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 );
// Safety check
if (getuid() == 0 || getgid() == 0) {
error_client( client, "UID is 0 - aborting." );
_exit(142);
}
#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
char **argv = new char*[argc + 1];
int i = 0;
if (j.language() == CompileJob::Lang_C)
argv[i++] = strdup( "usr/bin/gcc" );
else if (j.language() == CompileJob::Lang_CXX)
argv[i++] = strdup( "usr/bin/g++" );
else
assert(0);
bool hasPipe = false;
//.........这里部分代码省略.........
示例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);
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]);
//.........这里部分代码省略.........
示例6: 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 );
//.........这里部分代码省略.........
示例7: analyse_argv
//.........这里部分代码省略.........
always_local = true;
break;
}
if ( it->first == "-Xclang" ) {
++it;
++it;
} else if ( it->second != Arg_Rest || it->first.at( 0 ) == '-' || it->first.at( 0 ) == '@' )
++it;
else if ( ifile.empty() ) {
#if CLIENT_DEBUG
log_info() << "input file: " << it->first << endl;
#endif
job.setInputFile( it->first );
ifile = it->first;
it = args.erase( it );
} else {
log_info() << "found another non option on command line. Two input files? " << it->first << endl;
always_local = true;
args = backup;
job.setInputFile( string() );
break;
}
}
if ( ifile.find( '.' ) != string::npos ) {
string::size_type dot_index = ifile.find_last_of( '.' );
string ext = ifile.substr( dot_index + 1 );
if (ext == "cc"
|| ext == "cpp" || ext == "cxx"
|| ext == "cp" || ext == "c++"
|| ext == "C" || ext == "ii") {
#if CLIENT_DEBUG
if ( job.language() != CompileJob::Lang_CXX )
log_info() << "switching to C++ for " << ifile << endl;
#endif
job.setLanguage( CompileJob::Lang_CXX );
} else if(ext == "mi" || ext == "m"
|| ext == "mii" || ext == "mm"
|| ext == "M" ) {
job.setLanguage( CompileJob::Lang_OBJC );
} else if ( ext == "s" || ext == "S" || // assembler
ext == "ads" || ext == "adb" || // ada
ext == "f" || ext == "for" || // fortran
ext == "FOR" || ext == "F" ||
ext == "fpp" || ext == "FPP" ||
ext == "r" ) {
always_local = true;
} else if ( ext != "c" && ext != "i" ) { // C is special, it depends on arg[0] name
log_warning() << "unknown extension " << ext << endl;
always_local = true;
}
if ( !always_local && ofile.empty() ) {
ofile = ifile.substr( 0, dot_index );
if ( seen_s )
ofile += ".s";
else
ofile += ".o";
string::size_type slash = ofile.find_last_of( '/' );
if ( slash != string::npos )
ofile = ofile.substr( slash + 1 );
}
if ( !always_local && seen_md && !seen_mf) {
string dfile = ofile.substr( 0, ofile.find_last_of( '.' ) ) + ".d";