-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support to compile ftgrays/ftraster/gpac-evg
preparing for new renderer implementation
- Loading branch information
Showing
6 changed files
with
609 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"C_Cpp.default.defines": [ "STANDALONE_", | ||
"FALL_THROUGH=((void)0)", "FT_BEGIN_HEADER" ], | ||
"C_Cpp.default.includePath": [ "src/evg", "src/raster" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,79 @@ | ||
|
||
fn main() { // https://doc.rust-lang.org/stable/cargo/reference/build-scripts.html | ||
// https://doc.rust-lang.org/stable/cargo/reference/build-scripts.html | ||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
//println!("cargo:rerun-if-changed=build.rs"); // XXX: prevent re-run indead | ||
// By default, cargo always re-run the build script if any file within the package | ||
// is changed, and no any rerun-if instruction is emitted. | ||
println!("cargo:rerun-if-changed=src/"); | ||
|
||
println!("cargo:rerun-if-changed=.git/index"); | ||
let output = std::process::Command::new("git") | ||
.args(["rev-parse", "--short", "HEAD"]).output().unwrap(); | ||
println!("cargo:rustc-env=BUILD_GIT_HASH={}", String::from_utf8(output.stdout).unwrap()); | ||
.args(["rev-parse", "--short", "HEAD"]).output()?; | ||
println!("cargo:rustc-env=BUILD_GIT_HASH={}", String::from_utf8(output.stdout)?); | ||
|
||
println!("cargo:rustc-env=BUILD_TIMESTAMP={}", | ||
chrono::Local::now().format("%H:%M:%S%z %Y-%m-%d")); | ||
|
||
//println!("cargo:rerun-if-changed=build.rs"); // XXX: prevent re-run indead | ||
#[cfg(feature = "cc")] { use std::path::PathBuf; | ||
#[derive(Debug)] struct DoctestComment; | ||
impl bindgen::callbacks::ParseCallbacks for DoctestComment { | ||
fn process_comment(&self, comment: &str) -> Option<String> { | ||
Some(format!("````c,ignore\n{comment}\n````")) // FIXME: | ||
} | ||
} | ||
|
||
let module = "ftgrays"; | ||
cc::Build::new().flag("-std=c17").flag("-pedantic") | ||
.define("FALL_THROUGH", "((void)0)").file("src/raster/ftgrays.c") | ||
.opt_level(3).define("NDEBUG", None).file("src/raster/ftraster.c") | ||
.files(glob::glob("src/raster/stroke/*.c")?.filter_map(Result::ok)) | ||
.flag("-Wno-unused-variable")//.flag("-Wno-unused-function") | ||
.define("STANDALONE_", None).compile(module); | ||
|
||
// The bindgen::Builder is the main entry point to bindgen, | ||
// and lets you build up options for the resulting bindings. | ||
bindgen::Builder::default() //.header("src/raster/ftimage.h") | ||
.clang_arg("-DSTANDALONE_").header("src/raster/ftgrays.h") | ||
.clang_arg("-DFT_BEGIN_HEADER=").clang_arg("-DFT_END_HEADER=") | ||
.clang_arg("-DFT_STATIC_BYTE_CAST(type,var)=(type)(unsigned char)(var)") | ||
.allowlist_item("FT_OUTLINE_.*|FT_RASTER_FLAG_.*|FT_CURVE_TAG.*") | ||
.layout_tests(false).derive_copy(false).allowlist_var("ft_standard_raster") | ||
.allowlist_var("ft_grays_raster").allowlist_type("FT_Outline|FT_Pixel_Mode") | ||
.default_enum_style(bindgen::EnumVariation::Rust { non_exhaustive: true }) | ||
.default_macro_constant_type(bindgen::MacroTypeVariation::Signed) | ||
.parse_callbacks(Box::new(DoctestComment)).generate_comments(false) // XXX: | ||
// Tell cargo to invalidate the built crate whenever any of the | ||
// included header files changed. | ||
.parse_callbacks(Box::new(bindgen::CargoCallbacks)).generate()? | ||
.write_to_file(PathBuf::from(std::env::var("OUT_DIR")?).join(format!("{module}.rs")))?; | ||
|
||
/* ln -s /path/to/freetype2/{include/freetype/ftimage.h,src/smooth/ftgrays.[ch],\ | ||
src/raster/ft{misc.h,raster.c}} src/raster/ | ||
* ln -s /path/to/freetype2/src/{raster/ftmisc.h,base/ft{stroke,trigon}.c} src/raster/stroke/ | ||
* ln -s /path/to/freetype2/include/freetype/ft{stroke,trigon,image}.h src/raster/stroke/ | ||
* ln -s /path/to/gpac/src/evg/{ftgrays.c,rast_soft.h,stencil.c,surface.c,\ | ||
raster_{argb,rgb,565,yuv}.c},raster3d.c src/evg/ | ||
* ln -s /path/to/gpac/src/utils/{path2d{,_stroke},math,alloc,color,error}.c src/evg/ | ||
* ln -s /path/gpac/include/gpac/{evg,setup,constants,maths,color,path2d,\ | ||
tools,thread}.h src/evg/gpac/ | ||
* touch src/evg/gpac/{Remotery,config_file,configuration,main,module,version}.h | ||
*/ | ||
let module = "gpac_evg"; | ||
cc::Build::new().flag("-std=c17").flag("-Isrc/evg").define("GPAC_FIXED_POINT", None) | ||
.flag("-Wno-unused-parameter").define("GPAC_DISABLE_THREADS", None) | ||
.flag("-Wno-pointer-sign").define("GPAC_DISABLE_LOG", None) | ||
.files(glob::glob("src/evg/*.c")?.filter_map(Result::ok)) | ||
.opt_level(3).define("NDEBUG", None).compile(module); | ||
|
||
bindgen::Builder::default().header("src/evg/gpac/evg.h").clang_arg("-Isrc/evg") | ||
.default_enum_style(bindgen::EnumVariation::Rust { non_exhaustive: true }) | ||
.clang_arg("-DGPAC_DISABLE_THREADS").allowlist_function("gf_evg_s.*") | ||
//.allowlist_item("GF_LINE_.*") | ||
.clang_arg("-DGPAC_FIXED_POINT").allowlist_function("gf_path_.*") | ||
.layout_tests(false).derive_copy(false).new_type_alias("Fixed") | ||
.parse_callbacks(Box::new(bindgen::CargoCallbacks)).generate()? | ||
.write_to_file(PathBuf::from(std::env::var("OUT_DIR")?).join(format!("{module}.rs")))?; | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ pub mod tinyvg; | |
pub mod render; | ||
pub mod convert; | ||
|
||
#[cfg(feature = "cc")] pub mod revg; | ||
|
Oops, something went wrong.