diff --git a/CHANGELOG.md b/CHANGELOG.md index 89a612bc..42f78761 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/cmd/fusesoc.rs b/src/cmd/fusesoc.rs index a52230c9..18e98199 100644 --- a/src/cmd/fusesoc.rs +++ b/src/cmd/fusesoc.rs @@ -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)); diff --git a/src/config.rs b/src/config.rs index 58c08f83..5f8535e3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -35,7 +35,7 @@ pub struct Manifest { /// The dependencies. pub dependencies: IndexMap, /// The source files. - pub sources: Option, + pub sources: Sources, /// The include directories exported to dependent packages. pub export_include_dirs: Vec, /// The plugin binaries. @@ -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::, Error>(None), |src| { - Ok(Some(src.prefix_paths(prefix)?)) - })?, + sources: self.sources.prefix_paths(prefix)?, export_include_dirs: self .export_include_dirs .into_iter() @@ -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())) diff --git a/src/sess.rs b/src/sess.rs index ff2b490b..a4e5cf98 100644 --- a/src/sess.rs +++ b/src/sess.rs @@ -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; @@ -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> = IndexMap::new(); @@ -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, @@ -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. diff --git a/src/src.rs b/src/src.rs index 8c936d6a..17071eff 100644 --- a/src/src.rs +++ b/src/src.rs @@ -53,7 +53,7 @@ impl<'ctx> SourceGroup<'ctx> { let group = group.simplify(); // Discard empty groups. - if group.files.is_empty() { + if group.files.is_empty() && group.package.is_none() { return None; }