Search in sources :

Example 1 with SourceInfo

use of sharpen.xobotos.config.SourceInfo in project XobotOS by xamarin.

the class XobotBuilder method checkFileList.

private void checkFileList() {
    final IPath sourcePath = _sourceFolder.getLocation();
    final IPath outputPath = _outputFolder.getLocation();
    final URI outputURI = outputPath.toFile().toURI();
    final SourceInfo sourceInfo = _configFile.getSourceInfo();
    final List<LocationFilter> excludeFilters = sourceInfo.getLocationFilters();
    ArrayList<String> extraCSharpSources = new ArrayList<String>();
    for (final String dir : sourceInfo.getExtraCSharpSources()) {
        File path = _project.getLocation().append(dir).toFile();
        collectAllFiles(extraCSharpSources, path.toURI(), path, ".cs");
    }
    for (final Entry<ICompilationUnit, Boolean> entry : _sources.entrySet()) {
        final ICompilationUnit unit = entry.getKey();
        String unitName = getUnitName(unit);
        String sourceName = unitName.replace('.', '/') + ".java";
        File sourceFile = sourcePath.append(sourceName).toFile();
        String outputName = unitName.replace('.', '/') + ".cs";
        File outputFile = outputPath.append(outputName).toFile();
        URI uri = outputURI.relativize(outputFile.toURI());
        if (_api.compilationUnitDefinesBindings(unitName)) {
            /*
				 * This CompilationUnit defines bindings. We
				 * must always parse it, but don't need to
				 * regenerate it if the output is up-to-date.
				 */
            _mustParse.put(unit, true);
        }
        if (extraCSharpSources.contains(uri.getPath())) {
            entry.setValue(false);
            continue;
        }
        if (outputFile.exists() && (outputFile.lastModified() >= sourceFile.lastModified())) {
            entry.setValue(false);
            continue;
        }
        /*
			 * Check location filters.
			 */
        Match match = Match.NO_MATCH;
        for (final LocationFilter filter : excludeFilters) {
            match = filter.matches(unitName);
            if (match != Match.NO_MATCH)
                break;
        }
        if (match != Match.NO_MATCH) {
            entry.setValue(match == Match.POSITIVE);
            continue;
        }
        /*
			 * Default to building.
			 */
        entry.setValue(true);
    }
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) IPath(org.eclipse.core.runtime.IPath) SourceInfo(sharpen.xobotos.config.SourceInfo) URI(java.net.URI) Match(sharpen.xobotos.config.LocationFilter.Match) LocationFilter(sharpen.xobotos.config.LocationFilter) ConfigFile(sharpen.xobotos.config.ConfigFile) CSProjectFile(sharpen.xobotos.config.CSProjectFile)

Example 2 with SourceInfo

use of sharpen.xobotos.config.SourceInfo in project XobotOS by xamarin.

the class SharpenBuilder method build.

@Override
protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException {
    final ConfigFile configFile = getConfigFile();
    final SourceInfo sourceInfo = configFile.getSourceInfo();
    final IFolder outputFolder = getProject().getFolder(sourceInfo.getOutputFolder());
    try {
        if (kind == CLEAN_BUILD) {
            outputFolder.delete(true, false, monitor);
            return null;
        } else if (kind == FULL_BUILD)
            outputFolder.delete(true, false, null);
        else if (kind == AUTO_BUILD || kind == INCREMENTAL_BUILD)
            WorkspaceUtilities.initializeTree(outputFolder, null);
        else
            return null;
    } catch (Exception e) {
        throw new RuntimeException("Cannot setup build environment: " + e);
    }
    Map<ICompilationUnit, Boolean> sources = new HashMap<ICompilationUnit, Boolean>();
    final IJavaProject javaProject = JavaCore.create(getProject());
    final List<ICompilationUnit> allUnits = JavaModelUtility.collectCompilationUnits(javaProject);
    if (kind == FULL_BUILD) {
        for (final ICompilationUnit unit : allUnits) {
            sources.put(unit, true);
        }
    } else {
        for (final ICompilationUnit unit : allUnits) {
            sources.put(unit, false);
        }
        IResourceDelta delta = getDelta(getProject());
        ChangedCompilationUnitCollector collector = new ChangedCompilationUnitCollector();
        delta.accept(collector);
        for (final ICompilationUnit unit : collector.changes()) {
            sources.put(unit, true);
        }
    }
    XobotBuilder.run(configFile, getProject(), sources, monitor);
    return null;
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) SourceInfo(sharpen.xobotos.config.SourceInfo) ConfigFile(sharpen.xobotos.config.ConfigFile) HashMap(java.util.HashMap) CoreException(org.eclipse.core.runtime.CoreException) IJavaProject(org.eclipse.jdt.core.IJavaProject)

Example 3 with SourceInfo

use of sharpen.xobotos.config.SourceInfo in project XobotOS by xamarin.

the class SharpenBuilder method clean.

@Override
protected void clean(IProgressMonitor monitor) throws CoreException {
    final ConfigFile configFile = getConfigFile();
    final SourceInfo sourceInfo = configFile.getSourceInfo();
    final IFolder outputFolder = getProject().getFolder(sourceInfo.getOutputFolder());
    outputFolder.delete(true, false, monitor);
}
Also used : SourceInfo(sharpen.xobotos.config.SourceInfo) ConfigFile(sharpen.xobotos.config.ConfigFile)

Aggregations

ConfigFile (sharpen.xobotos.config.ConfigFile)3 SourceInfo (sharpen.xobotos.config.SourceInfo)3 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)2 URI (java.net.URI)1 HashMap (java.util.HashMap)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 CSProjectFile (sharpen.xobotos.config.CSProjectFile)1 LocationFilter (sharpen.xobotos.config.LocationFilter)1 Match (sharpen.xobotos.config.LocationFilter.Match)1