diff --git a/lib/filesystem.gsl b/lib/filesystem.gsl index 7d4355d5..b596c48b 100644 --- a/lib/filesystem.gsl +++ b/lib/filesystem.gsl @@ -98,6 +98,34 @@ function global.discover_files(files, meta, path, recurse) abort "Directory open failure: $(error_text)" endif + if defined(my.files.path) + echo "Rediscovering directory '$(my.files.path)'" + endif + + if defined(my.files.path) & !(my.files.path = my.directory.path) + abort "Directory path '$(my.files.path)' reused does not match intended assignment path '$(my.directory.path)'" + endif + + if defined(my.files.name) & !(my.files.name = my.directory.name) + abort "Directory name '$(my.files.name)' reused does not match intended assignment name '$(my.directory.name)'" + endif + + if defined(my.files.query) & !(my.files.query = my.path) + abort "Directory query '$(my.files.query)' reused does not match intended assignment path '$(my.path)'" + endif + + if defined(my.files.path) & !(my.files.path = my.directory.path) + abort "Directory path '$(my.files.path)' does not match intended '$(my.directory.path)'" + endif + + if defined(my.files.name) & !(my.files.name = my.directory.name) + abort "Directory name '$(my.files.name)' does not match intended '$(my.directory.name)'" + endif + + if defined(my.files.query) & !(my.files.query = my.path) + abort "Directory query '$(my.files.query)' does not match intended '$(my.path)'" + endif + my.files.path = my.directory.path my.files.name = my.directory.name my.files.query = my.path @@ -118,6 +146,7 @@ function global.discover_files(files, meta, path, recurse) #if !(my.modified_name = _file.name) # check for redundancy, if so skip if !(count(my.files.file, (count.name = my.modified_name)) = 0) + echo "Detected collision: $(my.modified_name) | $(_file.path)" next endif #endif @@ -157,9 +186,20 @@ function global.populate_files_from_path(path_substitutions, files, filters, fil define my.path = path_append(my.absolute_path_base, my.files_path.path) define my.recurse = is_defined_positive(my.files_path, "recursive") - new my.files.directory as _directory - discover_files(_directory, my.filters, my.path, my.recurse) - endnew + if (count(my.files.directory, this.path = "$(my.path)/", this) > 0) + # echo "Repopulating '$(my.path)'" + define my.matched_directory = my.files->directory(this.path = "$(my.path)/", this) + discover_files(my.matched_directory, my.filters, my.path, my.recurse) + else + # echo "Populating '$(my.path)'" + # for my.files.directory as _directory + # echo " Existing: $(_directory.path)" + # endfor + + new my.files.directory as _directory + discover_files(_directory, my.filters, my.path, my.recurse) + endnew + endif new my.path_substitutions.substitution as _sub _sub.absolute_path = my.path diff --git a/templates/msbuild/sln.gsl b/templates/msbuild/sln.gsl index cf96e22a..1d7bd47c 100644 --- a/templates/msbuild/sln.gsl +++ b/templates/msbuild/sln.gsl @@ -118,8 +118,12 @@ EndProject . define my.indent = emit_solution_matrix.indent . $(my.indent)GlobalSection(SolutionConfigurationPlatforms) = preSolution -. for my.toolchain->msvc->axis(.name = "configuration").entry as _config -. for my.toolchain->msvc->axis(.name = "platform").entry as _platform +. for my.toolchain->msvc->axis(.name = "platform").entry as _platform \ + where !defined(_platform.hidden) by _platform.value +. +. for my.toolchain->msvc->axis(.name = "configuration").entry as _config \ + where !defined(_config.hidden) +. \t$(my.indent)$(_config.value)|$(_platform.value) = $(_config.value)|$(_platform.value) . endfor . endfor @@ -145,9 +149,13 @@ $(my.indent)EndGlobalSection . define my.toolchain = emit_target_matrix.toolchain . define my.indent = emit_target_matrix.indent . -. for my.toolchain->msvc->axis(.name = "configuration").entry as _config -. define my.target_config = _config->$(name(my.target)).value -. for my.toolchain->msvc->axis(.name = "platform").entry as _platform +. for my.toolchain->msvc->axis(.name = "platform").entry as _platform \ + where !defined(_platform.hidden) by _platform.value +. +. for my.toolchain->msvc->axis(.name = "configuration").entry as _config \ + where !defined(_config.hidden) +. +. define my.target_config = _config->$(name(my.target)).value $(my.indent){$(my.target.uuid:upper)}.$(_config.value)|$(_platform.value).ActiveCfg = $(my.target_config)|$(_platform.value) $(my.indent){$(my.target.uuid:upper)}.$(_config.value)|$(_platform.value).Build.0 = $(my.target_config)|$(_platform.value) . endfor diff --git a/templates/msbuild/vcxproj.filters.gsl b/templates/msbuild/vcxproj.filters.gsl index b46cc3c5..c3e74c4c 100644 --- a/templates/msbuild/vcxproj.filters.gsl +++ b/templates/msbuild/vcxproj.filters.gsl @@ -89,18 +89,6 @@ function matches_substitution(substitutions, path) endfor endfunction -function populate_uuid(files, seed) - define my.files = populate_uuid.files - my.files.uuid = populate_uuid.seed - define my.seed = uuid_inc(my.files.uuid) - - for my.files.directory as _directory - my.seed = populate_uuid(_directory, my.seed) - endfor - - return my.seed -endfunction - function accumulate_filters(result, files, substitutions, target) define my.result = accumulate_filters.result define my.files = accumulate_filters.files @@ -127,7 +115,6 @@ function accumulate_filters(result, files, substitutions, target) new my.result.filter as _filter _filter.path = my.filter_path _filter.target_uuid = my.target.uuid - _filter.files_uuid = my.files.uuid endnew else echo "Collision using filter path '$(my.filter_path)'." @@ -215,8 +202,6 @@ endfunction . populate_files(_substitutions, _files, my.meta->discovery, \ my.target, my.absolute_root, my.intended_prefix) . -. my.seed = populate_uuid(_files, my.seed) -. . # Filters . emit_filters(_files, _substitutions, my.target, my.indent) @@ -285,13 +270,17 @@ endfunction . define my.target = emit_filters.target . define my.indent = emit_filters.indent . +. define my.next_uuid = 0 +. . new filters as _filters . accumulate_filters(_filters, my.files, my.substitutions, my.target) . . for _filters.filter as _filter by _filter.path $(my.indent) - $(my.indent){$(to_uuid(_filter.target_uuid, _filter.files_uuid):upper)} + $(my.indent){$(to_uuid(_filter.target_uuid, my.next_uuid):upper)} $(my.indent) +. +. my.next_uuid = uuid_inc(my.next_uuid) . endfor . endnew .endmacro # emit_filters diff --git a/templates/msbuild/vcxproj.gsl b/templates/msbuild/vcxproj.gsl index fd64c94d..d918d2e2 100644 --- a/templates/msbuild/vcxproj.gsl +++ b/templates/msbuild/vcxproj.gsl @@ -97,6 +97,74 @@ function nuget_target(package) return "$(my.prefix)/$(my.relative_path)/$(my.targets_file)" endfunction +function linearize_sources(result, files, substitutions, filters, disambiguation_type) + define my.result = linearize_sources.result + define my.files = linearize_sources.files + define my.substitutions = linearize_sources.substitutions + define my.filters = linearize_sources.filters + define my.disambiguation_type = linearize_sources.disambiguation_type? + + for my.files.file as _file where matches_filters(my.filters, _file.name) + define my.applicable_sub = matches_substitution(my.substitutions, _file.path) + + define my.sanitized_path = string.substr(_file.path, \ + string.length(my.applicable_sub.absolute_path), string.length(_file.path) - 1) + + define my.filename = path_append(my.applicable_sub.relative_path_prefix, \ + path_append(my.sanitized_path, _file.name)) + + define my.filter_path = my.sanitized_path + + if defined(my.applicable_sub.filter) + my.filter_path = path_append(my.applicable_sub.filter, my.sanitized_path) + endif + + if ends_with(my.filter_path, "/") + my.filter_path = string.substr(my.filter_path, 0, \ + string.length(my.filter_path) - 2) + endif + + + new my.result.item as _item + _item.name = my.filename + if defined(my.disambiguation_type) + define my.splitpoint = string.locate_last(_file.name, ".") + _item.collision_name = string.substr(_file.name, 0, my.splitpoint - 1) + + define my.path_to_prefix = string.replace(my.sanitized_path, "/|_") + _item.disambiguated = "$(my.applicable_sub.unprefixed_path)$(my.path_to_prefix)$(_item.collision_name).$(my.disambiguation_type)" + endif + endnew + endfor + + for my.files.directory as _directory + linearize_sources(my.result, _directory, my.substitutions, my.filters, \ + my.disambiguation_type) + endfor +endfunction + +function annotate_conflicts(items) + define my.items = annotate_conflicts.items + + new names as _names + for my.items.item as _item by _item.collision_name + if (count(_names.item, this.name = _item.collision_name, this) > 0) + _names->item(this.name = _item.collision_name, this).deconflict = 1 + else + new _names.item as _identifier + _identifier.name = _item.collision_name + endnew + endif + endfor + + for _names.item as _identifier where defined(_identifier.deconflict) + for my.items.item as _item where _item.collision_name = _identifier.name + _item.has_conflict = 1 + endfor + endfor + endnew +endfunction + ############################################################################### # Generation ############################################################################### @@ -159,23 +227,35 @@ endfunction . # ClCompile -. new conflicts as _conflicts -. emit_items("ClCompile", _files, _substitutions, \ - my.meta->sources, my.item_indent, _conflicts) +. new items as _items +. linearize_sources(_items, _files, _substitutions, my.meta->sources, "obj") +. annotate_conflicts(_items) +. emit_items("ClCompile", _items, my.item_indent) . endnew . # ClInclude -. emit_items("ClInclude", _files, _substitutions, my.meta->headers, my.item_indent) +. new items as _items +. linearize_sources(_items, _files, _substitutions, my.meta->headers) +. emit_items("ClInclude", _items, my.item_indent) +. endnew . # None -. emit_items("None", _files, _substitutions, my.meta->other, my.item_indent) - +. new items as _items +. linearize_sources(_items, _files, _substitutions, my.meta->other) +. new _items.item as _packagesconfig +. _packagesconfig.name = "packages.config" +. endnew +. emit_items("None", _items, my.item_indent) +. endnew . # ResourceCompile -. emit_items("ResourceCompile", _files, _substitutions, my.meta->resource, my.item_indent) +. new items as _items +. linearize_sources(_items, _files, _substitutions, my.meta->resource) +. emit_items("ResourceCompile", _items, my.item_indent) +. endnew . emit_import_projects(my.target, my.repository, my.configuration, \ my.toolchain, my.toolset, my.meta, " ") @@ -211,9 +291,9 @@ endfunction . $(my.indent) . -. for my.toolchain->msvc->axis(.name = "configuration").entry as _config -. define my.target_config = _config->$(name(my.target)).value -. for my.toolchain->msvc->axis(.name = "platform").entry as _platform +. for my.toolchain->msvc->axis(.name = "platform").entry as _platform by _platform.value +. for my.toolchain->msvc->axis(.name = "configuration").entry as _config +. define my.target_config = _config->$(name(my.target)).value . $(my.indent) $(my.indent)$(my.target_config) @@ -226,56 +306,21 @@ $(my.indent) . .endmacro # emit_project_configuration . -.macro emit_items(item_name, files, substitutions, filters, indent, conflicts) +.macro emit_items(item_name, files, indent) . define my.item_name = emit_items.item_name . define my.files = emit_items.files -. define my.substitutions = emit_items.substitutions -. define my.filters = emit_items.filters . define my.indent = emit_items.indent -. define my.conflicts = emit_items.conflicts? -. -. for my.files.file as _file where matches_filters(my.filters, _file.name) -. define my.conflicted = 0 -. define my.applicable_sub = matches_substitution(my.substitutions, _file.path) -. define my.sanitized_path = string.substr(_file.path, string.length(my.applicable_sub.absolute_path), string.length(_file.path) - 1) -. define my.filename = path_append(my.applicable_sub.relative_path_prefix, \ - path_append(my.sanitized_path, _file.name)) -. define my.filter_path = my.sanitized_path -. if defined(my.applicable_sub.filter) -. my.filter_path = path_append(my.applicable_sub.filter, my.sanitized_path) -. endif -. if ends_with(my.filter_path, "/") -. my.filter_path = string.substr(my.filter_path, 0, string.length(my.filter_path) - 2) -. endif . -. define my.splitpoint = string.locate_last(_file.name, ".") -. define my.filename_base = string.substr(_file.name, 0, my.splitpoint - 1) +. for my.files.item as _file by _file.name +. define my.lineend = defined(_file.has_conflict) ?? ">" ? " />" +$(my.indent)<$(my.item_name) Include="$(path(_file.name))"$(my.lineend) . -. if defined(my.conflicts) -. if (count(my.conflicts.conflict, count.name = my.filename_base) > 0) -. my.conflicted = 1 -. else -. new my.conflicts.conflict as _conflict -. _conflict.name = my.filename_base -. endnew -. endif -. endif -. -. if my.conflicted -. define my.path_to_prefix = string.replace(my.sanitized_path, "/|_") -. define my.disambiguated = "$(my.applicable_sub.unprefixed_path)$(my.path_to_prefix)$(my.filename_base).obj" -$(my.indent)<$(my.item_name) Include="$(path(my.filename))"> - $(my.indent)\$(IntDir)$(my.disambiguated) +. if defined(_file.has_conflict) + $(my.indent)\$(IntDir)$(_file.disambiguated) $(my.indent) -. else -$(my.indent)<$(my.item_name) Include="$(path(my.filename))" /> . endif . endfor . -. for my.files.directory as _directory -. emit_items(my.item_name, _directory, my.substitutions, my.filters, \ - my.indent, my.conflicts) -. endfor .endmacro # emit_items . .macro emit_import_projects(target, repository, configuration, toolchain, toolset, meta, indent) @@ -293,7 +338,9 @@ $(my.indent) . . new dependencies as _dependencies . target_dependency_list(_dependencies, my.target, my.repository, my.configuration) -. for _dependencies.dependency as _depend where defined(_depend->nuget) +. for _dependencies.dependency as _depend by _depend.name \ + where defined(_depend->nuget) +. . for _depend->nuget.resource as _resource where \ !defined(_resource.component) . @@ -315,7 +362,7 @@ $(my.indent) . endfor . . # address component resources -. for _depend.component as _component +. for _depend.component as _component by _component.name . for _depend->nuget.resource as _resource where \ defined(_resource.component) & (_resource.component = _component.name) . @@ -358,7 +405,9 @@ $(my.indent)build(build.method = "cmake")) + CONFIGURE_OPTIONS_CMAKE=( "${CONFIGURE_OPTIONS_CMAKE[@]}" "-Dwith-tests=OFF" ) +. endif +. +. if defined(my.meta->build(build.method = "gnu")) + CONFIGURE_OPTIONS_GNU=( "${CONFIGURE_OPTIONS_GNU[@]}" "--without-tests" ) +. endif + fi + # --prefix if [[ -z "${PREFIX}" ]]; then # Always set a prefix (required for OSX and lib detection). diff --git a/version4.xml b/version4.xml index 63151a3f..f051c819 100644 --- a/version4.xml +++ b/version4.xml @@ -49,7 +49,7 @@