Skip to content

Commit

Permalink
Update to Chrome 130. CEF 130.1.16+g5a7e5ed+chromium-130.0.6723.117.
Browse files Browse the repository at this point in the history
Change default configuration to Release.
Treat compile warnings as errors.
Log versions at startup.
Improve main.mm logic, copy from cefclient/cefsimple.

To enable logging to terminal add switch in settings.json:
"enable-logging": "stderr". This will remove file logging.
  • Loading branch information
cztomczak committed Nov 10, 2024
1 parent 3366127 commit 2dc5552
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build/
downloads/
php/
.DS_STORE
.vscode/
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Versions
set(PHPDESKTOP_VERSION "127.0")
set(CEF_VERSION "127.3.2+gf1af617+chromium-127.0.6533.100")
set(PHPDESKTOP_VERSION "130.0")
set(CEF_VERSION "130.1.16+g5a7e5ed+chromium-130.0.6723.117")
cmake_minimum_required(VERSION 3.21)

# Project and general options
Expand All @@ -11,6 +11,7 @@ add_definitions(-DPHPDESKTOP_VERSION="${PHPDESKTOP_VERSION}")
set(CMAKE_CXX_FLAGS "-std=c++20 -Wfatal-errors")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DDEBUG_CONFIGURATION")
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PHP Desktop Chrome v127 for Mac
# PHP Desktop Chrome 130 for Mac

## Build instructions

Expand Down
5 changes: 5 additions & 0 deletions app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// All rights reserved. Licensed under BSD 3-clause license.
// Project website: https://github.com/cztomczak/phpdesktop

#include <stdlib.h>

#include "app.h"
#include "client.h"
#include "mongoose_server.h"
Expand Down Expand Up @@ -63,6 +65,9 @@ void App::OnBeforeCommandLineProcessing(const CefString& process_type,
if (process_type.empty())
{
// Browser process type is an empty string
if (getenv("PHPDESKTOP_ENABLE_LOGGING_STDERR")) {
command_line->AppendSwitchWithValue("enable-logging", "stderr");
}
json_value* app_settings = Settings();
json_value switches =(*app_settings)["chrome"]["command_line_switches"];
if (switches.type == json_object) {
Expand Down
4 changes: 3 additions & 1 deletion buildandrun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ retval=$?
if [ $retval -ne 0 ]; then
echo "ninja FAILED with error code $retval"
exit $retval
else
export PHPDESKTOP_ENABLE_LOGGING_STDERR=1
open -W --stdout $(tty) --stderr $(tty) "./Release/PHP Desktop.app"
fi
open -W --stdout $(tty) --stderr $(tty) "./Debug/PHP Desktop.app"
2 changes: 1 addition & 1 deletion cleanbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ if [[ $(uname -m) == "arm64" ]]; then
elif [[ $(uname -m) == "x86_64" ]]; then
PHPDESKTOP_ARCH="x86_64"
fi
cmake -G "Ninja" -DPROJECT_ARCH="$PHPDESKTOP_ARCH" -DCMAKE_BUILD_TYPE=Debug $ROOTDIR
cmake -G "Ninja" -DPROJECT_ARCH="$PHPDESKTOP_ARCH" -DCMAKE_BUILD_TYPE=Release $ROOTDIR
ninja -j 8 phpdesktop
1 change: 1 addition & 0 deletions client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ void Client::OnBeforeClose(CefRefPtr<CefBrowser> browser)

if (browser_list_.empty()) {
// All browser windows have closed. Quit the application message loop.
LOG(INFO) << "Quit message loop";
CefQuitMessageLoop();
}
}
Expand Down
22 changes: 18 additions & 4 deletions main.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "settings.h"

#include "include/cef_application_mac.h"
#include "include/cef_version.h"
#include "include/base/cef_logging.h"
#include "include/wrapper/cef_helpers.h"
#import "include/wrapper/cef_library_loader.h"
Expand Down Expand Up @@ -76,6 +77,7 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:
(NSApplication*)sender {
return NSTerminateNow;
}
// applicationShouldHandleReopen TODO?
@end

int main(int argc, char **argv) {
Expand All @@ -88,6 +90,9 @@ int main(int argc, char **argv) {

@autoreleasepool {

[SharedApplication sharedApplication];
CHECK([NSApp isKindOfClass:[SharedApplication class]]);

// Passing ENV variables to PHP using the --cgi-environment
// command line arg passed to app.
if (argv) {
Expand All @@ -112,6 +117,8 @@ int main(int argc, char **argv) {
// Log what process type is launching
if (!cmdline->HasSwitch("type")) {
// If there is no --type flag then this is main process
LOG(INFO) << "PHP Desktop version: " << PHPDESKTOP_VERSION;
LOG(INFO) << "Chrome version: " << CEF_VERSION;
LOG(INFO) << "Launching Browser process (main process)\n";
} else {
const std::string& process_type = cmdline->GetSwitchValue("type");
Expand Down Expand Up @@ -238,19 +245,20 @@ int remote_debugging_port(
// App implements application-level callbacks for the browser process.
CefRefPtr<App> app(new App);

[SharedApplication sharedApplication];

// Log messages created by LOG() macro will be written to debug.log
// file only after CEF was initialized. Before CEF is initialized
// all logs are only printed to console.
LOG(INFO) << "Initialize CEF";
LOG(INFO) << "Note that logging to terminal doesn't work from this point on, "
<< "unless you add --enable-logging=stderr switch to settings.json";
if (!CefInitialize(main_args, cef_settings, app.get(), nullptr)) {
LOG(ERROR) << "Failed to initialize CEF";
return 1;
return CefGetExitCode();;
}

// Create the application delegate.
NSObject* delegate = [[SharedAppDelegate alloc] init];
SharedAppDelegate* delegate = [[SharedAppDelegate alloc] init];
NSApp.delegate = delegate;
[delegate performSelectorOnMainThread:@selector(createApplication:)
withObject:nil
waitUntilDone:NO];
Expand All @@ -264,6 +272,12 @@ int remote_debugging_port(
LOG(INFO) << "Shutdown CEF";
CefShutdown();

// Release the delegate.
#if !__has_feature(objc_arc)
[delegate release];
#endif // !__has_feature(objc_arc)
delegate = nil;

} // end @autoreleasepool

return 0;
Expand Down

0 comments on commit 2dc5552

Please sign in to comment.