-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proper way to generate code from build.rs (#293)
- Loading branch information
Showing
4 changed files
with
15 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,15 +1,25 @@ | ||
use std::env::var_os; | ||
use std::path::Path; | ||
|
||
use golem_openapi_client_generator::parse_openapi_specs; | ||
|
||
fn main() { | ||
println!("Starting code generation for Golem OpenAPI client."); | ||
let out_dir = var_os("OUT_DIR").unwrap(); | ||
|
||
println!("Output directory: {:?}", out_dir); | ||
|
||
golem_openapi_client_generator::gen( | ||
parse_openapi_specs(&[Path::new("../openapi/golem-service.yaml").to_path_buf()]) | ||
.expect("Failed to parse OpenAPI spec."), | ||
Path::new("."), | ||
Path::new(&out_dir), | ||
"golem-client", | ||
"0.0.0", | ||
false, | ||
true, | ||
) | ||
.expect("Failed to generate client code from OpenAPI spec.") | ||
.expect("Failed to generate client code from OpenAPI spec."); | ||
|
||
println!("cargo::rerun-if-changed=build.rs"); | ||
println!("cargo::rerun-if-changed=../openapi/golem-service.yaml"); | ||
} |
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 +1 @@ | ||
|
||
include!(concat!(env!("OUT_DIR"), "/src/lib.rs")); |