Skip to content
Merged
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
5 changes: 0 additions & 5 deletions generate4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,15 @@ main()
# Generate property copiers and artifact generators.
msg_warn "${GSL} -script:gsl.copy_properties.sh generate4.xml"
eval ${GSL} -script:gsl.copy_properties.sh generate4.xml
msg_warn "${GSL} -script:gsl.generate_artifacts.sh generate4.xml"
eval ${GSL} -script:gsl.generate_artifacts.sh generate4.xml

# Make property copiers and artifact generators executable.
msg_verbose "Modifying properties of shell scripts."
eval chmod +x copy_properties.sh
eval chmod +x generate_artifacts.sh

# Execute property copiers and artifact generators.

msg "Execute copy_properties.sh..."
eval ./copy_properties.sh
msg "Execute generate_artifacts.sh..."
eval ./generate_artifacts.sh
msg "Execute generate.sh..."
eval ./generate.sh version4.xml
msg "Execute copy_projects.sh..."
Expand Down
10 changes: 0 additions & 10 deletions generate4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -948,16 +948,6 @@
</integration>

<templates source="generate4.xml">
<!-- common artifacts -->
<template name="gsl.package.pc.in" />

<!-- autotools -->
<template name="gsl.configure.ac" />
<template name="gsl.Makefile.am" />
<template name="gsl.runner.sh" />

<!-- msvc -->
<template name="gsl.debug.natvis" />
</templates>

</generate>
13 changes: 12 additions & 1 deletion lib/filesystem.gsl
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function global.populate_files(path_substitutions, files, filters, target, absol
endnew
endfunction

function repository_absolute_path(repository, configuration)
function global.repository_absolute_path(repository, configuration)
define my.repository = repository_absolute_path.repository
define my.configuration = repository_absolute_path.configuration

Expand All @@ -274,6 +274,17 @@ function repository_absolute_path(repository, configuration)
return my.directory.path
endfunction

function global.matches_substitution(substitutions, path)
define my.substitutions = matches_substitution.substitutions
define my.path = matches_substitution.path

for my.substitutions.substitution as _sub
if starts_with(my.path, _sub.absolute_path)
return _sub
endif
endfor
endfunction

.endtemplate
.template 1
.
Expand Down
47 changes: 47 additions & 0 deletions lib/gnu-output.gsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.template 0
###############################################################################
# Copyright (c) 2014-2026 libbitcoin developers (see COPYING).
#
# GSL libbitcoin gnu utilities in the 'global' scope.
#
# This is a code generator built using the iMatix GSL code generation
# language. See https://github.com/imatix/gsl for details.
###############################################################################

###############################################################################
# Functions
###############################################################################

.endtemplate
.template 1
.
.##############################################################################
.# Macros
.##############################################################################
.
.macro global.copyleft(name)
###############################################################################
# Copyright (c) 2014-2026 $(my.name) developers (see COPYING).
#
# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY
#
###############################################################################
.endmacro
.
.macro global.heading1(text)

# $(my.text)
#==============================================================================
.endmacro
.
.macro global.heading2(text)
# $(my.text)
#------------------------------------------------------------------------------
.endmacro
.
.macro global.heading3(text)
# $(my.text)
.endmacro
.
.endtemplate

182 changes: 171 additions & 11 deletions lib/xml.gsl
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,46 @@ function global.is_defined_positive(node, attribute)
((my.node.$(my.attribute) = "true") | (my.node.$(my.attribute) = "yes"))
endfunction

function global.merge_child(destination, element, identifier)
function global.linearize(result, host)
define my.result = linearize.result
define my.host = linearize.host

copy my.host to my.result

for my.host.$(name(my.host)) as _child
linearize(my.result, _child)
endfor
endfunction

function global.merge_child(destination, element, identifier, context)
define my.destination = merge_child.destination
define my.element = merge_child.element
define my.identifier = merge_child.identifier
define my.context = merge_child.context

if (count(my.destination.$(name(my.element)), count.$(my.identifier) = my.element.$(my.identifier)) = 0)
copy my.element to my.destination
endif

define my.match = my.destination->$(name(my.element))(this.$(my.identifier) = my.element.$(my.identifier), this)

if defined(my.match) & defined(my.context) & defined(my.context.name)
new my.match.context as _context
_context.name = my.context.name
_context.type = name(my.context)
endnew
endif
endfunction

function global.merge_children_select(destination, source, name, identifier)
function global.merge_children_select(destination, source, context, name, identifier)
define my.destination = merge_children_select.destination
define my.source = merge_children_select.source
define my.context = merge_children_select.context
define my.name = merge_children_select.name
define my.identifier = merge_children_select.identifier

for my.source.$(my.name) as _child
merge_child(my.destination, _child, my.identifier)
merge_child(my.destination, _child, my.identifier, my.context)
endfor
endfunction

Expand Down Expand Up @@ -92,16 +114,38 @@ function global.canonicalize(result, host, registrar, name, identifier)
endfor
endfunction

function global.merge_components(dependencies, element)
function global.merge_components(dependencies, element, context)
define my.dependencies = merge_components.dependencies
define my.element = merge_components.element
define my.context = merge_components.context

define my.contextualize_children = 0

if (count(my.dependencies.dependency, dependency.name = my.element.name) > 0)
define my.destination = my.dependencies->dependency(dependency.name = my.element.name)

merge_children_select(my.destination, my.element, "component", "name")
merge_children_select(my.destination, my.element, my.context, "component", "name")
else
copy my.element to my.dependencies
my.contextualize_children = 1
endif

define my.match = my.dependencies->dependency(dependency.name = my.element.name)

if defined(my.match) & defined(my.context) & defined(my.context.name)
new my.match.context as _context
_context.name = my.context.name
_context.type = name(my.context)
endnew

if my.contextualize_children
for my.match.component as _component
new _component.context as _context
_context.name = my.context.name
_context.type = name(my.context)
endnew
endfor
endif
endif
endfunction

Expand Down Expand Up @@ -189,10 +233,11 @@ function global.find_option_declaration(name, target, repository)
abort "Missing option matching name '$(my.name)'."
endfunction

function global.get_option(reference, target, repository)
function global.get_option(reference, target, repository, separator)
define my.reference = get_option.reference
define my.target = get_option.target
define my.repository = get_option.repository
define my.separator = get_option.separator ? "-"
define my.result = ""

if (defined(my.reference.option))
Expand All @@ -202,32 +247,35 @@ function global.get_option(reference, target, repository)
abort "Target '$(my.target.name)' missing option '$(my.reference.option)'."
endif

my.result = "$(my.option.type:lower)-$(my.option.name:lower)"
my.result = "$(my.option.type:lower)$(my.separator)$(my.option.name:lower)"
endif

return my.result
endfunction

function global.target_dependency_list(result, target, repository, configuration)
function global.target_dependency_list(result, target, repository, configuration, recurse)
define my.result = target_dependency_list.result
define my.target = target_dependency_list.target
define my.repository = target_dependency_list.repository
define my.configuration = target_dependency_list.configuration
define my.recurse = target_dependency_list.recurse

define my.registrar = my.configuration->registrar(id = "dependency")

for my.target.dependency as _dep
if (count_matches_name(my.configuration, "repository", _dep.name) > 0)
if ((my.recurse) & \
(count_matches_name(my.configuration, "repository", _dep.name) > 0))

define my.dep_repository = my.configuration->repository(name = _dep.name)
define my.dep_target = my.dep_repository->library(name = _dep.name)

target_dependency_list(my.result, my.dep_target, \
my.dep_repository, my.configuration)
my.dep_repository, my.configuration, my.recurse)
else
canonicalize_element(my.result, _dep, my.registrar, "name")
endif

merge_components(my.result, _dep)
merge_components(my.result, _dep, my.target)
endfor
endfunction

Expand Down Expand Up @@ -255,6 +303,85 @@ function global.canonical_dependency_list(result, repository, configuration)
endfor
endfunction

function global.accumulate_repository_dependencies(result, repository)
define my.result = accumulate_repository_dependencies.result
define my.repository = accumulate_repository_dependencies.repository

for my.repository. as _target where is_target_element(_target)
for _target.dependency as _dep
merge_components(my.result, _dep, _target)

define my.match = my.result->dependency(this.name = _dep.name, this)

new my.match.context as _context
_context.type = name(_target)
_context.name = _target.name
endnew
endfor
endfor

for my.repository.library as _library
if (count(my.result.dependency, this.name = _library.name, this) > 0)
delete my.result->dependency(this.name = _library.name, this)
endif
endfor
endfunction

function accumulate_target_flags(result, target, repository, configuration, meta)
define my.result = accumulate_target_flags.result
define my.target = accumulate_target_flags.target
define my.repository = accumulate_target_flags.repository
define my.configuration = accumulate_target_flags.configuration
define my.meta = accumulate_target_flags.meta

for my.target->compiler.flag as _flag
new _flag.target as _flag_target
_flag_target.name = my.target.name
_flag_target.type = name(my.target)
endnew

if !defined(_flag.id)
copy _flag to my.result

elsif (count(my.result.flag, defined(this.id) & (this.id = _flag.id), this) = 0)
define my.canonical = my.configuration->canonical->compiler->flag( \
(this.id = _flag.id), this)?

if defined(my.canonical)
copy my.canonical to my.result
define my.copied = my.result->flag(\
defined(this.id) & (this.id = _flag.id), this)

new my.copied.target as _flag_target
_flag_target.name = my.target.name
_flag_target.type = name(my.target)
endnew
else
copy _flag to my.result
endif
else
define my.match = my.result->flag(defined(this.id) & \
(this.id = _flag.id), this)

new my.match.target as _flag_target
_flag_target.name = my.target.name
_flag_target.type = name(my.target)
endnew
endif
endfor
endfunction

function accumulate_flags(result, repository, configuration, meta)
define my.result = accumulate_flags.result
define my.repository = accumulate_flags.repository
define my.configuration = accumulate_flags.configuration
define my.meta = accumulate_flags.meta

for my.repository. as _target where is_target_element(_target)
accumulate_target_flags(my.result, _target, my.repository, my.configuration, my.meta)
endfor
endfunction

function global.calculate_presets(result, configuration, repository)
define my.result = calculate_presets.result
define my.configuration = calculate_presets.configuration
Expand Down Expand Up @@ -310,6 +437,39 @@ function global.is_target_element(element)
| (name(my.element) = "binary")
endfunction

function global.symbol_text(symbol)
define my.symbol = symbol_text.symbol

if defined(my.symbol.name)
return "$(my.symbol.name)=$(my.symbol.value)"
endif

return my.symbol.value
endfunction

function global.symbol(flag)
define my.flag = symbol.flag
define my.result = ""

if (count(my.flag.symbol) > 0)
for my.flag.symbol as _symbol
if !first()
my.result = "$(my.result) $(symbol_text(_symbol))"
else
my.result = "$(symbol_text(_symbol))"
endif
endfor
else
if !defined(my.flag.symbol)
abort "$(name(my.target)) | Flag requires 'symbol'."
endif

my.result = "$(my.flag.symbol)"
endif

return my.result
endfunction

.endtemplate
.template 1
.
Expand Down
Loading
Loading