mirror of
https://github.com/fathyb/carbonyl.git
synced 2025-01-08 11:47:27 +08:00
chore(ci): build Chromium on CI (#111)
This commit is contained in:
parent
50e27adce7
commit
dda5b5c51d
@ -1,99 +1,191 @@
|
||||
import pkg from '../package.json'
|
||||
import pkg from "../package.json";
|
||||
|
||||
const { version } = JSON.parse(pkg)
|
||||
const { version } = JSON.parse(pkg);
|
||||
const triple = (platform, arch) => `${archs[arch]}-${platforms[platform]}`
|
||||
const sharedLib = {
|
||||
macos: 'dylib',
|
||||
linux: 'so'
|
||||
}
|
||||
macos: "dylib",
|
||||
linux: "so",
|
||||
};
|
||||
const platforms = {
|
||||
macos: 'apple-darwin',
|
||||
linux: 'unknown-linux-gnu',
|
||||
}
|
||||
macos: "apple-darwin",
|
||||
linux: "unknown-linux-gnu",
|
||||
};
|
||||
const archs = {
|
||||
arm64: 'aarch64',
|
||||
amd64: 'x86_64',
|
||||
}
|
||||
arm64: "aarch64",
|
||||
amd64: "x86_64",
|
||||
};
|
||||
|
||||
export const jobs = ['arm64', 'amd64']
|
||||
.flatMap((arch) =>
|
||||
['macos', 'linux'].map((platform) => ({ platform, arch })),
|
||||
)
|
||||
.map(({ platform, arch }) => {
|
||||
const triple = `${archs[arch]}-${platforms[platform]}`
|
||||
const lib = `build/${triple}/release/libcarbonyl.${sharedLib[platform]}`
|
||||
|
||||
return { platform, arch, triple, lib }
|
||||
})
|
||||
.flatMap(({ platform, arch, triple, lib }) => [
|
||||
export const jobs = ["macos", "linux"].flatMap(platform => {
|
||||
return [
|
||||
{
|
||||
name: `Build core (${platform}/${arch})`,
|
||||
docker:
|
||||
platform === 'linux'
|
||||
? {
|
||||
image: 'fathyb/rust-cross',
|
||||
cache: ['/usr/local/cargo/registry'],
|
||||
}
|
||||
: undefined,
|
||||
agent: { tags: platform === 'linux' ? ['docker'] : ['macos'] },
|
||||
name: `Build runtime (${platform})`,
|
||||
agent: { tags: ["chromium-src", platform] },
|
||||
steps: [
|
||||
{
|
||||
name: 'Install Rust toolchain',
|
||||
command: `rustup target add ${triple}`,
|
||||
serial: ['arm64', 'amd64'].map(arch => (
|
||||
{ import: { workspace: `core-${triple(platform, arch)}` } }
|
||||
))
|
||||
},
|
||||
{
|
||||
name: 'Build core library',
|
||||
command: `cargo build --target ${triple} --release`,
|
||||
env: { MACOSX_DEPLOYMENT_TARGET: '10.13' },
|
||||
},
|
||||
{
|
||||
name: 'Set core library install name',
|
||||
command:
|
||||
platform === 'macos'
|
||||
? `install_name_tool -id @executable_path/libcarbonyl.dylib ${lib}`
|
||||
: 'echo not necessary',
|
||||
},
|
||||
{
|
||||
export: {
|
||||
workspace: triple,
|
||||
path: 'build/*/release/*.{dylib,so,dll}',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
// TODO: setup shared build dir
|
||||
name: `Build (${platform}/${arch})`,
|
||||
docker: 'fathyb/rust-cross',
|
||||
agent: { tags: ['docker'] },
|
||||
steps: [
|
||||
{
|
||||
import: {
|
||||
workspace: triple,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Fetch binaries',
|
||||
command: `scripts/runtime-pull.sh ${triple}`,
|
||||
},
|
||||
{
|
||||
name: 'Zip binaries',
|
||||
name: 'Fetch Chromium',
|
||||
command: `
|
||||
mkdir build/zip
|
||||
cp -r build/pre-built/${triple} build/zip/carbonyl-${version}
|
||||
cp ${lib} build/zip/carbonyl-${version}
|
||||
if [ -z "$CHROMIUM_ROOT" ]; then
|
||||
echo "Chromium build environment not setup"
|
||||
|
||||
cd build/zip
|
||||
zip -r package.zip carbonyl-${version}
|
||||
`,
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if scripts/runtime-pull.sh arm64; then
|
||||
touch skip-build-arm64
|
||||
fi
|
||||
if scripts/runtime-pull.sh amd64; then
|
||||
touch skip-build-amd64
|
||||
fi
|
||||
|
||||
if [ ! -f skip-build-amd64 ] || [ ! -f skip-build-amd64 ]; then
|
||||
cp chromium/.gclient "$CHROMIUM_ROOT"
|
||||
|
||||
scripts/gclient.sh sync
|
||||
scripts/patches.sh apply
|
||||
|
||||
rm -rf "$CHROMIUM_ROOT/src/carbonyl"
|
||||
mkdir "$CHROMIUM_ROOT/src/carbonyl"
|
||||
ln -s "$(pwd)/src" "$CHROMIUM_ROOT/src/carbonyl/src"
|
||||
ln -s "$(pwd)/build" "$CHROMIUM_ROOT/src/carbonyl/build"
|
||||
fi
|
||||
`
|
||||
},
|
||||
{
|
||||
export: {
|
||||
artifact: {
|
||||
name: `carbonyl.${platform}-${arch}.zip`,
|
||||
path: 'build/zip/package.zip',
|
||||
},
|
||||
},
|
||||
parallel: ['arm64', 'amd64'].map(arch => {
|
||||
const target = platform === 'linux' && arch === 'amd64'
|
||||
? 'Default'
|
||||
: arch
|
||||
|
||||
return {
|
||||
serial: [
|
||||
{
|
||||
name: `Build Chromium (${arch})`,
|
||||
command: `
|
||||
if [ ! -f skip-build-${arch} ]; then
|
||||
(
|
||||
export PATH="$PATH:$CHROMIUM_ROOT/depot_tools"
|
||||
|
||||
cd "$CHROMIUM_ROOT/src/out/${target}"
|
||||
ninja headless:headless_shell -j4
|
||||
)
|
||||
|
||||
scripts/copy-binaries.sh ${target} ${arch}
|
||||
fi
|
||||
`,
|
||||
env: {
|
||||
AR_AARCH64_UNKNOWN_LINUX_GNU: "aarch64-linux-gnu-ar",
|
||||
CC_AARCH64_UNKNOWN_LINUX_GNU: "aarch64-linux-gnu-gcc",
|
||||
CXX_AARCH64_UNKNOWN_LINUX_GNU: "aarch64-linux-gnu-g++",
|
||||
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: "aarch64-linux-gnu-gcc",
|
||||
AR_X86_64_UNKNOWN_LINUX_GNU: "x86_64-linux-gnu-ar",
|
||||
CC_X86_64_UNKNOWN_LINUX_GNU: "x86_64-linux-gnu-gcc",
|
||||
CXX_X86_64_UNKNOWN_LINUX_GNU: "x86_64-linux-gnu-g++",
|
||||
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: "x86_64-linux-gnu-gcc",
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
parallel: [
|
||||
{
|
||||
name: `Push binaries to CDN (${arch})`,
|
||||
command: `
|
||||
if [ ! -f skip-build-${arch} ]; then
|
||||
scripts/runtime-push.sh ${arch}
|
||||
fi
|
||||
`,
|
||||
env: {
|
||||
CDN_ACCESS_KEY_ID: { secret: true },
|
||||
CDN_SECRET_ACCESS_KEY: { secret: true }
|
||||
}
|
||||
},
|
||||
{
|
||||
export: {
|
||||
workspace: `runtime-${triple(platform, arch)}`,
|
||||
path: `build/pre-built/${triple(platform, arch)}`
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
}
|
||||
],
|
||||
},
|
||||
])
|
||||
...['arm64', 'amd64'].flatMap((arch) => {
|
||||
const triple = `${archs[arch]}-${platforms[platform]}`;
|
||||
const lib = `build/${triple}/release/libcarbonyl.${sharedLib[platform]}`;
|
||||
|
||||
return [
|
||||
{
|
||||
name: `Build core (${platform}/${arch})`,
|
||||
docker:
|
||||
platform === "linux"
|
||||
? {
|
||||
image: "fathyb/rust-cross",
|
||||
cache: ["/usr/local/cargo/registry"],
|
||||
}
|
||||
: undefined,
|
||||
agent: { tags: platform === "linux" ? ["docker"] : ["macos"] },
|
||||
steps: [
|
||||
{
|
||||
name: "Install Rust toolchain",
|
||||
command: `rustup target add ${triple}`,
|
||||
},
|
||||
{
|
||||
name: "Build core library",
|
||||
command: `cargo build --target ${triple} --release`,
|
||||
env: { MACOSX_DEPLOYMENT_TARGET: "10.13" },
|
||||
},
|
||||
{
|
||||
name: "Set core library install name",
|
||||
command:
|
||||
platform === "macos"
|
||||
? `install_name_tool -id @executable_path/libcarbonyl.dylib ${lib}`
|
||||
: "echo not necessary",
|
||||
},
|
||||
{
|
||||
export: {
|
||||
workspace: `core-${triple}`,
|
||||
path: "build/*/release/*.{dylib,so,dll}",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: `Package (${platform}/${arch})`,
|
||||
docker: "fathyb/rust-cross",
|
||||
agent: { tags: ["docker"] },
|
||||
steps: [
|
||||
{
|
||||
import: { workspace: `runtime-${triple}` },
|
||||
},
|
||||
{
|
||||
name: "Zip binaries",
|
||||
command: `
|
||||
mkdir build/zip
|
||||
cp -r build/pre-built/${triple} build/zip/carbonyl-${version}
|
||||
|
||||
cd build/zip
|
||||
zip -r package.zip carbonyl-${version}
|
||||
`,
|
||||
},
|
||||
{
|
||||
export: {
|
||||
artifact: {
|
||||
name: `carbonyl.${platform}-${arch}.zip`,
|
||||
path: "build/zip/package.zip",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
})
|
||||
]
|
||||
})
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit b7d8efd8bee494f4cfacacc19cf50fc4d4be3900
|
||||
Subproject commit 10369890bb0452c44ab2bfc1240aeb61db3b345c
|
@ -2,14 +2,22 @@
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
if [ -z "$CARBONYL_ROOT" ]; then
|
||||
echo "CARBONYL_ROOT should be defined"
|
||||
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [ -z "$CHROMIUM_ROOT" ]; then
|
||||
export CHROMIUM_ROOT="$CARBONYL_ROOT/chromium"
|
||||
fi
|
||||
if [ -z "$CHROMIUM_SRC" ]; then
|
||||
export CHROMIUM_SRC="$CHROMIUM_ROOT/src"
|
||||
fi
|
||||
if [ -z "$DEPOT_TOOLS_ROOT" ]; then
|
||||
export DEPOT_TOOLS_ROOT="$CHROMIUM_ROOT/depot_tools"
|
||||
fi
|
||||
|
||||
export CHROMIUM_SRC="$CHROMIUM_ROOT/src"
|
||||
export PATH="$PATH:$DEPOT_TOOLS_ROOT"
|
||||
|
||||
if [ ! -f "$DEPOT_TOOLS_ROOT/README.md" ] && [ -z "$SKIP_DEPOT_TOOLS" ]; then
|
||||
|
@ -6,10 +6,10 @@ export SKIP_DEPOT_TOOLS="true"
|
||||
cd "$CARBONYL_ROOT"
|
||||
source "scripts/env.sh"
|
||||
|
||||
"$CARBONYL_ROOT/scripts/runtime-pull.sh" aarch64-unknown-linux-gnu
|
||||
"$CARBONYL_ROOT/scripts/runtime-pull.sh" x86_64-unknown-linux-gnu
|
||||
"$CARBONYL_ROOT/scripts/runtime-pull.sh" aarch64-apple-darwin
|
||||
"$CARBONYL_ROOT/scripts/runtime-pull.sh" x86_64-apple-darwin
|
||||
"$CARBONYL_ROOT/scripts/runtime-pull.sh" amd64 linux
|
||||
"$CARBONYL_ROOT/scripts/runtime-pull.sh" arm64 linux
|
||||
"$CARBONYL_ROOT/scripts/runtime-pull.sh" amd64 macos
|
||||
"$CARBONYL_ROOT/scripts/runtime-pull.sh" arm64 macos
|
||||
|
||||
VERSION_ID="$(git rev-parse --short HEAD)" \
|
||||
node "$CARBONYL_ROOT/scripts/npm-publish.mjs"
|
||||
|
@ -10,30 +10,23 @@ chromium_upstream="92da8189788b1b373cbd3348f73d695dfdc521b6"
|
||||
skia_upstream="486deb23bc2a4d3d09c66fef52c2ad64d8b4f761"
|
||||
|
||||
if [[ "$1" == "apply" ]]; then
|
||||
if [[ -d carbonyl ]]; then
|
||||
git add -A carbonyl
|
||||
fi
|
||||
|
||||
echo "Stashing Chromium changes.."
|
||||
|
||||
git add -A .
|
||||
git stash
|
||||
git checkout "$chromium_upstream"
|
||||
echo "Applying Chromium patches.."
|
||||
for patch in "$CARBONYL_ROOT/chromium/patches/chromium"/*.patch; do
|
||||
git am --committer-date-is-author-date "$patch"
|
||||
done
|
||||
|
||||
echo "Applying Chromium patches.."
|
||||
git checkout "$chromium_upstream"
|
||||
git am --committer-date-is-author-date "$CARBONYL_ROOT/chromium/patches/chromium"/*
|
||||
"$CARBONYL_ROOT/scripts/restore-mtime.sh" "$chromium_upstream"
|
||||
|
||||
cd third_party/skia
|
||||
echo "Stashing Skia changes.."
|
||||
cd third_party/skia
|
||||
git add -A .
|
||||
git stash
|
||||
git checkout "$skia_upstream"
|
||||
echo "Applying Skia patches.."
|
||||
for patch in "$CARBONYL_ROOT/chromium/patches/skia"/*.patch; do
|
||||
git am --committer-date-is-author-date "$patch"
|
||||
done
|
||||
|
||||
echo "Applying Skia patches.."
|
||||
git checkout "$skia_upstream"
|
||||
git am --committer-date-is-author-date "$CARBONYL_ROOT/chromium/patches/skia"/*
|
||||
"$CARBONYL_ROOT/scripts/restore-mtime.sh" "$skia_upstream"
|
||||
|
||||
echo "Patches successfully applied"
|
||||
|
@ -9,9 +9,9 @@ platform="$2"
|
||||
|
||||
if [ -z "$platform" ]; then
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
platform="unknown-linux-gnu"
|
||||
platform="linux"
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
platform="apple-darwin"
|
||||
platform="macos"
|
||||
else
|
||||
echo "Unsupported platform: $OSTYPE"
|
||||
|
||||
@ -19,6 +19,12 @@ if [ -z "$platform" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$platform" == "linux" ]; then
|
||||
platform="unknown-linux-gnu"
|
||||
elif [ "$platform" == "macos" ]; then
|
||||
platform="apple-darwin"
|
||||
fi
|
||||
|
||||
if [ -z "$cpu" ]; then
|
||||
cpu="$(uname -m)"
|
||||
fi
|
||||
|
@ -8,9 +8,8 @@ source "scripts/env.sh"
|
||||
|
||||
echo "Computing Chromium patches sha.."
|
||||
|
||||
sha=$(scripts/runtime-hash.sh)
|
||||
|
||||
triple="$1"
|
||||
sha="$(scripts/runtime-hash.sh)"
|
||||
triple="$(scripts/platform-triple.sh "$@")"
|
||||
|
||||
if [ ! -f "build/pre-built/$triple.tgz" ]; then
|
||||
url="https://carbonyl.fathy.fr/runtime/$sha/$triple.tgz"
|
||||
|
@ -1,3 +1,3 @@
|
||||
mod browser;
|
||||
mod bridge;
|
||||
|
||||
pub use browser::*;
|
||||
pub use bridge::*;
|
||||
|
@ -33,38 +33,21 @@ impl Keyboard {
|
||||
}
|
||||
pub fn key(key: u8, modifiers: u8) -> Option<Event> {
|
||||
let modifiers = KeyModifiers::parse(modifiers);
|
||||
|
||||
match key {
|
||||
let char = match key {
|
||||
// Up
|
||||
b'A' => Some(Event::KeyPress {
|
||||
key: Key {
|
||||
char: 0x11,
|
||||
modifiers,
|
||||
},
|
||||
}),
|
||||
b'A' => 0x11,
|
||||
// Down
|
||||
b'B' => Some(Event::KeyPress {
|
||||
key: Key {
|
||||
char: 0x12,
|
||||
modifiers,
|
||||
},
|
||||
}),
|
||||
b'B' => 0x12,
|
||||
// Right
|
||||
b'C' => Some(Event::KeyPress {
|
||||
key: Key {
|
||||
char: 0x13,
|
||||
modifiers,
|
||||
},
|
||||
}),
|
||||
b'C' => 0x13,
|
||||
// Left
|
||||
b'D' => Some(Event::KeyPress {
|
||||
key: Key {
|
||||
char: 0x14,
|
||||
modifiers,
|
||||
},
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
b'D' => 0x14,
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
Some(Event::KeyPress {
|
||||
key: Key { char, modifiers },
|
||||
})
|
||||
}
|
||||
|
||||
pub fn parse(&mut self, key: u8) -> ParseControlFlow {
|
||||
|
Loading…
Reference in New Issue
Block a user