From 2dc5552aa31cb4a3c417c29f1fa0dfc26a0b1998 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Sun, 10 Nov 2024 21:08:03 +0100 Subject: [PATCH] Update to Chrome 130. CEF 130.1.16+g5a7e5ed+chromium-130.0.6723.117. 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. --- .gitignore | 1 + CMakeLists.txt | 5 +++-- README.md | 2 +- app.cpp | 5 +++++ buildandrun.sh | 4 +++- cleanbuild.sh | 2 +- client.cpp | 1 + main.mm | 22 ++++++++++++++++++---- 8 files changed, 33 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index f82528e..19a5e22 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build/ downloads/ php/ .DS_STORE +.vscode/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 3675d8c..60e5199 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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}) diff --git a/README.md b/README.md index 3d48492..53de5f8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# PHP Desktop Chrome v127 for Mac +# PHP Desktop Chrome 130 for Mac ## Build instructions diff --git a/app.cpp b/app.cpp index f67ebe4..7d56804 100644 --- a/app.cpp +++ b/app.cpp @@ -2,6 +2,8 @@ // All rights reserved. Licensed under BSD 3-clause license. // Project website: https://github.com/cztomczak/phpdesktop +#include + #include "app.h" #include "client.h" #include "mongoose_server.h" @@ -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) { diff --git a/buildandrun.sh b/buildandrun.sh index dd785e0..773b37f 100755 --- a/buildandrun.sh +++ b/buildandrun.sh @@ -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" diff --git a/cleanbuild.sh b/cleanbuild.sh index 532a043..11fea06 100755 --- a/cleanbuild.sh +++ b/cleanbuild.sh @@ -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 diff --git a/client.cpp b/client.cpp index 974ebcd..7d96fc8 100644 --- a/client.cpp +++ b/client.cpp @@ -176,6 +176,7 @@ void Client::OnBeforeClose(CefRefPtr browser) if (browser_list_.empty()) { // All browser windows have closed. Quit the application message loop. + LOG(INFO) << "Quit message loop"; CefQuitMessageLoop(); } } diff --git a/main.mm b/main.mm index 96812e5..7f44567 100644 --- a/main.mm +++ b/main.mm @@ -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" @@ -76,6 +77,7 @@ - (NSApplicationTerminateReply)applicationShouldTerminate: (NSApplication*)sender { return NSTerminateNow; } + // applicationShouldHandleReopen TODO? @end int main(int argc, char **argv) { @@ -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) { @@ -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"); @@ -238,19 +245,20 @@ int remote_debugging_port( // App implements application-level callbacks for the browser process. CefRefPtr 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]; @@ -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;