コード例 #1
0
ファイル: package.c プロジェクト: lzpfmh/ponyc
bool package_init(pass_opt_t* opt)
{
  if(!codegen_init(opt))
    return false;

  // package_add_paths for command line paths has already been done. Here, we
  // append the paths from an optional environment variable, and then the paths
  // that are relative to the compiler location on disk.
  package_add_paths(getenv("PONYPATH"));
  add_exec_dir();

  // Convert all the safe packages to their full paths.
  strlist_t* full_safe = NULL;

  while(safe != NULL)
  {
    const char* path;
    safe = strlist_pop(safe, &path);

    // Lookup (and hence normalise) path.
    path = find_path(NULL, path, NULL);

    if(path == NULL)
    {
      strlist_free(full_safe);
      return false;
    }

    full_safe = strlist_push(full_safe, path);
  }

  safe = full_safe;
  return true;
}
コード例 #2
0
ファイル: package.c プロジェクト: dleonard0/ponyc
bool package_init(pass_opt_t* opt)
{
  if(!codegen_init(opt))
    return false;

  package_add_paths(getenv("PONYPATH"));
  add_exec_dir();

  // Convert all the safe packages to their full paths.
  strlist_t* full_safe = NULL;

  while(safe != NULL)
  {
    const char* path;
    safe = strlist_pop(safe, &path);

    // Lookup (and hence normalise) path.
    path = find_path(NULL, path);

    if(path == NULL)
    {
      strlist_free(full_safe);
      return false;
    }

    full_safe = strlist_push(full_safe, path);
  }

  safe = full_safe;
  return true;
}
コード例 #3
0
ファイル: package.c プロジェクト: dipinhora/ponyc
bool package_init(pass_opt_t* opt)
{
  // package_add_paths for command line paths has already been done. Here, we
  // append the paths from an optional environment variable, and then the paths
  // that are relative to the compiler location on disk.
  package_add_paths(getenv("PONYPATH"), opt);
  if(!add_exec_dir(opt))
  {
    errorf(opt->check.errors, NULL, "Error adding package paths relative to ponyc binary location");
    return false;
  }

  // Finally we add OS specific paths.
#ifdef PLATFORM_IS_POSIX_BASED
  add_path("/usr/local/lib", opt);
  add_path("/opt/local/lib", opt);
#endif

  // Convert all the safe packages to their full paths.
  strlist_t* full_safe = NULL;
  strlist_t* safe = opt->safe_packages;

  while(safe != NULL)
  {
    const char* path;
    safe = strlist_pop(safe, &path);

    // Lookup (and hence normalise) path.
    path = find_path(NULL, path, NULL, NULL, opt);

    if(path == NULL)
    {
      strlist_free(full_safe);
      strlist_free(safe);
      opt->safe_packages = NULL;
      return false;
    }

    full_safe = strlist_push(full_safe, path);
  }

  opt->safe_packages = full_safe;

  if(opt->simple_builtin)
    package_add_magic_src("builtin", simple_builtin, opt);

  return true;
}