-
Notifications
You must be signed in to change notification settings - Fork 57
Add ability to override files #267
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
Open
mrogenmoserTT
wants to merge
6
commits into
pulp-platform:master
Choose a base branch
from
tenstorrent:files_override
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
721ca0e
Add ability for file-specific comments
mrogenmoserTT 51409a1
Add the ability to override files
mrogenmoserTT 5749e1f
Add override files to the README
thinckleyTT fe85c36
Add warning for unsupported configuration
mrogenmoserTT ecf4beb
Fix --no-source-annotation flag placement options
mrogenmoserTT f5ee875
Clarify file/comment info for script templates
mrogenmoserTT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -233,6 +233,8 @@ pub struct Sources { | |
| pub defines: IndexMap<String, Option<String>>, | ||
| /// The source files. | ||
| pub files: Vec<SourceFile>, | ||
| /// The files in this source will override other files. | ||
| pub override_files: bool, | ||
| } | ||
|
|
||
| impl PrefixPaths for Sources { | ||
|
|
@@ -617,6 +619,7 @@ impl Validate for PartialManifest { | |
| include_dirs: Vec::new(), | ||
| defines: IndexMap::new(), | ||
| files: vec![srcs.unwrap()], | ||
| override_files: false, | ||
| }), | ||
| None => None, | ||
| }, | ||
|
|
@@ -869,6 +872,8 @@ pub struct PartialSources { | |
| pub vhd: Option<String>, | ||
| /// The list of external flists to include. | ||
| pub external_flists: Option<Vec<String>>, | ||
| /// The files in this source will override other files. | ||
| pub override_files: Option<bool>, | ||
| /// Unknown extra fields | ||
| #[serde(flatten)] | ||
| extra: HashMap<String, Value>, | ||
|
|
@@ -922,6 +927,7 @@ impl Validate for PartialSources { | |
| v: None, | ||
| vhd: None, | ||
| external_flists: None, | ||
| override_files: None, | ||
| extra: _, | ||
| } => PartialSourceFile::SvFile(sv).validate(vctx), | ||
| PartialSources { | ||
|
|
@@ -933,6 +939,7 @@ impl Validate for PartialSources { | |
| v: Some(v), | ||
| vhd: None, | ||
| external_flists: None, | ||
| override_files: None, | ||
| extra: _, | ||
| } => PartialSourceFile::VerilogFile(v).validate(vctx), | ||
| PartialSources { | ||
|
|
@@ -944,6 +951,7 @@ impl Validate for PartialSources { | |
| v: None, | ||
| vhd: Some(vhd), | ||
| external_flists: None, | ||
| override_files: None, | ||
| extra: _, | ||
| } => PartialSourceFile::VhdlFile(vhd).validate(vctx), | ||
| PartialSources { | ||
|
|
@@ -955,6 +963,7 @@ impl Validate for PartialSources { | |
| v: None, | ||
| vhd: None, | ||
| external_flists, | ||
| override_files, | ||
| extra, | ||
| } => { | ||
| let external_flists: Result<Vec<_>> = external_flists | ||
|
|
@@ -1153,7 +1162,7 @@ impl Validate for PartialSources { | |
| .flatten() | ||
| .collect::<Vec<_>>(); | ||
|
|
||
| let include_dirs: Result<Vec<_>> = include_dirs | ||
| let include_dirs = include_dirs | ||
| .unwrap_or_default() | ||
| .iter() | ||
| .filter_map(|path| match env_path_from_string(path.to_string()) { | ||
|
|
@@ -1170,7 +1179,7 @@ impl Validate for PartialSources { | |
| } | ||
| } | ||
| }) | ||
| .collect(); | ||
| .collect::<Result<Vec<_>>>()?; | ||
|
|
||
| let defines = defines.unwrap_or_default(); | ||
| let files: Result<Vec<_>> = post_glob_files | ||
|
|
@@ -1191,11 +1200,17 @@ impl Validate for PartialSources { | |
| .emit(); | ||
| }); | ||
| } | ||
| if override_files.is_some_and(|x| x) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe |
||
| && (!include_dirs.is_empty() || !defines.is_empty()) | ||
| { | ||
| Warnings::OverrideFilesWithExtras(vctx.package_name.to_string()).emit(); | ||
| } | ||
| Ok(SourceFile::Group(Box::new(Sources { | ||
| target: target.unwrap_or_default(), | ||
| include_dirs: include_dirs?, | ||
| include_dirs, | ||
| defines, | ||
| files, | ||
| override_files: override_files.is_some_and(|x| x), | ||
| }))) | ||
| } | ||
| PartialSources { | ||
|
|
@@ -1207,6 +1222,7 @@ impl Validate for PartialSources { | |
| v: _v, | ||
| vhd: _vhd, | ||
| external_flists: None, | ||
| override_files: None, | ||
| extra: _, | ||
| } => Err(Error::new( | ||
| "Only a single source with a single type is supported.", | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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,16 +1,18 @@ | ||
| {% for file_group in srcs %}{# loop over all file groups | ||
| #}{% if source_annotations %}{# Add source annotations | ||
| {% for file_group in srcs %}{# loop over all file groups | ||
| #}{% if source_annotations %}{# Add source annotations | ||
| #}// {{ file_group.metadata }} | ||
| {% endif %}{# | ||
| #}{% for file in file_group.files %}{# loop over all files | ||
| #}{% if relativize_path %}{# make path relative if necessary | ||
| #}{% if file is starting_with(root) %}{# keep path unless it starts with common root | ||
| #}{{ file | replace(from=root, to='') | trim_start_matches(pat='/') }} | ||
| #}{% for file in file_group.files %}{# loop over all files | ||
| #}{% if source_annotations %}{% if file.comment %}{# add file-specific comment | ||
| #}// {{ file.comment }} | ||
| {% endif %}{% endif %}{% if relativize_path %}{# make path relative if necessary | ||
| #}{% if file.file is starting_with(root) %}{# keep path unless it starts with common root | ||
| #}{{ file.file | replace(from=root, to='') | trim_start_matches(pat='/') }} | ||
| {% else %}{# | ||
| #}{{ file }} | ||
| #}{{ file.file }} | ||
| {% endif %}{# | ||
| #}{% else %}{# | ||
| #}{{ file }} | ||
| #}{{ file.file }} | ||
| {% endif %}{# | ||
| #}{% endfor %}{# | ||
| #}{% endfor %} |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be done twice?