org.qbicc.machine.tool.gnu.GnuLinkerInvokerImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qbicc-machine-tool-gnu Show documentation
Show all versions of qbicc-machine-tool-gnu Show documentation
Support for the GNU compiler suite
The newest version!
package org.qbicc.machine.tool.gnu;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import io.smallrye.common.constraint.Assert;
/**
*
*/
final class GnuLinkerInvokerImpl extends AbstractGccInvoker implements GnuLinkerInvoker {
private final List libraryPaths = new ArrayList<>(4);
private final List libraries = new ArrayList<>(4);
private final List objectFiles = new ArrayList<>(4);
private Path outputPath = TMP.resolve("qbicc-output-image");
private boolean isPie = false;
GnuLinkerInvokerImpl(final GccToolChainImpl tool) {
super(tool);
}
public void addLibraryPath(final Path path) {
libraryPaths.add(Assert.checkNotNullParam("path", path));
}
public int getLibraryPathCount() {
return libraryPaths.size();
}
public Path getLibraryPath(final int index) throws IndexOutOfBoundsException {
return libraryPaths.get(index);
}
public void addLibrary(final String name) {
libraries.add(Assert.checkNotNullParam("name", name));
}
public int getLibraryCount() {
return libraries.size();
}
public String getLibrary(final int index) throws IndexOutOfBoundsException {
return libraries.get(index);
}
public void addObjectFile(final Path path) {
objectFiles.add(Assert.checkNotNullParam("path", path));
}
public int getObjectFileCount() {
return objectFiles.size();
}
public Path getObjectFile(final int index) throws IndexOutOfBoundsException {
return objectFiles.get(index);
}
public void setOutputPath(final Path path) {
outputPath = Assert.checkNotNullParam("path", path);
}
public Path getOutputPath() {
return outputPath;
}
public void setIsPie(boolean isPie) {
this.isPie = isPie;
}
public boolean getIsPie() {
return isPie;
}
void addArguments(final List cmd) {
if (isPie) {
cmd.add("-pie");
} else {
cmd.add("-no-pie");
}
for (Path libraryPath : libraryPaths) {
cmd.add("-L" + libraryPath.toString());
}
for (Path objectFile : objectFiles) {
cmd.add(objectFile.toString());
}
for (String library : libraries) {
cmd.add("-l" + library);
}
cmd.add("-o");
cmd.add(outputPath.toString());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy