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-mac-console-demo.sh at master · webliteca/swingwebview Expand file tree/ Copy pathrun-mac-console-demo.shMore file actions executable file ·130 lines (122 loc) · 5.01 KB / Copy pathrun-mac-console-demo.shFile metadata and controlsexecutable file ·130 lines (122 loc) · 5.01 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 #!/bin/bash # One-shot script: build the macOS native lib, build WebView.jar, build and run # the console + DevTools Swing demo. No Ant required. # # Usage: ./run-mac-console-demo.sh # Override: JAVA_HOME=/path/to/jdk ./run-mac-console-demo.sh # set -e REPO_DIR="$(cd "$(dirname "$0")" && pwd)" cd "$REPO_DIR" # --------------------------------------------------------------------------- # 1. Resolve JAVA_HOME # --------------------------------------------------------------------------- if [ -z "$JAVA_HOME" ]; then if [ -x /usr/libexec/java_home ]; then JAVA_HOME="$(/usr/libexec/java_home)" 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.:" >&2 echo " brew install --cask temurin" >&2 echo " export JAVA_HOME=\"\$(/usr/libexec/java_home)\"" >&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. Build libwebview.dylib if missing or source is newer. # The directory name has to match NativeLibraryUtil.Architecture lowercased # (osx_64 for Intel, osx_arm64 for Apple Silicon). The JVM os.arch value # determines which folder the runtime extractor looks in. # --------------------------------------------------------------------------- case "$(uname -m)" in arm64|aarch64) NATIVE_DIR=osx_arm64 ;; x86_64) NATIVE_DIR=osx_64 ;; *) NATIVE_DIR=osx_64 ;; esac echo "Native dir: $NATIVE_DIR" mkdir -p "$REPO_DIR/src/$NATIVE_DIR" DYLIB="$REPO_DIR/src/$NATIVE_DIR/libwebview.dylib" NEED_DYLIB=0 if [ ! -f "$DYLIB" ]; then NEED_DYLIB=1 else for src in src_c/webview.c src_c/webview.h src_c/webview_embed.cpp; do if [ "$src" -nt "$DYLIB" ]; then NEED_DYLIB=1; break; fi done fi if [ "$NEED_DYLIB" = "1" ]; then echo "Building libwebview.dylib (arch: $(uname -m)) ..." # Note: src_c/webview.c (the upstream zserge WebView engine for the legacy # `WebView` Java class) is intentionally NOT compiled here. Its Cocoa # branch in webview.h relies on the implicit variadic prototype of # objc_msgSend which has been removed from the macOS SDK (Xcode 15+) and # is broken on ARM64 for struct-by-value arguments anyway. Fixing it is # a separate effort. For this demo we only need the # embedded WebView entry points which live in webview_embed.cpp. # # libjawt lives in different places across JDK distributions # (Corretto 8: $JAVA_HOME/jre/lib, JDK 9+: $JAVA_HOME/lib, Temurin: same, # GraalVM: different again). Rather than probe every layout, defer # JAWT symbol resolution to runtime via -undefined dynamic_lookup: by # the time this dylib is loaded the JVM has already loaded libjawt for # Swing/AWT, so JAWT_GetAWT resolves naturally then. c++ \ -I"$JAVA_HOME/include" -I"$JAVA_HOME/include/darwin" \ -dynamiclib \ src_c/webview_embed.cpp \ -o "$DYLIB" \ -DWEBVIEW_COCOA=1 \ -std=c++11 \ -framework WebKit -framework Cocoa -framework QuartzCore \ -Wl,-undefined,dynamic_lookup echo "Built $DYLIB" else echo "libwebview.dylib up to date." fi # --------------------------------------------------------------------------- # 3. Compile WebView Java sources to build/classes-webview # --------------------------------------------------------------------------- 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" # --------------------------------------------------------------------------- # 4. Build WebView.jar -- bundle classes + osx_64/libwebview.dylib at the 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 "$DYLIB" "$STAGE/$NATIVE_DIR/libwebview.dylib" ( cd "$STAGE" && "$JAR" cf "$WV_JAR" . ) echo "Built $WV_JAR" # --------------------------------------------------------------------------- # 5. Compile and run the console demo # --------------------------------------------------------------------------- DEMO_DIR="$REPO_DIR/demos/WebViewConsoleDemo" DEMO_CLASSES="$BUILD_DIR/classes-demo" mkdir -p "$DEMO_CLASSES" echo "Compiling demo ..." "$JAVAC" -d "$DEMO_CLASSES" \ -classpath "$WV_JAR" \ "$DEMO_DIR/src/ca/weblite/webview/demos/WebViewConsoleDemo.java" echo "Launching demo ..." exec "$JAVA" \ -cp "$DEMO_CLASSES:$WV_JAR" \ ca.weblite.webview.demos.WebViewConsoleDemo |
| 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. |