Example #1
0
  static private List getCommandCompilerCPP(String avrBasePath,
    List includePaths, String sourceName, String objectName,
    Map<String, String> boardPreferences) {
    
    List baseCommandCompilerCPP = new ArrayList(Arrays.asList(new String[] {
      avrBasePath + "avr-g++",
      "-c", // compile, don't link
      "-g", // include debugging info (so errors include line numbers)
      "-Os", // optimize for size
      Preferences.getBoolean("build.verbose") ? "-Wall" : "-w", // show warnings if verbose
      "-fno-exceptions",
      "-ffunction-sections", // place each function in its own section
      "-fdata-sections",
      "-mmcu=" + boardPreferences.get("build.mcu"),
      "-DF_CPU=" + boardPreferences.get("build.f_cpu"),
      "-MMD", // output dependancy info
      "-DUSB_VID=" + boardPreferences.get("build.vid"),
      "-DUSB_PID=" + boardPreferences.get("build.pid"),      
      "-DARDUINO=" + Base.REVISION,
    }));

    for (int i = 0; i < includePaths.size(); i++) {
      baseCommandCompilerCPP.add("-I" + (String) includePaths.get(i));
    }

    baseCommandCompilerCPP.add(sourceName);
    baseCommandCompilerCPP.add("-o");
    baseCommandCompilerCPP.add(objectName);

    return baseCommandCompilerCPP;
  }
Example #2
0
  private synchronized void init() throws SQLException {
    if (isClosed) return;

    // do tables exists?
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery(TABLE_NAMES_SELECT_STMT);

    ArrayList<String> missingTables = new ArrayList(TABLES.keySet());
    while (rs.next()) {
      String tableName = rs.getString("name");
      missingTables.remove(tableName);
    }

    for (String missingTable : missingTables) {
      try {
        Statement createStmt = conn.createStatement();
        // System.out.println("Adding table "+ missingTable);
        createStmt.executeUpdate(TABLES.get(missingTable));
        createStmt.close();

      } catch (Exception e) {
        System.err.println(e.getClass().getName() + ": " + e.getMessage());
      }
    }
  }
 private void resolveLocalFileHeaderData(
     final Map<ZipEntry, NameAndComment> entriesWithoutUTF8Flag) throws IOException {
   for (final Entry ze : this.entries) {
     final OffsetEntry offsetEntry = ze.getOffsetEntry();
     final long offset = offsetEntry.headerOffset;
     this.archive.seek(offset + 26L);
     this.archive.readFully(this.SHORT_BUF);
     final int fileNameLen = ZipShort.getValue(this.SHORT_BUF);
     this.archive.readFully(this.SHORT_BUF);
     final int extraFieldLen = ZipShort.getValue(this.SHORT_BUF);
     int skipped;
     for (int lenToSkip = fileNameLen; lenToSkip > 0; lenToSkip -= skipped) {
       skipped = this.archive.skipBytes(lenToSkip);
       if (skipped <= 0) {
         throw new IOException("failed to skip file name in local file header");
       }
     }
     final byte[] localExtraData = new byte[extraFieldLen];
     this.archive.readFully(localExtraData);
     ze.setExtra(localExtraData);
     offsetEntry.dataOffset = offset + 26L + 2L + 2L + fileNameLen + extraFieldLen;
     if (entriesWithoutUTF8Flag.containsKey(ze)) {
       final NameAndComment nc = entriesWithoutUTF8Flag.get(ze);
       ZipUtil.setNameAndCommentFromExtraFields(ze, nc.name, nc.comment);
     }
     final String name = ze.getName();
     LinkedList<ZipEntry> entriesOfThatName = this.nameMap.get(name);
     if (entriesOfThatName == null) {
       entriesOfThatName = new LinkedList<ZipEntry>();
       this.nameMap.put(name, entriesOfThatName);
     }
     entriesOfThatName.addLast(ze);
   }
 }
 public void setSdkInfo(Map<String, String> map) {
   if (map != null) {
     mMinSdkVersion = map.get("minSdkVersion");
     mTargetSdkVersion = map.get("targetSdkVersion");
     mMaxSdkVersion = map.get("maxSdkVersion");
   }
 }
Example #5
0
 /**
  * Expands list of files to process into full list of all files that can be found by recursively
  * descending directories.
  */
 void expand(File dir, String[] files, boolean isUpdate) {
   if (files == null) {
     return;
   }
   for (int i = 0; i < files.length; i++) {
     File f;
     if (dir == null) {
       f = new File(files[i]);
     } else {
       f = new File(dir, files[i]);
     }
     if (f.isFile()) {
       if (entries.add(f)) {
         if (isUpdate) entryMap.put(entryName(f.getPath()), f);
       }
     } else if (f.isDirectory()) {
       if (entries.add(f)) {
         if (isUpdate) {
           String dirPath = f.getPath();
           dirPath = (dirPath.endsWith(File.separator)) ? dirPath : (dirPath + File.separator);
           entryMap.put(entryName(dirPath), f);
         }
         expand(f, f.list(), isUpdate);
       }
     } else {
       error(formatMsg("error.nosuch.fileordir", String.valueOf(f)));
       ok = false;
     }
   }
 }
Example #6
0
 @Override
 public void removeKey(final String key) {
   final String[] parts =
       (String[])
           Iterables.toArray(
               Splitter.on('.').split((CharSequence) this.createRelativeKey(key)),
               (Class) String.class);
   final Map<String, Tag> parent = this.findLastParent(parts);
   parent.remove(parts[parts.length - 1]);
 }
Example #7
0
 private Map<String, Tag> findLastParent(final String[] parts) {
   Map<String, Tag> map = NBTStorage.this.root;
   for (int i = 0; i < parts.length - 1; ++i) {
     if (!map.containsKey(parts[i]) || !(map.get(parts[i]) instanceof CompoundTag)) {
       return null;
     }
     map = map.get(parts[i]).getValue();
   }
   return map;
 }
Example #8
0
 public void addEnvToIntent(Intent intent) {
   Map<String, String> envMap = System.getenv();
   Set<Map.Entry<String, String>> envSet = envMap.entrySet();
   Iterator<Map.Entry<String, String>> envIter = envSet.iterator();
   int c = 0;
   while (envIter.hasNext()) {
     Map.Entry<String, String> entry = envIter.next();
     intent.putExtra("env" + c, entry.getKey() + "=" + entry.getValue());
     c++;
   }
 }
  /**
   * Determines best content encoding for the response, based on the request -- in particular, based
   * on its "Accept-Encoding" header.
   *
   * @param httpRequest request
   * @return best content encoding
   */
  static String getBestContentEncoding(HttpServletRequest httpRequest) {

    String forcedEncoding = (String) httpRequest.getAttribute(CompressingFilter.FORCE_ENCODING_KEY);
    String bestEncoding;
    if (forcedEncoding != null) {

      bestEncoding = forcedEncoding;

    } else {

      String acceptEncodingHeader =
          httpRequest.getHeader(CompressingHttpServletResponse.ACCEPT_ENCODING_HEADER);
      if (acceptEncodingHeader == null) {

        bestEncoding = NO_ENCODING;

      } else {

        bestEncoding = BEST_ENCODING_CACHE.get(acceptEncodingHeader);

        if (bestEncoding == null) {

          // No cached value; must parse header to determine best encoding
          // I don't synchronize on bestEncodingCache; it's not worth it to avoid the rare case
          // where
          // two thread get in here and both parse the header. It's only a tiny bit of extra work,
          // and
          // avoids the synchronization overhead.

          if (acceptEncodingHeader.indexOf((int) ',') >= 0) {
            // multiple encodings are accepted
            bestEncoding = selectBestEncoding(acceptEncodingHeader);
          } else {
            // one encoding is accepted
            bestEncoding = parseBestEncoding(acceptEncodingHeader);
          }

          BEST_ENCODING_CACHE.put(acceptEncodingHeader, bestEncoding);
        }
      }
    }

    // User-specified encoding might not be supported
    if (!isSupportedResponseContentEncoding(bestEncoding)) {
      bestEncoding = NO_ENCODING;
    }

    return bestEncoding;
  }
  /**
   * Helper function to get value from map.
   *
   * @param map Map to take value from.
   * @param key Key to search in map.
   * @param ifNull Default value if {@code null} was returned by map.
   * @param <K> Key type.
   * @param <V> Value type.
   * @return Value from map or default value if map return {@code null}.
   */
  public static <K, V> V getOrElse(Map<K, V> map, K key, V ifNull) {
    assert map != null;

    V res = map.get(key);

    return res != null ? res : ifNull;
  }
Example #11
0
 private Tag findLastTag(final String key, final boolean relative) {
   final String[] parts =
       (String[])
           Iterables.toArray(
               Splitter.on('.')
                   .omitEmptyStrings()
                   .split((CharSequence) (relative ? this.createRelativeKey(key) : key)),
               (Class) String.class);
   if (parts.length == 0) {
     return new CompoundTag(NBTStorage.this.name, NBTStorage.this.root);
   }
   final Map<String, Tag> map = this.findLastParent(parts);
   if (!map.containsKey(parts[parts.length - 1])) {
     return null;
   }
   return map.get(parts[parts.length - 1]);
 }
Example #12
0
 private void readCentralDirectoryEntry(final Map<ZipEntry, NameAndComment> noUTF8Flag)
     throws IOException {
   this.archive.readFully(this.CFH_BUF);
   int off = 0;
   final OffsetEntry offset = new OffsetEntry();
   final Entry ze = new Entry(offset);
   final int versionMadeBy = ZipShort.getValue(this.CFH_BUF, off);
   off += 2;
   ze.setPlatform(versionMadeBy >> 8 & 0xF);
   off += 2;
   final GeneralPurposeBit gpFlag = GeneralPurposeBit.parse(this.CFH_BUF, off);
   final boolean hasUTF8Flag = gpFlag.usesUTF8ForNames();
   final ZipEncoding entryEncoding =
       hasUTF8Flag ? ZipEncodingHelper.UTF8_ZIP_ENCODING : this.zipEncoding;
   ze.setGeneralPurposeBit(gpFlag);
   off += 2;
   ze.setMethod(ZipShort.getValue(this.CFH_BUF, off));
   off += 2;
   final long time = ZipUtil.dosToJavaTime(ZipLong.getValue(this.CFH_BUF, off));
   ze.setTime(time);
   off += 4;
   ze.setCrc(ZipLong.getValue(this.CFH_BUF, off));
   off += 4;
   ze.setCompressedSize(ZipLong.getValue(this.CFH_BUF, off));
   off += 4;
   ze.setSize(ZipLong.getValue(this.CFH_BUF, off));
   off += 4;
   final int fileNameLen = ZipShort.getValue(this.CFH_BUF, off);
   off += 2;
   final int extraLen = ZipShort.getValue(this.CFH_BUF, off);
   off += 2;
   final int commentLen = ZipShort.getValue(this.CFH_BUF, off);
   off += 2;
   final int diskStart = ZipShort.getValue(this.CFH_BUF, off);
   off += 2;
   ze.setInternalAttributes(ZipShort.getValue(this.CFH_BUF, off));
   off += 2;
   ze.setExternalAttributes(ZipLong.getValue(this.CFH_BUF, off));
   off += 4;
   final byte[] fileName = new byte[fileNameLen];
   this.archive.readFully(fileName);
   ze.setName(entryEncoding.decode(fileName), fileName);
   offset.headerOffset = ZipLong.getValue(this.CFH_BUF, off);
   this.entries.add(ze);
   final byte[] cdExtraData = new byte[extraLen];
   this.archive.readFully(cdExtraData);
   ze.setCentralDirectoryExtra(cdExtraData);
   this.setSizesAndOffsetFromZip64Extra(ze, offset, diskStart);
   final byte[] comment = new byte[commentLen];
   this.archive.readFully(comment);
   ze.setComment(entryEncoding.decode(comment));
   if (!hasUTF8Flag && this.useUnicodeExtraFields) {
     noUTF8Flag.put(ze, new NameAndComment(fileName, comment));
   }
 }
Example #13
0
  /**
   * Writes the index file out to <code>jos</code>. <code>oldEntries</code> gives the names of the
   * files that were removed, <code>movedMap</code> maps from the new name to the old name.
   */
  private static void createIndex(JarOutputStream jos, List oldEntries, Map movedMap)
      throws IOException {
    StringWriter writer = new StringWriter();

    writer.write(VERSION_HEADER);
    writer.write("\r\n");

    // Write out entries that have been removed
    for (int counter = 0; counter < oldEntries.size(); counter++) {
      String name = (String) oldEntries.get(counter);

      writer.write(REMOVE_COMMAND);
      writer.write(" ");
      writeEscapedString(writer, name);
      writer.write("\r\n");
    }

    // And those that have moved
    Iterator names = movedMap.keySet().iterator();

    if (names != null) {
      while (names.hasNext()) {
        String newName = (String) names.next();
        String oldName = (String) movedMap.get(newName);

        writer.write(MOVE_COMMAND);
        writer.write(" ");
        writeEscapedString(writer, oldName);
        writer.write(" ");
        writeEscapedString(writer, newName);
        writer.write("\r\n");
      }
    }

    JarEntry je = new JarEntry(INDEX_NAME);
    byte[] bytes = writer.toString().getBytes("UTF-8");

    writer.close();
    jos.putNextEntry(je);
    jos.write(bytes, 0, bytes.length);
  }
Example #14
0
 @Override
 public Map<String, Object> getValuesDeep() {
   final Tag tag = this.findLastTag(this.path, false);
   if (!(tag instanceof CompoundTag)) {
     return Collections.emptyMap();
   }
   final Queue<Node> node =
       new ArrayDeque<Node>(
           (Collection<? extends Node>) ImmutableList.of((Object) new Node(tag)));
   final Map<String, Object> values = (Map<String, Object>) Maps.newHashMap();
   while (!node.isEmpty()) {
     final Node root = node.poll();
     for (final Map.Entry<String, Tag> entry : root.values.entrySet()) {
       final String key = this.createRelativeKey(root.parent, entry.getKey());
       if (entry.getValue() instanceof CompoundTag) {
         node.add(new Node(key, entry.getValue()));
       } else {
         values.put(key, entry.getValue().getValue());
       }
     }
   }
   return values;
 }
Example #15
0
  static private List getCommandCompilerS(String avrBasePath, List includePaths,
    String sourceName, String objectName, Map<String, String> boardPreferences) {
    List baseCommandCompiler = new ArrayList(Arrays.asList(new String[] {
      avrBasePath + "avr-gcc",
      "-c", // compile, don't link
      "-g", // include debugging info (so errors include line numbers)
      "-assembler-with-cpp",
      "-mmcu=" + boardPreferences.get("build.mcu"),
      "-DF_CPU=" + boardPreferences.get("build.f_cpu"),      
      "-DARDUINO=" + Base.REVISION,
      "-DUSB_VID=" + boardPreferences.get("build.vid"),
      "-DUSB_PID=" + boardPreferences.get("build.pid"),
    }));

    for (int i = 0; i < includePaths.size(); i++) {
      baseCommandCompiler.add("-I" + (String) includePaths.get(i));
    }

    baseCommandCompiler.add(sourceName);
    baseCommandCompiler.add("-o"+ objectName);

    return baseCommandCompiler;
  }
 static {
   Map<String, CompressingStreamFactory> temp = new HashMap<>(11);
   temp.put(GZIP_ENCODING, GZIP_CSF);
   temp.put(X_GZIP_ENCODING, GZIP_CSF);
   temp.put(COMPRESS_ENCODING, ZIP_CSF);
   temp.put(X_COMPRESS_ENCODING, ZIP_CSF);
   temp.put(DEFLATE_ENCODING, DEFLATE_CSF);
   FACTORY_MAP = Collections.unmodifiableMap(temp);
 }
Example #17
0
 private void putTag(final String key, final Tag tag) {
   final String[] parts =
       (String[])
           Iterables.toArray(
               Splitter.on('.').split((CharSequence) this.createRelativeKey(key)),
               (Class) String.class);
   Map<String, Tag> parent = NBTStorage.this.root;
   for (int i = 0; i < parts.length - 1; ++i) {
     if (!parent.containsKey(parts[i]) || !(parent.get(parts[i]) instanceof CompoundTag)) {
       parent.put(parts[i], new CompoundTag(parts[i]));
     }
     parent = parent.get(parts[i]).getValue();
   }
   parent.put(tag.getName(), tag);
 }
Example #18
0
  /** Updates an existing jar file. */
  boolean update(InputStream in, OutputStream out, InputStream newManifest, JarIndex jarIndex)
      throws IOException {
    ZipInputStream zis = new ZipInputStream(in);
    ZipOutputStream zos = new JarOutputStream(out);
    ZipEntry e = null;
    boolean foundManifest = false;
    boolean updateOk = true;

    if (jarIndex != null) {
      addIndex(jarIndex, zos);
    }

    // put the old entries first, replace if necessary
    while ((e = zis.getNextEntry()) != null) {
      String name = e.getName();

      boolean isManifestEntry = equalsIgnoreCase(name, MANIFEST_NAME);

      if ((jarIndex != null && equalsIgnoreCase(name, INDEX_NAME)) || (Mflag && isManifestEntry)) {
        continue;
      } else if (isManifestEntry && ((newManifest != null) || (ename != null) || (pname != null))) {
        foundManifest = true;
        if (newManifest != null) {
          // Don't read from the newManifest InputStream, as we
          // might need it below, and we can't re-read the same data
          // twice.
          FileInputStream fis = new FileInputStream(mname);
          boolean ambiguous = isAmbiguousMainClass(new Manifest(fis));
          fis.close();
          if (ambiguous) {
            return false;
          }
        }

        // Update the manifest.
        Manifest old = new Manifest(zis);
        if (newManifest != null) {
          old.read(newManifest);
        }
        if (!updateManifest(old, zos)) {
          return false;
        }
      } else {
        if (!entryMap.containsKey(name)) { // copy the old stuff
          // do our own compression
          ZipEntry e2 = new ZipEntry(name);
          e2.setMethod(e.getMethod());
          e2.setTime(e.getTime());
          e2.setComment(e.getComment());
          e2.setExtra(e.getExtra());
          if (e.getMethod() == ZipEntry.STORED) {
            e2.setSize(e.getSize());
            e2.setCrc(e.getCrc());
          }
          zos.putNextEntry(e2);
          copy(zis, zos);
        } else { // replace with the new files
          File f = entryMap.get(name);
          addFile(zos, f);
          entryMap.remove(name);
          entries.remove(f);
        }
      }
    }

    // add the remaining new files
    for (File f : entries) {
      addFile(zos, f);
    }
    if (!foundManifest) {
      if (newManifest != null) {
        Manifest m = new Manifest(newManifest);
        updateOk = !isAmbiguousMainClass(m);
        if (updateOk) {
          if (!updateManifest(m, zos)) {
            updateOk = false;
          }
        }
      } else if (ename != null || pname != null) {
        if (!updateManifest(new Manifest(), zos)) {
          updateOk = false;
        }
      }
    }
    zis.close();
    zos.close();
    return updateOk;
  }
Example #19
0
  /**
   * Compile with avr-gcc.
   *
   * @param sketch Sketch object to be compiled.
   * @param buildPath Where the temporary files live and will be built from.
   * @param primaryClassName the name of the combined sketch file w/ extension
   * @return true if successful.
   * @throws RunnerException Only if there's a problem. Only then.
   * 
  * [ROBOTIS]Changed prototype to support ARM Cortex-M3 based CM-900 Pandora project
  * 2012-09-26 [email protected]
  * */
  public boolean compile(Sketch sketch, //change return type[ROBOTIS]
                         String buildPath,
                         String primaryClassName,
                         boolean verbose,
                         List<String> ignored) throws RunnerException {
    this.sketch = sketch;
    this.buildPath = buildPath;
    this.primaryClassName = primaryClassName; //예를 들면 cpp파일로 변환된 AnalogReadSerial.cpp
    this.verbose = verbose;
    this.sketchIsCompiled = false;
    System.out.println("Compiler.compile() sketch ="+sketch.getName()+"buildpath ="+buildPath+"primaryClassName ="+primaryClassName);
    // the pms object isn't used for anything but storage
    MessageStream pms = new MessageStream(this);

    String avrBasePath = Base.getAvrBasePath();
    System.out.println("[ROBOTIS]avrBasePath ="+avrBasePath);
    Map<String, String> boardPreferences = Base.getBoardPreferences();
    String core = boardPreferences.get("build.core");
    System.out.println("[ROBOTIS]build.core ="+core);
    if (core == null) {
    	RunnerException re = new RunnerException(_("No board selected; please choose a board from the Tools > Board menu."));
      re.hideStackTrace();
      throw re;
    }
    String corePath;
    
    if (core.indexOf(':') == -1) {
      Target t = Base.getTarget();
      File coreFolder = new File(new File(t.getFolder(), "cores"), core);
      corePath = coreFolder.getAbsolutePath();
      
    } else {
      Target t = Base.targetsTable.get(core.substring(0, core.indexOf(':')));
      File coreFolder = new File(t.getFolder(), "cores");
      coreFolder = new File(coreFolder, core.substring(core.indexOf(':') + 1));
      corePath = coreFolder.getAbsolutePath();
    }

    System.out.println("[ROBOTIS]corePath ="+corePath);
    
    String variant = boardPreferences.get("build.variant");
    String variantPath = null;
    
    if (variant != null) {
      if (variant.indexOf(':') == -1) {
	Target t = Base.getTarget();
	File variantFolder = new File(new File(t.getFolder(), "variants"), variant);
	variantPath = variantFolder.getAbsolutePath();
      } else {
	Target t = Base.targetsTable.get(variant.substring(0, variant.indexOf(':')));
	File variantFolder = new File(t.getFolder(), "variants");
	variantFolder = new File(variantFolder, variant.substring(variant.indexOf(':') + 1));
	variantPath = variantFolder.getAbsolutePath();
      }
    }

    List<File> objectFiles = new ArrayList<File>();

   // 0. include paths for core + all libraries

   sketch.setCompilingProgress(20);
   List includePaths = new ArrayList();
   includePaths.add(corePath);
   if (variantPath != null) includePaths.add(variantPath);
   for (File file : sketch.getImportedLibraries()) {
     includePaths.add(file.getPath());
   }

   // 1. compile the sketch (already in the buildPath)

   sketch.setCompilingProgress(30);
   objectFiles.addAll(
     compileFiles(avrBasePath, buildPath, includePaths,
               findFilesInPath(buildPath, "S", false),
               findFilesInPath(buildPath, "c", false),
               findFilesInPath(buildPath, "cpp", false),
               boardPreferences));
   sketchIsCompiled = true;

   // 2. compile the libraries, outputting .o files to: <buildPath>/<library>/

   sketch.setCompilingProgress(40);
   for (File libraryFolder : sketch.getImportedLibraries()) {
     File outputFolder = new File(buildPath, libraryFolder.getName());
     File utilityFolder = new File(libraryFolder, "utility");
     createFolder(outputFolder);
     // this library can use includes in its utility/ folder
     includePaths.add(utilityFolder.getAbsolutePath());
     objectFiles.addAll(
       compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
               findFilesInFolder(libraryFolder, "S", false),
               findFilesInFolder(libraryFolder, "c", false),
               findFilesInFolder(libraryFolder, "cpp", false),
               boardPreferences));
     outputFolder = new File(outputFolder, "utility");
     createFolder(outputFolder);
     objectFiles.addAll(
       compileFiles(avrBasePath, outputFolder.getAbsolutePath(), includePaths,
               findFilesInFolder(utilityFolder, "S", false),
               findFilesInFolder(utilityFolder, "c", false),
               findFilesInFolder(utilityFolder, "cpp", false),
               boardPreferences));
     // other libraries should not see this library's utility/ folder
     includePaths.remove(includePaths.size() - 1);
   }

   // 3. compile the core, outputting .o files to <buildPath> and then
   // collecting them into the core.a library file.

   sketch.setCompilingProgress(50);
  includePaths.clear();
  includePaths.add(corePath);  // include path for core only
  if (variantPath != null) includePaths.add(variantPath);
  List<File> coreObjectFiles =
    compileFiles(avrBasePath, buildPath, includePaths,
              findFilesInPath(corePath, "S", true),
              findFilesInPath(corePath, "c", true),
              findFilesInPath(corePath, "cpp", true),
              boardPreferences);

   String runtimeLibraryName = buildPath + File.separator + "core.a";
   List baseCommandAR = new ArrayList(Arrays.asList(new String[] {
     avrBasePath + "avr-ar",
     "rcs",
     runtimeLibraryName
   }));
   for(File file : coreObjectFiles) {
     List commandAR = new ArrayList(baseCommandAR);
     commandAR.add(file.getAbsolutePath());
     execAsynchronously(commandAR);
   }

    // 4. link it all together into the .elf file
    // For atmega2560, need --relax linker option to link larger
    // programs correctly.
    String optRelax = "";
    String atmega2560 = new String ("atmega2560");
    if ( atmega2560.equals(boardPreferences.get("build.mcu")) ) {
        optRelax = new String(",--relax");
    }
   sketch.setCompilingProgress(60);
    List baseCommandLinker = new ArrayList(Arrays.asList(new String[] {
      avrBasePath + "avr-gcc",
      "-Os",
      "-Wl,--gc-sections"+optRelax,
      "-mmcu=" + boardPreferences.get("build.mcu"),
      "-o",
      buildPath + File.separator + primaryClassName + ".elf"
    }));

    for (File file : objectFiles) {
      baseCommandLinker.add(file.getAbsolutePath());
    }

    baseCommandLinker.add(runtimeLibraryName);
    baseCommandLinker.add("-L" + buildPath);
    baseCommandLinker.add("-lm");

    execAsynchronously(baseCommandLinker);

    List baseCommandObjcopy = new ArrayList(Arrays.asList(new String[] {
      avrBasePath + "avr-objcopy",
      "-O",
      "-R",
    }));
    
    List commandObjcopy;

    // 5. extract EEPROM data (from EEMEM directive) to .eep file.
    sketch.setCompilingProgress(70);
    commandObjcopy = new ArrayList(baseCommandObjcopy);
    commandObjcopy.add(2, "ihex");
    commandObjcopy.set(3, "-j");
    commandObjcopy.add(".eeprom");
    commandObjcopy.add("--set-section-flags=.eeprom=alloc,load");
    commandObjcopy.add("--no-change-warnings");
    commandObjcopy.add("--change-section-lma");
    commandObjcopy.add(".eeprom=0");
    commandObjcopy.add(buildPath + File.separator + primaryClassName + ".elf");
    commandObjcopy.add(buildPath + File.separator + primaryClassName + ".eep");
    execAsynchronously(commandObjcopy);
    
    // 6. build the .hex file
    sketch.setCompilingProgress(80);
    commandObjcopy = new ArrayList(baseCommandObjcopy);
    commandObjcopy.add(2, "ihex");
    commandObjcopy.add(".eeprom"); // remove eeprom data
    commandObjcopy.add(buildPath + File.separator + primaryClassName + ".elf");
    commandObjcopy.add(buildPath + File.separator + primaryClassName + ".hex");
    execAsynchronously(commandObjcopy);
    
    sketch.setCompilingProgress(90);
   
    return true;
  }
Example #20
0
 static {
   TABLES.put("users", CREATE_USERS_TABLE);
   TABLES.put("staticdata", CREATE_STATIC_DATA_TABLE);
   TABLES.put("followrequests", CREATE_FOLLOW_REQUESTS_TABLE);
   TABLES.put("metadatablobs", CREATE_METADATA_BLOBS_TABLE);
 }
 static boolean isSupportedRequestContentEncoding(String contentEncoding) {
   return NO_ENCODING.equals(contentEncoding) || FACTORY_MAP.containsKey(contentEncoding);
 }
 /**
  * Returns the instance associated to the given content encoding.
  *
  * @param contentEncoding content encoding (e.g. "gzip")
  * @return instance for content encoding
  */
 static CompressingStreamFactory getFactoryForContentEncoding(String contentEncoding) {
   assert FACTORY_MAP.containsKey(contentEncoding);
   return FACTORY_MAP.get(contentEncoding);
 }