Skip to content

Commit

Permalink
Fix sources & scripts export for empty source lists
Browse files Browse the repository at this point in the history
Fixes #166
  • Loading branch information
micprog committed Apr 17, 2024
1 parent 69c82e9 commit ce47cf4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased
### Fixed
- Fix sources & scripts export for packages with empty source lists

## 0.28.1 - 2024-02-22
### Added
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 @@ -1218,8 +1219,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 @@ -1245,7 +1245,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 @@ -1254,9 +1254,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
2 changes: 1 addition & 1 deletion src/src.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit ce47cf4

Please sign in to comment.