コード例 #1
0
    public List<CompilerMessage> parseStream(String data) {

      List<CompilerMessage> messages = new ArrayList<CompilerMessage>();

      Matcher matcher = pattern.matcher(data);

      if (matcher.find()) {
        String filename = matcher.group(1);
        String url = CompilationTaskWorker.generateFileUrl(basePath, filename);
        messages.add(
            new CompilerMessage(
                CompilerMessageCategory.ERROR,
                matcher.group(3),
                url,
                Integer.parseInt(matcher.group(2)),
                -1));
      } else {

        // Ignore error lines that start with the compiler as the line that follows this contains
        // the error that
        // we're interested in. Otherwise, the error is more severe and we should display it
        if (!StringUtils.startsWith(data, GoSdkUtil.getCompilerName(goSdkData.TARGET_ARCH))) {
          messages.add(new CompilerMessage(CompilerMessageCategory.ERROR, data, null, -1, -1));
        }
      }

      return messages;
    }
コード例 #2
0
  private void make(
      final CompileContext context,
      final Chunk<Module> moduleChunk,
      VirtualFile[] files,
      OutputSink sink) {
    String basePath = project.getBaseDir().getPath();
    File makeFile = new File(basePath, "/Makefile");
    if (!makeFile.exists()) {
      // TODO Generate the Makefile
      context.addMessage(
          CompilerMessageCategory.ERROR,
          "Makefile doesn't exist at " + makeFile.getPath(),
          null,
          -1,
          -1);
    } else {
      GeneralCommandLine command = new GeneralCommandLine();
      final Sdk projectSdk = null;
      final GoSdkData goSdkData = goSdkData(projectSdk);
      command.setExePath(getMakeBinary(projectSdk));
      command.addParameter("-C");
      command.addParameter(project.getBaseDir().getPath());
      command.addParameter("-f");
      command.addParameter(makeFile.getPath());
      command.addParameter("-e");
      command.addParameter("install");
      command.addParameter("clean");
      command
          .getEnvironment()
          .putAll(
              new HashMap<String, String>() {
                {
                  put("GOROOT", projectSdk.getHomePath());
                  put("GOARCH", goSdkData.TARGET_ARCH.getName());
                  put("GOOS", goSdkData.TARGET_OS.getName());
                  put("GOBIN", goSdkData.GO_BIN_PATH);
                  put("PATH", System.getenv("PATH") + File.pathSeparator + goSdkData.GO_BIN_PATH);
                  put("TARGDIR", getOutputPath(context, moduleChunk));
                }
              });

      CompilationTaskWorker compilationTaskWorker =
          new CompilationTaskWorker(new MakeOutputStreamParser(projectSdk, goSdkData, basePath));
      compilationTaskWorker.executeTask(command, basePath, context);
    }
  }