GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — swingwebview/run-linux-media-smoketest.sh at master · webliteca/swingwebview Expand file tree/ Copy pathrun-linux-media-smoketest.shMore file actions executable file ·201 lines (187 loc) · 8.17 KB / Copy pathrun-linux-media-smoketest.shFile metadata and controlsexecutable file ·201 lines (187 loc) · 8.17 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 #!/bin/bash # One-shot script: build the Linux native lib, build WebView.jar, compile # and run the media smoke tests. No Ant required. # 1. WebViewMediaSmokeTest (Canvas 33): HTML media plays in the lightweight # engine. # 2. WebViewMediaPermissionSmokeTest (Canvas 35): camera / microphone / # screen-capture requests reach a WebViewPermissionHandler, DENY gives # NotAllowedError and ALLOW gives a stream -- against WebKitGTK's mock # capture devices (WEBVIEW_MOCK_CAPTURE_DEVICES=1), so no camera needed. # Exits 0 when both pass, 1 when either fails. Runs headless under Xvfb, e.g.: # xvfb-run -a ./run-linux-media-smoketest.sh # # Usage: ./run-linux-media-smoketest.sh # Override: JAVA_HOME=/path/to/jdk ./run-linux-media-smoketest.sh # # Required packages: # - g++, pkg-config # - libgtk-3-dev # - libwebkit2gtk-4.1-dev (Ubuntu 24.04+) or libwebkit2gtk-4.0-dev (older) # - libx11-dev # - libxt-dev <-- pulled in because JDK 8's jawt_md.h includes # <X11/Intrinsic.h>. JDK 9+ does not need this. set -e set -o pipefail REPO_DIR="$(cd "$(dirname "$0")" && pwd)" cd "$REPO_DIR" # --------------------------------------------------------------------------- # 1. Resolve JAVA_HOME # --------------------------------------------------------------------------- if [ -z "$JAVA_HOME" ]; then if command -v javac >/dev/null 2>&1; then JAVAC_PATH="$(readlink -f "$(command -v javac)" 2>/dev/null || command -v javac)" JAVA_HOME="$(dirname "$(dirname "$JAVAC_PATH")")" fi fi if [ -z "$JAVA_HOME" ] || [ ! -d "$JAVA_HOME" ]; then echo "JAVA_HOME is not set and could not be resolved automatically." >&2 echo "Install a JDK and export JAVA_HOME, e.g. via mise / asdf:" >&2 echo " mise install # picks up .tool-versions" >&2 exit 1 fi export JAVA_HOME echo "Using JAVA_HOME=$JAVA_HOME" JAVAC="$JAVA_HOME/bin/javac" JAVA="$JAVA_HOME/bin/java" JAR="$JAVA_HOME/bin/jar" for tool in "$JAVAC" "$JAVA" "$JAR"; do if [ ! -x "$tool" ]; then echo "Missing tool: $tool" >&2; exit 1 fi done # --------------------------------------------------------------------------- # 2. Pick a WebKit pkg-config name # --------------------------------------------------------------------------- if pkg-config --exists webkit2gtk-4.1; then WEBKIT_PKG=webkit2gtk-4.1 elif pkg-config --exists webkit2gtk-4.0; then WEBKIT_PKG=webkit2gtk-4.0 else echo "Neither webkit2gtk-4.1 nor webkit2gtk-4.0 was found via pkg-config." >&2 echo "Install one of the following with your package manager:" >&2 echo " Debian/Ubuntu 24.04+: sudo apt install libgtk-3-dev libwebkit2gtk-4.1-dev libx11-dev" >&2 echo " Debian/Ubuntu older: sudo apt install libgtk-3-dev libwebkit2gtk-4.0-dev libx11-dev" >&2 echo " Fedora: sudo dnf install gtk3-devel webkit2gtk4.1-devel libX11-devel" >&2 exit 1 fi if ! pkg-config --exists gtk+-3.0; then echo "gtk+-3.0 (libgtk-3-dev) is required." >&2 exit 1 fi echo "Using WebKit package: $WEBKIT_PKG" # JDK 8's jawt_md.h on Linux #include's <X11/Intrinsic.h>, which is in # libxt-dev (Debian/Ubuntu) -- separate from libx11-dev. Probe with the # preprocessor so we surface a clear message before cl/g++ buries the # error several screens of WebKit deprecation noise deep. if ! printf '#include <X11/Intrinsic.h>\nint main(){return 0;}\n' | \ g++ -E -x c++ - >/dev/null 2>&1; then echo "" >&2 echo "ERROR: <X11/Intrinsic.h> not found." >&2 echo "" >&2 echo "JDK 8 on Linux pulls X11 Intrinsics in via jawt_md.h. Install:" >&2 echo " Debian/Ubuntu: sudo apt install libxt-dev" >&2 echo " Fedora: sudo dnf install libXt-devel" >&2 echo " Arch: sudo pacman -S libxt" >&2 echo "" >&2 echo "JDK 9 and newer do not have this dependency. If you are using" >&2 echo "JDK 9+ and still hit this, your headers are in an unusual spot." >&2 echo "" >&2 exit 1 fi echo "Found X11 Intrinsics." # --------------------------------------------------------------------------- # 3. Build libwebview.so for the current arch. # The directory name has to match NativeLibraryUtil.Architecture lowercased # (linux_64 on x86_64, linux_arm64 on aarch64); the JVM os.arch decides # which folder the runtime extractor looks in. # --------------------------------------------------------------------------- case "$(uname -m)" in x86_64|amd64) NATIVE_DIR=linux_64 ;; aarch64|arm64) NATIVE_DIR=linux_arm64 ;; armv7l|armv7) NATIVE_DIR=linux_arm ;; i?86) NATIVE_DIR=linux_32 ;; *) NATIVE_DIR=linux_64 ;; esac echo "Native dir: $NATIVE_DIR (arch: $(uname -m))" mkdir -p "$REPO_DIR/src/$NATIVE_DIR" SO="$REPO_DIR/src/$NATIVE_DIR/libwebview.so" NEED_SO=0 if [ ! -f "$SO" ]; then NEED_SO=1 else for src in src_c/webview.c src_c/webview.h src_c/webview_embed.cpp src_c/webkit_loader.cpp src_c/webkit_loader.h src_c/webkit_shim.h; do if [ "$src" -nt "$SO" ]; then NEED_SO=1; break; fi done fi if [ "$NEED_SO" = "1" ]; then echo "Building libwebview.so ..." # libjawt is intentionally NOT linked at build time -- the Linux dynamic # linker's default behaviour for shared objects is to permit undefined # symbols, and webview_embed.cpp's resolve_jawt_get_awt() looks libjawt # up via dlopen at first call. WebViewNative also does an explicit # System.loadLibrary("jawt") before loading this lib, so the symbol is # already in-process either way. g++ -fPIC -std=c++11 -Wall \ -DWEBVIEW_GTK=1 \ -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/linux" \ -I./src_c \ $(pkg-config --cflags gtk+-3.0 "$WEBKIT_PKG") \ src_c/webview.c src_c/webview_embed.cpp src_c/webkit_loader.cpp \ $(pkg-config --libs gtk+-3.0) \ -lX11 -ldl \ -shared -o "$SO" echo "Built $SO" else echo "libwebview.so up to date." fi # --------------------------------------------------------------------------- # 4. Compile WebView Java sources # --------------------------------------------------------------------------- BUILD_DIR="$REPO_DIR/build" WV_CLASSES="$BUILD_DIR/classes-webview" WV_JAR="$REPO_DIR/dist/WebView.jar" mkdir -p "$WV_CLASSES" "$REPO_DIR/dist" echo "Compiling WebView Java sources ..." find src -name '*.java' > "$BUILD_DIR/wv-sources.txt" "$JAVAC" -d "$WV_CLASSES" -classpath "lib/*" @"$BUILD_DIR/wv-sources.txt" # --------------------------------------------------------------------------- # 5. Build WebView.jar -- classes + <arch>/libwebview.so at jar root. # --------------------------------------------------------------------------- echo "Building WebView.jar ..." STAGE="$BUILD_DIR/stage-webview" rm -rf "$STAGE" mkdir -p "$STAGE/$NATIVE_DIR" cp -R "$WV_CLASSES"/. "$STAGE"/ cp "$SO" "$STAGE/$NATIVE_DIR/libwebview.so" ( cd "$STAGE" && "$JAR" cf "$WV_JAR" . ) echo "Built $WV_JAR" # --------------------------------------------------------------------------- # 6. Compile and run the media smoke tests # --------------------------------------------------------------------------- DEMO_DIR="$REPO_DIR/demos/WebViewMediaSmokeTest" DEMO_CLASSES="$BUILD_DIR/classes-media-smoke" mkdir -p "$DEMO_CLASSES" echo "Compiling smoke tests ..." "$JAVAC" -d "$DEMO_CLASSES" -classpath "$WV_JAR" \ "$DEMO_DIR/src/ca/weblite/webview/demos/WebViewMediaSmokeTest.java" \ "$DEMO_DIR/src/ca/weblite/webview/demos/WebViewMediaPermissionSmokeTest.java" # Force the X11 GDK backend (the native pump does too) and disable the # DMA-BUF renderer, which fails silently in virtualized environments. export GDK_BACKEND=x11 export WEBKIT_DISABLE_DMABUF_RENDERER=1 echo "Running media playback smoke test (Canvas 33) ..." set +e "$JAVA" -cp "$DEMO_CLASSES:$WV_JAR" ca.weblite.webview.demos.WebViewMediaSmokeTest PLAYBACK=$? echo "Running media permission smoke test (Canvas 35) ..." # Canvas 35 D7c: a test-only switch that turns on WebKitGTK's mock camera, # microphone and screen devices. WEBVIEW_MOCK_CAPTURE_DEVICES=1 \ "$JAVA" -cp "$DEMO_CLASSES:$WV_JAR" ca.weblite.webview.demos.WebViewMediaPermissionSmokeTest PERMISSION=$? set -e echo "playback smoke test: exit $PLAYBACK; permission smoke test: exit $PERMISSION" if [ "$PLAYBACK" -ne 0 ] || [ "$PERMISSION" -ne 0 ]; then exit 1 fi exit 0 |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |