示例#1
0
static const char* addCurrentDirToSourceFile(const char* filename,
                                             const char* modFilename) {
  // Do nothing if modFilename is NULL
  if (modFilename == NULL) {
    return filename;
  }

  // Do nothing if the filename is already absolute
  if (filename[0] == '/') {
    return filename;
  }

  // Do nothing if the current module's directory is "./"
  const char* modDir = getDirectory(modFilename);
  if (strcmp(modDir, ".") == 0) {
    return filename;
  }

  // If the file is a .c or .o...
  if (isCSource(filename) || isObjFile(filename)) {
    // ...and it isn't already an absolute path, add the module directory
    return astr(modDir, "/", filename);
  }

  // If the file is a .h, add the module's directory to the -I path
  if (isCHeader(filename)) {
    for_vector(const char, dir, incDirs) {
      if (dir == modDir) {
        // we've already added this -I directory, so don't do it again
        return filename;
      }
    }
    addIncInfo(modDir);
    return filename;
  }

  // otherwise, leave it as-is
  return filename;
}
示例#2
0
文件: files.cpp 项目: DawidvC/chapel
static void genObjFiles(FILE* makefile) {
  int filenum = 0;
  int first = 1;
  while (const char* inputFilename = nthFilename(filenum++)) {
    bool objfile = isObjFile(inputFilename);
    bool cfile = isCSource(inputFilename);
    if (objfile || cfile) {
      if (first) {
        fprintf(makefile, "CHPL_CL_OBJS = \\\n");
        first = 0;
      }
      if (objfile) {
        fprintf(makefile, "\t%s \\\n", inputFilename);
      } else {
        const char* pathlessFilename = stripdirectories(inputFilename);
        const char* objFilename = genIntermediateFilename(astr(pathlessFilename, ".o"));
        fprintf(makefile, "\t%s \\\n", objFilename);
      }
    }
  }
  if (!first)
    fprintf(makefile, "\n");
}
示例#3
0
文件: files.cpp 项目: DawidvC/chapel
static bool isRecognizedSource(const char* filename) {
  return (isCSource(filename) ||
          isCHeader(filename) ||
          isObjFile(filename) ||
          isChplSource(filename));
}