From: Michael Zucchi Date: Mon, 22 Apr 2019 09:19:35 +0000 (+0930) Subject: Move generator to nativez-gen. X-Git-Tag: jjmpeg-4.0~2 X-Git-Url: https://code.zedzone.au/cvs?a=commitdiff_plain;h=c0842c7de33a5f8aec1b78e52ca1012f0ed7d2eb;p=jjmpeg Move generator to nativez-gen. Fix for various nativez changes. Split library table into per-platform files. Linux can optionally use the major version number in the .so library name. - this is enabled by default. Update java.make. --- diff --git a/config.make b/config.make index e77b258..657bb75 100644 --- a/config.make +++ b/config.make @@ -5,7 +5,7 @@ JAVA_HOME ?= /usr/local/jdk-11.0.2 JAVAFX_HOME ?= /usr/local/javafx-sdk-11.0.2 FFMPEG_HOME ?= /opt/ffmpeg/4.0 -# See also JAVACFLAGS +# See also JAVACFLAGS --module-path NATIVEZ_HOME=../nativez/bin/notzed.nativez/$(TARGET) JAVACFLAGS += --module-path $(JAVAFX_HOME)/lib:../nativez/bin/notzed.nativez @@ -16,25 +16,26 @@ JAR ?= jar JMOD ?= jmod # Linux options +# USE_SO_VERSION adds the major version to the library open name for ffmpeg libs on linux. linux-amd64_CPPFLAGS = \ - -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -linux-amd64_CFLAGS = -fPIC -Wall -Os + -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux \ + -DUSE_SO_VERSION=1 +linux-amd64_CFLAGS = -fPIC -Os -Wall linux-amd64_CC = cc linux-amd64_LD = ld linux-amd64_SO = .so linux-amd64_LIB = lib -linux-amd64_JMOD_LIBS = --libs # Windows options -windows-amd64_CPPFLAGS= \ +windows-amd64_CPPFLAGS = \ -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux \ -DHAVE_ALIGNED_MALLOC \ -DWIN32 +windows-amd64_CFLAGS = -Os -Wall windows-amd64_CC = x86_64-w64-mingw32-gcc windows-amd64_LD = x86_64-w64-mingw32-ld windows-amd64_LDFLAGS = -Wl,--subsystem,windows windows-amd64_SO = .dll windows-amd64_LIB = -windows-amd64_JMOD_LIBS = --cmds diff --git a/java.make b/java.make index ac60f16..7228203 100644 --- a/java.make +++ b/java.make @@ -62,7 +62,8 @@ # _jnidir Location for jni generated files (per target). # _objdir Location for c objects (per target). # _incdir Location for output includes, .jmod staging. -# _libdir Location for output libraries, .jmod staging. +# _libdir Location for output libraries, .jmod staging. May point to _bindir. +# _bindir Location for output commands, .jmod staging. # Define libraries # ---------------- @@ -92,6 +93,7 @@ # _SOURCES .c, .cc, .C - source files for library. Paths are relative to src//jni. # _HEADERS header files for jmod +# _COMMANDS commands/bin/scripts for jmod # _LDFLAGS link flags # _LIBADD extra objects to add to link line @@ -155,7 +157,8 @@ $(1)_genjavadir:=bin/gen/$(1)/classes $(1)_jnidir:=bin/$(1)/$(TARGET)/jni $(1)_objdir:=bin/$(1)/$(TARGET)/obj $(1)_incdir:=bin/$(1)/$(TARGET)/include -$(1)_libdir:=bin/$(1)/$(TARGET)/lib +$(1)_libdir:=$$(if $$(filter windows-%,$(TARGET)),bin/$(1)/$(TARGET)/bin,bin/$(1)/$(TARGET)/lib) +$(1)_bindir:=bin/$(1)/$(TARGET)/bin ifndef $(1)_JAVA $(1)_JAVA := $$(shell find src/$(1)/classes -type f -name '*.java') endif @@ -211,7 +214,8 @@ bin/$(1)/$(TARGET)/$(1).jmod: bin/status/$(1).classes bin/status/$(1).data --class-path bin/modules/$(1) \ $$(if $$(wildcard bin/$(1)/$(TARGET)/include),--header-files bin/$(1)/$(TARGET)/include) \ $$(if $$(wildcard src/$(1)/legal),--legal-notices src/$(1)/legal) \ - $$($(TARGET)_JMOD_LIBS) bin/$(1)/$(TARGET)/lib \ + $$(if $$(wildcard $$($(1)_bindir)),--cmds $$($(1)_bindir)) \ + $$(if $$(wildcard $$($(1)_libdir)),--libs $$($(1)_libdir)) \ $$@ # Create an IDE source zip, paths have to match --module-source-path @@ -289,7 +293,9 @@ $($(1)_objdir)/%.d: src/$(1)/jni/%.c bin/status/$(1).classes $($(TARGET)_CPPFLAGS) $($(2)_CPPFLAGS) $$< -o $$@.d 2>/dev/null @sed 's,\($$*\.o\) *:,\1 $$@ : ,g' $$@.d > $$@ ; rm $$@.d -bin jni $(1) bin/$(1)/$(TARGET)/$(1).jmod: $($(1)_libdir)/$(LIB)$(2)$(SO) $(addprefix $($(1)_incdir)/,$($(2)_HEADERS)) +bin jni $(1) bin/$(1)/$(TARGET)/$(1).jmod: $($(1)_libdir)/$(LIB)$(2)$(SO) \ + $(addprefix $($(1)_incdir)/,$($(2)_HEADERS)) \ + $(addprefix $($(1)_bindir)/,$($(2)_COMMANDS)) $(if $(filter clean dist gen,$(MAKECMDGOALS)),,-include $$($(2)_OBJS:.o=.d)) endef diff --git a/src/notzed.jjmpeg/jni/extract-proto.pl b/src/notzed.jjmpeg/jni/extract-proto.pl deleted file mode 100755 index 835eb7f..0000000 --- a/src/notzed.jjmpeg/jni/extract-proto.pl +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/perl - -$ffmpeg_home = "/opt/ffmpeg/4.0"; - -$args = "$0 ".join " ", @ARGV; - -while ($#ARGV >= 0) { - my $cmd = shift; - if ($cmd eq "-f") { - $ffmpeg_home = shift; - } else { - $in = $cmd; - } -} - -die ("No input file") if ! -f $in; - -$header = ""; -$librart = ""; -@functions = (); -@headers = (); -%proto = (); -$last_library = ""; -$mode = ""; - -open IN,"<$in"; - -while () { - chop; - - if (m/^#/) { - next; - } elsif (m/^header (.*) (.*) \{/) { - $library = $1; - $header = $2; - push @headers, $header; - - %proto = (); - open PROTO, "cproto -x -I$ffmpeg_home/include $ffmpeg_home/include/$header|"; - - while () { - chop; - $cproto = $_; - if (m/([a-zA-Z0-9_]*)\(/) { - $func = $1; - $proto{$func} = $cproto; - } - } - close PROTO; - - if ($library ne $last_library) { - push @functions, "#$library"; - $last_library = $library; - } - $mode = "proto"; - } elsif (m/^java (.*) (.*) \{/) { - # wouldn't it be nice to get this from the .class ... - $name = $1; - $class = $2; - $mode = "java"; - push @classes,"#$name:$class"; - } elsif (m/^}$/) { - $mode = ""; - } elsif ($mode eq "proto") { - if (m/\s*([a-zA-Z0-9_]+)/) { - my $func= $1; - my $cproto = $proto{$func}; - - die ("No function $func in $header") if !defined($cproto); - - push @functions, $cproto; - } - } elsif ($mode eq "java") { - if (m/(static)? *([\w<>]*) *, *([\[\w<>\(\)\/;]*)/) { - push @classes,"$1,$2,$3"; - } - } -} -close IN; - -$date = `date`; -chop $date; -print "/* This file was autogenerated on $date: */\n"; -print "/* $0 $args */\n"; - -if ($#headers >= 0) { - # Handle C prototype mappings - foreach $h (@headers) { - print "#include <$h>\n"; - } - - print "static struct functable {\n"; - foreach $func (@functions) { - if ($func =~ m/^\#(.+)/) { - print "\t/* lib$1 */\n"; - } else { - $dfunc = $func; - $dfunc =~ s/([a-zA-Z0-9_]*)(\(.*;)/(*\1)\2/; - print "\t$dfunc\n"; - } - } - print "} fn;\n"; - print "static const char *fn_names =\n"; - foreach $func (@functions) { - if ($func =~ m/^(\#.+)/) { - print "\t\"$func\\0\"\n"; - } else { - $func =~ m/([a-zA-Z0-9_]*)\(/; - print "\t\"$1\\0\"\n"; - } - } - print "\t;\n"; -} - -if ($#classes >= 0) { - # Handle java defines - $name = ""; - $class = ""; - print "static struct {\n"; - foreach $func (@classes) { - if ($func =~ m/^#(.+):(.+)/) { - $name = $1; - $class = $2; - print "\t// $class\n"; - print "\tjclass $name"."_classid;\n"; - printf "#define $name"."_classid java.$name"."_classid\n"; - } elsif ($func =~ m/(.*),(.+),\((.*)\).*/) { - my $method = $2; - my $args = $3; - - $args =~ s/L.*?;/l/g; - $args =~ s/\[/_/g; - $args =~ tr/A-Z/a-z/; - - $method =~ s//new/; - - print "\tjmethodID $name"."_$method"."_$args;\n"; - print "#define $name"."_$method"."_$args java.$name"."_$method"."_$args\n"; - } elsif ($func =~ m/(.*),(.+),(.+)/) { - my $field = $2; - my $type = $3; - - print "\tjfieldID $name"."_$field;\n"; - print "#define $name"."_$field java.$name"."_$field\n"; - } else { - die("can't parse java signature $func"); - } - } - print "} java;\n"; - print "static const char *java_names =\n"; - foreach $func (@classes) { - if ($func =~ m/^#(.+):(.+)/) { - $name = $1; - $class = $2; - - print "\t\"#$class\\0\"\n"; - } elsif ($func =~ m/static,(.*),(.*\(.*\).*)/) { - print "\t\":$1\\0$2\\0\"\n"; - } elsif ($func =~ m/,(.*),(.*\(.*\).*)/) { - print "\t\".$1\\0$2\\0\"\n"; - } elsif ($func =~ m/static,(.*),(.*)/) { - print "\t\";$1\\0$2\\0\"\n"; - } elsif ($func =~ m/,(.*),(.*)/) { - print "\t\",$1\\0$2\\0\"\n"; - } - } - print "\t;\n"; -} diff --git a/src/notzed.jjmpeg/jni/jj-avcodec.c b/src/notzed.jjmpeg/jni/jj-avcodec.c index 5b4b59b..fd77fa6 100644 --- a/src/notzed.jjmpeg/jni/jj-avcodec.c +++ b/src/notzed.jjmpeg/jni/jj-avcodec.c @@ -22,13 +22,10 @@ #include "au_notzed_jjmpeg_AVCodec.h" #include "jjmpeg.h" - #include "jj-avcodec.h" -#undef DLCALL -#define DLCALL(x) (fn.x) jint AVCodec_OnLoad(JavaVM *vmi, JNIEnv *env) { - return jj_ResolveFunctions(env, fn_names, &fn); + return nativez_ResolveFunctions(env, jj_libtable, fn_names, &fn); } /* ********************************************************************** */ diff --git a/src/notzed.jjmpeg/jni/jj-avcodeccontext.c b/src/notzed.jjmpeg/jni/jj-avcodeccontext.c index c852d76..78bda20 100644 --- a/src/notzed.jjmpeg/jni/jj-avcodeccontext.c +++ b/src/notzed.jjmpeg/jni/jj-avcodeccontext.c @@ -24,11 +24,8 @@ #include "jjmpeg.h" #include "jj-avcodeccontext.h" -#undef DLCALL -#define DLCALL(x) (fn.x) - jint AVCodecContext_OnLoad(JavaVM *vmi, JNIEnv *env) { - return jj_ResolveFunctions(env, fn_names, &fn); + return nativez_ResolveFunctions(env, jj_libtable, fn_names, &fn); } /* ********************************************************************** */ diff --git a/src/notzed.jjmpeg/jni/jj-avcodecparameters.c b/src/notzed.jjmpeg/jni/jj-avcodecparameters.c index 16622e6..b38fa03 100644 --- a/src/notzed.jjmpeg/jni/jj-avcodecparameters.c +++ b/src/notzed.jjmpeg/jni/jj-avcodecparameters.c @@ -22,13 +22,10 @@ #include "au_notzed_jjmpeg_AVCodecParameters.h" #include "jjmpeg.h" - #include "jj-avcodecparameters.h" -#undef DLCALL -#define DLCALL(x) (fn.x) jint AVCodecParameters_OnLoad(JavaVM *vmi, JNIEnv *env) { - return jj_ResolveFunctions(env, fn_names, &fn); + return nativez_ResolveFunctions(env, jj_libtable, fn_names, &fn); } /* ********************************************************************** */ diff --git a/src/notzed.jjmpeg/jni/jj-avdevice.c b/src/notzed.jjmpeg/jni/jj-avdevice.c index 6db0739..2169d0b 100644 --- a/src/notzed.jjmpeg/jni/jj-avdevice.c +++ b/src/notzed.jjmpeg/jni/jj-avdevice.c @@ -30,9 +30,9 @@ #include "jj-avdevice.h" jint AVDevice_OnLoad(JavaVM *vmi, JNIEnv *env) { - if (jj_ResolveReferences(env, java_names, &java)) + if (nativez_ResolveReferences(env, java_names, &java)) return -1; - jj_ResolveFunctions(env, fn_names, &fn); + nativez_ResolveFunctions(env, jj_libtable, fn_names, &fn); return 0; } diff --git a/src/notzed.jjmpeg/jni/jj-avformatcontext.c b/src/notzed.jjmpeg/jni/jj-avformatcontext.c index d7c0160..643e959 100644 --- a/src/notzed.jjmpeg/jni/jj-avformatcontext.c +++ b/src/notzed.jjmpeg/jni/jj-avformatcontext.c @@ -34,8 +34,8 @@ */ jint AVFormatContext_OnLoad(JavaVM *vmi, JNIEnv *env) { - return jj_ResolveReferences(env, java_names, &java) - || jj_ResolveFunctions(env, fn_names, &fn); + return nativez_ResolveReferences(env, java_names, &java) + || nativez_ResolveFunctions(env, jj_libtable, fn_names, &fn); } /* ********************************************************************** */ diff --git a/src/notzed.jjmpeg/jni/jj-avframe.c b/src/notzed.jjmpeg/jni/jj-avframe.c index 822362c..bf79809 100644 --- a/src/notzed.jjmpeg/jni/jj-avframe.c +++ b/src/notzed.jjmpeg/jni/jj-avframe.c @@ -25,15 +25,12 @@ #include "au_notzed_jjmpeg_AVFrame_SampleReader.h" #include "jjmpeg.h" - #include "jj-avframe.h" -#undef DLCALL -#define DLCALL(x) (fn.x) #define MAX(a, b) ((a)>(b)?(a):(b)) jint AVFrame_OnLoad(JavaVM *vmi, JNIEnv *env) { - return jj_ResolveFunctions(env, fn_names, &fn); + return nativez_ResolveFunctions(env, jj_libtable, fn_names, &fn); } /* ********************************************************************** */ diff --git a/src/notzed.jjmpeg/jni/jj-aviocontext.c b/src/notzed.jjmpeg/jni/jj-aviocontext.c index 26841a2..2b27ac2 100644 --- a/src/notzed.jjmpeg/jni/jj-aviocontext.c +++ b/src/notzed.jjmpeg/jni/jj-aviocontext.c @@ -20,12 +20,11 @@ #include "au_notzed_jjmpeg_AVIOContext.h" #include "jjmpeg.h" - #include "jj-aviocontext.h" jint AVIOContext_OnLoad(JavaVM *vmi, JNIEnv *env) { - return jj_ResolveReferences(env, java_names, &java) - || jj_ResolveFunctions(env, fn_names, &fn); + return nativez_ResolveReferences(env, java_names, &java) + || nativez_ResolveFunctions(env, jj_libtable, fn_names, &fn); } /* ********************************************************************** */ diff --git a/src/notzed.jjmpeg/jni/jj-avmisc.c b/src/notzed.jjmpeg/jni/jj-avmisc.c index 26e8fa8..396a603 100644 --- a/src/notzed.jjmpeg/jni/jj-avmisc.c +++ b/src/notzed.jjmpeg/jni/jj-avmisc.c @@ -26,24 +26,19 @@ #include "au_notzed_jjmpeg_AVInputFormat.h" #include "au_notzed_jjmpeg_AVOutputFormat.h" #include "au_notzed_jjmpeg_AVRational.h" -#include "au_notzed_jjmpeg_SwsContext.h" - #include "au_notzed_jjmpeg_AVCodecID.h" #include "au_notzed_jjmpeg_AVPixelFormat.h" #include "au_notzed_jjmpeg_AVSampleFormat.h" #include "au_notzed_jjmpeg_AVChannelLayout.h" #include "au_notzed_jjmpeg_AVMediaType.h" - #include "au_notzed_jjmpeg_AVError.h" +#include "au_notzed_jjmpeg_SwsContext.h" #include "jjmpeg.h" - #include "jj-avmisc.h" -#undef DLCALL -#define DLCALL(x) (fn.x) jint AVMisc_OnLoad(JavaVM *vmi, JNIEnv *env) { - return jj_ResolveFunctions(env, fn_names, &fn); + return nativez_ResolveFunctions(env, jj_libtable, fn_names, &fn); } /* ********************************************************************** */ diff --git a/src/notzed.jjmpeg/jni/jj-avoptions.c b/src/notzed.jjmpeg/jni/jj-avoptions.c index f834ffb..0194348 100644 --- a/src/notzed.jjmpeg/jni/jj-avoptions.c +++ b/src/notzed.jjmpeg/jni/jj-avoptions.c @@ -25,8 +25,8 @@ #include "jj-avoptions.h" jint AVOptions_OnLoad(JavaVM *vmi, JNIEnv *env) { - return jj_ResolveReferences(env, java_names, &java) - || jj_ResolveFunctions(env, fn_names, &fn); + return nativez_ResolveReferences(env, java_names, &java) + || nativez_ResolveFunctions(env, jj_libtable, fn_names, &fn); } #define GETP(name) void *name = NativeZ_getP(env, j ## name) diff --git a/src/notzed.jjmpeg/jni/jj-avpacket.c b/src/notzed.jjmpeg/jni/jj-avpacket.c index b43cb2d..bd57fa4 100644 --- a/src/notzed.jjmpeg/jni/jj-avpacket.c +++ b/src/notzed.jjmpeg/jni/jj-avpacket.c @@ -25,8 +25,8 @@ #include "jj-avpacket.h" jint AVPacket_OnLoad(JavaVM *vmi, JNIEnv *env) { - return jj_ResolveReferences(env, java_names, &java) - || jj_ResolveFunctions(env, fn_names, &fn); + return nativez_ResolveReferences(env, java_names, &java) + || nativez_ResolveFunctions(env, jj_libtable, fn_names, &fn); } /* ********************************************************************** */ diff --git a/src/notzed.jjmpeg/jni/jj-avstream.c b/src/notzed.jjmpeg/jni/jj-avstream.c index 945488a..fc8edfc 100644 --- a/src/notzed.jjmpeg/jni/jj-avstream.c +++ b/src/notzed.jjmpeg/jni/jj-avstream.c @@ -27,7 +27,7 @@ #include "jj-avstream.h" jint AVStream_OnLoad(JavaVM *vmi, JNIEnv *env) { - return jj_ResolveReferences(env, java_names, &java); + return nativez_ResolveReferences(env, java_names, &java); } /* ********************************************************************** */ diff --git a/src/notzed.jjmpeg/jni/jj-avutil.c b/src/notzed.jjmpeg/jni/jj-avutil.c index fc3add1..a8d4bb7 100644 --- a/src/notzed.jjmpeg/jni/jj-avutil.c +++ b/src/notzed.jjmpeg/jni/jj-avutil.c @@ -23,8 +23,8 @@ #include "jj-avutil.h" jint AVUtil_OnLoad(JavaVM *vmi, JNIEnv *env) { - return jj_ResolveReferences(env, java_names, &java) - || jj_ResolveFunctions(env, fn_names, &fn); + return nativez_ResolveReferences(env, java_names, &java) + || nativez_ResolveFunctions(env, jj_libtable, fn_names, &fn); } static jobject jlogger_ref; diff --git a/src/notzed.jjmpeg/jni/jjmpeg-jni.c b/src/notzed.jjmpeg/jni/jjmpeg-jni.c index 16d397e..a59381c 100644 --- a/src/notzed.jjmpeg/jni/jjmpeg-jni.c +++ b/src/notzed.jjmpeg/jni/jjmpeg-jni.c @@ -19,34 +19,11 @@ #include -#include -#include -#include -#include -#include -#include - #include "jjmpeg.h" #include "jjmpeg-jni.h" #define D(x) -static int fail(const char *ctx, const char *what) __attribute__ ((noinline)); - -#undef DLSO -#define DLSO(name, v, flags) { #name, v, flags } - -static NZLibTable libtable[] = { - DLSO(avutil, LIBAVUTIL_VERSION_MAJOR, 0), - DLSO(avcodec, LIBAVCODEC_VERSION_MAJOR, 0), - DLSO(avformat, LIBAVFORMAT_VERSION_MAJOR, 0), - DLSO(swscale, LIBSWSCALE_VERSION_MAJOR, 0), // noncore? - DLSO(swresample, LIBSWRESAMPLE_VERSION_MAJOR, 0), // noncore? - DLSO(avdevice, LIBAVDEVICE_VERSION_MAJOR, DLSO_NONCORE), - - { 0 } -}; - typedef jint (*onLoad)(JavaVM *, JNIEnv *); static onLoad ctors[] = { @@ -75,9 +52,9 @@ jint JNI_OnLoad(JavaVM *vmi, void *reserved) { if ((*vmi)->GetEnv(vmi, (void *)&env, JNI_VERSION_1_4) < 0) return 0; - if (jj_ResolveReferences(env, java_names, &java) != 0 - || jj_ResolveLibraries(env, libtable) != 0 - || jj_ResolveFunctions(env, fn_names, &fn) != 0) + if (nativez_ResolveReferences(env, java_names, &java) != 0 + || nativez_ResolveLibraries(env, jj_libtable) != 0 + || nativez_ResolveFunctions(env, jj_libtable, fn_names, &fn) != 0) return -1; /* Call other onload functions */ @@ -92,121 +69,6 @@ jint JNI_OnLoad(JavaVM *vmi, void *reserved) { /* ********************************************************************** */ -static int fail(const char *ctx, const char *what) { - fprintf(stderr, "%s: %s\n", ctx, what); - perror(ctx); - fflush(stderr); - return -1; -} - -// temporary -#include - -int jj_ResolveLibraries(JNIEnv *env, NZLibTable *table) { - char name[64]; - - for (int i=0;table[i].name;i++) { - void *lib; - - sprintf(name, "lib%s.so", table[i].name); - - lib = dlopen(name, RTLD_LAZY | RTLD_GLOBAL); - if (!lib) { - return fail("open library", name); - } - - table[i].ptr = lib; - } - return 0; -} - -static int jj_ResolveFunctionsX(JNIEnv *env, const NZLibTable *table, const char *fn_names, void *fnp) { - void *lib = NULL; - const char *name = fn_names; - int index = 0; - const char *lib_name = ""; - void **fn = fnp; - - while (*name) { - const char *next = name + strlen(name) + 1; - - if (*name == '#') { - lib = NULL; - lib_name = name+1; - for (int i=0;table[i].name;i++) { - if (strcmp(table[i].name, lib_name) == 0) { - lib = table[i].ptr; - break; - } - } - } else if (lib) { - void *entry = dlsym(lib, name); - - fn[index++] = entry; - if (!entry) { - return fail("resolve function", name); - } - } else { - return fail("find function library", lib_name); - } - - name = next; - } - - return 0; -} - -int jj_ResolveFunctions(JNIEnv *env, const char *fn_names, void *fnp) { - return jj_ResolveFunctionsX(env, libtable, fn_names, fnp); -} - -int jj_ResolveReferences(JNIEnv *env, const char *jn_names, void *jnp) { - jclass jc = NULL; - - const char *name = jn_names; - int index = 0; - void **jn = jnp; - const char *cname = "?"; - - while (*name) { - const char *next = name + strlen(name) + 1; - - switch (*name) { - case '#': // class - jc = (*env)->FindClass(env, name + 1); - jn[index] = jc = (*env)->NewGlobalRef(env, jc); - cname = name + 1; - break; - case ',': // field - jn[index] = (*env)->GetFieldID(env, jc, name+1, next); - break; - case ';': // static field - jn[index] = (*env)->GetStaticFieldID(env, jc, name+1, next); - break; - case '.': // method - jn[index] = (*env)->GetMethodID(env, jc, name+1, next); - break; - case ':': // static method - jn[index] = (*env)->GetStaticMethodID(env, jc, name+1, next); - break; - default: - return fail("Invalid table", name); - } - - if (!jn[index]) - return fail(cname, name+1); - - if (*name != '#') - next = next + strlen(next) + 1; - name = next; - index += 1; - } - - return 0; -} - -/* ********************************************************************** */ - void jjthrowAVIOException(JNIEnv *env, int error, const char *msg) { jvalue jargs[2]; jthrowable jex; diff --git a/src/notzed.jjmpeg/jni/jjmpeg-linux.c b/src/notzed.jjmpeg/jni/jjmpeg-linux.c new file mode 100644 index 0000000..f673dcb --- /dev/null +++ b/src/notzed.jjmpeg/jni/jjmpeg-linux.c @@ -0,0 +1,26 @@ + +#include +#include +#include +#include +#include +#include + +#include "nativez.h" + +#if defined(USE_SO_VERSION) +#define SIFY(n) #n +#define SO(n, v, f) NZSO(n, "lib" n ".so." SIFY(v), f) +#else +#define SO(n, v, f) NZSO(n, "lib" n ".so", f) +#endif + +NZLibTable jj_libtable[] = { + SO("avutil", LIBAVUTIL_VERSION_MAJOR, 0), + SO("avcodec", LIBAVCODEC_VERSION_MAJOR, 0), + SO("avformat", LIBAVFORMAT_VERSION_MAJOR, 0), + SO("swscale", LIBSWSCALE_VERSION_MAJOR, 0), // noncore? + SO("swresample", LIBSWRESAMPLE_VERSION_MAJOR, 0), // noncore? + SO("avdevice", LIBAVDEVICE_VERSION_MAJOR, NZSO_NONCORE), + NZSO_END +}; diff --git a/src/notzed.jjmpeg/jni/jjmpeg-windows.c b/src/notzed.jjmpeg/jni/jjmpeg-windows.c new file mode 100644 index 0000000..fae2714 --- /dev/null +++ b/src/notzed.jjmpeg/jni/jjmpeg-windows.c @@ -0,0 +1,22 @@ + +#include +#include +#include +#include +#include +#include + +#include "nativez.h" + +#define SIFY(n) #n +#define SO(n, v, f) NZSO(n, n "-" SIFY(v) ".dll", f) + +NZLibTable jj_libtable[] = { + SO("avutil", LIBAVUTIL_VERSION_MAJOR, 0), + SO("avcodec", LIBAVCODEC_VERSION_MAJOR, 0), + SO("avformat", LIBAVFORMAT_VERSION_MAJOR, 0), + SO("swscale", LIBSWSCALE_VERSION_MAJOR, 0), // noncore? + SO("swresample", LIBSWRESAMPLE_VERSION_MAJOR, 0), // noncore? + SO("avdevice", LIBAVDEVICE_VERSION_MAJOR, NZSO_NONCORE), + NZSO_END +}; diff --git a/src/notzed.jjmpeg/jni/jjmpeg.h b/src/notzed.jjmpeg/jni/jjmpeg.h index 433b32b..d29f641 100644 --- a/src/notzed.jjmpeg/jni/jjmpeg.h +++ b/src/notzed.jjmpeg/jni/jjmpeg.h @@ -210,13 +210,9 @@ jint AVStream_OnLoad(JavaVM *vmi, JNIEnv *env); jint AVUtil_OnLoad(JavaVM *vmi, JNIEnv *env); -/* temporary */ -int jj_ResolveFunctions(JNIEnv *env, const char *fn_names, void *fnp); -int jj_ResolveLibraries(JNIEnv *env, NZLibTable *table); -int jj_ResolveReferences(JNIEnv *env, const char *jn_names, void *jnp); -#undef DLCALL +extern NZLibTable jj_libtable[]; + #define DLCALL(x) (fn.x) -#undef DLCHECK_RET #define DLCHECK_RET(env, x, ret) do { if (!nativez_NonNull(env, #x, (void *)fn.x)) { return ret; } } while (0) #endif diff --git a/src/notzed.jjmpeg/jni/jni.make b/src/notzed.jjmpeg/jni/jni.make index acea673..a712c73 100644 --- a/src/notzed.jjmpeg/jni/jni.make +++ b/src/notzed.jjmpeg/jni/jni.make @@ -21,6 +21,7 @@ notzed.jjmpeg_JNI_LIBRARIES = jjmpeg jjmpeg_SOURCES = \ jjmpeg-jni.c \ + jjmpeg-$(TARGET:-amd64=).c \ jj-avcodec.c \ jj-avcodeccontext.c \ jj-avcodecparameters.c \ @@ -34,11 +35,12 @@ jjmpeg_SOURCES = \ jj-avstream.c \ jj-avutil.c -linux-amd64_jjmpeg_LDFLAGS = -ldl +linux-amd64_jjmpeg_LDLIBS = -L$(NATIVEZ_HOME)/lib -lnativez -dl +windows-amd64_jjmpeg_LDLIBS = -L$(NATIVEZ_HOME)/bin -lnativez -jjmpeg_LDLIBS=-L$(NATIVEZ_HOME)/lib -lnativez $($(TARGET)_jjmpeg_LDFLAGS) +jjmpeg_LDLIBS=$($(TARGET)_jjmpeg_LDLIBS) jjmpeg_CPPFLAGS=-I$(FFMPEG_HOME)/include -I$(NATIVEZ_HOME)/include -I$(notzed.jjmpeg_jnidir) -jjmpeg_CFLAGS=-Wall -Wmissing-prototypes -Wno-pointer-sign +jjmpeg_CFLAGS=-Wmissing-prototypes -Wno-pointer-sign jjmpeg_DEFS = \ jjmpeg-jni.def \ @@ -61,4 +63,4 @@ $(foreach def,$(jjmpeg_DEFS),$(eval $(call jjmpeg_makedep,$(def:.def=)))) $(notzed.jjmpeg_jnidir)/%.h: src/notzed.jjmpeg/jni/%.def @install -d $(@D) - src/notzed.jjmpeg/jni/extract-proto.pl -f "$(FFMPEG_HOME)" $< > $@ || ( rm $@ ; exit 1) + $(NATIVEZ_HOME)/bin/nativez-gen -J -b "$(FFMPEG_HOME)/include" $< > $@ || ( rm $@ ; exit 1)