Skip to main content
summaryrefslogtreecommitdiffstats
path: root/p2
diff options
context:
space:
mode:
authorDoug Schaefer2008-12-05 14:25:28 -0500
committerDoug Schaefer2008-12-05 14:25:28 -0500
commit5c28d8407c07543599ceb72fb153c2e15c46c7b3 (patch)
tree67fbc184d7fe05dabe404c7724fcc33c56b96866 /p2
parentac5006b94ea2b3a8294f0df1c380387181a301cf (diff)
downloadorg.eclipse.cdt-5c28d8407c07543599ceb72fb153c2e15c46c7b3.tar.gz
org.eclipse.cdt-5c28d8407c07543599ceb72fb153c2e15c46c7b3.tar.xz
org.eclipse.cdt-5c28d8407c07543599ceb72fb153c2e15c46c7b3.zip
p2 generator for open source SDKs. This once includes MinGW for Wascana.
Diffstat (limited to 'p2')
-rw-r--r--p2/org.eclipse.cdt.p2.generator/.classpath11
-rw-r--r--p2/org.eclipse.cdt.p2.generator/.project28
-rw-r--r--p2/org.eclipse.cdt.p2.generator/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--p2/org.eclipse.cdt.p2.generator/META-INF/MANIFEST.MF16
-rw-r--r--p2/org.eclipse.cdt.p2.generator/build.properties5
-rw-r--r--p2/org.eclipse.cdt.p2.generator/plugin.xml18
-rw-r--r--p2/org.eclipse.cdt.p2.generator/src/org/eclipse/cdt/p2/generator/Activator.java76
-rw-r--r--p2/org.eclipse.cdt.p2.generator/src/org/eclipse/cdt/p2/generator/MinGWGenerator.java144
8 files changed, 305 insertions, 0 deletions
diff --git a/p2/org.eclipse.cdt.p2.generator/.classpath b/p2/org.eclipse.cdt.p2.generator/.classpath
new file mode 100644
index 0000000000..67889f3aad
--- /dev/null
+++ b/p2/org.eclipse.cdt.p2.generator/.classpath
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
+ <accessrules>
+ <accessrule kind="accessible" pattern="**/internal/provisional/**"/>
+ </accessrules>
+ </classpathentry>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/p2/org.eclipse.cdt.p2.generator/.project b/p2/org.eclipse.cdt.p2.generator/.project
new file mode 100644
index 0000000000..fc1c628df0
--- /dev/null
+++ b/p2/org.eclipse.cdt.p2.generator/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.p2.generator</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/p2/org.eclipse.cdt.p2.generator/.settings/org.eclipse.jdt.core.prefs b/p2/org.eclipse.cdt.p2.generator/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..f313740144
--- /dev/null
+++ b/p2/org.eclipse.cdt.p2.generator/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Mon Dec 01 20:43:28 EST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/p2/org.eclipse.cdt.p2.generator/META-INF/MANIFEST.MF b/p2/org.eclipse.cdt.p2.generator/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..439a879d82
--- /dev/null
+++ b/p2/org.eclipse.cdt.p2.generator/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Generator Plug-in
+Bundle-SymbolicName: org.eclipse.cdt.p2.generator;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.eclipse.cdt.p2.generator.Activator
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.cdt.p2;bundle-version="5.0.0",
+ org.eclipse.equinox.p2.artifact.repository;bundle-version="1.0.2",
+ org.eclipse.equinox.p2.core;bundle-version="1.0.0",
+ org.eclipse.equinox.p2.metadata;bundle-version="1.0.0",
+ org.eclipse.equinox.p2.engine;bundle-version="1.0.1",
+ org.eclipse.equinox.p2.metadata.repository;bundle-version="1.0.0",
+ org.eclipse.equinox.p2.metadata.generator;bundle-version="1.0.1"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/p2/org.eclipse.cdt.p2.generator/build.properties b/p2/org.eclipse.cdt.p2.generator/build.properties
new file mode 100644
index 0000000000..e9863e281e
--- /dev/null
+++ b/p2/org.eclipse.cdt.p2.generator/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/p2/org.eclipse.cdt.p2.generator/plugin.xml b/p2/org.eclipse.cdt.p2.generator/plugin.xml
new file mode 100644
index 0000000000..73a72853ed
--- /dev/null
+++ b/p2/org.eclipse.cdt.p2.generator/plugin.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ id="mingwGenerator"
+ name="MinGW Generator"
+ point="org.eclipse.core.runtime.applications">
+ <application
+ cardinality="singleton-global"
+ thread="main"
+ visible="true">
+ <run
+ class="org.eclipse.cdt.p2.generator.MinGWGenerator">
+ </run>
+ </application>
+ </extension>
+
+</plugin>
diff --git a/p2/org.eclipse.cdt.p2.generator/src/org/eclipse/cdt/p2/generator/Activator.java b/p2/org.eclipse.cdt.p2.generator/src/org/eclipse/cdt/p2/generator/Activator.java
new file mode 100644
index 0000000000..eabd95beb7
--- /dev/null
+++ b/p2/org.eclipse.cdt.p2.generator/src/org/eclipse/cdt/p2/generator/Activator.java
@@ -0,0 +1,76 @@
+package org.eclipse.cdt.p2.generator;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.cdt.p2.generator";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T getService(Class<T> clazz) {
+ BundleContext context = plugin.getBundle().getBundleContext();
+ ServiceReference ref = context.getServiceReference(clazz.getName());
+ return (ref != null) ? (T)context.getService(ref) : null;
+ }
+
+ public Bundle getBundle(String symbolicName) {
+ PackageAdmin packageAdmin = getService(PackageAdmin.class);
+ if (packageAdmin == null)
+ return null;
+ Bundle[] bundles = packageAdmin.getBundles(symbolicName, null);
+ if (bundles == null)
+ return null;
+ //Return the first bundle that is not installed or uninstalled
+ for (int i = 0; i < bundles.length; i++) {
+ if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
+ return bundles[i];
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/p2/org.eclipse.cdt.p2.generator/src/org/eclipse/cdt/p2/generator/MinGWGenerator.java b/p2/org.eclipse.cdt.p2.generator/src/org/eclipse/cdt/p2/generator/MinGWGenerator.java
new file mode 100644
index 0000000000..4824620673
--- /dev/null
+++ b/p2/org.eclipse.cdt.p2.generator/src/org/eclipse/cdt/p2/generator/MinGWGenerator.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Doug Schaefer - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.cdt.p2.generator;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.p2.internal.repo.artifact.InstallArtifactRepository;
+import org.eclipse.cdt.p2.internal.touchpoint.SDKTouchpoint;
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.ArtifactDescriptor;
+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepository;
+import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager;
+import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
+import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
+import org.eclipse.equinox.internal.provisional.p2.metadata.ProvidedCapability;
+import org.eclipse.equinox.internal.provisional.p2.metadata.RequiredCapability;
+import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.InstallableUnitDescription;
+import org.eclipse.equinox.internal.provisional.p2.metadata.generator.MetadataGeneratorHelper;
+import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepository;
+import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager;
+import org.eclipse.osgi.service.resolver.VersionRange;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+
+/**
+ * @author DSchaefe
+ *
+ */
+public class MinGWGenerator implements IApplication {
+
+ private static final String REPO_NAME = "MinGW";
+
+ IMetadataRepository metaRepo;
+ IArtifactRepository artiRepo;
+
+ @Override
+ public Object start(IApplicationContext context) throws Exception {
+ context.applicationRunning();
+
+ Activator.getDefault().getBundle("org.eclipse.equinox.p2.exemplarysetup").start(Bundle.START_TRANSIENT); //$NON-NLS-1$
+
+ URL repoLocation = new File("C:\\Wascana\\repo").toURI().toURL();
+
+ IMetadataRepositoryManager metaRepoMgr = Activator.getDefault().getService(IMetadataRepositoryManager.class);
+ IArtifactRepositoryManager artiRepoMgr = Activator.getDefault().getService(IArtifactRepositoryManager.class);
+
+ metaRepo = metaRepoMgr.createRepository(repoLocation, REPO_NAME, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY, null);
+ artiRepo = artiRepoMgr.createRepository(repoLocation, REPO_NAME, IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY, null);
+
+ IInstallableUnit binutilsIU = createBinutils();
+
+ // toolchain
+ InstallableUnitDescription mingwToolchainDesc = createIUDesc(
+ "wascana.mingw",
+ new Version(1, 0, 0),
+ "MinGW Toolchain");
+ RequiredCapability[] mingwToolchainReqs = new RequiredCapability[] {
+ MetadataFactory.createRequiredCapability(
+ IInstallableUnit.NAMESPACE_IU_ID,
+ binutilsIU.getId(), new VersionRange(null), null, false, false)
+ };
+ mingwToolchainDesc.setRequiredCapabilities(mingwToolchainReqs);
+ mingwToolchainDesc.setProperty(IInstallableUnit.PROP_TYPE_CATEGORY, Boolean.TRUE.toString());
+ IInstallableUnit mingwToolchainIU = MetadataFactory.createInstallableUnit(mingwToolchainDesc);
+
+ metaRepo.addInstallableUnits(new IInstallableUnit[] {
+ binutilsIU,
+// gccCoreIU,
+// gccGppIU,
+ mingwToolchainIU,
+// wascanaIU
+ });
+
+ System.out.println("done");
+
+ return EXIT_OK;
+ }
+
+ @Override
+ public void stop() {
+ }
+
+ private IInstallableUnit createBinutils() throws ProvisionException, MalformedURLException {
+ String binutilsId = "wascana.mingw.binutils";
+ Version binutilsVersion = new Version("2.18.50.20080109-2");
+ InstallableUnitDescription binutilsDesc = createIUDesc(
+ binutilsId, binutilsVersion, "MinGW binutils");
+ binutilsDesc.setProperty(IInstallableUnit.PROP_TYPE_GROUP, Boolean.TRUE.toString());
+ IArtifactKey binutilsArti = addRemoteArtifact(
+ binutilsDesc,
+ binutilsId,
+ binutilsVersion,
+ new File("C:\\Wascana\\tars\\binutils-2.18.50-20080109-2.tar.gz").toURI().toURL(),
+ "mingw",
+ InstallArtifactRepository.GZIP_COMPRESSON);
+ binutilsDesc.setArtifacts(new IArtifactKey[] { binutilsArti });
+ return MetadataFactory.createInstallableUnit(binutilsDesc);
+ }
+
+ private InstallableUnitDescription createIUDesc(String id, Version version, String name) throws ProvisionException {
+ InstallableUnitDescription iuDesc = new MetadataFactory.InstallableUnitDescription();
+ iuDesc.setId(id);
+ iuDesc.setVersion(version);
+ iuDesc.setSingleton(true);
+ iuDesc.setProperty(IInstallableUnit.PROP_NAME, name);
+ iuDesc.setCapabilities(new ProvidedCapability[] {
+ MetadataFactory.createProvidedCapability(IInstallableUnit.NAMESPACE_IU_ID, id, version)
+ });
+ return iuDesc;
+ }
+
+ private IArtifactKey addRemoteArtifact(
+ InstallableUnitDescription iuDesc,
+ String id, Version version, URL location, String subdir, String compression) throws ProvisionException {
+ iuDesc.setTouchpointType(SDKTouchpoint.TOUCHPOINT_TYPE);
+ Map<String, String> tpdata = new HashMap<String, String>();
+ tpdata.put("uninstall", "uninstall()");
+ iuDesc.addTouchpointData(MetadataFactory.createTouchpointData(tpdata));
+ IArtifactKey artiKey = MetadataGeneratorHelper.createLauncherArtifactKey(id, version);
+ ArtifactDescriptor artiDesc = new ArtifactDescriptor(artiKey);
+ artiDesc.setProperty(InstallArtifactRepository.SUB_DIR, subdir);
+ artiDesc.setProperty(InstallArtifactRepository.COMPRESSION, compression);
+ artiDesc.setRepositoryProperty("artifact.reference", location.toString());
+ artiRepo.addDescriptor(artiDesc);
+ return artiKey;
+ }
+
+}

Back to the top