diff options
author | Melody Horn <melody@boringcactus.com> | 2021-04-06 16:20:09 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-04-06 16:20:09 -0600 |
commit | 110029ce3b7f205cce01f7d74dd2c8777f860c31 (patch) | |
tree | 2f5ca5070463678880c2b9893fc567acb63398df /src/makefile/input.rs | |
parent | cffe9f4085cf28e9a1e62346cfb31ed0470a49ff (diff) | |
download | makers-110029ce3b7f205cce01f7d74dd2c8777f860c31.tar.gz makers-110029ce3b7f205cce01f7d74dd2c8777f860c31.zip |
implement exported variables
Diffstat (limited to 'src/makefile/input.rs')
-rw-r--r-- | src/makefile/input.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs index 13ced8e..7651306 100644 --- a/src/makefile/input.rs +++ b/src/makefile/input.rs @@ -16,6 +16,8 @@ use super::command_line::CommandLine; #[cfg(feature = "full")] use super::conditional::{Line as ConditionalLine, State as ConditionalState}; use super::inference_rules::InferenceRule; +#[cfg(feature = "full")] +use super::r#macro::ExportConfig; use super::r#macro::{Macro, Set as MacroSet, Source as MacroSource}; use super::target::Target; use super::token::{tokenize, Token, TokenString}; @@ -295,12 +297,27 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { LineType::Macro => self.read_macro(line_tokens, line_number)?, LineType::Unknown => { if !line_tokens.is_empty() { + // TODO handle assignments here #[cfg(feature = "full")] if line_tokens.starts_with("export") { - log::error!("export directive not supported yet"); + let mut line_tokens = line_tokens; + line_tokens.strip_prefix("export"); + if line_tokens.is_empty() { + self.macros.exported = ExportConfig::all_but(); + } else { + let exported = self.expand_macros(&line_tokens)?; + self.macros.exported.add_all(exported.split_whitespace()); + } continue; } else if line_tokens.starts_with("unexport") { - log::error!("unexport directive not supported yet"); + let mut line_tokens = line_tokens; + line_tokens.strip_prefix("unexport"); + if line_tokens.is_empty() { + self.macros.exported = ExportConfig::only(); + } else { + let exported = self.expand_macros(&line_tokens)?; + self.macros.exported.remove_all(exported.split_whitespace()); + } continue; } bail!( @@ -423,6 +440,7 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { let (targets, not_targets) = line_tokens .split_once(':') .ok_or_else(|| eyre!("read_rule couldn't find a ':' on line {}", line_number))?; + // TODO handle rule-specific variables let targets = self.expand_macros(&targets)?; let targets = targets.split_whitespace().collect::<Vec<_>>(); let (prerequisites, mut commands) = match not_targets.split_once(';') { |