All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gradle.language.nativeplatform.internal.AbstractNativeCompileSpec Maven / Gradle / Ivy

There is a newer version: 8.11.1
Show newest version
/*
 * Copyright 2013 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gradle.language.nativeplatform.internal;

import org.gradle.api.internal.changedetection.changes.DiscoveredInputRecorder;
import org.gradle.internal.operations.logging.BuildOperationLogger;
import org.gradle.nativeplatform.internal.AbstractBinaryToolSpec;
import org.gradle.nativeplatform.toolchain.internal.NativeCompileSpec;

import java.io.File;
import java.util.*;

public abstract class AbstractNativeCompileSpec extends AbstractBinaryToolSpec implements NativeCompileSpec {

    private List includeRoots = new ArrayList();
    private List sourceFiles = new ArrayList();
    private List removedSourceFiles = new ArrayList();
    private boolean incrementalCompile;
    private Map macros = new LinkedHashMap();
    private File objectFileDir;
    private boolean positionIndependentCode;
    private BuildOperationLogger oplogger;
    private File prefixHeaderFile;
    private File preCompiledHeaderObjectFile;
    private Map sourceFileIncludeDirectives;
    private String preCompiledHeader;
    private DiscoveredInputRecorder discoveredInputRecorder;

    @Override
    public List getIncludeRoots() {
        return includeRoots;
    }

    @Override
    public void include(File... includeRoots) {
        Collections.addAll(this.includeRoots, includeRoots);
    }

    @Override
    public void include(Iterable includeRoots) {
        addAll(this.includeRoots, includeRoots);
    }

    @Override
    public List getSourceFiles() {
        return sourceFiles;
    }

    @Override
    public void source(Iterable sources) {
        addAll(sourceFiles, sources);
    }

    @Override
    public void setSourceFiles(Collection sources) {
        sourceFiles.clear();
        sourceFiles.addAll(sources);
    }

    @Override
    public List getRemovedSourceFiles() {
        return removedSourceFiles;
    }

    @Override
    public void removedSource(Iterable sources) {
        addAll(removedSourceFiles, sources);
    }

    @Override
    public void setRemovedSourceFiles(Collection sources) {
        removedSourceFiles.clear();
        removedSourceFiles.addAll(sources);
    }

    @Override
    public boolean isIncrementalCompile() {
        return incrementalCompile;
    }

    @Override
    public void setIncrementalCompile(boolean flag) {
        incrementalCompile = flag;
    }

    @Override
    public File getObjectFileDir() {
        return objectFileDir;
    }

    @Override
    public void setObjectFileDir(File objectFileDir) {
        this.objectFileDir = objectFileDir;
    }

    @Override
    public Map getMacros() {
        return macros;
    }

    @Override
    public void setMacros(Map macros) {
        this.macros = macros;
    }

    @Override
    public void define(String name) {
        macros.put(name, null);
    }

    @Override
    public void define(String name, String value) {
        macros.put(name, value);
    }

    @Override
    public boolean isPositionIndependentCode() {
        return positionIndependentCode;
    }

    @Override
    public void setPositionIndependentCode(boolean positionIndependentCode) {
        this.positionIndependentCode = positionIndependentCode;
    }

    @Override
    public File getPreCompiledHeaderObjectFile() {
        return preCompiledHeaderObjectFile;
    }

    @Override
    public void setPreCompiledHeaderObjectFile(File preCompiledHeaderObjectFile) {
        this.preCompiledHeaderObjectFile = preCompiledHeaderObjectFile;
    }

    @Override
    public File getPrefixHeaderFile() {
        return prefixHeaderFile;
    }

    @Override
    public void setPrefixHeaderFile(File pchFile) {
        this.prefixHeaderFile = pchFile;
    }

    @Override
    public String getPreCompiledHeader() {
        return preCompiledHeader;
    }

    @Override
    public void setPreCompiledHeader(String preCompiledHeader) {
        this.preCompiledHeader = preCompiledHeader;
    }

    private void addAll(List list, Iterable iterable) {
        for (File file : iterable) {
            list.add(file);
        }
    }

    @Override
    public BuildOperationLogger getOperationLogger() {
        return oplogger;
    }

    @Override
    public void setOperationLogger(BuildOperationLogger oplogger) {
        this.oplogger = oplogger;
    }

    @Override
    public Map getSourceFileIncludeDirectives() {
        return sourceFileIncludeDirectives;
    }

    @Override
    public void setSourceFileIncludeDirectives(Map map) {
        this.sourceFileIncludeDirectives = map;
    }

    @Override
    public void setDiscoveredInputRecorder(DiscoveredInputRecorder inputs) {
        this.discoveredInputRecorder = inputs;
    }

    @Override
    public DiscoveredInputRecorder getDiscoveredInputRecorder() {
        return discoveredInputRecorder;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy