Search in sources :

Example 1 with IOSTarget

use of org.robovm.compiler.target.ios.IOSTarget in project robovm by robovm.

the class Config method build.

private Config build() throws IOException {
    // Create a clone of this Config before we have done anything with it so
    // that builder() has a fresh Config it can use.
    this.configBeforeBuild = clone(this);
    if (home == null) {
        home = Home.find();
    }
    if (bootclasspath == null) {
        bootclasspath = new ArrayList<File>();
    }
    if (classpath == null) {
        classpath = new ArrayList<File>();
    }
    if (mainJar != null) {
        mainClass = getMainClass(mainJar);
        classpath.add(mainJar);
    }
    if (executableName == null && imageName != null) {
        executableName = imageName;
    }
    if (!skipLinking && executableName == null && mainClass == null) {
        throw new IllegalArgumentException("No target and no main class specified");
    }
    if (!skipLinking && classpath.isEmpty()) {
        throw new IllegalArgumentException("No classpath specified");
    }
    if (skipLinking) {
        skipInstall = true;
    }
    if (executableName == null) {
        executableName = mainClass;
    }
    if (imageName == null || !imageName.equals(executableName)) {
        imageName = executableName;
    }
    List<File> realBootclasspath = bootclasspath == null ? new ArrayList<File>() : bootclasspath;
    if (!isSkipRuntimeLib()) {
        realBootclasspath = new ArrayList<File>(bootclasspath);
        realBootclasspath.add(0, home.rtPath);
    }
    this.vtableCache = new VTable.Cache();
    this.itableCache = new ITable.Cache();
    this.marshalerLookup = new MarshalerLookup(this);
    if (!skipInstall) {
        if (installDir == null) {
            installDir = new File(".", executableName);
        }
        installDir.mkdirs();
    }
    if (targetType != null) {
        if (ConsoleTarget.TYPE.equals(targetType)) {
            target = new ConsoleTarget();
        } else if (IOSTarget.TYPE.equals(targetType)) {
            target = new IOSTarget();
        } else {
            for (TargetPlugin plugin : getTargetPlugins()) {
                if (plugin.getTarget().getType().equals(targetType)) {
                    target = plugin.getTarget();
                    break;
                }
            }
            if (target == null) {
                throw new IllegalArgumentException("Unsupported target '" + targetType + "'");
            }
        }
    } else {
        // Auto
        if (os == OS.ios) {
            target = new IOSTarget();
        } else {
            target = new ConsoleTarget();
        }
    }
    if (!getArchs().isEmpty()) {
        sliceArch = getArchs().get(0);
    }
    target.init(this);
    os = target.getOs();
    sliceArch = target.getArch();
    dataLayout = new DataLayout(getTriple());
    osArchDepLibDir = new File(new File(home.libVmDir, os.toString()), sliceArch.toString());
    if (treeShakerMode != null && treeShakerMode != TreeShakerMode.none && os.getFamily() == Family.darwin && sliceArch == Arch.x86) {
        logger.warn("Tree shaking is not supported when building " + "for OS X/iOS x86 32-bit due to a bug in Xcode's linker. No tree " + "shaking will be performed. Run in 64-bit mode instead to " + "use tree shaking.");
        treeShakerMode = TreeShakerMode.none;
    }
    dependencyGraph = new DependencyGraph(getTreeShakerMode());
    RamDiskTools ramDiskTools = new RamDiskTools();
    ramDiskTools.setupRamDisk(this, this.cacheDir, this.tmpDir);
    this.cacheDir = ramDiskTools.getCacheDir();
    this.tmpDir = ramDiskTools.getTmpDir();
    File osDir = new File(cacheDir, os.toString());
    File archDir = new File(osDir, sliceArch.toString());
    osArchCacheDir = new File(archDir, debug ? "debug" : "release");
    osArchCacheDir.mkdirs();
    this.clazzes = new Clazzes(this, realBootclasspath, classpath);
    mergeConfigsFromClasspath();
    return this;
}
Also used : TargetPlugin(org.robovm.compiler.plugin.TargetPlugin) DataLayout(org.robovm.compiler.llvm.DataLayout) MarshalerLookup(org.robovm.compiler.MarshalerLookup) DependencyGraph(org.robovm.compiler.DependencyGraph) RamDiskTools(org.robovm.compiler.util.io.RamDiskTools) VTable(org.robovm.compiler.VTable) IOSTarget(org.robovm.compiler.target.ios.IOSTarget) ITable(org.robovm.compiler.ITable) Clazzes(org.robovm.compiler.clazz.Clazzes) JarFile(java.util.jar.JarFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) ConsoleTarget(org.robovm.compiler.target.ConsoleTarget)

Aggregations

File (java.io.File)1 JarFile (java.util.jar.JarFile)1 ZipFile (java.util.zip.ZipFile)1 DependencyGraph (org.robovm.compiler.DependencyGraph)1 ITable (org.robovm.compiler.ITable)1 MarshalerLookup (org.robovm.compiler.MarshalerLookup)1 VTable (org.robovm.compiler.VTable)1 Clazzes (org.robovm.compiler.clazz.Clazzes)1 DataLayout (org.robovm.compiler.llvm.DataLayout)1 TargetPlugin (org.robovm.compiler.plugin.TargetPlugin)1 ConsoleTarget (org.robovm.compiler.target.ConsoleTarget)1 IOSTarget (org.robovm.compiler.target.ios.IOSTarget)1 RamDiskTools (org.robovm.compiler.util.io.RamDiskTools)1