GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — swingwebview/run-mac-content-rules-demo.sh at master · webliteca/swingwebview

Expand file tree

/

run-mac-content-rules-demo.sh

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
executable file
·
120 lines (112 loc) · 4.4 KB
/

run-mac-content-rules-demo.sh

Copy path

File metadata and controls

executable file
·
120 lines (112 loc) · 4.4 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#!/bin/bash
# One-shot script: build the macOS native lib, build WebView.jar, compile
# and run the content rules demo (WebViewContentRulesDemo, Canvas 37).
#
# Serves a page from http://localhost:8124/ that loads ads, a third-party
# script, a fetch beacon and .ad-slot elements, in the heavyweight component
# (the supported macOS mode). A content rule list (WKContentRuleList) blocks
# and hides them before any request is sent. See demos/WebViewContentRulesDemo/README.md for the AC-mapped checklist.
#
# Usage: ./run-mac-content-rules-demo.sh
# CRDEMO_AUTO=1 ./run-mac-content-rules-demo.sh # run the checks, exit (0 = passed)
# Override: JAVA_HOME=/path/to/jdk ./run-mac-content-rules-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
# ---------------------------------------------------------------------------
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)) ..."
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
# ---------------------------------------------------------------------------
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 -- classes + osx_*/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 content rules demo
# ---------------------------------------------------------------------------
DEMO_DIR="$REPO_DIR/demos/WebViewContentRulesDemo"
DEMO_CLASSES="$BUILD_DIR/classes-content-rules-demo"
mkdir -p "$DEMO_CLASSES"
echo "Compiling demo ..."
"$JAVAC" -d "$DEMO_CLASSES" \
-classpath "$WV_JAR" \
"$DEMO_DIR/src/ca/weblite/webview/demos/WebViewContentRulesDemo.java"
echo "Launching WebViewContentRulesDemo ..."
exec "$JAVA" \
"-Dcrdemo.auto=${CRDEMO_AUTO:+true}" \
-cp "$DEMO_CLASSES:$WV_JAR" \
ca.weblite.webview.demos.WebViewContentRulesDemo
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.