-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP]Tweak cli parse and xcframework.toml load
- Loading branch information
Showing
11 changed files
with
109 additions
and
99 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
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
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
File renamed without changes.
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,57 +1,19 @@ | ||
use anyhow::Result; | ||
|
||
use crate::conf::Configuration; | ||
use crate::cli::Configuration; | ||
|
||
pub fn build(conf: &Configuration) -> Result<()> { | ||
let mut args: Vec<String> = vec![]; | ||
|
||
args.push("build".into()); | ||
let mut cmd = conf.cli.clap_cargo.build_cmd(); | ||
|
||
if conf.target_dir != "target" { | ||
args.push(format!("--target-dir={}", conf.target_dir)); | ||
} | ||
|
||
if let Some(manifest_path) = &conf.cli.manifest_path { | ||
args.push(format!("--manifest-path={manifest_path}")); | ||
} | ||
if conf.cli.quiet { | ||
args.push("--quiet".into()); | ||
} | ||
|
||
if let Some(package) = &conf.cli.package { | ||
args.push(format!("--package={package}")); | ||
} | ||
|
||
for _ in 0..conf.cli.verbose { | ||
args.push("-v".into()); | ||
} | ||
|
||
if let Some(flags) = &conf.cli.unstable_flags { | ||
args.push(format!("-Z={flags}")); | ||
cmd.args(["--target-dir", conf.target_dir.as_str()]); | ||
} | ||
|
||
if conf.cli.release { | ||
args.push("--release".into()); | ||
} | ||
|
||
if let Some(profile) = &conf.cli.profile { | ||
args.push(format!("--profile={profile}")); | ||
} | ||
|
||
if !conf.cli.features.is_empty() { | ||
args.push(format!("--features={}", conf.cli.features.join(","))); | ||
} | ||
|
||
if conf.cli.all_features { | ||
args.push("--all-features".into()); | ||
for target in conf.cargo_section.chosen_targets() { | ||
cmd.args(["--target", target]); | ||
} | ||
|
||
if conf.cli.no_default_features { | ||
args.push("--no-default-features".into()); | ||
} | ||
cmd.status()?; | ||
|
||
for target in conf.cargo_section.chosen_targets() { | ||
args.push(format!("--target={}", target)); | ||
} | ||
super::run_cargo(&args, conf.cli.quiet) | ||
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
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
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 @@ | ||
mod cargo; | ||
pub mod cargo; |
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,5 +1,63 @@ | ||
// use crate::config::Config; | ||
// | ||
// pub fn build(config: Config) -> Result<()> { | ||
// crate::core::build::build_targets(pkg, profile, lib_type, targets, sequentially) | ||
// } | ||
use anyhow::{Context, Result}; | ||
use cargo_metadata::Metadata; | ||
|
||
use crate::{config::Config, Produced}; | ||
|
||
// TODO: fix all testing | ||
pub fn build(config: Config, metadata: &Metadata) -> Result<Produced> { | ||
let lib_name = "mymath"; | ||
let pkg = &metadata.root_package().context("Missing package")?.name; | ||
let profile = "release"; | ||
|
||
let bundle_name = config.name.as_ref().unwrap_or(pkg); | ||
|
||
let targets = config.targets(); | ||
let lib_type = &config.lib_type; | ||
let sequentially = false; | ||
|
||
let libs_dir = metadata.target_directory.join("libs"); | ||
std::fs::create_dir_all(&libs_dir)?; | ||
|
||
let platform_lib_paths = | ||
crate::core::build::build_targets(pkg, lib_name, profile, lib_type, targets, sequentially)?; | ||
|
||
let libs = | ||
crate::core::lipo_create_platform_libraries(&platform_lib_paths, bundle_name, &libs_dir)?; | ||
|
||
let header_paths = config.header_paths; | ||
let module_paths = config.module_paths; | ||
let frameworks_dir = metadata.target_directory.join("frameworks"); | ||
std::fs::create_dir_all(&frameworks_dir)?; | ||
|
||
let framework_paths = libs | ||
.into_iter() | ||
.map(|(platform, lib_path)| { | ||
std::fs::create_dir_all(&frameworks_dir)?; | ||
|
||
crate::core::wrap_as_framework( | ||
platform, | ||
lib_type, | ||
&lib_path, | ||
&header_paths, | ||
&module_paths, | ||
bundle_name, | ||
&frameworks_dir, | ||
) | ||
}) | ||
.collect::<anyhow::Result<Vec<_>>>()?; | ||
|
||
let output_dir = metadata.target_directory.join("xcframeworks"); | ||
let xcframework_path = | ||
crate::core::create_xcframework(framework_paths, bundle_name, &output_dir)?; | ||
|
||
println!("✅ Created XCFramework at {:?}", xcframework_path); | ||
|
||
let is_zipped = false; | ||
let path = xcframework_path; | ||
|
||
Ok(Produced { | ||
module_name: bundle_name.to_string(), | ||
path, | ||
is_zipped, | ||
}) | ||
} |