mirror of
https://github.com/aphrody-labs/cef-rs.git
synced 2026-10-13 21:06:46 +00:00
feat: decouple the crate version from CEF version
This commit is contained in:
12 files changed
+88
-33
No files matched your search
@@ -35,7 +35,7 @@ jobs:
|
||||
|
||||
- name: Update Bindings
|
||||
run: |
|
||||
cargo run -p update-bindings -- -b -d ${{ matrix.target }}
|
||||
cargo run -p update-bindings -- -b -d -t ${{ matrix.target }}
|
||||
|
||||
- name: Pack Changes
|
||||
id: pack-changes
|
||||
@@ -75,7 +75,7 @@ jobs:
|
||||
|
||||
- name: Update Bindings
|
||||
run: |
|
||||
cargo run -p update-bindings -- -b -d ${{ matrix.target }}
|
||||
cargo run -p update-bindings -- -b -d -t ${{ matrix.target }}
|
||||
|
||||
- name: Pack Changes
|
||||
id: pack-changes
|
||||
@@ -117,7 +117,7 @@ jobs:
|
||||
|
||||
- name: Update Bindings
|
||||
run: |
|
||||
cargo run -p update-bindings -- -b -d ${{ matrix.target }}
|
||||
cargo run -p update-bindings -- -b -d -t ${{ matrix.target }}
|
||||
|
||||
- name: Pack Changes
|
||||
id: pack-changes
|
||||
|
||||
+4
-3
@@ -4,7 +4,7 @@ resolver = "2"
|
||||
members = ["download-cef", "update-bindings", "export-cef-dir", "sys", "cef"]
|
||||
|
||||
[workspace.package]
|
||||
version = "135.0.22"
|
||||
version = "137.0.0+137.0.8"
|
||||
edition = "2021"
|
||||
license = "Apache-2.0 OR MIT"
|
||||
authors = [
|
||||
@@ -15,8 +15,8 @@ authors = [
|
||||
repository = "https://github.com/tauri-apps/cef-rs"
|
||||
|
||||
[workspace.dependencies]
|
||||
cef-dll-sys = { version = "135.0.22", path = "sys" }
|
||||
download-cef = { version = "1.3", path = "download-cef" }
|
||||
cef-dll-sys = { version = "137.0.0", path = "sys" }
|
||||
download-cef = { version = "1.4", path = "download-cef" }
|
||||
|
||||
anyhow = "1"
|
||||
bindgen = "0.71"
|
||||
@@ -27,6 +27,7 @@ plist = "1"
|
||||
proc-macro2 = "1"
|
||||
quote = "1"
|
||||
regex = "1"
|
||||
semver = "1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
syn = { version = "2", features = ["full"] }
|
||||
|
||||
+1
-2
@@ -59,11 +59,10 @@ impl Args {
|
||||
argc: _argv.len() as i32,
|
||||
argv: _argv.as_ptr() as *mut *mut _,
|
||||
};
|
||||
let cmd_line = command_line_create().map(|cmd_line| {
|
||||
let cmd_line = command_line_create().inspect(|cmd_line| {
|
||||
if !_argv.is_empty() {
|
||||
cmd_line.init_from_argv(_argv.len() as i32, _argv.as_ptr());
|
||||
}
|
||||
cmd_line
|
||||
});
|
||||
|
||||
Self {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "download-cef"
|
||||
description = "Download and extract pre-built CEF (Chromium Embedded Framework) archives."
|
||||
version = "1.3.0"
|
||||
version = "1.4.0"
|
||||
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
@@ -9,6 +9,7 @@ authors.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[dependencies]
|
||||
semver.workspace = true
|
||||
serde.workspace = true
|
||||
thiserror.workspace = true
|
||||
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
#![doc = include_str!("../README.md")]
|
||||
|
||||
use bzip2::bufread::BzDecoder;
|
||||
use semver::Version;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sha1_smol::Sha1;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fmt::{self, Display},
|
||||
fs::{self, File},
|
||||
io::{self, BufReader, IsTerminal},
|
||||
path::{Path, PathBuf},
|
||||
sync::Mutex,
|
||||
};
|
||||
|
||||
#[macro_use]
|
||||
@@ -19,6 +22,8 @@ pub enum Error {
|
||||
UnsupportedTarget(String),
|
||||
#[error("HTTP request error: {0}")]
|
||||
Request(#[from] ureq::Error),
|
||||
#[error("Invalid version: {0}")]
|
||||
InvalidVersion(#[from] semver::Error),
|
||||
#[error("Version not found: {0}")]
|
||||
VersionNotFound(String),
|
||||
#[error("Missing Content-Length header")]
|
||||
@@ -53,6 +58,29 @@ pub const WINDOWS_TARGETS: &[&str] = &[
|
||||
"i686-pc-windows-msvc",
|
||||
];
|
||||
|
||||
pub fn default_version(version: &'static str) -> String {
|
||||
static VERSIONS: Mutex<Option<HashMap<&'static str, String>>> = Mutex::new(None);
|
||||
let mut versions = VERSIONS.lock().expect("Lock error");
|
||||
if versions.is_none() {
|
||||
*versions = Some(HashMap::new());
|
||||
};
|
||||
let versions = versions.as_mut().unwrap();
|
||||
versions
|
||||
.entry(version)
|
||||
.or_insert_with(|| {
|
||||
Version::parse(version)
|
||||
.map(|version| {
|
||||
if version.build.is_empty() {
|
||||
version.to_string()
|
||||
} else {
|
||||
version.build.to_string()
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|_| version.to_string())
|
||||
})
|
||||
.clone()
|
||||
}
|
||||
|
||||
const URL: &str = "https://cef-builds.spotifycdn.com";
|
||||
|
||||
#[derive(Deserialize, Serialize, Default)]
|
||||
@@ -103,6 +131,13 @@ impl CefPlatform {
|
||||
.find(|v| v.cef_version.starts_with(&version_prefix))
|
||||
.ok_or_else(|| Error::VersionNotFound(cef_version.to_string()))
|
||||
}
|
||||
|
||||
pub fn latest(&self) -> Result<&CefVersion> {
|
||||
self.versions
|
||||
.iter()
|
||||
.max_by_key(|v| Version::parse(&v.cef_version).ok())
|
||||
.ok_or_else(|| Error::VersionNotFound("latest".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
|
||||
@@ -12,4 +12,5 @@ repository.workspace = true
|
||||
anyhow.workspace = true
|
||||
clap.workspace = true
|
||||
download-cef.workspace = true
|
||||
semver.workspace = true
|
||||
serde_json.workspace = true
|
||||
@@ -6,8 +6,16 @@ use std::{
|
||||
fs::{self, File},
|
||||
io::Write,
|
||||
path::PathBuf,
|
||||
sync::OnceLock,
|
||||
};
|
||||
|
||||
fn default_version() -> &'static str {
|
||||
static DEFAULT_VERSION: OnceLock<String> = OnceLock::new();
|
||||
DEFAULT_VERSION
|
||||
.get_or_init(|| download_cef::default_version(env!("CARGO_PKG_VERSION")))
|
||||
.as_str()
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(about, long_about = None)]
|
||||
struct Args {
|
||||
@@ -17,6 +25,8 @@ struct Args {
|
||||
save_archive: bool,
|
||||
#[arg(short, long, default_value = DEFAULT_TARGET)]
|
||||
target: String,
|
||||
#[arg(short, long, default_value = default_version())]
|
||||
version: String,
|
||||
output: String,
|
||||
}
|
||||
|
||||
@@ -63,7 +73,7 @@ fn main() -> anyhow::Result<()> {
|
||||
fs::remove_dir_all(old_cef_dir)?
|
||||
}
|
||||
|
||||
let cef_version = env!("CARGO_PKG_VERSION");
|
||||
let cef_version = args.version.as_str();
|
||||
let index = CefIndex::download()?;
|
||||
let platform = index.platform(target)?;
|
||||
let version = platform.version(cef_version)?;
|
||||
|
||||
@@ -17,5 +17,6 @@ convert_case.workspace = true
|
||||
proc-macro2.workspace = true
|
||||
quote.workspace = true
|
||||
regex.workspace = true
|
||||
semver.workspace = true
|
||||
syn.workspace = true
|
||||
thiserror.workspace = true
|
||||
@@ -3,3 +3,6 @@
|
||||
Download the prebuilt [Chromium Embedded Framework](https://github.com/chromiumembedded/cef)
|
||||
archive on any supported platform and run `bindgen` on the C API for the `cef-dll-sys` crate,
|
||||
then regenerate the safe bindings in the `cef` crate.
|
||||
|
||||
You can find the latest version of the prebuilt CEF archives on the [Chromium Embedded Framework
|
||||
(CEF) Automated Builds](https://cef-builds.spotifycdn.com/index.html).
|
||||
@@ -5,7 +5,7 @@ extern crate thiserror;
|
||||
|
||||
use clap::Parser;
|
||||
use download_cef::DEFAULT_TARGET;
|
||||
use std::{fs, io::Read, path::Path};
|
||||
use std::{fs, io::Read, path::Path, sync::OnceLock};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
@@ -31,6 +31,13 @@ mod dirs;
|
||||
mod parse_tree;
|
||||
mod upgrade;
|
||||
|
||||
fn default_version() -> &'static str {
|
||||
static DEFAULT_VERSION: OnceLock<String> = OnceLock::new();
|
||||
DEFAULT_VERSION
|
||||
.get_or_init(|| download_cef::default_version(env!("CARGO_PKG_VERSION")))
|
||||
.as_str()
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(about, long_about = None)]
|
||||
struct Args {
|
||||
@@ -38,16 +45,19 @@ struct Args {
|
||||
download: bool,
|
||||
#[arg(short, long)]
|
||||
bindgen: bool,
|
||||
target: Option<String>,
|
||||
#[arg(short, long, default_value = DEFAULT_TARGET)]
|
||||
target: String,
|
||||
#[arg(short, long, default_value = default_version())]
|
||||
version: String,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args = Args::parse();
|
||||
let target = args.target.as_deref().unwrap_or(DEFAULT_TARGET);
|
||||
let target = args.target.as_str();
|
||||
|
||||
if args.bindgen {
|
||||
if args.download {
|
||||
let _ = upgrade::download(target);
|
||||
let _ = upgrade::download(target, args.version.as_str());
|
||||
}
|
||||
|
||||
upgrade::sys_bindgen(target)?;
|
||||
|
||||
@@ -2351,20 +2351,20 @@ impl ParseTree<'_> {
|
||||
Ok(ModifiedType { ty, modifiers }) => {
|
||||
self.cef_name_map
|
||||
.get(&ty.to_token_stream().to_string())
|
||||
.and_then(|entry| match entry {
|
||||
.map(|entry| match entry {
|
||||
NameMapEntry {
|
||||
ty: NameMapType::StructDeclaration(_),
|
||||
..
|
||||
} => match modifiers.as_slice() {
|
||||
[TypeModifier::ConstPtr] => {
|
||||
Some(quote! { result.map(|result| result.into()).unwrap_or(std::ptr::null()) })
|
||||
quote! { result.map(|result| result.into()).unwrap_or(std::ptr::null()) }
|
||||
}
|
||||
[TypeModifier::MutPtr] => {
|
||||
Some(quote! { result.map(|result| result.into()).unwrap_or(std::ptr::null_mut()) })
|
||||
quote! { result.map(|result| result.into()).unwrap_or(std::ptr::null_mut()) }
|
||||
}
|
||||
_ => Some(quote! { result.into() }),
|
||||
_ => quote! { result.into() },
|
||||
}
|
||||
_ => Some(quote! { result.into() }),
|
||||
_ => quote! { result.into() },
|
||||
})
|
||||
.or_else(|| {
|
||||
if unwrapped_args.is_empty() {
|
||||
@@ -2785,20 +2785,20 @@ impl ParseTree<'_> {
|
||||
Ok(ModifiedType { ty, modifiers }) => {
|
||||
self.cef_name_map
|
||||
.get(&ty.to_token_stream().to_string())
|
||||
.and_then(|entry| match entry {
|
||||
.map(|entry| match entry {
|
||||
NameMapEntry {
|
||||
ty: NameMapType::StructDeclaration(_),
|
||||
..
|
||||
} => match modifiers.as_slice() {
|
||||
[TypeModifier::ConstPtr] => {
|
||||
Some(quote! { result.map(|result| result.into()).unwrap_or(std::ptr::null()) })
|
||||
quote! { result.map(|result| result.into()).unwrap_or(std::ptr::null()) }
|
||||
}
|
||||
[TypeModifier::MutPtr] => {
|
||||
Some(quote! { result.map(|result| result.into()).unwrap_or(std::ptr::null_mut()) })
|
||||
quote! { result.map(|result| result.into()).unwrap_or(std::ptr::null_mut()) }
|
||||
}
|
||||
_ => Some(quote! { result.into() }),
|
||||
_ => quote! { result.into() },
|
||||
}
|
||||
_ => Some(quote! { result.into() }),
|
||||
_ => quote! { result.into() },
|
||||
})
|
||||
.or_else(|| {
|
||||
if unwrapped_args.is_empty() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::dirs;
|
||||
use std::{
|
||||
env,
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
};
|
||||
@@ -19,16 +18,11 @@ const TARGETS: &[&str] = &[
|
||||
"arm-unknown-linux-gnueabi",
|
||||
];
|
||||
|
||||
pub fn download(target: &str) -> PathBuf {
|
||||
pub fn download(target: &str, version: &str) -> PathBuf {
|
||||
assert!(TARGETS.contains(&target), "unsupported target {target}");
|
||||
|
||||
let archive = download_cef::download_target_archive(
|
||||
target,
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
dirs::get_out_dir(),
|
||||
true,
|
||||
)
|
||||
.expect("download failed");
|
||||
let archive = download_cef::download_target_archive(target, version, dirs::get_out_dir(), true)
|
||||
.expect("download failed");
|
||||
|
||||
download_cef::extract_target_archive(target, &archive, dirs::get_out_dir(), true)
|
||||
.expect("extraction failed")
|
||||
|
||||
Reference in new issue
Block a user