Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update supported CEF version, and a bunch of other changes #22

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
309b78a
Add TODO
Mar 31, 2024
03bef76
add third_party
Mar 31, 2024
4088c55
Fix the linux version
Mar 31, 2024
6c933a5
Avoid casts, use designated initializers, wrap cef_string_set
Mar 31, 2024
395a5e5
eliminate global variable
Mar 31, 2024
fba604f
Handle errors
Mar 31, 2024
d7d415d
Implement real reference counting
Mar 31, 2024
f8db35b
Fix a warning in GCC
Mar 31, 2024
5e8d25c
update README
Mar 31, 2024
97bd0e9
update link for downloading builds
Mar 31, 2024
4a37b79
add windows todos
Mar 31, 2024
e5ed305
make DEBUG_CALLBACK more concise, don't override wcslen
Mar 31, 2024
2ed71db
platformize atomic increment/decrement
Mar 31, 2024
7ba4a10
comments
Mar 31, 2024
e208883
more comments
Mar 31, 2024
ade07e7
Add deps.bat
Apr 1, 2024
9ae65e8
Swap newlines in deps.bat
Apr 1, 2024
9a167af
Fix the windows MinGW build
Apr 1, 2024
4c79044
Update main_win.c to match main_linux.c
Apr 1, 2024
74b041b
Add an MSVC build script
Apr 1, 2024
62e47c8
Update info about the windows build in the README
Apr 1, 2024
bb715f8
Fix whitespace
Apr 1, 2024
64b66fd
comment update
Apr 1, 2024
423f0ed
remove TODO
Apr 1, 2024
c28b750
Update the linux build to support CEF 129
Sep 29, 2024
b0a22b1
Update main_win to work with the latest CEF version
Sep 29, 2024
6d9b9b9
Temporary fix for GPU process crash on windows
Sep 29, 2024
80bb67f
Only pass --use-angle to the browser process
Sep 30, 2024
819fbe4
update supported CEF version in the README
Sep 30, 2024
603d6e4
Add a manifest to the GCC build
Oct 1, 2024
c8b5d5b
Add the manifest to the msvc build
Oct 1, 2024
8fb0da5
update .gitignore
Oct 1, 2024
2d3318e
Update clean.bat
Oct 1, 2024
255ec9f
Fix manifest not actually getting added
Oct 1, 2024
9e39c98
Remove workaround for GPU crash since that's now fixed
Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* -text
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
Release/*
.idea/
.idea/
*.swp
/cef_extracted
/Release
*.obj
*.pdb
*.res
*.coff
41 changes: 27 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
info:
@echo "Use 'make gtk2' for GTK+ 2 example, or 'make gtk3' for GTK+ 3 example."
gtk2:
@echo "----------------------------------------------------------------------"
@rm -f Release/cefcapi-gtk2
@clear
gcc -std=c99 -Wall -Werror -o Release/cefcapi-gtk2 -I. -I.. -Wl,-rpath,. -L./Release examples/main_linux.c -lX11 -lcef `pkg-config --libs --cflags gtk+-2.0`
cd Release/ && ./cefcapi-gtk2 && cd ../
gtk3:
@echo "----------------------------------------------------------------------"
@rm -f Release/cefcapi-gtk3
@clear
gcc -std=c99 -Wall -Werror -o Release/cefcapi-gtk3 -I. -I.. -Wl,-rpath,. -L./Release examples/main_linux.c -lX11 -lcef `pkg-config --libs --cflags gtk+-3.0`
cd Release/ && ./cefcapi-gtk3 && cd ../
CFILES = examples/main_linux.c
HFILES = capi/*.h examples/gtk.h

CC = gcc
WARNINGS = -Wall -Wextra -Wpedantic -Wconversion -Wno-unused-parameter
SYSTEM_DEPS = `pkg-config --cflags gtk+-3.0 | sed "s>-I/>-isystem/>g"`
DBG_FLAGS = -g
CFLAGS = $(DBG_FLAGS) $(WARNINGS) $(SYSTEM_DEPS) -isystem ./cef_extracted -I.
LFLAGS = -L$(OUT) -Wl,-rpath=\$$ORIGIN `pkg-config --libs gtk+-3.0` -lX11 -lcef
OUT = ./Release
EXE = $(OUT)/cef_example
SELF = Makefile

all: $(EXE) $(SELF)

run: all
$(EXE)

clean:
rm -rf ./cef_extracted ./Release

$(SELF): extract_deps.mk
touch $(SELF)

$(EXE): $(OUT)/libcef.so $(HFILES) $(CFILES) $(SELF)
$(CC) $(CFLAGS) -o $(EXE) $(CFILES) $(LFLAGS)

include extract_deps.mk
39 changes: 9 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,32 @@ Table of contents:
* [Support development](#support-development)
* [Updating CEF version](#updating-cef-version)


## Examples

- Windows: see [main_win.c](examples/main_win.c)
- Linux: see [main_linux.c](examples/main_linux.c)
- Mac: not available yet ([Issue #15](../../issues/15))


## Compatibility

Tested configurations:
- Windows:
- Binary: `cef_binary_3.3202.1692.g18a939d_windows32.tar.bz2`
- Compilers: mingw-gcc 5.3.0 and TDM-gcc 5.1.0 on Windows 7 64-bit
- Binary: `cef_binary_129.0.6+ga918aa7+chromium-129.0.6668.29_windows64_beta.tar.bz2`
- Compilers: mingw-w64 gcc 11.2.0 and Visual Studio 2022 on Windows 10 64-bit
- Linux:
- Binary: `cef_binary_3.3202.1692.g18a939d_linux64.tar.bz2`
- Compiler: Linux: gcc 4.8.2 on Ubuntu 14.04 64-bit
- Compiler: gcc 6.3.0 on Debian 9.2 (stretch) 64-bit

- Binary: `cef_binary_129.0.6+ga918aa7+chromium-129.0.6668.29_linux64_beta.tar.bz2`
- Compiler: Linux: gcc 9.4.0 on Ubuntu 20.04 64-bit

## Getting started

1. Download "Standard Distribution" binaries from Spotify
Automated Builds for the supported CEF version mentioned
in the Compatibility section above:
http://opensource.spotify.com/cefbuilds/index.html
2. Create cefcapi/Release/ directory
3. Copy cef_binary*/Release/* to cefcapi/Release/
4. Copy cef_binary*/Resources/* to cefcapi/Release/
5. On Linux run "make gtk2" (GTK+ 2 example) or "make gtk3" (GTK+ 3 example) in the root directory.
Note that you may need to build CEF with "use_gtk3=true" to link it with GTK+ 3.
6. On Windows run the "build.bat" script in the root directory

https://cef-builds.spotifycdn.com/index.html
2. Put the cef*.tar.bz file into third_party
3. On Linux run "make run" (example uses GTK+ 3)
4. On Windows run "build_msvc.bat" or "build_gcc.bat" to build with MSVC or MinGW, respectively
- 7zip will need to be installed, or you will need to extract cef manually

## Support development

Expand All @@ -61,17 +54,3 @@ by making a donation please click the Paypal Donate button:
<img src='https://raw.githubusercontent.com/wiki/cztomczak/cefpython/images/donate.gif' />
</a><br><br>


## Updating CEF version

If you download a CEF version newer than `3.3202.1692` then
apart from copying binaries to cefcapi/Release/ directory
you will also have to update the include/ directory with CEF
header files.

In the include/ directory you can find two files: "cef_version_win.h"
and "cef_version_linux.h" - these header files were copied
from CEF binary distributions for appropriate platforms and
their original file names were "cef_version.h".


11 changes: 0 additions & 11 deletions build.bat

This file was deleted.

20 changes: 20 additions & 0 deletions build_gcc.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@echo off

if not exist .\Release (
call .\deps.bat
)

set CC=x86_64-w64-mingw32-gcc
set WARNINGS=-Wall -Wextra -Wpedantic -Wconversion -Wno-unused-parameter
set DBG_FLAGS=-g
set CFLAGS=%DBG_FLAGS% %WARNINGS% -isystem.\cef_extracted -I.
set LFLAGS=-L.\Release -lcef

set CFILES=.\examples\main_win.c

set RC=x86_64-w64-mingw32-windres
set RCFILE=main.rc

%RC% -o out.coff %RCFILE%

%CC% %CFLAGS% -o .\Release\cef_example.exe %CFILES% out.coff %LFLAGS%
29 changes: 29 additions & 0 deletions build_msvc.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@echo off

if not exist .\Release (
call .\deps.bat
)

if "%VSINSTALLDIR%" equ "" (
for /f "usebackq delims=" %%i in (`"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -prerelease -latest -property installationPath`) do (
call "%%i\VC\Auxiliary\Build\vcvars64.bat"
goto :LOADED
)
)

:LOADED

set CC=cl
set WARNINGS=/W4 /wd4100
set DBG_FLAGS=/Zi
set CFLAGS=%DBG_FLAGS% %WARNINGS% /I.\cef_extracted /I. /nologo
set LFLAGS=/link /LIBPATH:.\Release /SUBSYSTEM:CONSOLE libcef.lib

set CFILES=.\examples\main_win.c

set RC=rc
set RCFILE=main.rc

%RC% /nologo /fo browser.res %RCFILE%

%CC% %CFLAGS% /Fe.\Release\cef_example.exe browser.res %CFILES% %LFLAGS%
99 changes: 41 additions & 58 deletions capi/cef_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,85 +5,68 @@

#include "cef_base.h"
#include "include/capi/cef_app_capi.h"
#include "include/capi/cef_browser_process_handler_capi.h"

// ----------------------------------------------------------------------------
// cef_app_t
// ----------------------------------------------------------------------------

struct my_cef_app {
cef_app_t base;
cef_browser_process_handler_t process_handler;
};

///
// Implement this structure to provide handler implementations. Methods will be
// called by the process and/or thread indicated.
///

///
// Provides an opportunity to view and/or modify command-line arguments before
// processing by CEF and Chromium. The |process_type| value will be NULL for
// the browser process. Do not keep a reference to the cef_command_line_t
// object passed to this function. The CefSettings.command_line_args_disabled
// value can be used to start with an NULL command-line object. Any values
// specified in CefSettings that equate to command-line arguments will be set
// before this function is called. Be cautious when using this function to
// modify command-line arguments for non-browser processes as this may result
// in undefined behavior including crashes.
/// Return the handler for functionality specific to the browser process. This
/// function is called on multiple threads in the browser process.
///
void CEF_CALLBACK on_before_command_line_processing(
struct _cef_app_t* self, const cef_string_t* process_type,
struct _cef_command_line_t* command_line) {
DEBUG_CALLBACK("on_before_command_line_processing\n");
struct _cef_browser_process_handler_t *CEF_CALLBACK get_browser_process_handler(struct _cef_app_t* self_in){
return &container_of(self_in, struct my_cef_app, base)->process_handler;
}

///
// Provides an opportunity to register custom schemes. Do not keep a reference
// to the |registrar| object. This function is called on the main thread for
// each process and the registered schemes should be the same across all
// processes.
/// Implement this function to provide app-specific behavior when an already
/// running app is relaunched with the same CefSettings.root_cache_path value.
/// For example, activate an existing app window or create a new app window.
/// |command_line| will be read-only. Do not keep a reference to
/// |command_line| outside of this function. Return true (1) if the relaunch
/// is handled or false (0) for default relaunch behavior. Default behavior
/// will create a new default styled Chrome window.
///
void CEF_CALLBACK on_register_custom_schemes(
struct _cef_app_t* self,
struct _cef_scheme_registrar_t* registrar) {
DEBUG_CALLBACK("on_register_custom_schemes\n");
}

/// To avoid cache corruption only a single app instance is allowed to run for
/// a given CefSettings.root_cache_path value. On relaunch the app checks a
/// process singleton lock and then forwards the new launch arguments to the
/// already running app process before exiting early. Client apps should
/// therefore check the cef_initialize() return value for early exit before
/// proceeding.
///
// Return the handler for resource bundle events. If
// CefSettings.pack_loading_disabled is true (1) a handler must be returned.
// If no handler is returned resources will be loaded from pack files. This
// function is called by the browser and render processes on multiple threads.
/// This function will be called on the browser process UI thread.
///
struct _cef_resource_bundle_handler_t*
CEF_CALLBACK get_resource_bundle_handler(struct _cef_app_t* self) {
DEBUG_CALLBACK("get_resource_bundle_handler\n");
return NULL;
int CEF_CALLBACK on_already_running_app_relaunch(
struct _cef_browser_process_handler_t* self,
struct _cef_command_line_t* command_line,
const cef_string_t* current_directory
){
printf("TODO: implement on_already_running_app_relaunch\n");
command_line->base.release(&command_line->base);
return 1;
}

///
// Return the handler for functionality specific to the browser process. This
// function is called on multiple threads in the browser process.
///
struct _cef_browser_process_handler_t*
CEF_CALLBACK get_browser_process_handler(struct _cef_app_t* self) {
DEBUG_CALLBACK("get_browser_process_handler\n");
return NULL;
}
void initialize_cef_app(struct my_cef_app* app) {
printf("initialize_cef_app\n");
app->base.base.size = sizeof *app;
initialize_fake_reference_counting(&app->base.base);

///
// Return the handler for functionality specific to the render process. This
// function is called on the render process main thread.
///
struct _cef_render_process_handler_t*
CEF_CALLBACK get_render_process_handler(struct _cef_app_t* self) {
DEBUG_CALLBACK("get_render_process_handler\n");
return NULL;
}
app->process_handler.base.size = sizeof app->process_handler;
initialize_fake_reference_counting(&app->process_handler.base);

void initialize_cef_app(cef_app_t* app) {
printf("initialize_cef_app\n");
app->base.size = sizeof(cef_app_t);
initialize_cef_base_ref_counted((cef_base_ref_counted_t*)app);
// callbacks
app->on_before_command_line_processing = on_before_command_line_processing;
app->on_register_custom_schemes = on_register_custom_schemes;
app->get_resource_bundle_handler = get_resource_bundle_handler;
app->get_browser_process_handler = get_browser_process_handler;
app->get_render_process_handler = get_render_process_handler;

app->base.get_browser_process_handler = &get_browser_process_handler;
app->process_handler.on_already_running_app_relaunch = &on_already_running_app_relaunch;
}
Loading