Example #1
0
  /**
   * Given a library file, find the configuration element that matches the current platform and
   * target
   *
   * @param lib
   * @return the configuration that matches the current platform and target
   */
  private Configuration getTargetConfiguration(Library lib) {
    String matchedConfigName = null;

    // check whether platform and target match what we support
    ArrayList<Platform> platforms = lib.getPlatforms();
    if (platforms != null) {
      for (Platform p : platforms) {
        if (p.getValue().equals(_platform)) {
          ArrayList<Target> targets = p.getTargets();

          if (targets != null) {
            for (Target t : targets) {
              if (t.getVersion().equals(_targetVersion)) {
                matchedConfigName = t.getConfigName();
              }
            }
          }
        }
      }
    }

    // make sure the config is defined
    if (matchedConfigName != null) {
      ArrayList<Configuration> configurations = lib.getConfigurations();

      for (Configuration config : configurations) {
        if (config.getName().equals(matchedConfigName)) {
          return config;
        }
      }
    }

    return null;
  }