Skip to content
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

Fix sources & scripts export for empty source lists #167

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
- Make panic an error when lockfile is not up to date with dependencies.
- Fix Readme dependency version indication for exact match.
- Fix vendor file copying for symbolic links.
- Fix sources & scripts export for packages with empty source lists

### Added
- Add `completion` command to generate shell autocomplete integration.
Expand Down
21 changes: 9 additions & 12 deletions src/cmd/fusesoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,15 @@ pub fn run_single(sess: &Session, matches: &ArgMatches) -> Result<()> {

let name = &sess.manifest.package.name;

let srcs = match &sess.manifest.sources {
Some(sources) => Ok(sess
.load_sources(
sources,
Some(name.as_str()),
sess.manifest.dependencies.keys().cloned().collect(),
IndexMap::new(),
version_string.clone(),
)
.flatten()),
None => Err(Error::new("Error in loading sources")),
}?;
let srcs = sess
.load_sources(
&sess.manifest.sources,
Some(name.as_str()),
sess.manifest.dependencies.keys().cloned().collect(),
IndexMap::new(),
version_string.clone(),
)
.flatten();

let core_path = &sess.root.join(format!("{}.core", name));

Expand Down
15 changes: 8 additions & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct Manifest {
/// The dependencies.
pub dependencies: IndexMap<String, Dependency>,
/// The source files.
pub sources: Option<Sources>,
pub sources: Sources,
/// The include directories exported to dependent packages.
pub export_include_dirs: Vec<PathBuf>,
/// The plugin binaries.
Expand All @@ -53,11 +53,7 @@ impl PrefixPaths for Manifest {
Ok(Manifest {
package: self.package,
dependencies: self.dependencies.prefix_paths(prefix)?,
sources: self
.sources
.map_or(Ok::<Option<Sources>, Error>(None), |src| {
Ok(Some(src.prefix_paths(prefix)?))
})?,
sources: self.sources.prefix_paths(prefix)?,
export_include_dirs: self
.export_include_dirs
.into_iter()
Expand Down Expand Up @@ -355,7 +351,12 @@ impl Validate for PartialManifest {
Ok(Manifest {
package: pkg,
dependencies: deps,
sources: srcs,
sources: srcs.unwrap_or(Sources {
target: TargetSpec::Wildcard,
include_dirs: vec![],
defines: IndexMap::new(),
files: vec![],
}),
export_include_dirs: exp_inc_dirs
.iter()
.map(|path| env_path_from_string(path.to_string()))
Expand Down
9 changes: 4 additions & 5 deletions src/sess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use crate::config::{self, Config, Manifest};
use crate::error::*;
// use crate::future_throttle::FutureThrottle;
use crate::git::Git;
use crate::src::SourceFile::Group;
use crate::src::SourceGroup;
use crate::target::TargetSpec;
use crate::util::try_modification_time;
Expand Down Expand Up @@ -1250,8 +1251,7 @@ impl<'io, 'sess: 'io, 'ctx: 'sess> SessionIo<'sess, 'ctx> {
let files = manifests
.into_iter()
.flatten()
.filter_map(|m| {
m.sources.as_ref().map(|s| {
.map(|m| {
// Collect include dirs from export_include_dirs of package and direct dependencies
let mut export_include_dirs: IndexMap<String, IndexSet<&Path>> =
IndexMap::new();
Expand All @@ -1277,7 +1277,7 @@ impl<'io, 'sess: 'io, 'ctx: 'sess> SessionIo<'sess, 'ctx> {
}
self.sess
.load_sources(
s,
&m.sources,
Some(m.package.name.as_str()),
m.dependencies.keys().cloned().collect(),
export_include_dirs,
Expand All @@ -1286,9 +1286,8 @@ impl<'io, 'sess: 'io, 'ctx: 'sess> SessionIo<'sess, 'ctx> {
Err(_) => None,
},
)
.into()
})
})
.map(|sg| Group(Box::new(sg)))
.collect();

// Create a source group for this rank.
Expand Down
9 changes: 7 additions & 2 deletions src/src.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ impl<'ctx> SourceGroup<'ctx> {
let group = group.simplify();

// Discard empty groups.
if group.files.is_empty() {
if group.files.is_empty()
&& group.include_dirs.is_empty()
&& group.defines.is_empty()
&& group.target.is_wildcard()
&& group.package.is_none()
{
return None;
}

Expand Down Expand Up @@ -221,7 +226,7 @@ impl<'ctx> SourceGroup<'ctx> {
let mut files = vec![];
let subfiles = std::mem::take(&mut self.files);
let flush_files = |files: &mut Vec<SourceFile<'ctx>>, into: &mut Vec<SourceGroup<'ctx>>| {
if files.is_empty() {
if files.is_empty() && self.package.is_none() {
return;
}
let files = std::mem::take(files);
Expand Down
Loading