--- a/src/Pure/Admin/build_jcef.scala Fri Feb 18 21:40:01 2022 +0000
+++ b/src/Pure/Admin/build_jcef.scala Fri Feb 18 23:12:13 2022 +0100
@@ -4,7 +4,7 @@
Build Isabelle component for Java Chromium Embedded Framework (JCEF).
See also:
- - https://github.com/jcefbuild/jcefbuild
+ - https://github.com/jcefmaven/jcefbuild
- https://github.com/chromiumembedded/java-cef
*/
@@ -15,23 +15,34 @@
{
/* platform information */
- sealed case class JCEF_Platform(platform_name: String, archive: String)
- {
- def archive_path: Path = Path.explode(archive)
- def dir(component_dir: Path): Path = component_dir + Path.basic(platform_name)
- }
+ sealed case class JCEF_Platform(
+ platform_name: String, archive: String, lib: String, library: String)
+
+ private val linux_library =
+ """ISABELLE_JCEF_LIBRARY="$ISABELLE_JCEF_LIB/libcef.so"
+ export LD_LIBRARY_PATH="$ISABELLE_JCEF_LIB:$JAVA_HOME/lib:$LD_LIBRARY_PATH""""
+
+ private val macos_library =
+ """export JAVA_LIBRARY_PATH="$ISABELLE_JCEF_HOME/bin/jcef_app.app/Contents/Java:$ISABELLE_JCEF_LIB:$JAVA_LIBRARY_PATH""""
+
+ private val windows_library =
+ """export PATH="$ISABELLE_JCEF_LIB:$PATH""""
val platforms: List[JCEF_Platform] =
List(
- JCEF_Platform("x86_64-linux", "linux64.zip"),
- JCEF_Platform("x86_64-windows", "win64.zip"),
- JCEF_Platform("x86_64-darwin", "macosx64.zip"))
+ JCEF_Platform("x86_64-linux", "linux-amd64.tar.gz", "bin/lib/linux64", linux_library),
+ JCEF_Platform("arm64-linux", "linux-arm64.tar.gz", "bin/lib/linux64", linux_library),
+ JCEF_Platform("x86_64-darwin", "macosx-amd64.tar.gz",
+ "bin/jcef_app.app/Contents/Frameworks/Chromium Embedded Framework.framework/Libraries", macos_library),
+ JCEF_Platform("arm64-darwin", "macosx-arm64.tar.gz",
+ "bin/jcef_app.app/Contents/Frameworks/Chromium Embedded Framework.framework/Libraries", macos_library),
+ JCEF_Platform("x86_64-windows", "windows-amd64.tar.gz", "bin/lib/win64", windows_library))
/* build JCEF */
- val default_url = "https://github.com/jcefbuild/jcefbuild/releases/download"
- val default_version = "v1.0.10-83.4.0+gfd6631b+chromium-83.0.4103.106"
+ val default_url = "https://github.com/jcefmaven/jcefbuild/releases/download"
+ val default_version = "1.0.18"
def build_jcef(
base_url: String = default_url,
@@ -41,44 +52,43 @@
{
/* component name */
- val Version = """^([^+]+).*$""".r
- val component =
- version match {
- case Version(name) => "jcef-" + name
- case _ => error("Bad component version " + quote(version))
- }
+ val component = "jcef-" + version
val component_dir = Isabelle_System.new_directory(target_dir + Path.basic(component))
progress.echo("Component " + component_dir)
/* download and assemble platforms */
- for (platform <- platforms) {
- Isabelle_System.with_tmp_file("archive", ext = "zip")(archive_file =>
- {
- val url = base_url + "/" + Url.encode(version) + "/" + platform.archive
- Isabelle_System.download_file(url, archive_file, progress = progress)
- Isabelle_System.bash("unzip -x " + File.bash_path(archive_file),
- cwd = component_dir.file).check
+ val platform_settings: List[String] =
+ for (platform <- platforms) yield {
+ Isabelle_System.with_tmp_file("archive", ext = "tar.gz")(archive_file =>
+ {
+ val url = base_url + "/" + version + "/" + platform.archive
+ Isabelle_System.download_file(url, archive_file, progress = progress)
+
+ val platform_dir = component_dir + Path.explode(platform.platform_name)
+ Isabelle_System.make_directory(platform_dir)
+ Isabelle_System.gnutar("-xzf " + File.bash_path(archive_file), dir = platform_dir).check
- val unzip_dir = component_dir + Path.explode("java-cef-build-bin")
- for {
- file <- File.find_files(unzip_dir.file).iterator
- name = file.getName if name.containsSlice("LICENSE")
- target_file = component_dir + Path.explode(name) if !target_file.is_file
- } Isabelle_System.move_file(File.path(file), target_file)
+ for {
+ file <- File.find_files(platform_dir.file).iterator
+ name = file.getName
+ if name.endsWith(".dll") || name.endsWith(".exe")
+ } File.set_executable(File.path(file), true)
- val platform_dir = component_dir + Path.explode(platform.platform_name)
- Isabelle_System.move_file(unzip_dir + Path.explode("bin"), platform_dir)
- for {
- file <- File.find_files(platform_dir.file).iterator
- name = file.getName
- if name.endsWith(".dll") || name.endsWith(".exe")
- } File.set_executable(File.path(file), true)
+ val classpath =
+ File.find_files(platform_dir.file, pred = (file => file.getName.endsWith(".jar")))
+ .flatMap(file => File.relative_path(platform_dir, File.path(file)))
+ .map(jar => " " + quote("$ISABELLE_JCEF_HOME/" + jar.implode))
+ .mkString(" \\\n")
- Isabelle_System.rm_tree(unzip_dir)
- })
- }
+ " " + platform.platform_name + ")\n" +
+ " " + "classpath \\\n" + classpath + "\n" +
+ " " + "ISABELLE_JCEF_LIB=\"$ISABELLE_JCEF_HOME/" + platform.lib + "\"\n" +
+ " " + platform.library + "\n" +
+ " " + ";;"
+ })
+ }
/* settings */
@@ -87,27 +97,13 @@
File.write(etc_dir + Path.basic("settings"),
"""# -*- shell-script -*- :mode=shellscript:
-if [ -d "$COMPONENT/${ISABELLE_WINDOWS_PLATFORM64:-$ISABELLE_PLATFORM64}" ]
+ISABELLE_JCEF_PLATFORM="${ISABELLE_WINDOWS_PLATFORM64:-${ISABELLE_APPLE_PLATFORM64:-$ISABELLE_PLATFORM64}}"
+if [ -d "$COMPONENT/$ISABELLE_JCEF_PLATFORM" ]
then
- ISABELLE_JCEF_HOME="$COMPONENT/${ISABELLE_WINDOWS_PLATFORM64:-$ISABELLE_PLATFORM64}"
+ ISABELLE_JCEF_HOME="$COMPONENT/$ISABELLE_JCEF_PLATFORM"
ISABELLE_JCEF_LIBRARY=""
- case "$ISABELLE_PLATFORM_FAMILY" in
- linux)
- classpath "$ISABELLE_JCEF_HOME/"*.jar
- ISABELLE_JCEF_LIB="$ISABELLE_JCEF_HOME/lib/linux64"
- ISABELLE_JCEF_LIBRARY="$ISABELLE_JCEF_LIB/libcef.so"
- export LD_LIBRARY_PATH="$ISABELLE_JCEF_LIB:$LD_LIBRARY_PATH"
- ;;
- windows)
- classpath "$ISABELLE_JCEF_HOME/"*.jar
- ISABELLE_JCEF_LIB="$ISABELLE_JCEF_HOME/lib/win64"
- export PATH="$ISABELLE_JCEF_LIB:$PATH"
- ;;
- macos)
- classpath "$ISABELLE_JCEF_HOME/jcef_app.app/Contents/Java/"*.jar
- ISABELLE_JCEF_LIB="$ISABELLE_JCEF_HOME/jcef_app.app/Contents/Frameworks/Chromium Embedded Framework.framework/Libraries"
- export JAVA_LIBRARY_PATH="$ISABELLE_JCEF_HOME/jcef_app.app/Contents/Java:$ISABELLE_JCEF_LIB:$JAVA_LIBRARY_PATH"
- ;;
+ case "$ISABELLE_JCEF_PLATFORM" in
+""" + cat_lines(platform_settings) + """
esac
fi
""")
@@ -118,11 +114,11 @@
File.write(component_dir + Path.basic("README"),
"""This distribution of Java Chromium Embedded Framework (JCEF)
has been assembled from the binary builds from
-""" + base_url + """
+https://github.com/jcefmaven/jcefbuild/releases/tag/""" +version + """
Examples invocations:
-* command-line
+* Command-line
isabelle env bash -c 'isabelle java -Djava.library.path="$(platform_path "$ISABELLE_JCEF_LIB")" tests.detailed.MainFrame'
@@ -133,6 +129,11 @@
org.cef.CefApp.startup(Array())
GUI_Thread.later { val frame = new tests.detailed.MainFrame(false, false, false, Array()); frame.setSize(1200,900); frame.setVisible(true) }
+* Demo websites
+
+ https://mozilla.github.io/pdf.js/web/viewer.html
+ https://www.w3schools.com/w3css/w3css_demo.asp
+
Makarius
""" + Date.Format.date(Date.now()) + "\n")