Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit e1042a0

Browse files
committed
[packages,Publisher] Fixes #421. Publisher.Collation.IncludeAllModulesInNamespace now only includes modules that generate the specified pathkey.
1 parent 0551f8f commit e1042a0

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

Changelog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
20-Jan-2018 Fixes #421. Publisher.Collation.IncludeAllModulesInNamespace now only includes modules that generate the specified pathkey.
2+
13
20-Jan-2018 Fixes #420. Container source modules which are passed into C[.Cxx].ConsoleApplication.ExtendSource() should not standalone compile, as there is no guarantee that they have sufficient dependencies in order to compile. The applications consuming them may provide those dependencies.
24

35
20-Jan-2018 Fixes #419. Publisher.Collation.IncludeAllModulesInNamespace now includes an optional regular expression filter. By default, the function will match all Bam.Core.Module based classes. Using the filter will then reduce this list down to only those Modules whose name matches the filter.

packages/Publisher/bam/Scripts/CollatedObject.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,20 @@ protected override void
222222
throw new Bam.Core.Exception("The publishing directory for '{0}' has yet to be set", this.SourcePath);
223223
}
224224
}
225-
this.RegisterGeneratedFile(Key,
226-
this.CreateTokenizedString("$(0)/#valid($(RenameLeaf),@filename($(1)))",
227-
new[] { this.publishingDirectory, this.SourcePath }));
228225
if (null != this.sourceModule)
229226
{
230227
this.Requires(this.sourceModule);
228+
if (!this.sourceModule.GeneratedPaths.ContainsKey(this.sourcePathKey))
229+
{
230+
// this shouldn't happen, but just in case, a sensible error...
231+
throw new Bam.Core.Exception("Unable to locate generated path '{0}' in module '{1}' for collation",
232+
this.sourcePathKey.ToString(),
233+
this.sourceModule.ToString());
234+
}
231235
}
236+
this.RegisterGeneratedFile(Key,
237+
this.CreateTokenizedString("$(0)/#valid($(RenameLeaf),@filename($(1)))",
238+
new[] { this.publishingDirectory, this.SourcePath }));
232239
this.Ignore = false;
233240
}
234241

packages/Publisher/bam/Scripts/Collation.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ public void
410410
/// namespace, and collate them beside each other.
411411
/// Each found module will be an anchor. Any shared dependencies should appear once depending on the build mode. IDE
412412
/// build projects should each have a copy of shared dependencies in order for them to be debuggable.
413+
/// Only modules that have generated the specified pathkey will be included.
413414
/// </summary>
414415
/// <param name="nameSpace">Namespace containing all modules of interest.</param>
415416
/// <param name="key">PathKey of the modules that will be collated.</param>
@@ -422,19 +423,26 @@ public void
422423
Bam.Core.TokenizedString anchorPublishRoot = null,
423424
System.Text.RegularExpressions.Regex filter = null)
424425
{
425-
var gen = this.GetType().GetMethod("Include", new[] { typeof(Bam.Core.PathKey), typeof(Bam.Core.TokenizedString) });
426+
var genericFindReference = typeof(Bam.Core.Graph).GetMethod("FindReferencedModule");
427+
var genericInclude = this.GetType().GetMethod("Include", new[] { typeof(Bam.Core.PathKey), typeof(Bam.Core.TokenizedString) });
426428
var moduleTypes = global::System.Reflection.Assembly.GetExecutingAssembly().GetTypes().Where(
427429
item => item.Namespace == nameSpace &&
428-
item.IsSubclassOf(typeof(Bam.Core.Module)) &&
429-
item != this.GetType());
430+
item.IsSubclassOf(typeof(Bam.Core.Module)));
430431
if (null != filter)
431432
{
432433
moduleTypes = moduleTypes.Where(item => filter.IsMatch(item.Name));
433434
}
434435
foreach (var type in moduleTypes)
435436
{
436-
var meth = gen.MakeGenericMethod(new[] { type });
437-
meth.Invoke(this, new object[] { key, anchorPublishRoot });
437+
var findModule = genericFindReference.MakeGenericMethod(new[] { type });
438+
var module = findModule.Invoke(Bam.Core.Graph.Instance, null) as Bam.Core.Module;
439+
if (!module.GeneratedPaths.ContainsKey(key))
440+
{
441+
continue;
442+
}
443+
444+
var moduleTypeInclude = genericInclude.MakeGenericMethod(new[] { type });
445+
moduleTypeInclude.Invoke(this, new object[] { key, anchorPublishRoot });
438446
}
439447
}
440448

@@ -634,7 +642,7 @@ public Bam.Core.TokenizedString
634642
return mod.defaultPublishPath;
635643
}
636644
}
637-
throw new Bam.Core.Exception("Unable to locate publish directory for module {0} with path key {1}", module.ToString(), modulePathKey.ToString());
645+
throw new Bam.Core.Exception("Unable to identify a publish directory for module {0} with path key {1}", module.ToString(), modulePathKey.ToString());
638646
}
639647

640648
/// <summary>

0 commit comments

Comments
 (0)