Skip to content

Commit 453daa0

Browse files
committed
initial: add build scripts
0 parents  commit 453daa0

8 files changed

Lines changed: 620 additions & 0 deletions

File tree

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
name: Build All-in-one
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build_windows_x64:
10+
name: Build for Windows (x64)
11+
runs-on: windows-2022
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Build
17+
run: ./Update-Win64.ps1
18+
shell: pwsh
19+
working-directory: ./scripts
20+
21+
- name: Upload Artifact
22+
uses: actions/upload-artifact@v4
23+
with:
24+
name: build-windows-x64
25+
path: output/CefViewCore/
26+
27+
build_macos_universal:
28+
name: Build for macOS (x64 & ARM64)
29+
runs-on: macos-14
30+
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Select specific Xcode version
36+
uses: maxim-lobanov/setup-xcode@v1
37+
with:
38+
xcode-version: "15.4"
39+
- name: Verify Xcode version
40+
run: xcodebuild -version
41+
42+
- name: Build
43+
run: |
44+
chmod +x Update-Mac.sh
45+
./Update-Mac.sh
46+
shell: bash
47+
working-directory: ./scripts
48+
49+
- name: Upload Artifact
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: build-macos-universal
53+
path: output/CefViewCore/
54+
55+
build_linux_x64:
56+
name: Build for Linux (x64)
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Checkout
60+
uses: actions/checkout@v4
61+
62+
- name: Install Dependencies
63+
run: |
64+
sudo apt-get update
65+
sudo apt-get install -y build-essential clang cmake git libc++-dev libc++abi-dev libx11-dev
66+
67+
- name: Build
68+
run: |
69+
chmod +x Update-Linux.sh
70+
./Update-Linux.sh
71+
shell: bash
72+
working-directory: ./scripts
73+
74+
- name: Upload Artifact
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: build-linux-x64
78+
path: output/CefViewCore/
79+
80+
build_linux_arm64:
81+
name: Build for Linux (ARM64)
82+
runs-on: ubuntu-24.04-arm
83+
steps:
84+
- name: Checkout
85+
uses: actions/checkout@v4
86+
87+
- name: Install Dependencies
88+
run: |
89+
sudo apt-get update
90+
sudo apt-get install -y build-essential clang cmake git libc++-dev libc++abi-dev libx11-dev
91+
92+
- name: Build
93+
run: |
94+
chmod +x Update-LinuxArm64.sh
95+
./Update-LinuxArm64.sh
96+
working-directory: ./scripts
97+
98+
- name: Upload Artifact
99+
uses: actions/upload-artifact@v4
100+
with:
101+
name: build-linux-arm64
102+
path: output/CefViewCore/
103+
104+
package:
105+
name: Package All-in-one Artifact
106+
needs:
107+
[
108+
build_windows_x64,
109+
build_macos_universal,
110+
build_linux_x64,
111+
build_linux_arm64,
112+
]
113+
runs-on: ubuntu-latest
114+
steps:
115+
- name: Checkout
116+
uses: actions/checkout@v4
117+
118+
- name: Download all artifacts
119+
uses: actions/download-artifact@v4
120+
with:
121+
path: artifacts
122+
123+
- name: Combine artifacts
124+
run: |
125+
mkdir -p final_artifact
126+
# Recursively copy the contents of each artifact directory
127+
# The -n/--no-clobber option prevents overwriting files, although conflicts should not happen with this structure
128+
cp -rT artifacts/build-windows-x64 final_artifact
129+
cp -rT artifacts/build-macos-universal final_artifact
130+
cp -rT artifacts/build-linux-x64 final_artifact
131+
cp -rT artifacts/build-linux-arm64 final_artifact
132+
133+
- name: Create Version File
134+
run: cp scripts/ThirdParty-Config.txt final_artifact/VERSION
135+
136+
- name: Upload final artifact
137+
uses: actions/upload-artifact@v4
138+
with:
139+
name: CefViewCore-binaries
140+
path: final_artifact/
141+
142+
release:
143+
name: Create GitHub Release
144+
needs: package
145+
runs-on: ubuntu-latest
146+
permissions:
147+
contents: write
148+
steps:
149+
- name: Checkout
150+
uses: actions/checkout@v4
151+
152+
- name: Download CefViewCore-binaries artifact
153+
uses: actions/download-artifact@v4
154+
with:
155+
name: CefViewCore-binaries
156+
path: CefViewCore-binaries
157+
158+
- name: Get versions from config file
159+
id: versions
160+
run: |
161+
CEF_VERSION=$(grep "CEF_VERSION=" scripts/ThirdParty-Config.txt | cut -d'=' -f2)
162+
CORE_VERSION=$(grep "CORE_VERSION=" scripts/ThirdParty-Config.txt | cut -d'=' -f2)
163+
CEF_VERSION_MAJOR_MINOR_PATCH=$(echo "$CEF_VERSION" | cut -d'+' -f1)
164+
CORE_VERSION_SHORT=$(echo "$CORE_VERSION" | cut -c1-7)
165+
TAG_NAME="${CEF_VERSION_MAJOR_MINOR_PATCH}+${CORE_VERSION_SHORT}"
166+
echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT
167+
echo "zip_name=CefViewCore-binaries-${TAG_NAME}.zip" >> $GITHUB_OUTPUT
168+
169+
- name: Zip the artifact
170+
run: |
171+
cd CefViewCore-binaries
172+
zip -r ../${{ steps.versions.outputs.zip_name }} .
173+
cd ..
174+
shell: bash
175+
176+
- name: Create Release
177+
uses: softprops/action-gh-release@v2
178+
with:
179+
tag_name: ${{ steps.versions.outputs.tag_name }}
180+
files: ${{ steps.versions.outputs.zip_name }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
scripts/Work
2+
output/CefViewCore/**
3+
!output/CefViewCore/VERSION

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# UCefView Third-party Build Scripts
2+
3+
This repository contains the scripts used to build and package the `CefViewCore` library, which is a core dependency for the UCefView project. These scripts handle the process of checking out the correct version of the source code, compiling it for various target platforms, and organizing the output into a standardized directory structure.
4+
5+
## Overview
6+
7+
The main purpose of these scripts is to automate the update process for the pre-compiled `CefViewCore` binaries. Each script is tailored for a specific operating system and architecture.
8+
9+
The general workflow for each script is as follows:
10+
1. **Read Configuration**: Reads repository URLs and version information from `ThirdParty-Config.txt`.
11+
2. **Fetch Source**: Clones the `CefViewCore` repository from GitHub and checks out a specific commit.
12+
3. **Compile**: Builds the project using CMake and the native toolchain for the target platform.
13+
4. **Package**: Copies the resulting headers, libraries, and other artifacts to the `../output/CefViewCore` directory.
14+
15+
## File Descriptions
16+
17+
- `README.md`: This documentation file.
18+
- `ThirdParty-Config.txt`: A configuration file specifying the `CefViewCore` repository, the exact git commit to use, and the CEF (Chromium Embedded Framework) version. This ensures that builds are consistent and reproducible.
19+
- `Update-Win64.ps1`: A PowerShell script to build the dependencies for **Windows (x86_64)**. It performs a special step where it renames `UCefViewHelper.exe` to `UCefViewHelper.bin`.
20+
- `Update-Mac.sh`: A shell script to build dependencies for **macOS**. It compiles separate versions for `x86_64` and `arm64` and then uses `lipo` to create universal (multi-architecture) binaries for the framework and libraries.
21+
- `Update-Linux.sh`: A shell script to build the dependencies for **Linux (x86_64)**.
22+
- `Update-LinuxArm64.sh`: A shell script to build the dependencies for **Linux (arm64)**.
23+
24+
## How to Use
25+
26+
To update the third-party binaries, run the script corresponding to your target platform.
27+
28+
**Prerequisites:**
29+
Before running the scripts, ensure you have the necessary build tools installed for your platform. This typically includes:
30+
- Git
31+
- CMake
32+
- A C++ compiler toolchain (e.g., Visual Studio on Windows, Xcode on macOS, Clang/GCC on Linux)
33+
34+
For more detailed prerequisites, please refer to the `CefViewCore` repository: [https://github.com/CefView/CefViewCore](https://github.com/CefView/CefViewCore)
35+
36+
### Windows
37+
38+
Open a PowerShell terminal and execute:
39+
```powershell
40+
./Update-Win64.ps1
41+
```
42+
43+
### macOS
44+
45+
Open a terminal and execute:
46+
```bash
47+
./Update-Mac.sh
48+
```
49+
50+
### Linux
51+
52+
Open a terminal and execute:
53+
```bash
54+
# For x86_64
55+
./Update-Linux.sh
56+
57+
# For arm64
58+
./Update-LinuxArm64.sh
59+
```

scripts/ThirdParty-Config.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CORE_REPO=https://github.com/CefView/CefViewCore.git
2+
CORE_VERSION=f2089f2091fddab7c9642256f0d7c717f9de830e
3+
CORE_BUILD_TYPE=Release
4+
CEF_HELPER_NAME=UCefViewHelper
5+
CEF_VERSION=126.2.18+g3647d39+chromium-126.0.6478.183

scripts/Update-Linux.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
3+
#===================================================================
4+
#region Read Config Values
5+
source ThirdParty-Config.txt
6+
#endregion
7+
8+
#===================================================================
9+
#region Set Directories
10+
ROOT_DIR="$(pwd)"
11+
echo "ROOT_DIR: $ROOT_DIR"
12+
13+
WORK_DIR=$ROOT_DIR/Work
14+
15+
INSTALL_DIR=$WORK_DIR/install
16+
echo "INSTALL_DIR: $INSTALL_DIR"echo "WORK_DIR: $WORK_DIR"
17+
18+
SOURCE_DIR=$WORK_DIR/src
19+
echo "SOURCE_DIR: $SOURCE_DIR"
20+
mkdir -p $SOURCE_DIR
21+
22+
SOURCE_THIRDPARTY_DIR=$ROOT_DIR/../output/CefViewCore
23+
echo "SOURCE_THIRDPARTY_DIR: $SOURCE_THIRDPARTY_DIR"
24+
#endregion
25+
26+
#===================================================================
27+
#region Update Source Repository
28+
cd $SOURCE_DIR
29+
30+
# Get source repo
31+
git init
32+
git remote remove origin
33+
git remote add origin $CORE_REPO
34+
git fetch
35+
git -c advice.detachedHead=false checkout --force $CORE_VERSION
36+
#endregion
37+
38+
#===================================================================
39+
# Build Linux x86_64
40+
echo "Building Linux x86_64..."
41+
mkdir -p $INSTALL_DIR
42+
cd $SOURCE_DIR
43+
# Build and install
44+
cmake -G "Unix Makefiles" \
45+
-DCMAKE_C_COMPILER=clang \
46+
-DCMAKE_CXX_COMPILER=clang++ \
47+
-DCMAKE_CXX_FLAGS=-stdlib=libc++ \
48+
-DCMAKE_BUILD_TYPE=$CORE_BUILD_TYPE \
49+
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
50+
-DPROJECT_ARCH=x86_64 \
51+
-DTARGET_ARCH=x86_64 \
52+
-DUSE_SANDBOX=ON \
53+
-DCEF_SDK_VERSION=$CEF_VERSION \
54+
-DCEFVIEW_WING_NAME=$CEF_HELPER_NAME \
55+
-B "$SOURCE_DIR/build/linux.x86_64" \
56+
--fresh
57+
58+
cmake --build "$SOURCE_DIR/build/linux.x86_64" --config $CORE_BUILD_TYPE
59+
cmake --install "$SOURCE_DIR/build/linux.x86_64" --config $CORE_BUILD_TYPE
60+
61+
cd $ROOT_DIR
62+
63+
echo "Updating bin files..."
64+
cmake -E copy_directory "$INSTALL_DIR/$CORE_BUILD_TYPE/bin" "$SOURCE_THIRDPARTY_DIR/bin/Linux"
65+
66+
# Copy Header Files
67+
echo "Updating header files..."
68+
cmake -E copy_directory "$INSTALL_DIR/include" "$SOURCE_THIRDPARTY_DIR/include/Linux"
69+
70+
# Copy lib files
71+
echo "Updating lib files..."
72+
cmake -E copy_directory "$INSTALL_DIR/$CORE_BUILD_TYPE/lib" "$SOURCE_THIRDPARTY_DIR/lib/Linux"
73+
74+
# Strip libcef.so to reduce size
75+
strip "$SOURCE_THIRDPARTY_DIR/bin/Linux/libcef.so"

0 commit comments

Comments
 (0)