提交 35f0a40e 编写于 作者: R Richard Wilkes

Make the setup script more general

上级 027eef0e
......@@ -4,8 +4,8 @@ import (
// #include <stdlib.h>
// #include "include/internal/cef_types.h"
// #cgo CFLAGS: -I ${SRCDIR}/cef
// #cgo darwin LDFLAGS: -framework Cocoa -F ${SRCDIR}/cef/Release -framework "Chromium Embedded Framework"
// #cgo windows LDFLAGS: -L${SRCDIR}/cef/Release -lcef -Wl,--subsystem,windows
// #cgo darwin LDFLAGS: -framework Cocoa -F ${SRCDIR}/cef/lib -framework "Chromium Embedded Framework"
// #cgo windows LDFLAGS: -L${SRCDIR}/cef/lib -lcef -Wl,--subsystem,windows
"C"
)
......
......@@ -5,25 +5,28 @@ Go bindings for the
Currently works for macOS and Windows. Linux support will be coming at some
point as well.
## Initial setup
Run `setup.sh` in this directory to pull the version of CEF these bindings
were created for.
## Extra environment setup required for Windows
## Initial setup required for Windows
- Download and run the installer from http://www.msys2.org/
- In the mingw64 msys2 console, run the following:
- `pacman -Syu`
- `pacman -Su`
- `pacman -S mingw64/mingw-w64-x86_64-gcc mingw64/mingw-w64-x86_64-go msys/git`
## Initial setup
In the root of the repo, run (if using Windows, do this from a mingw64 msys2
console):
```
./cef.sh --headers cef --libs cef/lib
```
## Example application
https://github.com/richardwilkes/webapp and
https://github.com/richardwilkes/webapp-example use these bindings to create
an example desktop application.
## Updating the CEF version to be used
The CEF version can be updated in the `setup.sh` script file by changing the
`CEF_VERSION` variable. If a different version is pulled, the source files
The CEF version can be updated in the `cef.sh` script file by changing the
`CEF_VERSION` variable. If a different CEF version is pulled, the source files
should be generated again by running `go generate ./...` on a macOS machine.
Code generation might be possible on other platforms, but has not been tested
there.
#!/usr/bin/env bash
set -eo pipefail
CEF_VERSION=3.3538.1852.gcb937fc
SELF=$0
function help() {
echo "$SELF [options]"
echo ""
echo " --clear Clears the cache"
echo " --headers <path> Install the CEF headers into <path>, replacing existing contents"
echo " --libs <path> Install the CEF libraries into <path>, replacing existing contents"
echo " -c Same as --clear"
echo " -H <path> Same as --headers"
echo " -l <path> Same as --libs"
}
# Process the command line
while (( "$#" )); do
case "$1" in
-c|--clear)
CLEAR_CACHE=1
shift
;;
-H|--headers)
if [ "x$2" == "x" ]; then
echo "$1 requires a path"
exit 1
fi
INSTALL_HEADERS=$2
shift 2
;;
-l|--libs)
if [ "x$2" == "x" ]; then
echo "$1 requires a path"
exit 1
fi
INSTALL_LIBS=$2
shift 2
;;
*)
help
exit 1
;;
esac
done
if [ "x$CLEAR_CACHE" == "x" ] && [ "x$INSTALL_HEADERS" == "x" ] && [ "x$INSTALL_LIBS" == "x" ]; then
help
exit 1
fi
# Setup PLATFORM and CACHEDIR
case $(uname -s) in
Darwin*)
PLATFORM=macosx64
CACHEDIR="$HOME/Library/Caches"
;;
Linux*)
PLATFORM=linux64
if [ "$XDG_CACHE_HOME" != "" ]; then
CACHEDIR="$XDG_CACHE_HOME"
else
CACHEDIR="$HOME/.cache"
fi
;;
MINGW64*)
PLATFORM=windows64
CACHEDIR="$LocalAppData"
;;
*)
echo "Unsupported OS: $(uname -s)"
exit 1
;;
esac
CACHEDIR="$CACHEDIR/gocef"
if [ "x$CLEAR_CACHE" == "x1" ]; then
/bin/rm -rf "$CACHEDIR"
fi
CEF_BASE=cef_binary_${CEF_VERSION}_${PLATFORM}_minimal
CEF_ARCHIVE=$CEF_BASE.tar.bz2
# Function to download the CEF archive if it doesn't already exist
function download_cef_archive() {
if [ ! -f "$CACHEDIR/$CEF_ARCHIVE" ]; then
mkdir -p "$CACHEDIR"
curl -L -o "$CACHEDIR/$CEF_ARCHIVE" http://opensource.spotify.com/cefbuilds/$CEF_ARCHIVE
fi
}
# Install the CEF headers
if [ "x$INSTALL_HEADERS" != "x" ]; then
EXISTING=""
if [ -e "$INSTALL_HEADERS/include/cef_version.h" ]; then
EXISTING=`grep "#define CEF_VERSION " "$INSTALL_HEADERS/include/cef_version.h" | cut -f 2 -d '"'`
fi
if [ $CEF_VERSION != "$EXISTING" ]; then
download_cef_archive
/bin/rm -rf "$INSTALL_HEADERS"
mkdir -p "$INSTALL_HEADERS"
bunzip2 --stdout "$CACHEDIR/$CEF_ARCHIVE" | tar xf - -C "$INSTALL_HEADERS" \
--strip-components 1 \
--include $CEF_BASE/include/cef_application_mac.h \
--include $CEF_BASE/include/cef_version.h \
--include $CEF_BASE/include/base \
--include $CEF_BASE/include/internal \
--include $CEF_BASE/include/capi \
--exclude $CEF_BASE/include/capi/cef_\*_util_capi.h \
--exclude $CEF_BASE/include/capi/cef_parser_capi.h \
--exclude $CEF_BASE/include/capi/cef_thread_capi.h \
--exclude $CEF_BASE/include/capi/cef_trace_capi.h \
--exclude $CEF_BASE/include/capi/cef_xml_reader_capi.h \
--exclude $CEF_BASE/include/capi/cef_zip_reader_capi.h \
--exclude $CEF_BASE/include/capi/test \
--exclude $CEF_BASE/include/capi/views
fi
fi
# Install the CEF libraries
if [ "x$INSTALL_LIBS" != "x" ]; then
EXISTING=""
if [ -e "$INSTALL_LIBS/version.txt" ]; then
EXISTING=`cat "$INSTALL_LIBS/version.txt"`
fi
if [ $CEF_VERSION != "$EXISTING" ]; then
download_cef_archive
/bin/rm -rf "$INSTALL_LIBS"
mkdir -p "$INSTALL_LIBS"
bunzip2 --stdout "$CACHEDIR/$CEF_ARCHIVE" | tar xf - -C "$INSTALL_LIBS" \
--strip-components 2 \
--include $CEF_BASE/Release \
--exclude $CEF_BASE/Release/cef_sandbox.a
echo "$CEF_VERSION" > "$INSTALL_LIBS/version.txt"
fi
fi
#!/usr/bin/env bash
set -eo pipefail
CEF_VERSION=3.3538.1852.gcb937fc
# Setup PLATFORM
case $(uname -s) in
Darwin*) PLATFORM=macosx64 ;;
#Linux*) PLATFORM=linux64 ;;
MINGW64*) PLATFORM=windows64 ;;
*) echo "Unsupported OS: $(uname -s)"; false ;;
esac
if [ -e cef/include/cef_version.h ]; then
EXISTING=`grep "#define CEF_VERSION " cef/include/cef_version.h | cut -f 2 -d '"'`
fi
if [ $CEF_VERSION != "$EXISTING" ]; then
/bin/rm -rf cef cef_binary_${CEF_VERSION}_${PLATFORM}_minimal
curl -L http://opensource.spotify.com/cefbuilds/cef_binary_${CEF_VERSION}_${PLATFORM}_minimal.tar.bz2 | bunzip2 | tar xf -
mv cef_binary_${CEF_VERSION}_${PLATFORM}_minimal cef
# Prune out the things we don't need
/bin/rm -rf cef/cmake cef/Debug \
cef/include/capi/test \
cef/include/capi/views \
cef/include/test \
cef/include/views \
cef/include/wrapper \
cef/libcef_dll
/bin/rm -f cef/CMakeLists.txt \
cef/Release/cef_sandbox.a \
cef/include/capi/cef_*_util_capi.h \
cef/include/capi/cef_parser_capi.h \
cef/include/capi/cef_thread_capi.h \
cef/include/capi/cef_trace_capi.h \
cef/include/capi/cef_xml_reader_capi.h \
cef/include/capi/cef_zip_reader_capi.h
mv cef/include/cef_version.h cef/
if [ $PLATFORM == "macosx64" ]; then
mv cef/include/cef_application_mac.h cef/
fi
/bin/rm -f cef/include/*.h
mv cef/*.h cef/include/
fi
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册