⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contikimotetypedialog.java

📁 Contiki是一个开源
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    // Recheck that contiki path exists    if (!contikiDir.exists()) {      if (errorStream != null) {        errorStream.println("Bad Contiki OS path");      }      logger.fatal("Contiki path does not exist: " + contikiDir.getAbsolutePath());      return false;    }    if (!contikiDir.isDirectory()) {      if (errorStream != null) {        errorStream.println("Bad Contiki OS path");      }      logger.fatal("Contiki path is not a directory");      return false;    }    if (libFile.exists()) {      if (errorStream != null) {        errorStream.println("Bad output filenames");      }      logger.fatal("Could not overwrite already existing library");      return false;    }    if (CoreComm.hasLibraryFileBeenLoaded(libFile)) {      if (errorStream != null) {        errorStream.println("Bad output filenames");      }      logger.fatal("A library has already been loaded with the same name before");      return false;    }    if (arFile.exists()) {      if (errorStream != null) {        errorStream.println("Bad output filenames");      }      logger.fatal("Could not overwrite already existing dependency file");      return false;    }    if (mapFile.exists()) {      if (errorStream != null) {        errorStream.println("Bad output filenames");      }      logger.fatal("Could not overwrite already existing map file");      return false;    }    try {      // Let Contiki 2.x regular make file compile      String[] cmd = new String[]{          GUI.getExternalToolsSetting("PATH_MAKE"),          libFile.getPath().replace(File.separatorChar, '/'),          "-f",          contikiDir.getPath().replace(File.separatorChar, '/')              + "/Makefile.include"};      String sourceDirs = System.getProperty("PROJECTDIRS", "");      String sourceFileNames = "";      // Prepare compilation command      String ccFlags = GUI.getExternalToolsSetting("COMPILER_ARGS", "");      String link1 = GUI.getExternalToolsSetting("LINK_COMMAND_1", "");      String link2 = GUI.getExternalToolsSetting("LINK_COMMAND_2", "");      String ar1 = GUI.getExternalToolsSetting("AR_COMMAND_1", "");      String ar2 = GUI.getExternalToolsSetting("AR_COMMAND_2", "");      link1 = link1.replace("$(MAPFILE)", mapFile.getPath().replace(File.separatorChar, '/'));      link2 = link2.replace("$(MAPFILE)", mapFile.getPath().replace(File.separatorChar, '/'));      ar1 = ar1.replace("$(MAPFILE)", mapFile.getPath().replace(File.separatorChar, '/'));      ar2 = ar2.replace("$(MAPFILE)", mapFile.getPath().replace(File.separatorChar, '/'));      ccFlags = ccFlags.replace("$(MAPFILE)", mapFile.getPath().replace(File.separatorChar, '/'));      link1 = link1.replace("$(LIBFILE)", libFile.getPath().replace(File.separatorChar, '/'));      link2 = link2.replace("$(LIBFILE)", libFile.getPath().replace(File.separatorChar, '/'));      ar1 = ar1.replace("$(LIBFILE)", libFile.getPath().replace(File.separatorChar, '/'));      ar2 = ar2.replace("$(LIBFILE)", libFile.getPath().replace(File.separatorChar, '/'));      ccFlags = ccFlags.replace("$(LIBFILE)", libFile.getPath().replace(File.separatorChar, '/'));      link1 = link1.replace("$(ARFILE)", arFile.getPath().replace(File.separatorChar, '/'));      link2 = link2.replace("$(ARFILE)", arFile.getPath().replace(File.separatorChar, '/'));      ar1 = ar1.replace("$(ARFILE)", arFile.getPath().replace(File.separatorChar, '/'));      ar2 = ar2.replace("$(ARFILE)", arFile.getPath().replace(File.separatorChar, '/'));      ccFlags = ccFlags.replace("$(ARFILE)", arFile.getPath().replace(File.separatorChar, '/'));      String javaHome = System.getenv().get("JAVA_HOME");      if (javaHome == null) {        javaHome = "";      }      link1 = link1.replace("$(JAVA_HOME)", javaHome);      link2 = link2.replace("$(JAVA_HOME)", javaHome);      ar1 = ar1.replace("$(JAVA_HOME)", javaHome);      ar2 = ar2.replace("$(JAVA_HOME)", javaHome);      ccFlags = ccFlags.replace("$(JAVA_HOME)", javaHome);      for (File sourceFile : sourceFiles) {        if (sourceFile.isDirectory()) {          // Add directory to search path          sourceDirs += " "              + sourceFile.getPath().replace(File.separatorChar, '/');          ccFlags += " -I"              + sourceFile.getPath().replace(File.separatorChar, '/');        } else if (sourceFile.isFile()) {          // Add both file name and directory          if (sourceFile.getParent() != null) {            sourceDirs += " "                + sourceFile.getParent().replace(File.separatorChar, '/');          }          sourceFileNames += " " + sourceFile.getName();        } else {          // Add filename and hope Contiki knows where to find it...          sourceFileNames += " " + sourceFile.getName();        }      }      // Add communication stack source files      sourceFileNames += commStack.getSourceFilenamesString();      logger.info("-- Compiling --");      logger.info("Project dirs: " + sourceDirs);      logger.info("Project sources: " + sourceFileNames);      logger.info("Compiler flags: " + ccFlags);      String[] env = new String[]{          "CONTIKI=" + contikiDir.getPath().replace(File.separatorChar, '/'),          "TARGET=cooja", "TYPEID=" + identifier,          "LINK_COMMAND_1=" + link1,          "LINK_COMMAND_2=" + link2,          "AR_COMMAND_1=" + ar1,          "AR_COMMAND_2=" + ar2,          "EXTRA_CC_ARGS=" + ccFlags,          "SYMBOLS=" + (includeSymbols?"1":""),          "CC=" + GUI.getExternalToolsSetting("PATH_C_COMPILER"),          "LD=" + GUI.getExternalToolsSetting("PATH_LINKER"),          "AR=" + GUI.getExternalToolsSetting("PATH_AR"),          "PROJECTDIRS=" + sourceDirs,          "PROJECT_SOURCEFILES=" + sourceFileNames,          "PATH=" + System.getenv("PATH")};/*      System.out.print("Full command:\n");      System.out.print((new File(".").getAbsolutePath()) + "/> ");      for (String s: cmd)        System.out.print(s + " ");      System.out.println();      System.out.println("Environment:\n");      for (String s: env)        System.out.print(s + "\n");*/      Process p = Runtime.getRuntime().exec(cmd, env, null);      final BufferedReader input = new BufferedReader(new InputStreamReader(p          .getInputStream()));      final BufferedReader err = new BufferedReader(new InputStreamReader(p          .getErrorStream()));      Thread readInput = new Thread(new Runnable() {        public void run() {          String readLine;          try {            while ((readLine = input.readLine()) != null) {              if (outputStream != null) {                outputStream.println(readLine);              }            }          } catch (IOException e) {            logger.warn("Error while reading from process");          }        }      }, "read input stream thread");      Thread readError = new Thread(new Runnable() {        public void run() {          String readLine;          try {            while ((readLine = err.readLine()) != null) {              if (errorStream != null) {                errorStream.println(readLine);                if (!GUI.isVisualized()) {                  logger.warn("COMPILATION OUTPUT: " + readLine);                }              }            }          } catch (IOException e) {            logger.warn("Error while reading from process");          }        }      }, "read input stream thread");      readInput.start();      readError.start();      while (readInput.isAlive() || readError.isAlive()) {        Thread.sleep(100);      }      input.close();      err.close();      p.waitFor();      if (p.exitValue() != 0) {        logger.fatal("Make file returned error: " + p.exitValue());        return false;      }    } catch (Exception e) {      logger.fatal("Error while compiling library: " + e);      e.printStackTrace();      return false;    }    return true;  }  /**   * Scans a directory for sourcefiles which defines a Contiki process.   *   * @param rootDirectory   *          Top directory to search in   * @return Process definitions found under rootDirectory, {sourcefile,   *         processname}   */  public static Vector<ContikiProcess> scanForProcesses(File rootDirectory) {    if (!rootDirectory.isDirectory()) {      logger.fatal("Not a directory: " + rootDirectory);      return new Vector<ContikiProcess>();    }    if (!rootDirectory.exists()) {      logger.fatal("Does not exist: " + rootDirectory);      return new Vector<ContikiProcess>();    }    Vector<ContikiProcess> processes = new Vector<ContikiProcess>();    // Scan in rootDirectory    try {      String line;      String cmdString = GUI.getExternalToolsSetting("CMD_GREP_PROCESSES")          + " '" + rootDirectory.getPath().replace(File.separatorChar, '/')          + "'/*.[ch]";      Pattern pattern = Pattern.compile(GUI.getExternalToolsSetting("REGEXP_PARSE_PROCESSES"));      String[] cmd = new String[3];      cmd[0] = GUI.getExternalToolsSetting("PATH_SHELL");      cmd[1] = "-c";      cmd[2] = cmdString;      Process p = Runtime.getRuntime().exec(cmd);      BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));      while ((line = input.readLine()) != null) {        Matcher matcher = pattern.matcher(line);        if (matcher.find()) {          File sourceFile = new File(rootDirectory, matcher.group(1));          if (!sourceFile.exists()) {            logger.fatal("Error during scan: Found file does not exist: " + sourceFile);          }          ContikiProcess process = new ContikiProcess(sourceFile, matcher.group(2));          processes.add(process);        }      }      input.close();//      BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream()));//      if (err.ready())//        logger.warn("Error occurred during scan:");//      while ((line = err.readLine()) != null) {//        logger.warn(line);//      }//      err.close();    } catch (IOException err) {      logger.fatal("Error while scanning for processes: " + err);      err.printStackTrace();    } catch (Exception err) {      logger.fatal("Error while scanning for processes: " + err);      err.printStackTrace();    }    return processes;  }  /**   * Scans a directory and all subdirectories for sourcefiles which defines a   * Contiki sensor.   *   * @param rootDirectory   *          Top directory to search in   * @return Sensor definitions found under rootDirectory, {sourcefile,   *         sensorname}   */  public static Vector<String[]> scanForSensors(File rootDirectory) {    if (!rootDirectory.isDirectory()) {      logger.fatal("Not a directory: " + rootDirectory);      return null;    }    if (!rootDirectory.exists()) {      logger.fatal("Does not exist: " + rootDirectory);      return null;    }    Vector<String[]> sensors = new Vector<String[]>();    // Scan in rootDirectory    try {      String line;      String cmdString = GUI.getExternalToolsSetting("CMD_GREP_SENSORS") + " '"          + rootDirectory.getPath().replace(File.separatorChar, '/') + "'";      Pattern pattern = Pattern.compile(GUI          .getExternalToolsSetting("REGEXP_PARSE_SENSORS"));      String[] cmd = new String[3];      cmd[0] = GUI.getExternalToolsSetting("PATH_SHELL");      cmd[1] = "-c";      cmd[2] = cmdString;      Process p = Runtime.getRuntime().exec(cmd);      BufferedReader input = new BufferedReader(new InputStreamReader(p          .getInputStream()));      while ((line = input.readLine()) != null) {        Matcher matcher = pattern.matcher(line);        if (matcher.find()) {          sensors.add(new String[]{matcher.group(1), matcher.group(2)});        }      }      input.close();      BufferedReader err = new BufferedReader(new InputStreamReader(p          .getErrorStream()));      if (err.ready()) {        logger.warn("Error occured during scan:");      }      while ((line = err.readLine()) != null) {        logger.warn(line);      }      err.close();    } catch (IOException err) {      logger.fatal("Error while scanning for sensors: " + err);      err.printStackTrace();    } catch (Exception err) {      logger.fatal("Error while scanning for sensors: " + err);      err.printStackTrace();    }    return sensors;  }  /**   * Scans a directory and all subdirectories for sourcefiles which defines a   * COOJA core interface.   *   * @param rootDirectory   *          Top directory to search in   * @return Core interface definitions found under rootDirectory, {sourcefile,   *         interfacename}   */  public static Vector<String[]> scanForInterfaces(File rootDirectory) {    if (!rootDirectory.isDirectory()) {      logger.fatal("Not a directory: " + rootDirectory);      return null;    }    if 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -