Skip to content
Closed
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
15 changes: 15 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ pub struct BuildCommand {
#[serde(default)]
pub show_config: bool,

/// Build target.
#[arg(short, long, value_enum, default_value_t = Target::Native)]
pub target: Target,

#[command(flatten)]
#[serde(default)]
pub tree_sitter: TreeSitter,
Expand All @@ -169,6 +173,7 @@ impl Default for BuildCommand {
out_dir: PathBuf::from(TSDL_OUT_DIR),
prefix: String::from(TSDL_PREFIX),
show_config: TSDL_SHOW_CONFIG,
target: Target::Native,
tree_sitter: TreeSitter::default(),
}
}
Expand Down Expand Up @@ -197,6 +202,16 @@ pub enum ParserConfig {
Ref(String),
}

#[derive(clap::ValueEnum, Clone, Debug, Deserialize, Diff, Serialize, PartialEq, Eq)]
#[diff(attr(
#[derive(Debug, PartialEq)]
))]
pub enum Target {
All,
Native,
Wasm,
}

#[derive(clap::Args, Clone, Debug, Diff, Deserialize, PartialEq, Eq, Serialize)]
#[diff(attr(
#[derive(Debug, PartialEq)]
Expand Down
7 changes: 6 additions & 1 deletion src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use tracing::error;
use url::Url;

use crate::{
args::{BuildCommand, ParserConfig},
args::{BuildCommand, ParserConfig, Target},
config,
consts::TSDL_FROM,
display::{Handle, Progress, ProgressState, TICK_CHARS},
Expand Down Expand Up @@ -70,6 +70,7 @@ fn build(command: &BuildCommand, progress: Progress) -> Result<()> {
command.build_dir.clone(),
command.out_dir.clone(),
&command.prefix,
&command.target,
)
.unwrap();
create_dir_all(&command.out_dir)
Expand Down Expand Up @@ -102,6 +103,7 @@ fn languages(
build_dir: PathBuf,
out_dir: PathBuf,
prefix: &str,
target: &Target,
) -> Result<Vec<Language>, error::LanguageCollection> {
let (res, errs) = unique_languages(
ts_cli,
Expand All @@ -111,6 +113,7 @@ fn languages(
requested_languages,
defined_parsers,
progress,
target,
);
if errs.is_empty() {
Ok(res.into_iter().map(Result::unwrap).collect())
Expand All @@ -135,6 +138,7 @@ fn unique_languages(
requested_languages: &Option<Vec<String>>,
defined_parsers: &Option<BTreeMap<String, ParserConfig>>,
progress: Arc<Mutex<Progress>>,
target: &Target,
) -> Languages {
let ts_cli = Arc::new(ts_cli);
let final_languages = requested_languages
Expand Down Expand Up @@ -162,6 +166,7 @@ fn unique_languages(
out_dir.canon().unwrap(),
prefix.into(),
repo,
target.clone(),
ts_cli.clone(),
)
})
Expand Down
5 changes: 5 additions & 0 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use tracing::warn;
use url::Url;

use crate::{
args::Target,
display::{Handle, ProgressHandle},
error,
git::{clone_fast, Ref},
Expand Down Expand Up @@ -57,6 +58,8 @@ pub struct Language {
out_dir: PathBuf,
prefix: String,
repo: Url,
#[allow(dead_code)]
target: Target,
ts_cli: Arc<PathBuf>,
}

Expand All @@ -72,6 +75,7 @@ impl Language {
out_dir: PathBuf,
prefix: String,
repo: Url,
target: Target,
ts_cli: Arc<PathBuf>,
) -> Self {
Language {
Expand All @@ -83,6 +87,7 @@ impl Language {
out_dir,
prefix,
repo,
target,
ts_cli,
}
}
Expand Down