java-gobject-introspection r118 - in trunk: . src src/org/gnome/gir/compiler src/org/gnome/gir/gobject src/org/gnome/gir/repository
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: java-gobject-introspection r118 - in trunk: . src src/org/gnome/gir/compiler src/org/gnome/gir/gobject src/org/gnome/gir/repository
- Date: Sat, 15 Nov 2008 22:21:30 +0000 (UTC)
Author: walters
Date: Sat Nov 15 22:21:30 2008
New Revision: 118
URL: http://svn.gnome.org/viewvc/java-gobject-introspection?rev=118&view=rev
Log:
Refactor to be single compilation process again
Modified:
trunk/src/jgir-compile-all.in
trunk/src/jgir-compile.in
trunk/src/org/gnome/gir/compiler/CodeFactory.java
trunk/src/org/gnome/gir/gobject/GType.java
trunk/src/org/gnome/gir/repository/GIntrospectionAPI.java
trunk/src/org/gnome/gir/repository/Repository.java
trunk/wscript
Modified: trunk/src/jgir-compile-all.in
==============================================================================
--- trunk/src/jgir-compile-all.in (original)
+++ trunk/src/jgir-compile-all.in Sat Nov 15 22:21:30 2008
@@ -3,36 +3,18 @@
classpath="@CLASSPATH@"
prefix="@PREFIX@"
-libdir=os.path.join(prefix, "lib64")
-if not os.path.isdir(libdir):
- libdir = os.path.join(prefix, "lib")
+# Just put this one in the env
+os.environ['TYPELIBDIR'] = "@TYPELIBDIR@"
java_opts=os.environ.get('JAVA_OPTS', None)
if java_opts:
java_opts = java_opts.split(' ')
else:
java_opts = []
-nsversions = []
-def compile_typelibs(dirname):
- repodir = os.path.join(dirname, 'girepository')
- for name in os.listdir(repodir):
- if not name.endswith('.typelib'):
- continue
- base,_ = os.path.splitext(name)
- nsversions.append(base)
- print "%r" % (base, )
- ns,version = base.rsplit('-', 1)
- args = ['java']
- args.extend(java_opts)
- args.extend(['-cp', classpath, 'org.gnome.gir.compiler.CodeFactory', ns, version])
- subprocess.check_call(args,
- stdout=sys.stdout,
- stderr=sys.stderr,
- close_fds=True)
-compile_typelibs(libdir)
-
-subprocess.check_call(['java', '-cp', classpath, 'org.gnome.gir.compiler.CodeFactory',
- '--verify', ','.join(nsversions)],
- stdout=sys.stdout,
- stderr=sys.stderr,
+args = ['java']
+args.extend(java_opts)
+args.extend(['-cp', classpath, 'org.gnome.gir.compiler.CodeFactory'])
+subprocess.check_call(args + ['--compileall'],
+ close_fds=True)
+subprocess.check_call(args + ['--verifyall'],
close_fds=True)
Modified: trunk/src/jgir-compile.in
==============================================================================
--- trunk/src/jgir-compile.in (original)
+++ trunk/src/jgir-compile.in Sat Nov 15 22:21:30 2008
@@ -2,6 +2,8 @@
import os,sys,subprocess
classpath="@CLASSPATH@"
+# Just put this one in the env
+os.environ['TYPELIBDIR'] = "@TYPELIBDIR@"
java_opts=os.environ.get('JAVA_OPTS', None)
if java_opts:
java_opts = java_opts.split(' ')
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 Sat Nov 15 22:21:30 2008
@@ -43,6 +43,7 @@
import java.io.File;
import java.io.FileOutputStream;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
@@ -1961,6 +1962,8 @@
logger.info(String.format("Skipping namespace %s with no shared library", namespace));
return null;
}
+
+ repo.unloadAll();
Set<String> classNames = new HashSet<String>();
ZipOutputStream zo = new ZipOutputStream(new FileOutputStream(destFile));
@@ -1977,7 +1980,7 @@
return destFile;
}
- public static void verifyJarFiles(Set<File> jarPaths) throws Exception {
+ public static void verifyJarFiles(List<File> jarPaths) throws Exception {
logger.info(String.format("Verifing %d jars", jarPaths.size()));
List<URL> urls = new ArrayList<URL>();
Map<String, InputStream> allClassnames = new HashMap<String, InputStream>();
@@ -2040,50 +2043,67 @@
return namespace.equals("GLib") || namespace.equals("GObject");
}
- public static void verifyAll(String[] nsversions) throws Exception {
- for (String nsversion : nsversions) {
- int dashIdx = nsversion.lastIndexOf('-');
- String namespace = nsversion.substring(0, dashIdx);
- String version = nsversion.substring(dashIdx+1);
-
- 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(jarPath);
-
- String[] deps = Repository.getDefault().getDependencies(namespace);
- if (deps != null) {
- for (String dep : deps) {
- String depNamespace = dep.substring(0, dep.lastIndexOf('-'));
- if (!namespaceIsExcluded(depNamespace))
- jarPaths.add(getJarPath(depNamespace));
- }
+ private static File getTypelibDir() {
+ return new File(System.getenv("TYPELIBDIR"));
+ }
+
+ public static void verifyAll() throws Exception {
+ File[] jars = getTypelibDir().listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".jar");
}
- verifyJarFiles(jarPaths);
+ });
+ Repository.getDefault().disableRequires();
+ verifyJarFiles(Arrays.asList(jars));
+ }
+
+ private static final class NsVer {
+ public String namespace;
+ public String version;
+
+ public static NsVer parse(String base) {
+ int dash = base.indexOf('-');
+ NsVer nsver = new NsVer();
+ nsver.namespace = base.substring(0, dash);
+ nsver.version = base.substring(dash+1, base.lastIndexOf('.'));
+ return nsver;
+ }
+ }
+
+ public static void compileAll() throws GErrorException, IOException {
+ File[] typelibs = getTypelibDir().listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".typelib");
+ }
+ });
+ for (File typelib : typelibs) {
+ String base = typelib.getName();
+
+ NsVer nsver = NsVer.parse(base);
+ if (namespaceIsExcluded(nsver.namespace))
+ continue;
+
+ compile(nsver.namespace, nsver.version);
}
}
public static void main(String[] args) throws Exception {
GObjectAPI.gobj.g_type_init();
- if (args[0].equals("--verify"))
- verifyAll(args[1].split(","));
+ if (args[0].equals("--compileall"))
+ compileAll();
+ else if (args[0].equals("--verifyall"))
+ verifyAll();
else if (args[0].endsWith(".typelib")) {
File typelib = new File(args[0]);
String base = typelib.getName();
- int dash = base.indexOf('-');
- String namespace = base.substring(0, dash);
- String version = base.substring(dash+1, base.lastIndexOf('.'));
+ NsVer nsver = NsVer.parse(base);
String parent = typelib.getParent();
if (parent == null)
parent = System.getProperty("user.dir");
Repository.getDefault().prependSearchPath(parent);
- compile(namespace, version);
+ compile(nsver.namespace, nsver.version);
} else {
String namespace = args[0];
String version = args[1];
Modified: trunk/src/org/gnome/gir/gobject/GType.java
==============================================================================
--- trunk/src/org/gnome/gir/gobject/GType.java (original)
+++ trunk/src/org/gnome/gir/gobject/GType.java Sat Nov 15 22:21:30 2008
@@ -89,10 +89,11 @@
String[] glibPointerUnmapped = new String[] { "Mutex", "Cond", "FreeFunc", "DestroyNotify", "MarkupParser",
"SpawnChildSetupFunc", "Node", "CompareFunc", "KeyFile", "PtrArray", "Func",
- "ThreadPool", "Source", "CompareDataFunc", "Array", "Data", "DataSet", "Date", "IOChannel" };
+ "ThreadPool", "Source", "CompareDataFunc", "Array", "Data", "DataSet", "Date", "IOChannel", "Regex",
+ "MappedFile" };
for (String unmapped : glibPointerUnmapped)
put("GLib." + unmapped, "com/sun/jna/Pointer");
- String[] glibIntegerUnmapped = new String[] { "SpawnFlags", "SeekType", "IOCondition" };
+ String[] glibIntegerUnmapped = new String[] { "SpawnFlags", "SeekType", "IOCondition", "RegexMatchFlags" };
for (String unmapped : glibIntegerUnmapped)
put("GLib." + unmapped, "java/lang/Integer");
Modified: trunk/src/org/gnome/gir/repository/GIntrospectionAPI.java
==============================================================================
--- trunk/src/org/gnome/gir/repository/GIntrospectionAPI.java (original)
+++ trunk/src/org/gnome/gir/repository/GIntrospectionAPI.java Sat Nov 15 22:21:30 2008
@@ -57,6 +57,7 @@
BaseInfo g_irepository_get_info(Repository repo, String namespace, int idx);
String g_irepository_get_shared_library(Repository repository, String namespace);
String g_irepository_get_typelib_path(Repository repository, String namespace);
+ void g_irepository_unload_all(Repository repo);
void g_base_info_ref(BaseInfo info);
void g_base_info_unref(BaseInfo info);
Modified: trunk/src/org/gnome/gir/repository/Repository.java
==============================================================================
--- trunk/src/org/gnome/gir/repository/Repository.java (original)
+++ trunk/src/org/gnome/gir/repository/Repository.java Sat Nov 15 22:21:30 2008
@@ -10,6 +10,14 @@
public class Repository extends PointerType {
+ private boolean disableRequires = false;
+
+ /* Needed for the compiler to be able to verify classes without loading typelibs
+ * which could potentially conflict. */
+ public void disableRequires() {
+ disableRequires = true;
+ }
+
public void prependSearchPath(String path) {
GIntrospectionAPI.gi.g_irepository_prepend_search_path(path);
}
@@ -23,6 +31,8 @@
}
public void require(String namespace, String version) throws GErrorException {
+ if (disableRequires)
+ return;
PointerByReference error = new PointerByReference(null);
if (GIntrospectionAPI.gi.g_irepository_require(this, namespace, version, 0, error) == null) {
throw new GErrorException(new GErrorStruct(error.getValue()));
@@ -74,4 +84,8 @@
GObjectGlobals.init();
return getNativeLibrary().g_irepository_get_default();
}
+
+ public void unloadAll() {
+ GIntrospectionAPI.gi.g_irepository_unload_all(this);
+ }
}
Modified: trunk/wscript
==============================================================================
--- trunk/wscript (original)
+++ trunk/wscript Sat Nov 15 22:21:30 2008
@@ -5,6 +5,7 @@
import Task,TaskGen,Node
from TaskGen import *
+import pproc
# the following two variables are used by the target "waf dist"
VERSION='0.1.0'
@@ -44,9 +45,16 @@
def set_options(opt):
pass
+def get_pkgconfig_var(conf, module, var):
+ conf.env[var] = pproc.Popen(['pkg-config', '--variable='+var, module],
+ stdout=pproc.PIPE).communicate()[0].strip()
+
def configure(conf):
conf.check_tool('gcc gnome java misc')
+
conf.check_pkg('gobject-introspection-1.0', destvar='GI', mandatory=True)
+ get_pkgconfig_var(conf, 'gobject-introspection-1.0', 'typelibdir')
+
conf.require_java_class('java.lang.Object')
asm_deps = ['asm', 'asm-util', 'asm-tree', 'asm-commons', 'asm-analysis']
for dep in asm_deps:
@@ -69,14 +77,15 @@
compscript.chmod = 0755
compscript.source = 'src/jgir-compile-all.in'
compscript.target = 'jgir-compile-all'
- compscript.dict = {'CLASSPATH': full_cp, 'PREFIX': bld.env['PREFIX']}
+ compscript.dict = {'CLASSPATH': full_cp, 'PREFIX': bld.env['PREFIX'],
+ 'TYPELIBDIR': bld.env['typelibdir']}
compscript = bld.new_task_gen('subst')
compscript.install_path = "${PREFIX}/bin"
compscript.chmod = 0755
compscript.source = 'src/jgir-compile.in'
compscript.target = 'jgir-compile'
- compscript.dict = {'CLASSPATH': full_cp}
+ compscript.dict = {'CLASSPATH': full_cp, 'TYPELIBDIR': bld.env['typelibdir']}
#libinvoke = bld.new_task_gen('cc', 'shlib')
#libinvoke.packages = ['gobject-introspection-1.0']
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]