Skip to content

Commit

Permalink
Release commit created with Cranko.
Browse files Browse the repository at this point in the history
+++ cranko-release-info-v1
[[projects]]
qnames = ["tectonic_xdv", "cargo"]
version = "0.1.12"
age = 12

[[projects]]
qnames = ["tectonic_errors", "cargo"]
version = "0.2.0"
age = 12

[[projects]]
qnames = ["tectonic_status_base", "cargo"]
version = "0.2.0"
age = 6

[[projects]]
qnames = ["tectonic_io_base", "cargo"]
version = "0.3.0"
age = 6

[[projects]]
qnames = ["tectonic_geturl", "cargo"]
version = "0.2.1"
age = 6

[[projects]]
qnames = ["tectonic_docmodel", "cargo"]
version = "0.1.0"
age = 6

[[projects]]
qnames = ["tectonic_dep_support", "cargo"]
version = "0.1.0"
age = 16

[[projects]]
qnames = ["tectonic_cfg_support", "cargo"]
version = "0.1.3"
age = 12

[[projects]]
qnames = ["tectonic_bundles", "cargo"]
version = "0.1.0"
age = 6

[[projects]]
qnames = ["tectonic_bridge_icu", "cargo"]
version = "0.2.0"
age = 12

[[projects]]
qnames = ["tectonic_bridge_graphite2", "cargo"]
version = "0.2.0"
age = 12

[[projects]]
qnames = ["tectonic_bridge_harfbuzz", "cargo"]
version = "0.2.2"
age = 8

[[projects]]
qnames = ["tectonic_bridge_freetype2", "cargo"]
version = "0.2.0"
age = 12

[[projects]]
qnames = ["tectonic_bridge_flate", "cargo"]
version = "0.1.5"
age = 0

[[projects]]
qnames = ["tectonic_bridge_core", "cargo"]
version = "0.2.2"
age = 0

[[projects]]
qnames = ["tectonic_xetex_layout", "cargo"]
version = "0.1.0"
age = 12

[[projects]]
qnames = ["tectonic_pdf_io", "cargo"]
version = "0.1.0"
age = 12

[[projects]]
qnames = ["tectonic_engine_xetex", "cargo"]
version = "0.1.3"
age = 0

[[projects]]
qnames = ["tectonic_engine_xdvipdfmx", "cargo"]
version = "0.1.2"
age = 0

[[projects]]
qnames = ["tectonic_engine_bibtex", "cargo"]
version = "0.1.3"
age = 0

[[projects]]
qnames = ["tectonic", "cargo"]
version = "0.6.3"
age = 1

+++
  • Loading branch information
cranko committed Jun 17, 2021
2 parents ab5c523 + dc4960b commit b3aad2a
Show file tree
Hide file tree
Showing 33 changed files with 751 additions and 283 deletions.
36 changes: 7 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions crates/bridge_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# tectonic_bridge_core 0.2.2 (2021-06-17)

- Switch from running [cbindgen] at build time to having the developer run it
manually. This really ought to fix the crate builds on docs.rs ([#788]), and
should speed builds too.

[cbindgen]: https://github.com/eqrion/cbindgen
[#788]: https://github.com/tectonic-typesetting/tectonic/issues/788


# tectonic_bridge_core 0.2.1 (2021-06-17)

- Attempt to fix crate builds on docs.rs — see [#788]. This works around an
Expand Down
3 changes: 1 addition & 2 deletions crates/bridge_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[package]
name = "tectonic_bridge_core"
version = "0.2.1"
version = "0.2.2"
authors = ["Peter Williams <[email protected]>"]
description = """
Exposing core backend APIs to the Tectonic C/C++ code.
Expand All @@ -28,7 +28,6 @@ tectonic_io_base = { path = "../io_base", version =">=0.3.0,<1"}
tectonic_status_base = { path = "../status_base", version =">=0.1.0,<1"}

[build-dependencies]
cbindgen = "^0.16"
cc = "^1.0.66"

[package.metadata.internal_dep_versions]
Expand Down
12 changes: 12 additions & 0 deletions crates/bridge_core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,15 @@ use tectonic_bridge_core;
This crate does not currently provide any [Cargo features][features].

[features]: https://doc.rust-lang.org/cargo/reference/features.html


## Updating the generated header

This crate exposes Rust functions to C/C++ code using a header file created by
[cbindgen]. To update the header, run:

[cbindgen]: https://github.com/eqrion/cbindgen/

```sh
cbindgen --output support/tectonic_bridge_core_generated.h
```
82 changes: 10 additions & 72 deletions crates/bridge_core/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,87 +4,25 @@
use std::{env, path::PathBuf};

fn main() {
let outdir = env::var("OUT_DIR").unwrap();
let manifest_dir: PathBuf = env::var("CARGO_MANIFEST_DIR").unwrap().into();

// Cargo exposes this as the environment variable DEP_XXX_INCLUDE, where XXX
// is the "links" setting in Cargo.toml. This is the key element that allows
// us to have a network of crates containing both C/C++ and Rust code that
// all interlink.
println!("cargo:include={}", outdir);

// cbindgen to generate the C header from our Rust code.

let mut gen_header_path: PathBuf = outdir.clone().into();
gen_header_path.push("tectonic_bridge_core_generated.h");

println!("cargo:rerun-if-changed=src/lib.rs");

let mut config = cbindgen::Config {
cpp_compat: true,
..Default::default()
};
config.enumeration.prefix_with_name = true;

let mut manifest_dir: PathBuf = env::var("CARGO_MANIFEST_DIR").unwrap().into();

// 2021 June: work around https://github.com/tectonic-typesetting/tectonic/issues/788
if env::var_os("DOCS_RS").is_some() {
env::set_var("CARGO_NET_OFFLINE", "true");
}

cbindgen::Builder::new()
.with_config(config)
.with_crate(&manifest_dir)
.with_language(cbindgen::Language::C)
.with_include_guard("TECTONIC_BRIDGE_CORE_GENERATED_H")
.with_style(cbindgen::Style::Type)
.with_after_include(
"
typedef struct ttbc_input_handle_t ttbc_input_handle_t;
typedef struct ttbc_output_handle_t ttbc_output_handle_t;
typedef ttbc_input_handle_t *rust_input_handle_t;
typedef ttbc_output_handle_t *rust_output_handle_t;",
)
.rename_item("CoreBridgeState", "ttbc_state_t")
.rename_item("Diagnostic", "ttbc_diagnostic_t")
.rename_item("FileFormat", "ttbc_file_format")
.rename_item("InputHandle", "ttbc_input_handle_t")
.rename_item("OutputHandle", "ttbc_output_handle_t")
.generate()
.expect("Unable to generate bindings")
.write_to_file(&gen_header_path);

// Copy the static header file for C preprocessing convenience.

let mut main_header_src = manifest_dir.clone();
let mut main_header_src = manifest_dir;
main_header_src.push("support");
main_header_src.push("tectonic_bridge_core.h");

let mut main_header_dest = PathBuf::from(outdir.clone());
main_header_dest.push("tectonic_bridge_core.h");

std::fs::copy(&main_header_src, &main_header_dest).expect("failed to copy main header");

println!("cargo:rerun-if-changed=support/tectonic_bridge_core.h");

// Now that we have that, we can compile our C support code.

let mut build = cc::Build::new();
build
.warnings(true)
.file("support/support.c")
.include(&outdir)
.include(&main_header_src)
.compile("libtectonic_bridge_core.a");

println!("cargo:rerun-if-changed=support/support.c");
println!("cargo:rerun-if-changed=support/tectonic_bridge_core.h");
println!("cargo:rerun-if-changed=support/tectonic_bridge_core_generated.h");

// Workaround so that we can `cargo package` this crate. Cf
// https://github.com/eqrion/cbindgen/issues/560 . cbindgen calls `cargo
// metadata` which creates a new Cargo.lock file when building this crate as
// part of its packaging process. This isn't noticed in regular builds since
// they occur in a workspace context. Lame but effective solution:
// unconditionally blow away the file.
manifest_dir.push("Cargo.lock");
let _ignored = std::fs::remove_file(&manifest_dir);
// Cargo exposes this as the environment variable DEP_XXX_INCLUDE, where XXX
// is the "links" setting in Cargo.toml. This is the key element that allows
// us to have a network of crates containing both C/C++ and Rust code that
// all interlink.
println!("cargo:include={}", main_header_src.display());
}
20 changes: 20 additions & 0 deletions crates/bridge_core/cbindgen.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
language = "C"
cpp_compat = true
style = "type"
include_guard = "TECTONIC_BRIDGE_CORE_GENERATED_H"
after_includes = """
typedef struct ttbc_input_handle_t ttbc_input_handle_t;
typedef struct ttbc_output_handle_t ttbc_output_handle_t;
typedef ttbc_input_handle_t *rust_input_handle_t;
typedef ttbc_output_handle_t *rust_output_handle_t;
"""

[enum]
prefix_with_name = true

[export.rename]
"CoreBridgeState" = "ttbc_state_t"
"Diagnostic" = "ttbc_diagnostic_t"
"FileFormat" = "ttbc_file_format"
"InputHandle" = "ttbc_input_handle_t"
"OutputHandle" = "ttbc_output_handle_t"
Loading

0 comments on commit b3aad2a

Please sign in to comment.