~ubuntu-branches/ubuntu/utopic/cmake/utopic

« back to all changes in this revision

Viewing changes to Source/cmFileCommand.cxx

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2013-10-10 12:54:39 UTC
  • mfrom: (1.14.7)
  • Revision ID: package-import@ubuntu.com-20131010125439-h0ahaj004on6oj92
Tags: 2.8.12-0ubuntu1
New upstream release LP: #1246701

Show diffs side-by-side

added added

removed removed

Lines of Context:
167
167
    {
168
168
    return this->HandleTimestampCommand(args);
169
169
    }
 
170
  else if ( subCommand == "GENERATE" )
 
171
    {
 
172
    return this->HandleGenerateCommand(args);
 
173
    }
170
174
 
171
175
  std::string e = "does not recognize sub-command "+subCommand;
172
176
  this->SetError(e.c_str());
1970
1974
  else
1971
1975
    {
1972
1976
    cmOStringStream e;
1973
 
    e << "Option TYPE given uknown value \"" << stype << "\".";
 
1977
    e << "Option TYPE given unknown value \"" << stype << "\".";
1974
1978
    this->FileCommand->SetError(e.str().c_str());
1975
1979
    return false;
1976
1980
    }
1985
1989
  // allow for / to be a valid destination
1986
1990
  if ( destination.size() < 2 && destination != "/" )
1987
1991
    {
1988
 
    this->FileCommand->SetError("called with inapropriate arguments. "
 
1992
    this->FileCommand->SetError("called with inappropriate arguments. "
1989
1993
        "No DESTINATION provided or .");
1990
1994
    return false;
1991
1995
    }
2485
2489
  cmWriteToFileCallback(void *ptr, size_t size, size_t nmemb,
2486
2490
                        void *data)
2487
2491
    {
2488
 
    register int realsize = (int)(size * nmemb);
 
2492
    int realsize = (int)(size * nmemb);
2489
2493
    std::ofstream* fout = static_cast<std::ofstream*>(data);
2490
2494
    const char* chPtr = static_cast<char*>(ptr);
2491
2495
    fout->write(chPtr, realsize);
2497
2501
  cmWriteToMemoryCallback(void *ptr, size_t size, size_t nmemb,
2498
2502
                          void *data)
2499
2503
    {
2500
 
    register int realsize = (int)(size * nmemb);
 
2504
    int realsize = (int)(size * nmemb);
2501
2505
    cmFileCommandVectorOfChar *vec
2502
2506
      = static_cast<cmFileCommandVectorOfChar*>(data);
2503
2507
    const char* chPtr = static_cast<char*>(ptr);
3250
3254
}
3251
3255
 
3252
3256
//----------------------------------------------------------------------------
 
3257
void cmFileCommand::AddEvaluationFile(const std::string &inputName,
 
3258
                                      const std::string &outputExpr,
 
3259
                                      const std::string &condition,
 
3260
                                      bool inputIsContent
 
3261
                                     )
 
3262
{
 
3263
  cmListFileBacktrace lfbt;
 
3264
  this->Makefile->GetBacktrace(lfbt);
 
3265
 
 
3266
  cmGeneratorExpression outputGe(lfbt);
 
3267
  cmsys::auto_ptr<cmCompiledGeneratorExpression> outputCge
 
3268
                                                = outputGe.Parse(outputExpr);
 
3269
 
 
3270
  cmGeneratorExpression conditionGe(lfbt);
 
3271
  cmsys::auto_ptr<cmCompiledGeneratorExpression> conditionCge
 
3272
                                              = conditionGe.Parse(condition);
 
3273
 
 
3274
  this->Makefile->GetLocalGenerator()
 
3275
                ->GetGlobalGenerator()->AddEvaluationFile(inputName,
 
3276
                                                          outputCge,
 
3277
                                                          this->Makefile,
 
3278
                                                          conditionCge,
 
3279
                                                          inputIsContent);
 
3280
}
 
3281
 
 
3282
//----------------------------------------------------------------------------
 
3283
bool cmFileCommand::HandleGenerateCommand(
 
3284
  std::vector<std::string> const& args)
 
3285
{
 
3286
  if (args.size() < 5)
 
3287
    {
 
3288
    this->SetError("Incorrect arguments to GENERATE subcommand.");
 
3289
    return false;
 
3290
    }
 
3291
  if (args[1] != "OUTPUT")
 
3292
    {
 
3293
    this->SetError("Incorrect arguments to GENERATE subcommand.");
 
3294
    return false;
 
3295
    }
 
3296
  std::string condition;
 
3297
  if (args.size() > 5)
 
3298
    {
 
3299
    if (args[5] != "CONDITION")
 
3300
      {
 
3301
      this->SetError("Incorrect arguments to GENERATE subcommand.");
 
3302
      return false;
 
3303
      }
 
3304
    if (args.size() != 7)
 
3305
      {
 
3306
      this->SetError("Incorrect arguments to GENERATE subcommand.");
 
3307
      return false;
 
3308
      }
 
3309
    condition = args[6];
 
3310
    if (condition.empty())
 
3311
      {
 
3312
      this->SetError("CONDITION of sub-command GENERATE must not be empty if "
 
3313
        "specified.");
 
3314
      return false;
 
3315
      }
 
3316
    }
 
3317
  std::string output = args[2];
 
3318
  const bool inputIsContent = args[3] != "INPUT";
 
3319
  if (inputIsContent && args[3] != "CONTENT")
 
3320
    {
 
3321
    this->SetError("Incorrect arguments to GENERATE subcommand.");
 
3322
    return false;
 
3323
    }
 
3324
  std::string input = args[4];
 
3325
 
 
3326
  this->AddEvaluationFile(input, output, condition, inputIsContent);
 
3327
  return true;
 
3328
}
 
3329
 
 
3330
//----------------------------------------------------------------------------
3253
3331
bool cmFileCommand::HandleTimestampCommand(
3254
3332
  std::vector<std::string> const& args)
3255
3333
{