Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make libcnb_runtime_build etc public #375

Merged
merged 4 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libcnb/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased]

- Allow compilation of libcnb.rs buildpacks on Windows. Please note that this does not imply Windows container support, it's meant to allow running unit tests without cross-compiling. ([#368](https://github.com/Malax/libcnb.rs/pull/368))
- Expose `runtime::libcnb_runtime_detect`, `runtime::libcnb_runtime_build` and their related types for advanced use-cases. Buildpack authors should not use these. ([#375](https://github.com/Malax/libcnb.rs/pull/375)).

## [0.6.0] 2022-02-28

Expand Down
2 changes: 1 addition & 1 deletion libcnb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub use error::*;
#[doc(inline)]
pub use libcnb_data as data;
pub use platform::*;
pub use runtime::libcnb_runtime;
pub use runtime::*;
pub use toml_file::*;

const LIBCNB_SUPPORTED_BUILDPACK_API: data::buildpack::BuildpackApi =
Expand Down
28 changes: 20 additions & 8 deletions libcnb/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ pub fn libcnb_runtime<B: Buildpack>(buildpack: &B) {
}
}

fn libcnb_runtime_detect<B: Buildpack>(
/// Detect entry point for this framework.
///
/// Exposed only to allow for advanced use-cases where detect is programmatically invoked.
#[doc(hidden)]
pub fn libcnb_runtime_detect<B: Buildpack>(
buildpack: &B,
args: DetectArgs,
) -> crate::Result<i32, B::Error> {
Expand Down Expand Up @@ -132,7 +136,11 @@ fn libcnb_runtime_detect<B: Buildpack>(
}
}

fn libcnb_runtime_build<B: Buildpack>(
/// Build entry point for this framework.
///
/// Exposed only to allow for advanced use-cases where detect is programmatically invoked.
#[doc(hidden)]
pub fn libcnb_runtime_build<B: Buildpack>(
buildpack: &B,
args: BuildArgs,
) -> crate::Result<i32, B::Error> {
Expand Down Expand Up @@ -177,13 +185,14 @@ fn libcnb_runtime_build<B: Buildpack>(
}
}

struct DetectArgs {
#[doc(hidden)]
pub struct DetectArgs {
pub platform_dir_path: PathBuf,
pub build_plan_path: PathBuf,
}

impl DetectArgs {
fn parse(args: &[String]) -> Result<DetectArgs, DetectArgsParseError> {
pub fn parse(args: &[String]) -> Result<DetectArgs, DetectArgsParseError> {
if let [_, platform_dir_path, build_plan_path] = args {
Ok(DetectArgs {
platform_dir_path: PathBuf::from(platform_dir_path),
Expand All @@ -196,18 +205,20 @@ impl DetectArgs {
}

#[derive(Debug)]
enum DetectArgsParseError {
#[doc(hidden)]
pub enum DetectArgsParseError {
InvalidArguments,
}

struct BuildArgs {
#[doc(hidden)]
pub struct BuildArgs {
pub layers_dir_path: PathBuf,
pub platform_dir_path: PathBuf,
pub buildpack_plan_path: PathBuf,
}

impl BuildArgs {
fn parse(args: &[String]) -> Result<BuildArgs, BuildArgsParseError> {
pub fn parse(args: &[String]) -> Result<BuildArgs, BuildArgsParseError> {
if let [_, layers_dir_path, platform_dir_path, buildpack_plan_path] = args {
Ok(BuildArgs {
layers_dir_path: PathBuf::from(layers_dir_path),
Expand All @@ -221,7 +232,8 @@ impl BuildArgs {
}

#[derive(Debug)]
enum BuildArgsParseError {
#[doc(hidden)]
pub enum BuildArgsParseError {
InvalidArguments,
}

Expand Down