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

GitHub actions linux build #2

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e1e4de3
Set up workflow for windows builds and releases
Jacoby6000 Oct 3, 2024
1357614
disable windows release publishing
Jacoby6000 Oct 3, 2024
ed3f9d7
Separate luajit cache/restore to avoid building it multiple times aft…
Jacoby6000 Oct 3, 2024
0f8d713
fix cef version usage
Jacoby6000 Oct 3, 2024
7820efd
Remove redundant cef step
Jacoby6000 Oct 3, 2024
7572d29
Remove some whitespace, test new CEF setup
Jacoby6000 Oct 3, 2024
df66cd0
library: clarify doc comment
Adamcake Oct 4, 2024
dfd3fca
library: api_close
Adamcake Oct 4, 2024
02a6550
library: doc comment typo
Adamcake Oct 4, 2024
1a66220
osr: block all popup creation
Adamcake Oct 4, 2024
eebc8c7
library, browser: plugin external browser API
Adamcake Oct 5, 2024
43e0576
library: standardise incoming messages
Adamcake Oct 5, 2024
0636240
browser: handle early-close
Adamcake Oct 5, 2024
ee8a021
window_plugin: OnBeforeClose -> NotifyClosed
Adamcake Oct 5, 2024
e673db6
library: correct some ipc doc comments
Adamcake Oct 5, 2024
c3adb84
browser: make Close() overridable
Adamcake Oct 5, 2024
b4767b0
library: add ipc browser closerequest messages
Adamcake Oct 5, 2024
cbe5298
window_plugin: send closerequest messages
Adamcake Oct 5, 2024
c99e9ac
library: browser_oncloserequest
Adamcake Oct 5, 2024
69488f0
Merge pull request #71 from Jacoby6000/github-actions-windows-build
Adamcake Oct 7, 2024
b536dab
Github actions Linux Builds
Jacoby6000 Oct 6, 2024
69da328
Disable release artifacts
Jacoby6000 Oct 6, 2024
ad6bad6
Fix zip structure for linux release zips, re-enable linux release art…
Jacoby6000 Oct 6, 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
222 changes: 222 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
name: Build
on:
push:
branches:
- master # Automatically build on push to master
pull_request:
branches:
- master # Automatically build on pull request to master
release:
types:
- published # Automatically build on release

env:
WINDOWS_CEF_VERSION: '114.0.5735.199'
LINUX_CEF_VERSION: '114.0.5735.134'
LUAJIT_VERSION: '2.1'
ENABLE_WINDOWS_RELEASES: 'false'
ENABLE_LINUX_RELEASES: 'true'

jobs:
build-windows-project:
name: Build Windows
runs-on: windows-2022
steps:
- name: Checkout Project
uses: actions/checkout@v4.2.0
with:
path: Bolt
submodules: recursive

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
with:
vs-version: 17.0

- uses: ilammy/msvc-dev-cmd@v1.13.0
with:
arch: x64

- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.30.x'

- name: Create Directories
run: |
mkdir cef

- name: Restore LuaJIT from Cache
id: restore-cache-luajit
uses: actions/cache/restore@v4
with:
path: LuaJIT
key: 'windows-luajit-${{ env.LUAJIT_VERSION }}'

- name: Checkout LuaJIT
if: steps.restore-cache-luajit.outputs.cache-hit != 'true'
uses: actions/checkout@v4.2.0
with:
path: LuaJIT
repository: LuaJIT/LuaJIT
ref: v${{ env.LUAJIT_VERSION }}

- name: Build LuaJIT
if: steps.restore-cache-luajit.outputs.cache-hit != 'true'
run: |
cd LuaJIT/src
.\msvcbuild.bat

- name: Save LuaJIT to Cache
if: steps.restore-cache-luajit.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: LuaJIT
key: 'windows-luajit-${{ env.LUAJIT_VERSION }}'

- name: Restore CEF from Cache
id: restore-cef-cache
uses: actions/cache/restore@v4
with:
path: Bolt\cef\dist
key: 'windows-cef-${{ env.WINDOWS_CEF_VERSION }}'

- name: Download CEF
if: steps.restore-cef-cache.outputs.cache-hit != 'true'
run: |
Invoke-WebRequest -Uri 'https://adamcake.com/cef/cef-${{ env.WINDOWS_CEF_VERSION }}-windows64-minimal-ungoogled.zip' -OutFile 'cef.zip'
Expand-Archive -Path 'cef.zip' -DestinationPath 'cef'
Copy-Item -Path (Get-ChildItem -Path "cef" -Directory | Select-Object -First 1).FullName -Destination "Bolt\cef\dist" -Recurse

- name: Save CEF to Cache
if: steps.restore-cef-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: Bolt\cef\dist
key: 'windows-cef-${{ env.WINDOWS_CEF_VERSION }}'

# At this point the file tree looks like
# D:\a\Bolt\Bolt
# - LuaJIT
# - <whole luaJIT source>
# - Bolt
# - <whole Bolt source>
# - cef
# - dist
# - <CEF release distribution>
#
# The tree has many nested Bolt dirs because of how GHA works.
# The first two Bolt dirs (D:\a\Bolt\Bolt) are the workspace provided by github.
# Github always does it this way.
# Then github normally clones directly in to the workspace with a folder of the repo name.
# However for our usecase we clone multiple repos, so we have D:\a\Bolt\Bolt\{LuaJIT, Bolt}
- name: Build Project
uses: threeal/cmake-action@v2.0.0
with:
source-dir: Bolt # The directory where CMakeLists.txt is located
build-dir: build # Makes it so that the build directory is set to Bolt/build
generator: Visual Studio 17
options: |
BOLT_LUAJIT_DIR=D:\a\Bolt\Bolt\LuaJIT\src
CMAKE_BUILD_TYPE=Release
BOLT_CEF_INSTALLDIR=D:\a\Bolt\Bolt\install-location
build-args: --config Release -j 4

# Installs to D:\a\Bolt\Bolt\install-location\bolt-launcher\*
- name: Create Release
run: cmake --install build/

# Uploads D:\a\Bolt\Bolt\install-location as a zip
# With `bolt-launcher` as the root directory of the zip file
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: Bolt-Windows-${{ github.sha }}
path: D:\a\Bolt\Bolt\install-location

# Uploads the zip file to the release matching the format of the above step
# Such that build artifacts and release artifacts are the same
- name: Attach Bolt Artifact to Release
if: github.event_name == 'release' && env.ENABLE_WINDOWS_RELEASES == 'true'
env:
GH_TOKEN: ${{ github.token }}
# In the script below we cd in to Bolt first, because otherwise the gh command will fail.
run: |
cd Bolt
Compress-Archive -Path D:\a\Bolt\Bolt\install-location\bolt-launcher -DestinationPath D:\a\Bolt\Bolt\Bolt-Windows.zip
gh release upload ${{ github.event.release.tag_name }} D:\a\Bolt\Bolt\Bolt-Windows.zip

build-linux-project:
name: Build Linux
runs-on: ubuntu-22.04
steps:
- name: Checkout Project
uses: actions/checkout@v4.2.0
with:
submodules: recursive

- name: Install package dependencies
run: sudo apt update && sudo apt install -y libx11-dev libxcb1-dev libarchive-dev libluajit-5.1-dev clang cmake ninja-build

- name: Restore CEF from Cache
id: restore-cef-cache
uses: actions/cache/restore@v4
with:
path: cef/dist
key: 'linux-cef-${{ env.LINUX_CEF_VERSION }}'

- name: Download CEF
if: steps.restore-cef-cache.outputs.cache-hit != 'true'
run: |
# Download cef and set up the directory structure
curl -o cef/cef.tar.gz 'https://adamcake.com/cef/cef-${{ env.LINUX_CEF_VERSION }}-linux-x86_64-minimal-ungoogled.tar.gz'
mkdir -p cef/dist

# Extract the cef tarball and copy the contents to the dist directory
tar -xzf cef/cef.tar.gz --directory cef/dist

cef_content_dir=$(ls -d cef/dist/* | head -n 1)
mv "$cef_content_dir"/* cef/dist/

# Clean up the extracted directory
rm -rf "$cef_content_dir"

- name: Save CEF to Cache
if: steps.restore-cef-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: cef/dist
key: 'linux-cef-${{ env.LINUX_CEF_VERSION }}'

- name: Build Project
uses: threeal/cmake-action@v2.0.0
with:
build-dir: build # Makes it so that the build directory is set to ./build
generator: Ninja
options: |
BOLT_LUAJIT_INCLUDE_DIR=/usr/include/luajit-2.1
CMAKE_BUILD_TYPE=Release
build-args: --config Release -j 4

- name: Create Release
run: |
cmake --install build/ --prefix install
chmod +x install/opt/bolt-launcher/bolt

- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: Bolt-Linux-${{ github.sha }}
path: install/opt/

# Uploads the zip file to the release matching the format of the above step
# Such that build artifacts and release artifacts are the same
- name: Attach Bolt Artifact to Release
if: github.event_name == 'release' && env.ENABLE_LINUX_RELEASES == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
cd install/opt
zip -r ../../Bolt-Linux.zip .
cd ../../
gh release upload ${{ github.event.release.tag_name }} Bolt-Linux.zip
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ add_executable(bolt
src/browser/client_posix.cxx src/browser/resource_handler.cxx src/browser/window_launcher.cxx
${WINDOW_LAUNCHER_OS_SPECIFIC} src/mime.cxx src/file_manager/directory.cxx client_cmake_gen.cxx
"${LIBRARY_IPC_OS_SPECIFIC}" ${BOLT_FILE_MANAGER_LAUNCHER_GEN} ${BOLT_STUB_INJECT_CXX}
src/browser/window_osr.cxx
src/browser/window_osr.cxx src/browser/window_plugin.cxx src/browser/window_plugin_requests.cxx
)
if(BOLT_STUB_INJECT_CXX)
add_dependencies(bolt BOLT_STUB_INJECT_DEPENDENCY)
Expand Down
38 changes: 14 additions & 24 deletions src/browser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
#include <fmt/core.h>

Browser::Window::Window(CefRefPtr<Browser::Client> client, Browser::Details details, CefString url, bool show_devtools):
browser_count(0), client(client.get()), show_devtools(show_devtools), details(details), window(nullptr), browser_view(nullptr), browser(nullptr), pending_child(nullptr)
browser_count(0), client(client.get()), show_devtools(show_devtools), details(details), window(nullptr), browser_view(nullptr), browser(nullptr), pending_child(nullptr), pending_delete(false)
{
fmt::print("[B] Browser::Window constructor, this={}\n", reinterpret_cast<uintptr_t>(this));
this->Init(client, details, url, show_devtools);
this->Init(url);
}

Browser::Window::Window(CefRefPtr<Browser::Client> client, Browser::Details details, bool show_devtools):
browser_count(0), client(client.get()), show_devtools(show_devtools), details(details), window(nullptr), browser_view(nullptr), browser(nullptr), pending_child(nullptr)
browser_count(0), client(client.get()), show_devtools(show_devtools), details(details), window(nullptr), browser_view(nullptr), browser(nullptr), pending_child(nullptr), pending_delete(false)
{
fmt::print("[B] Browser::Window popup constructor, this={}\n", reinterpret_cast<uintptr_t>(this));
}

void Browser::Window::Init(CefRefPtr<CefClient> client, Browser::Details details, CefString url, bool show_devtools) {
void Browser::Window::Init(CefString url) {
CefBrowserSettings browser_settings;
browser_settings.background_color = CefColorSetARGB(0, 0, 0, 0);
this->browser_view = CefBrowserView::CreateBrowserView(this, url, browser_settings, nullptr, nullptr, this);
Expand Down Expand Up @@ -146,19 +146,6 @@ void Browser::Window::OnBrowserDestroyed(CefRefPtr<CefBrowserView>, CefRefPtr<Ce
fmt::print("[B] OnBrowserDestroyed this={}\n", reinterpret_cast<uintptr_t>(this));
}

CefRefPtr<CefResourceRequestHandler> Browser::Window::GetResourceRequestHandler(
CefRefPtr<CefBrowser>,
CefRefPtr<CefFrame>,
CefRefPtr<CefRequest>,
bool,
bool,
const CefString&,
bool&
) {
// Custom resource handling is implemented by overriding this function in child classes
return nullptr;
}

bool Browser::Window::IsSameBrowser(CefRefPtr<CefBrowser> browser) const {
return this->browser->IsSame(browser);
}
Expand All @@ -172,8 +159,11 @@ void Browser::Window::Focus() const {

void Browser::Window::Close() {
fmt::print("[B] Close this={}\n", reinterpret_cast<uintptr_t>(this));
// Children will be closed when CEF calls DoClose for this instance
this->browser->GetHost()->CloseBrowser(true);
if (this->browser) {
this->browser->GetHost()->CloseBrowser(true);
} else {
this->pending_delete = true;
}
}

void Browser::Window::CloseChildrenExceptDevtools() {
Expand Down Expand Up @@ -201,10 +191,6 @@ CefRefPtr<CefLifeSpanHandler> Browser::Window::GetLifeSpanHandler() {
return this;
}

CefRefPtr<CefRequestHandler> Browser::Window::GetRequestHandler() {
return this;
}

bool Browser::Window::OnBeforePopup(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
Expand All @@ -227,13 +213,17 @@ bool Browser::Window::OnBeforePopup(
void Browser::Window::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
fmt::print("[B] Browser::OnAfterCreated for browser {}\n", browser->GetIdentifier());
this->browser_count += 1;
if (this->pending_delete) {
// calling CloseBrowser here would lead to a segmentation fault in CEF because we're still
// technically in the create function, which is going to assume the browser still exists.
browser->GetMainFrame()->SendProcessMessage(PID_RENDERER, CefProcessMessage::Create("__bolt_pluginbrowser_close"));
}
}

void Browser::Window::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
fmt::print("[B] Browser::OnBeforeClose for browser {}\n", browser->GetIdentifier());
if (this->browser && browser->IsSame(this->browser)) {
this->browser = nullptr;
this->file_manager = nullptr;
}
this->browser_count -= 1;
if (this->browser_count == 0) {
Expand Down
Loading