java-gobject-introspection r115 - trunk/src/org/gnome/gir/compiler



Author: walters
Date: Wed Nov  5 23:57:13 2008
New Revision: 115
URL: http://svn.gnome.org/viewvc/java-gobject-introspection?rev=115&view=rev

Log:
Skip compiling typelibs with no shared library

Modified:
   trunk/src/org/gnome/gir/compiler/CodeFactory.java

Modified: trunk/src/org/gnome/gir/compiler/CodeFactory.java
==============================================================================
--- trunk/src/org/gnome/gir/compiler/CodeFactory.java	(original)
+++ trunk/src/org/gnome/gir/compiler/CodeFactory.java	Wed Nov  5 23:57:13 2008
@@ -1827,8 +1827,10 @@
 		
 		globals.clinit = mv;
 	}
+
+	private static final class PrivateNamespaceException extends Exception {};
 	
-	private void compileNamespaceSingle(String namespace, String version) {
+	private void compileNamespaceSingle(String namespace, String version) throws PrivateNamespaceException {
 		alreadyCompiled.add(namespace);
 		
 		try {
@@ -1838,6 +1840,9 @@
 			throw new RuntimeException(e);
 		}
 		
+		if (repo.getSharedLibrary(namespace) == null)
+			throw new PrivateNamespaceException();
+		
 		String globalName = namespace + "Globals";
 		String peerInternalName = GType.getInternalName(namespace, globalName);
 		GlobalsCompilation global = new GlobalsCompilation(namespace, globalName);
@@ -1851,7 +1856,7 @@
 		global.close();
 	}	
 	
-	private List<ClassCompilation> compileNamespace(String namespace, String version) {
+	private List<ClassCompilation> compileNamespace(String namespace, String version) throws PrivateNamespaceException {
 		compileNamespaceSingle(namespace, version);
 		return finish();
 	}
@@ -1869,7 +1874,7 @@
 		return ret;		
 	}
 	
-	private List<ClassCompilation> compileNamespaceRecursive(String namespace) {
+	private List<ClassCompilation> compileNamespaceRecursive(String namespace) throws PrivateNamespaceException {
 		pendingCompilation.add(namespace);
 		while (pendingCompilation.size() > 0) {
 			String pending = pendingCompilation.iterator().next();
@@ -1882,7 +1887,7 @@
 		return finish();
 	}
 	
-	private static List<ClassCompilation> getStubsUnlocked(Repository repo, String namespace) {
+	private static List<ClassCompilation> getStubsUnlocked(Repository repo, String namespace) throws PrivateNamespaceException {
 		List<ClassCompilation> ret = loadedRepositories.get(namespace);
 		if (ret != null) {
 			return ret;
@@ -1897,13 +1902,13 @@
 		return ret;
 	}
 	
-	public static List<ClassCompilation> getNativeStubs(Repository repo, String namespace) {
+	public static List<ClassCompilation> getNativeStubs(Repository repo, String namespace) throws PrivateNamespaceException {
 		synchronized (loadedRepositories) {
 			return getStubsUnlocked(repo, namespace);
 		}
 	}
 	
-	public static List<ClassCompilation> compile(Repository repo, String namespace, String version) {
+	public static List<ClassCompilation> compile(Repository repo, String namespace, String version) throws PrivateNamespaceException {
 		CodeFactory cf = new CodeFactory(repo);
 		return cf.compileNamespace(namespace, version);
 	}
@@ -1938,6 +1943,8 @@
 		
 		if (destFile == null) {
 			destFile = getJarPath(namespace);
+			if (destFile == null)
+				return null;
 			logger.info("Will install to: " + destFile);
 		}
 		
@@ -1948,7 +1955,12 @@
 		
 		logger.info(String.format("Compiling namespace: %s version: %s", namespace, version));
 		List<ClassCompilation> stubs;
-		stubs = CodeFactory.compile(repo, namespace, version);
+		try {
+			stubs = CodeFactory.compile(repo, namespace, version);
+		} catch (PrivateNamespaceException e) {
+			logger.info(String.format("Skipping namespace %s with no shared library", namespace));
+			return null;
+		}
 
 		Set<String> classNames = new HashSet<String>();
 		ZipOutputStream zo = new ZipOutputStream(new FileOutputStream(destFile));
@@ -2016,7 +2028,10 @@
 	}
 	
 	public static File getJarPath(String namespace) {
-		File typelibPath = new File(Repository.getDefault().getTypelibPath(namespace));
+		String path = Repository.getDefault().getTypelibPath(namespace);
+		if (path == null)
+			return null;
+		File typelibPath = new File(path);
 		String version = Repository.getDefault().getNamespaceVersion(namespace);
 		return new File(typelibPath.getParent(), String.format("%s-%s.jar", namespace, version));		
 	}
@@ -2033,11 +2048,14 @@
 			
 			if (namespaceIsExcluded(namespace))
 				continue;
+			File jarPath = getJarPath(namespace);
+			if (jarPath == null)
+				continue;
 			
 			Set<File> jarPaths = new HashSet<File>();
 						
 			Repository.getDefault().require(namespace, version);
-			jarPaths.add(getJarPath(namespace));
+			jarPaths.add(jarPath);
 			
 			String[] deps = Repository.getDefault().getDependencies(namespace);
 			if (deps != null) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]