コード例 #1
0
ファイル: ErlangBuilder2.java プロジェクト: rampage/erlide
  @Override
  protected void clean(final IProgressMonitor monitor) throws CoreException {
    final IProject currentProject = getProject();
    if (currentProject == null || !currentProject.isAccessible()) {
      return;
    }

    if (BuilderHelper.isDebugging()) {
      ErlLogger.debug(
          "Cleaning "
              + currentProject.getName() // $NON-NLS-1$
              + " @ "
              + new Date(System.currentTimeMillis()));
    }

    try {
      initializeBuilder(monitor);
      MarkerUtils.removeProblemsAndTasksFor(currentProject);
      final IErlProject erlProject = CoreScope.getModel().getErlangProject(currentProject);
      final IFolder bf = currentProject.getFolder(erlProject.getOutputLocation());
      if (bf.exists()) {
        final IResource[] beams = bf.members();
        monitor.beginTask("Cleaning Erlang files", beams.length);
        if (beams.length > 0) {
          final float delta = 1.0f / beams.length;
          for (final IResource element : beams) {
            if ("beam".equals(element.getFileExtension())) {
              element.delete(true, monitor);
              notifier.updateProgressDelta(delta);
            }
          }
        }
      }

    } catch (final Exception e) {
      ErlLogger.error(e);
      final String msg =
          NLS.bind(BuilderMessages.build_inconsistentProject, e.getLocalizedMessage());
      MarkerUtils.addProblemMarker(currentProject, null, null, msg, 0, IMarker.SEVERITY_ERROR);
    } finally {
      cleanup();
      if (BuilderHelper.isDebugging()) {
        ErlLogger.debug(
            "Finished cleaning "
                + currentProject.getName() // $NON-NLS-1$
                + " @ "
                + new Date(System.currentTimeMillis()));
      }
    }
  }
コード例 #2
0
ファイル: ErlangBuilder2.java プロジェクト: rampage/erlide
 private void initializeBuilder(final IProgressMonitor monitor)
     throws CoreException, BackendException {
   final IProject currentProject = getProject();
   notifier = new BuildNotifier(monitor, currentProject);
   notifier.begin();
 }
コード例 #3
0
ファイル: ErlangBuilder2.java プロジェクト: rampage/erlide
 private void cleanup() {
   notifier.done();
   notifier = null;
 }
コード例 #4
0
ファイル: ErlangBuilder2.java プロジェクト: rampage/erlide
  @Override
  protected IProject[] build(
      final int kind, @SuppressWarnings("rawtypes") final Map args, final IProgressMonitor monitor)
      throws CoreException {
    final IProject project = getProject();
    if (project == null || !project.isAccessible()) {
      return new IProject[0];
    }

    if (BuilderHelper.isDebugging()) {
      ErlLogger.debug(
          "Starting build "
              + helper.buildKind(kind)
              + " of "
              + project.getName()
              + " @ "
              + new Date(System.currentTimeMillis()));
    }
    try {
      MarkerUtils.deleteMarkers(project);
      initializeBuilder(monitor);

      final OtpErlangList compilerOptions = CompilerPreferences.get(project);

      ErlLogger.debug("******** building %s: %s", getProject().getName(), compilerOptions);

      final Set<String> resourcesToBuild = getResourcesToBuild(kind, args, project);
      final int n = resourcesToBuild.size();
      if (n > 0) {
        final IBackend backend = BackendCore.getBackendManager().getBuildBackend(project);
        if (backend == null) {
          final String message =
              "No backend with the required " + "version could be found. Can't build.";
          MarkerUtils.addProblemMarker(project, null, null, message, 0, IMarker.SEVERITY_ERROR);
          throw new BackendException(message);
        }

        notifier.setProgressPerCompilationUnit(1.0f / n);

        final IPath projectPath = project.getLocation();
        final IErlProject erlProject = CoreScope.getModel().getErlangProject(project);
        final String outputDir = projectPath.append(erlProject.getOutputLocation()).toString();
        helper.ensureDirExists(outputDir);

        final Collection<IPath> includeDirs = helper.getAllIncludeDirs(project);

        final RpcEventProcessor processor =
            new RpcEventProcessor(new BuildHandler(), backend.createMbox());
        final OtpErlangPid watcher = processor.getPid();
        final OtpErlangPid builder =
            (OtpErlangPid)
                backend.call(
                    "erlide_builder",
                    "build_resources",
                    "lsslsxp",
                    resourcesToBuild,
                    outputDir,
                    includeDirs,
                    compilerOptions,
                    watcher);
        processor.setStarter(builder);
        processor.run();
      }

    } catch (final Exception e) {
      ErlLogger.error(e);
      final String msg =
          NLS.bind(BuilderMessages.build_inconsistentProject, e.getLocalizedMessage());
      MarkerUtils.addProblemMarker(project, null, null, msg, 0, IMarker.SEVERITY_ERROR);
    } finally {
      cleanup();
      if (BuilderHelper.isDebugging()) {
        ErlLogger.debug(
            "Finished build of "
                + project.getName() // $NON-NLS-1$
                + " @ "
                + new Date(System.currentTimeMillis()));
      }
    }
    return null;
  }