Skip to content
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
2 changes: 1 addition & 1 deletion code/compiler/core/build-engine.wren
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ class BuildEngine {
Soup.info("Pass Along Public Includes")

for (directory in arguments.PublicIncludes) {
result.PublicIncludes.add(directory)
result.PublicIncludes.add(directory)
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion code/compiler/gcc-tests/gcc-argument-builder-unit-tests.wren
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ class GCCArgumentBuilderUnitTests {
"./module.cpp",
"-o",
"C:/target/module.obj",
"-fmodules-ts",
"-interface",
"-ifcOutput",
"C:/target/module.ifc",
]

Assert.ListEqual(expectedArguments, actualArguments)
Expand Down
4 changes: 2 additions & 2 deletions code/extension-tests/tasks/recipe-build-task-unit-tests.wren
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class RecipeBuildTaskUnitTests {
var expectedActiveState = {
"Build": {
"LinkLibraries": [],
"PublicHeaderSets": [],
"KnownPublicHeaderSets": [],
"TargetType": "StaticLibrary",
"TargetRootDirectory": "/(TARGET)/",
"Compiler": "MOCK",
Expand Down Expand Up @@ -132,7 +132,7 @@ class RecipeBuildTaskUnitTests {
"LinkLibraries": [
"/Direct/Library.lib"
],
"PublicHeaderSets": [],
"KnownPublicHeaderSets": [],
"TargetType": "StaticLibrary",
"TargetRootDirectory": "/(TARGET)/",
"Compiler": "MOCK",
Expand Down
2 changes: 1 addition & 1 deletion code/extension/recipe.sml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: 'cpp'
Language: 'Wren|0'
Version: 0.19.3
Version: 0.19.4
Dependencies: {
Runtime: [
'soup|cpp-compiler@0'
Expand Down
77 changes: 75 additions & 2 deletions code/extension/tasks/expand-source-task.wren
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class ExpandSourceTask is SoupTask {
var activeState = Soup.activeState

var buildTable = activeState["Build"]
ExpandSourceTask.expandSource(globalState, buildTable)
ExpandSourceTask.expandPublicHeaderSets(globalState, buildTable)
}

static expandSource(globalState, buildTable) {
var allowedPaths = []
if (buildTable.containsKey("KnownSource")) {
// Fill in the info on existing source files
Expand Down Expand Up @@ -62,20 +66,66 @@ class ExpandSourceTask is SoupTask {
sourceFiles)
}

static expandPublicHeaderSets(globalState, buildTable) {
if (buildTable.containsKey("KnownPublicHeaderSets")) {
// Expand the source from all discovered files
Soup.info("Expand Public Header Sets")
var filesystem = globalState["FileSystem"]

var publicHeaderSets = []
for (value in buildTable["KnownPublicHeaderSets"]) {
var packageHeaderSet = {}
var root = Path.new(value["Root"])
packageHeaderSet["Root"] = root.toString
if (value.containsKey("Target")) {
packageHeaderSet["Target"] = value["Target"]
}

var allowedPaths = []
if (value.containsKey("Files")) {
// Fill in the info on existing files
for (file in ListExtensions.ConvertToPathList(value["Files"])) {
allowedPaths.add(root + file)
}
} else {
// Default to matching all header files under the root
allowedPaths.add(root + Path.new("./**/*.h"))
}

var headerFiles = ExpandSourceTask.DiscoverHeaderFiles(
filesystem, Path.new(), allowedPaths)

// Strip out the root so we can still resolve the final file path correctly
var relativeHeaderFiles = []
for (file in headerFiles) {
relativeHeaderFiles.add(file.GetRelativeTo(root))
}

packageHeaderSet["Files"] = ListExtensions.ConvertFromPathList(relativeHeaderFiles)

publicHeaderSets.add(packageHeaderSet)
}

ListExtensions.Append(
MapExtensions.EnsureList(buildTable, "PublicHeaderSets"),
publicHeaderSets)
}
}

static DiscoverCompileFiles(
currentDirectory, workingDirectory, preprocessors, allowedPaths, excludePaths) {
var files = []
for (directoryEntity in currentDirectory) {
if (directoryEntity is String) {
var file = workingDirectory + Path.new(directoryEntity)
Soup.info("Check File: %(file)")
// Soup.info("Check File: %(file)")
if (ExpandSourceTask.ShouldInclude(allowedPaths, excludePaths, file)) {
files.add(ExpandSourceTask.CreateSourceInfo(file, preprocessors))
}
} else {
for (child in directoryEntity) {
var directory = workingDirectory + Path.new(child.key)
Soup.info("Found Directory: %(directory)")
// Soup.info("Found Directory: %(directory)")
var subFiles = ExpandSourceTask.DiscoverCompileFiles(
child.value, directory, preprocessors, allowedPaths, excludePaths)
ListExtensions.Append(files, subFiles)
Expand All @@ -86,6 +136,29 @@ class ExpandSourceTask is SoupTask {
return files
}

static DiscoverHeaderFiles(currentDirectory, workingDirectory, allowedPaths) {
var files = []
for (directoryEntity in currentDirectory) {
if (directoryEntity is String) {
var file = workingDirectory + Path.new(directoryEntity)
// Soup.info("Check File: %(file)")
if (ExpandSourceTask.IsMatchAny(allowedPaths, file)) {
files.add(file)
}
} else {
for (child in directoryEntity) {
var directory = workingDirectory + Path.new(child.key)
// Soup.info("Found Directory: %(directory)")
var subFiles = ExpandSourceTask.DiscoverHeaderFiles(
child.value, directory, allowedPaths)
ListExtensions.Append(files, subFiles)
}
}
}

return files
}

static ShouldInclude(allowedPaths, excludePaths, file) {
if (ExpandSourceTask.IsMatchAny(allowedPaths, file)) {
// If we matched included, check if there is an explicit exclude
Expand Down
9 changes: 4 additions & 5 deletions code/extension/tasks/recipe-build-task.wren
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ class RecipeBuildTask is SoupTask {
}
}


var knownExcludeFiles = null
if (recipe.containsKey("Exclude")) {
knownExcludeFiles = []
Expand All @@ -177,9 +176,9 @@ class RecipeBuildTask is SoupTask {
}

// Load the public header files if present
var publicHeaderSets = []
var knownPublicHeaderSets = []
if (recipe.containsKey("PublicHeaders")) {
publicHeaderSets = recipe["PublicHeaders"]
knownPublicHeaderSets = recipe["PublicHeaders"]
}

// Check for warning settings
Expand Down Expand Up @@ -248,8 +247,8 @@ class RecipeBuildTask is SoupTask {
MapExtensions.EnsureList(build, "AssemblySource"),
assemblySourceFiles)
ListExtensions.Append(
MapExtensions.EnsureList(build, "PublicHeaderSets"),
publicHeaderSets)
MapExtensions.EnsureList(build, "KnownPublicHeaderSets"),
knownPublicHeaderSets)

build["EnableWarningsAsErrors"] = enableWarningsAsErrors

Expand Down