From 52154a2038c92da0d0f7393656c74b187b2c9ade Mon Sep 17 00:00:00 2001 From: Phillip Mienk Date: Mon, 6 Jul 2026 09:14:29 -0700 Subject: [PATCH 1/3] Comments, reorganization. --- version4.xml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/version4.xml b/version4.xml index 5ff19dbc..f9964139 100644 --- a/version4.xml +++ b/version4.xml @@ -2012,21 +2012,33 @@ - From 3810f9e178c67793d5d8906691869438419be386 Mon Sep 17 00:00:00 2001 From: Phillip Mienk Date: Tue, 7 Jul 2026 13:28:09 -0700 Subject: [PATCH 2/3] Changes to expand data-driven file copy, migrate props related files to vNext. --- copy_projects.cmd | 129 ----- copy_projects.sh | 48 -- generate4.cmd | 48 -- generate4.sh | 13 - generate4.xml | 953 ----------------------------------- gsl.copy_modules.cmd | 147 ------ gsl.copy_modules.sh | 130 ----- gsl.copy_properties.cmd | 163 ------ gsl.copy_properties.sh | 123 ----- gsl.generate_artifacts.cmd | 59 --- gsl.generate_artifacts.sh | 60 --- lib/xml.gsl | 22 + process/copy_statics.cmd.gsl | 31 +- process/copy_statics.gsl | 147 ++++++ process/copy_statics.sh.gsl | 47 +- utilities.gsl | 922 --------------------------------- version4.xml | 21 +- 17 files changed, 232 insertions(+), 2831 deletions(-) delete mode 100644 copy_projects.cmd delete mode 100755 copy_projects.sh delete mode 100644 generate4.xml delete mode 100644 gsl.copy_modules.cmd delete mode 100644 gsl.copy_modules.sh delete mode 100644 gsl.copy_properties.cmd delete mode 100755 gsl.copy_properties.sh delete mode 100644 gsl.generate_artifacts.cmd delete mode 100755 gsl.generate_artifacts.sh create mode 100644 process/copy_statics.gsl delete mode 100644 utilities.gsl diff --git a/copy_projects.cmd b/copy_projects.cmd deleted file mode 100644 index 3f2538ab..00000000 --- a/copy_projects.cmd +++ /dev/null @@ -1,129 +0,0 @@ -@echo off -setlocal EnableDelayedExpansion -setlocal EnableExtensions -REM ########################################################################### -REM Copyright (c) 2014-2026 libbitcoin developers (see COPYING). -REM -REM Generate libbitcoin-build artifacts from XML + GSL. -REM -REM This executes the iMatix GSL code generator. -REM See https://github.com/imatix/gsl for details. -REM -REM Direct GSL download https://www.nuget.org/api/v2/package/gsl/4.1.0.1 -REM Extract gsl.exe from package using NuGet's File > Export -REM ########################################################################### - -:: Assign arguments -set "SOURCE_DIR=output" -set "DEST_DIR=.." - -:: Check if source directory exists -if not exist "%SOURCE_DIR%" ( - call :msg_error "Error: Source directory '%SOURCE_DIR%' does not exist." - exit /b 1 -) - -:: Check if destination directory exists -if not exist "%DEST_DIR%" ( - call :msg_error "Error: Destination directory '%DEST_DIR%' does not exist." - exit /b 1 -) - -:: If no substring arguments are provided, copy all subdriectories -set "COPIED=0" - -if "%~1"=="" ( - call :msg_warn "No substrings specified. Copying all 'libbitcoin' subdirectories from '%SOURCE_DIR%' to '%DEST_DIR%'..." - - for /d %%i in ("%SOURCE_DIR%\libbitcoin*") do ( - call :copy_repository "%%i" "%%~nxi" - if not !ERRORLEVEL! equ 0 ( - exit /b 1 - ) - set /a COPIED+=1 - ) -) else ( - :: Copy subdirectories whose names contain any of the provided substrings - for /d %%i in ("%SOURCE_DIR%\libbitcoin*") do ( - set "dirpath=%%i" - set "dirname=%%~nxi" - call :msg_warn "Evaluating !dirname!..." - set "MATCHED=0" - for %%j in (%*) do ( - call :msg_warn "Value %%j" - echo.!dirname! | find /i "%%j" >nul - if !ERRORLEVEL! equ 0 ( - set "MATCHED=1" - ) - ) - - if !MATCHED! equ 1 ( - call :msg_warn "Copying '!dirname!'..." - call :copy_repository "!dirpath!" "!dirname!" - if not !ERRORLEVEL! equ 0 ( - call :msg_error "Error triggered exit." - exit /b 1 - ) - set /a COPIED+=1 - ) else ( - call :msg_warn " No match for '%%~nxi'" - ) - ) -) - -if !COPIED! equ 0 ( - call :msg_warn "Warning: No subdirectories found in '%SOURCE_DIR%' matching any provided substrings." -) else ( - call :msg_success "Copied !COPIED! repositories." -) - -popd -call :msg_success "Copy operation completed successfully." -exit /b 0 - - -:copy_repository - call :msg "Copying '%~2' to '%DEST_DIR%'..." - xcopy "%~1" "%DEST_DIR%\%~2" /E /I /Y - if not !ERRORLEVEL! equ 0 ( - call :msg_error " Copy failed for '%~2'" - exit /b 1 - ) - exit /b 0 - - -:msg_heading - call :msg "***************************************************************************" - call :msg "%~1" - call :msg "***************************************************************************" - exit /b !ERRORLEVEL! - -:msg - if "%~1" == "" ( - echo. - ) else ( - echo %~1 - ) - exit /b !ERRORLEVEL! - -:msg_empty - echo. - exit /b !ERRORLEVEL! - -:msg_verbose - if "!DISPLAY_VERBOSE!" == "yes" ( - echo %~1 - ) - exit /b !ERRORLEVEL! - -:msg_success - echo %~1 - exit /b !ERRORLEVEL! - -:msg_warn - echo %~1 - exit /b !ERRORLEVEL! - -:msg_error - echo %~1 - exit /b !ERRORLEVEL! diff --git a/copy_projects.sh b/copy_projects.sh deleted file mode 100755 index 2935e321..00000000 --- a/copy_projects.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# Assign arguments -source_dir="output" -dest_dir=".." - -# Check if source directory exists -if [ ! -d "$source_dir" ]; then - echo "Error: Source directory '$source_dir' does not exist." - exit 1 -fi - -# Create destination directory if it doesn't exist -mkdir -p "$dest_dir" - -# If no subdirectory arguments are provided, copy all subdirectories -if [ "$#" -eq 0 ]; then - echo "No substrings specified. Copying all 'libbitcoin' subdirectories from '$source_dir' to '$dest_dir'..." - for subdir in "$source_dir"/*/ ; do - if [ -d "$subdir" ]; then - subdir_name=$(basename "$subdir") - if [[ "$subdir_name" == *"libbitcoin-"* ]]; then - echo "Copying '$subdir_name' to '$dest_dir'..." - cp -r "$subdir" "$dest_dir/" - fi - fi - done -else - # Copy subdirectories whose names contain any of the provided substrings - copied=0 - for subdir in "$source_dir"/*/ ; do - if [ -d "$subdir" ]; then - subdir_name=$(basename "$subdir") - for substring in "$@"; do - if [[ "$subdir_name" == *"$substring"* ]]; then - echo "Copying '$subdir_name' to '$dest_dir'..." - cp -r "$subdir" "$dest_dir/" - copied=$((copied + 1)) - break - fi - done - fi - done - if [ "$copied" -eq 0 ]; then - echo "Warning: No subdirectories found in '$source_dir' matching any provided substrings." - fi -fi - -echo "Copy operation completed." diff --git a/generate4.cmd b/generate4.cmd index c62b04c8..2f0febaf 100644 --- a/generate4.cmd +++ b/generate4.cmd @@ -37,42 +37,6 @@ call :msg "GSL_EXE : !GSL_EXE!" call :msg "GITHUB_PATH : !GITHUB_PATH!" call :msg_heading "End Execution context" -!GSL_EXE! -q -script:"!CD!\gsl.copy_properties.cmd" "!CD!\generate4.xml" -if %ERRORLEVEL% neq 0 ( - call :msg_error "GSL execution failure." - exit /b 1 -) - -!GSL_EXE! -q -script:"!CD!\gsl.generate_artifacts.cmd" "!CD!\generate4.xml" -if %ERRORLEVEL% neq 0 ( - call :msg_error "GSL execution failure." - exit /b 1 -) - -if not exist "!CD!\copy_properties.cmd" ( - call :msg_error "Error: 'copy_properties.cmd' not found in '!CD!'." - exit /b 1 -) - -call :msg "Execute copy_properties.cmd..." -call "!CD!\copy_properties.cmd" -if %ERRORLEVEL% neq 0 ( - call :msg_error "Failure calling 'copy_properties.cmd'." - exit /b 1 -) - -if not exist "!CD!\generate_artifacts.cmd" ( - call :msg_error "Error: 'generate_artifacts.cmd' not found in '!CD!'." - exit /b 1 -) - -call :msg "Execute generate_artifacts.cmd..." -call "!CD!\generate_artifacts.cmd" -if %ERRORLEVEL% neq 0 ( - call :msg_error "Failure calling 'generate_artifacts.cmd'." - exit /b 1 -) - if not exist "!CD!\generate.cmd" ( call :msg_error "Error: 'generate.cmd' not found in '!CD!'." exit /b 1 @@ -90,18 +54,6 @@ if %ERRORLEVEL% neq 0 ( exit /b 1 ) -if not exist "!CD!\copy_projects.cmd" ( - call :msg_error "Error: 'copy_projects.cmd' not found in '!CD!'." - exit /b 1 -) - -call :msg "Execute copy_projects.cmd..." -call "!CD!\copy_projects.cmd" %* -if %ERRORLEVEL% neq 0 ( - call :msg_error "Failure calling 'copy_projects.cmd'." - exit /b 1 -) - REM Restore directory. popd call :msg_success "Script execution completed successfully." diff --git a/generate4.sh b/generate4.sh index 60a1870d..281de426 100755 --- a/generate4.sh +++ b/generate4.sh @@ -29,23 +29,10 @@ main() # Clean directories for generated build artifacts. remove_directory_force "output" - # 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 - - # Make property copiers and artifact generators executable. - msg_verbose "Modifying properties of shell scripts." - eval chmod +x copy_properties.sh - # Execute property copiers and artifact generators. - msg "Execute copy_properties.sh..." - eval ./copy_properties.sh msg "Execute generate.sh..." eval ./generate.sh version4.xml - msg "Execute copy_projects.sh..." - eval ./copy_projects.sh "$@" - pop_directory msg_success "Script execution completed successfully." } diff --git a/generate4.xml b/generate4.xml deleted file mode 100644 index a58b5d5c..00000000 --- a/generate4.xml +++ /dev/null @@ -1,953 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gsl.copy_modules.cmd b/gsl.copy_modules.cmd deleted file mode 100644 index c35456ee..00000000 --- a/gsl.copy_modules.cmd +++ /dev/null @@ -1,147 +0,0 @@ -.template 0 -############################################################################### -# Copyright (c) 2014-2026 libbitcoin developers (see COPYING). -# -# GSL generate copy_modules.cmd. -# -# This is a code generator built using the iMatix GSL code generation -# language. See https://github.com/imatix/gsl for details. -############################################################################### -# Function -############################################################################### - -function is_custom_module_find_dependency(dependency) - define my.dependency = is_custom_module_find_dependency.dependency - - return !(is_boost_dependency(my.dependency)\ - | is_boost_lib_dependency(my.dependency)\ - | is_java_dependency(my.dependency)\ - | is_python_dependency(my.dependency)\ - | is_pthread_dependency(my.dependency)\ - | is_iconv_dependency(my.dependency))\ - | is_package_dependency(my.dependency) -endfunction - -function get_find_cmake_name(dependency) - define my.dependency = get_find_cmake_name.dependency - return "Find$(my.dependency.name:neat).cmake" -endfunction - -############################################################################### -# Macros -############################################################################### -.endtemplate -.template 1 -. -.macro emit_initialize() - -REM Do everything relative to this file location. -pushd %~dp0 - -.endmacro # emit_initialize -. -.macro emit_repository_initialize(repository, path_prefix) -. define my.repository = emit_repository_initialize.repository -. define my.dest_path = make_windows_path(\ - "$(my.path_prefix)/$(my.repository.name)/builds/cmake/modules/") -. -call :pending "Seeding modules for $(my.repository.name)" -if not exist "$(my.dest_path)" call mkdir "$(my.dest_path)" -. emit_error_handler("Failed to create directory $(my.dest_path)") - -.endmacro # emit_repository_initialize -. -.macro emit_module_copy(repository, dependency, path_prefix) -. define my.repository = emit_module_copy.repository -. define my.dependency = emit_module_copy.dependency -. define my.src_path = make_windows_path(\ - "cmake/$(get_find_cmake_name(my.dependency))") -. define my.dest_path = make_windows_path(\ - "$(my.path_prefix)/$(my.repository.name)/builds/cmake/modules/") -. -call xcopy /y "$(my.src_path)" "$(my.dest_path)" -. emit_error_handler("Failed to copy $(my.src_path)") - -.endmacro # emit_module_copy -. -.macro emit_repository_completion_message(repository_name) -call :success "Completed population of $(my.repository_name) artifacts." - -.endmacro # emit_repository_completion_message -. -.macro emit_error_handler(message) -. define my.message = emit_error_handler.message -if %ERRORLEVEL% NEQ 0 ( - call :failure "$(my.message)" - call :cleanup - exit /b 1 -) -.endmacro # emit_error_handler -. -.macro emit_completion() -call :success "Successful duplication of modules to output directory." -exit /b 0 - -:cleanup -REM Restore directory. -popd - -.endmacro # emit_completion -. -.macro emit_lib_colorized_echos() -:pending -echo %~1 -exit /b 0 - -:success -echo %~1 -exit /b 0 - -:failure -echo %~1 -exit /b 0 -.endmacro # emit_lib_colorized_echos -. -.endtemplate -.template 0 -############################################################################### -# Generation -############################################################################### -function generate_copy_modules(path_prefix) - define out_file = "copy_modules.cmd" - notify(out_file) - output(out_file) - batch_no_echo() - bat_copyleft("libbitcoin-build") - - emit_initialize() - - for generate.repository by name as _repository - echo(" Evaluating repository: $(_repository.name)") - emit_repository_initialize(_repository, my.path_prefix) - for _repository->configure.dependency as _dependency\ - where is_custom_module_find_dependency(_dependency) - emit_module_copy(_repository, _dependency, my.path_prefix) - endfor - emit_repository_completion_message(_repository.name) - endfor - - emit_completion() - emit_lib_colorized_echos() -endfunction -############################################################################### -# Execution -############################################################################### -[global].root = ".." -[global].trace = 0 -[gsl].ignorecase = 0 - -# Note: expected context root libbitcoin-build directory -gsl from "library/math.gsl" -gsl from "library/string.gsl" -gsl from "library/collections.gsl" -gsl from "utilities.gsl" - -generate_copy_modules("output") - -.endtemplate diff --git a/gsl.copy_modules.sh b/gsl.copy_modules.sh deleted file mode 100644 index 2f40ea04..00000000 --- a/gsl.copy_modules.sh +++ /dev/null @@ -1,130 +0,0 @@ -.template 0 -############################################################################### -# Copyright (c) 2014-2026 libbitcoin developers (see COPYING). -# -# GSL generate copy_modules.sh. -# -# This is a code generator built using the iMatix GSL code generation -# language. See https://github.com/imatix/gsl for details. -############################################################################### -# Function -############################################################################### - -function is_custom_module_find_dependency(dependency) - define my.dependency = is_custom_module_find_dependency.dependency - - return !(is_boost_dependency(my.dependency)\ - | is_boost_lib_dependency(my.dependency)\ - | is_java_dependency(my.dependency)\ - | is_python_dependency(my.dependency)\ - | is_pthread_dependency(my.dependency)\ - | is_iconv_dependency(my.dependency))\ - | is_package_dependency(my.dependency) -endfunction - -function get_find_cmake_name(dependency) - define my.dependency = get_find_cmake_name.dependency - return "Find$(my.dependency.name:neat).cmake" -endfunction - -############################################################################### -# Macros -############################################################################### -.endtemplate -.template 1 -. -.macro emit_initialize() - -# Exit this script on the first build error. -set -e - -# Do everything relative to this file location. -cd \$(dirname "$0") - -.endmacro # emit_initialize -. -.macro emit_repository_initialize(repository, path_prefix) -. define my.repository = emit_repository_initialize.repository -. -print_pending "Seeding modules for $(my.repository.name)" -mkdir -p $(my.path_prefix)/$(my.repository.name)/builds/cmake/modules/ -. -.endmacro # emit_repository_initialize -. -.macro emit_module_copy(repository, dependency, path_prefix) -. define my.repository = emit_module_copy.repository -. define my.dependency = emit_module_copy.dependency -. -eval cp -f cmake/$(get_find_cmake_name(my.dependency)) $(my.path_prefix)/$(my.repository.name)/builds/cmake/modules/ -.endmacro # emit_module_copy -. -.macro emit_repository_completion_message(repository_name) -print_success "Completed population of $(my.repository_name) artifacts." - -.endmacro # emit_repository_completion_message -. -.macro emit_completion() -print_success "Successful duplication of modules to output directory." - -.endmacro # emit_completion -. -.macro emit_lib_colorized_echos() - -print_pending() -{ - local YELLOW_COLOR="" - local DEFAULT_COLOR="" - printf "$YELLOW_COLOR%b$DEFAULT_COLOR\\n" "$1"; -} - -print_success() -{ - local GREEN_COLOR="" - local DEFAULT_COLOR="" - printf "$GREEN_COLOR%b$DEFAULT_COLOR\\n" "$1"; -} -.endmacro # emit_lib_colorized_echos -. -.endtemplate -.template 0 -############################################################################### -# Generation -############################################################################### -function generate_copy_modules(path_prefix) - define out_file = "copy_modules.sh" - notify(out_file) - output(out_file) - shebang("bash") - copyleft("libbitcoin-build") - - emit_lib_colorized_echos() - emit_initialize() - - for generate.repository by name as _repository - echo(" Evaluating repository: $(_repository.name)") - emit_repository_initialize(_repository, my.path_prefix) - for _repository->configure.dependency as _dependency\ - where is_custom_module_find_dependency(_dependency) - emit_module_copy(_repository, _dependency, my.path_prefix) - endfor - emit_repository_completion_message(_repository.name) - endfor - - emit_completion() -endfunction -############################################################################### -# Execution -############################################################################### -[global].root = ".." -[global].trace = 0 -[gsl].ignorecase = 0 - -# Note: expected context root libbitcoin-build directory -gsl from "library/math.gsl" -gsl from "library/string.gsl" -gsl from "library/collections.gsl" -gsl from "utilities.gsl" - -generate_copy_modules("output") - -.endtemplate diff --git a/gsl.copy_properties.cmd b/gsl.copy_properties.cmd deleted file mode 100644 index 4c571855..00000000 --- a/gsl.copy_properties.cmd +++ /dev/null @@ -1,163 +0,0 @@ -.template 0 -############################################################################### -# Copyright (c) 2014-2026 libbitcoin developers (see COPYING). -# -# GSL generate copy_properties.cmd. -# -# This is a code generator built using the iMatix GSL code generation -# language. See https://github.com/imatix/gsl for details. -############################################################################### -# Macros -############################################################################### -.endtemplate -.template 1 -. -.macro emit_initialize() - -REM Do everything relative to this file location. -pushd %~dp0 - -.endmacro emit_initialize -. -.macro emit_import_copy_project(repository, source, output, import_name, vs_version) -. define my.repository = emit_import_copy_project.repository -. define my.msvc_path = "$(my.output)\\$(canonical_path_name(my.repository))\\builds\\msvc\\$(my.vs_version)" -if not exist "$(my.msvc_path)" call mkdir "$(my.msvc_path)" -. emit_error_handler("Failed to create directory.") - -call :pending "Seeding imports $(my.msvc_path)" -call xcopy /y "props\\$(my.source)\\import\\$(my.import_name).import.*" $(my.msvc_path) -. emit_error_handler("Failed to copy import files.") - -.endmacro emit_import_copy_project -. -.macro emit_import_copy(vs, repository, output, import_name) -. define my.vs = emit_import_copy.vs -. define my.repository = emit_import_copy.repository -REM Copy $(my.import_name) imports for $(my.repository.name) -. for my.vs.version as _version -. emit_import_copy_project(my.repository, my.vs.path, my.output, my.import_name, "$(_version.value)") -. endfor -. define my.msvc_path = "$(my.output)\\$(canonical_path_name(my.repository))\\builds\\msvc" -if not exist "$(my.msvc_path)\\build\\" call mkdir "$(my.msvc_path)\\build\\" -. emit_error_handler("Failed to create build directory.") -call xcopy /y "props\\$(my.vs.path)\\nuget.config" "$(my.msvc_path)" -. emit_error_handler("Failed to copy nuget.config.") - -call xcopy /y "props\\$(my.vs.path)\\build\\build_base.bat" "$(my.msvc_path)\\build\\" -. emit_error_handler("Failed to copy build_base.bat.") - -.endmacro -. -.macro emit_project_props_copy_project(repository, source, output, vs_version) -. define my.repository = emit_project_props_copy_project.repository -. define my.msvc_path = "$(my.output)\\$(canonical_path_name(my.repository))\\builds\\msvc\\$(my.vs_version)" -call :pending "Seeding props $(my.msvc_path)" -call xcopy /s /y "props\\$(my.source)\\project\\$(my.repository.name)\\*" $(my.msvc_path) -. emit_error_handler("Failed to copy import files.") - -.endmacro -. -.macro emit_project_props_copy(vs, repository, output) -. define my.vs = emit_project_props_copy.vs -. define my.repository = emit_project_props_copy.repository -REM Copy project props for $(my.repository.name) -. for my.vs.version as _version -. emit_project_props_copy_project(my.repository, my.vs.path, my.output, _version.value) -. endfor # _version -.endmacro -. -.macro emit_repository_completion_message(repository) -. my.repository = emit_repository_completion_message.repository -call :success "Completed population of $(my.repository.name) artifacts." -.endmacro emit_repository_completion_message -. -.macro emit_error_handler(message) -. define my.message = emit_error_handler.message -if %ERRORLEVEL% NEQ 0 ( - call :failure "$(my.message)" - call :cleanup - exit /b 1 -) -.endmacro emit_error_handler -. -.macro emit_completion() -call :success "Successful duplication of imports/props to output directory." -exit /b 0 - -:cleanup -REM Restore directory. -popd - -.endmacro emit_completion -. -.macro emit_lib_colorized_echos() -:pending -echo %~1 -exit /b 0 - -:success -echo %~1 -exit /b 0 - -:failure -echo %~1 -exit /b 0 -.endmacro emit_lib_colorized_echos -. -.endtemplate -.template 0 -############################################################################### -# Generation -############################################################################### -function generate_artifacts(path_prefix) - define out_file = "copy_properties.cmd" - notify(out_file) - output(out_file) - batch_no_echo() - bat_copyleft("libbitcoin-build") - - emit_initialize() - - for generate.repository by name as _repository - echo(" Evaluating repository: $(_repository.name)") - new configure as _dependencies - cumulative_dependencies(_dependencies, generate, _repository) - - for _dependencies.dependency as _dependency where\ - (count(generate.repository,\ - (count->package.library = _dependency.name)) > 0) - - define my.match = generate->repository(\ - repository->package.library = _dependency.name) - - emit_import_copy(generate->vs, _repository, my.path_prefix, my.match.name) - endfor - endnew - - emit_import_copy(generate->vs, _repository, my.path_prefix, _repository.name) - - emit_project_props_copy(generate->vs, _repository, my.path_prefix) - - emit_repository_completion_message(_repository) - endfor - - emit_completion() - emit_lib_colorized_echos() -endfunction -############################################################################### -# Execution -############################################################################### -[global].root = ".." -[global].trace = 0 -[gsl].ignorecase = 0 - -# Note: expected context root libbitcoin-build directory -gsl from "library/math.gsl" -gsl from "library/string.gsl" -gsl from "library/collections.gsl" -gsl from "utilities.gsl" - -generate_artifacts("output") - -.endtemplate diff --git a/gsl.copy_properties.sh b/gsl.copy_properties.sh deleted file mode 100755 index 0b3a6c8c..00000000 --- a/gsl.copy_properties.sh +++ /dev/null @@ -1,123 +0,0 @@ -.template 0 -############################################################################### -# Copyright (c) 2014-2026 libbitcoin developers (see COPYING). -# -# GSL generate copy_properties.sh. -# -# This is a code generator built using the iMatix GSL code generation -# language. See https://github.com/imatix/gsl for details. -############################################################################### -# Macros -############################################################################### -.endtemplate -.template 1 -. -.macro emit_initialize(vs) -. define my.vs = emit_initialize.vs - -# Exit this script on the first build error. -set -e - -# Do everything relative to this file location. -cd `dirname "$0"` - -declare -a vs_version=( \\ -. for my.vs.version as _version - "$(_version.value)" \\ -. endfor - ) - -.endmacro -. -.macro emit_import_copy(repository, source, output, import_name) -. define my.repository = emit_import_copy.repository -. -for version in "\${vs_version[@]}" -do - mkdir -p $(my.output)/$(canonical_path_name(my.repository))/builds/msvc/\$version/ - eval cp -f props/$(my.source)/import/$(my.import_name).import.* $(my.output)/$(canonical_path_name(my.repository))/builds/msvc/\$version/ -done - -.endmacro -. -.macro emit_project_props_copy(repository, source, output) -. define my.repository = emit_project_props_copy.repository -. -for version in "\${vs_version[@]}" -do - mkdir -p $(my.output)/$(canonical_path_name(my.repository))/builds/msvc/\$version/ - eval cp -rf props/$(my.source)/project/$(my.repository.name)/* $(my.output)/$(canonical_path_name(my.repository))/builds/msvc/\$version/ -done - -mkdir -p $(my.output)/$(canonical_path_name(my.repository))/builds/msvc/build/ -eval cp -rf props/$(my.source)/nuget.config $(my.output)/$(canonical_path_name(my.repository))/builds/msvc/ -eval cp -rf props/$(my.source)/build/build_base.bat $(my.output)/$(canonical_path_name(my.repository))/builds/msvc/build/ - -.endmacro -. -.macro emit_cumulative_dependencies(repositories, repository, dependencies) -. define my.repositories = emit_cumulative_dependencies.repositories -. define my.repository = emit_cumulative_dependencies.repository -. define my.dependencies = emit_cumulative_dependencies.dependencies -. - << project: $(_repository.name) >> -. for my.dependencies.dependency as _dependency where\ - (count(my.repositories.repository, (count->package.library = _dependency.name)) > 0) -. define my.match = my.repositories->repository(repository->package.library = _dependency.name) - << name: $(_dependency.name) repo_name: $(my.match.name) >> -. endfor - <> -.endmacro -. -.endtemplate -.template 0 -############################################################################### -# Generation -############################################################################### -function generate_artifacts(path_prefix) - define out_file = "copy_properties.sh" - notify(out_file) - output(out_file) - shebang("bash") - copyleft("libbitcoin-build") - - emit_initialize(generate->vs) - - for generate.repository by name as _repository - echo(" Evaluating repository: $(_repository.name)") - new configure as _dependencies - cumulative_dependencies(_dependencies, generate, _repository) - - for _dependencies.dependency as _dependency where\ - (count(generate.repository,\ - (count->package.library = _dependency.name)) > 0) - - define my.match = generate->repository(\ - repository->package.library = _dependency.name) - - emit_import_copy(_repository, generate->vs.path, my.path_prefix, my.match.name) - endfor - endnew - - emit_import_copy(_repository, generate->vs.path, my.path_prefix, _repository.name) - - emit_project_props_copy(_repository, generate->vs.path, my.path_prefix) - endfor - -endfunction -############################################################################### -# Execution -############################################################################### -[global].root = ".." -[global].trace = 0 -[gsl].ignorecase = 0 - -# Note: expected context root libbitcoin-build directory -gsl from "library/math.gsl" -gsl from "library/string.gsl" -gsl from "library/collections.gsl" -gsl from "utilities.gsl" - -generate_artifacts("output") - -.endtemplate diff --git a/gsl.generate_artifacts.cmd b/gsl.generate_artifacts.cmd deleted file mode 100644 index 12dd596a..00000000 --- a/gsl.generate_artifacts.cmd +++ /dev/null @@ -1,59 +0,0 @@ -.template 0 -############################################################################### -# Copyright (c) 2014-2026 libbitcoin developers (see COPYING). -# -# GSL generate generate_artifacts.cmd. -# -# This is a code generator built using the iMatix GSL code generation -# language. See https://github.com/imatix/gsl for details. -############################################################################### -# Generation -############################################################################### -.endtemplate -.template 1 -.macro generate_artifact() -. define out_file = "generate_artifacts.cmd" -. notify(out_file) -. output(out_file) -. batch_no_echo() -. bat_copyleft("libbitcoin-build") - -REM Do everything relative to this file location. -pushd %~dp0 - -REM Generate build artifacts. -. for generate->templates.template as _template -gsl -q -script:templates\\$(_template.name) $(generate->templates.source) -if %errorlevel% neq 0 goto error - -. endfor - -echo --- OKAY, generation completed. -goto end - -:error -echo *** ERROR, generation terminated early. - -:end -REM Restore directory. -popd - -.endmacro generate_artifact -.endtemplate -.template 0 -############################################################################### -# Execution -############################################################################### -[global].root = ".." -[global].trace = 0 -[gsl].ignorecase = 0 - -# Note: expected context root libbitcoin-build directory -gsl from "library/math.gsl" -gsl from "library/string.gsl" -gsl from "library/collections.gsl" -gsl from "utilities.gsl" - -generate_artifact() - -.endtemplate diff --git a/gsl.generate_artifacts.sh b/gsl.generate_artifacts.sh deleted file mode 100755 index 66ebcea7..00000000 --- a/gsl.generate_artifacts.sh +++ /dev/null @@ -1,60 +0,0 @@ -.template 0 -############################################################################### -# Copyright (c) 2014-2026 libbitcoin developers (see COPYING). -# -# GSL generate generate_artifacts.sh. -# -# This is a code generator built using the iMatix GSL code generation -# language. See https://github.com/imatix/gsl for details. -############################################################################### -# Generation -############################################################################### -.endtemplate -.template 1 -.macro generate_artifacts() -. define out_file = "generate_artifacts.sh" -. notify(out_file) -. output(out_file) -. shebang("bash") -. copyleft("libbitcoin-build") - -# Exit this script on the first build error. -set -e - -# Do everything relative to this file location. -cd `dirname "$0"` - -declare -a generator=( \\ -. for generate->templates.template as _template - "$(_template.name)" \\ -. endfor - ) - -# Generate build artifacts. -for generate in "\${generator[@]}" -do - gsl -q -script:templates/\$generate $(generate->templates.source) -done - -# Make generated scripts executable. -eval chmod +x "output/*/*.sh" - -.endmacro generate_artifacts -.endtemplate -.template 0 -############################################################################### -# Execution -############################################################################### -[global].root = ".." -[global].trace = 0 -[gsl].ignorecase = 0 - -# Note: expected context root libbitcoin-build directory -gsl from "library/math.gsl" -gsl from "library/string.gsl" -gsl from "library/collections.gsl" -gsl from "utilities.gsl" - -generate_artifacts() - -.endtemplate diff --git a/lib/xml.gsl b/lib/xml.gsl index c2e8ad95..2bc29065 100644 --- a/lib/xml.gsl +++ b/lib/xml.gsl @@ -279,6 +279,28 @@ function global.target_dependency_list(result, target, repository, configuration endfor endfunction +function global.populate_cumulative_repository_dependencies(result, repository, configuration) + define my.result = populate_cumulative_repository_dependencies.result + define my.repository = populate_cumulative_repository_dependencies.repository + define my.configuration = populate_cumulative_repository_dependencies.configuration + + for my.repository. as _target where is_target_element(_target) + for _target.dependency as _depend where \ + defined(my.configuration->repository(this.name = _depend.name, this)) + + if !defined(my.result->dependency(this.name = _depend.name, this)) + copy _depend to my.result + + define my.deprepo = my.configuration->repository(\ + this.name = _depend.name, this) + + populate_cumulative_repository_dependencies(\ + my.result, my.deprepo, my.configuration) + endif + endfor + endfor +endfunction + function global.canonical_dependency_list(result, repository, configuration) define my.result = canonical_dependency_list.result define my.repository = canonical_dependency_list.repository diff --git a/process/copy_statics.cmd.gsl b/process/copy_statics.cmd.gsl index 8c2d6a87..08dcc27a 100644 --- a/process/copy_statics.cmd.gsl +++ b/process/copy_statics.cmd.gsl @@ -6,6 +6,17 @@ # # This is a code generator built using the iMatix GSL code generation # language. See https://github.com/imatix/gsl for details. +############################################################################### +[global].root = ".." +[global].trace = 0 +[gsl].ignorecase = 0 +[gsl].shuffle = 0 + +# Note expected context root libbitcoin-build directory +gsl from "lib/output.gsl" +gsl from "lib/cmd-output.gsl" +gsl from "process/copy_statics.gsl" + ############################################################################### # Generation ############################################################################### @@ -29,13 +40,15 @@ if not exist "%RESULT_DIR%" ( . define path_suffix = "..\\" . define index = 0 . for configuration.repository as _repository -. for configuration->templates.template as _template -. for _template.file as _file +. new files as _files +. get_files(_files, _repository, configuration) +. +. for _files.file as _file . index = index + 1 -set "SOURCE[$(index)]=$(path_suffix)$(path(_file.SOURCE))" -set "DESTINATION[$(index)]=%RESULT_DIR%\\$(_repository.name)\\$(path(_file.DESTINATION))" +set "SOURCE[$(index)]=$(path_suffix)$(path(_file.source))" +set "DESTINATION[$(index)]=%RESULT_DIR%\\$(_repository.name)\\$(path(_file.destination))" . endfor -. endfor +. endnew . endfor set "LENGTH=$(index)" @@ -90,14 +103,6 @@ exit /b 0 ############################################################################### # Execution ############################################################################### -[global].root = ".." -[global].trace = 0 -[gsl].ignorecase = 0 - -# Note: expected context root libbitcoin-build directory -gsl from "lib/output.gsl" -gsl from "lib/cmd-output.gsl" -gsl from "library/string.gsl" generate_copy_script() diff --git a/process/copy_statics.gsl b/process/copy_statics.gsl new file mode 100644 index 00000000..8fe85d85 --- /dev/null +++ b/process/copy_statics.gsl @@ -0,0 +1,147 @@ +.template 0 +############################################################################### +# Copyright (c) 2014-2026 libbitcoin developers (see COPYING). +# +# GSL generate copy_statics shared library +# +# This is a code generator built using the iMatix GSL code generation +# language. See https://github.com/imatix/gsl for details. +############################################################################### +[global].root = ".." +[global].trace = 0 +[gsl].ignorecase = 0 +[gsl].shuffle = 0 + +# Note: expected context root libbitcoin-build directory +gsl from "library/string.gsl" +gsl from "lib/xml.gsl" +gsl from "lib/msbuild.gsl" + +############################################################################## +# Functions +############################################################################### +function get_base_files(result, configuration) + define my.result = get_base_files.result + define my.configuration = get_base_files.configuration + + for my.configuration->templates.template as _template + for _template.file as _file + copy _file to my.result + endfor + endfor +endfunction + +function get_files(result, repository, configuration) + define my.result = get_files.result + define my.repository = get_files.repository + define my.configuration = get_files.configuration + + get_base_files(my.result, my.configuration) + expand_repository(my.result, my.repository, my.configuration) + expand_repository_dependency(my.result, my.repository, my.configuration) + expand_target(my.result, my.repository, my.configuration) +endfunction + +function token_substitute(expression, token, value) + define my.expression = token_substitute.expression + define my.token = token_substitute.token + define my.value = token_substitute.value + + if is_token(my.token, my.expression) + return string.replace(my.expression, "$(my.token)|$(my.value)") + endif + + return my.expression +endfunction + +function expand_repository(result, repository, configuration) + define my.result = expand_repository.result + define my.repository = expand_repository.repository + define my.configuration = expand_repository.configuration + + for my.result.file as _file + _file.source = token_substitute(_file.source, "%repository%", my.repository.name) + _file.destination = token_substitute(_file.destination, "%repository%", \ + my.repository.name) + endfor +endfunction + +function expand_repository_dependency(result, repository, configuration) + define my.result = expand_repository_dependency.result + define my.repository = expand_repository_dependency.repository + define my.configuration = expand_repository_dependency.configuration + + new cumulative_repository_dependencies as _cumulative + populate_cumulative_repository_dependencies(_cumulative, _repository, configuration) + + for my.result.file as _file + if !(is_token("%repository_dependency%", _file.source) | \ + is_token("%repository_dependency%", _file.destination)) + + copy _file to _cumulative + delete _file + next + endif + + for _cumulative.dependency as _depend + copy _file to _cumulative + define _mutation = _cumulative->file((this.source = _file.source) & \ + (this.destination = _file.destination), this) + + _mutation.source = token_substitute(_file.source, \ + "%repository_dependency%", _depend.name) + + _mutation.destintion = token_substitute(_file.destination, \ + "%repository_dependency%", _depend.name) + endfor + + delete _file + endfor + + for _cumulative.file as _file + copy _file to my.result + endfor + delete _cumulative + endnew +endfunction + +function expand_target(result, repository, configuration) + define my.result = expand_target.result + define my.repository = expand_target.repository + define my.configuration = expand_target.configuration + + new temporary as _temp + for my.result.file as _file + if !(is_token("%target%", _file.source) | \ + is_token("%target%", _file.destination)) + + copy _file to _temp + delete _file + next + endif + + for my.repository. as _target where is_target_element(_target) + define my.name = target_name(_target) + + copy _file to _temp + define _mutation = _temp->file((this.source = _file.source) & \ + (this.destination = _file.destination), this) + + _mutation.source = token_substitute(_file.source, \ + "%target%", my.name) + + _mutation.destination = token_substitute(_file.destination, \ + "%target%", my.name) + endfor + + delete _file + endfor + + for _temp.file as _file + copy _file to my.result + endfor + delete _temp + endnew +endfunction + +.endtemplate diff --git a/process/copy_statics.sh.gsl b/process/copy_statics.sh.gsl index 8d476fe1..22906789 100644 --- a/process/copy_statics.sh.gsl +++ b/process/copy_statics.sh.gsl @@ -6,6 +6,17 @@ # # This is a code generator built using the iMatix GSL code generation # language. See https://github.com/imatix/gsl for details. +############################################################################### +[global].root = ".." +[global].trace = 0 +[gsl].ignorecase = 0 +[gsl].shuffle = 0 + +# Note: expected context root libbitcoin-build directory +gsl from "lib/output.gsl" +gsl from "lib/sh-output.gsl" +gsl from "process/copy_statics.gsl" + ############################################################################### # Generation ############################################################################### @@ -27,24 +38,28 @@ result_dir="$(configuration->templates.resultpath)" # Check if source directory exists if [ ! -d "$result_dir" ]; then - echo "Error: result directory '${reuslt_dir}' does not exist." + echo "Error: result directory '${result_dir}' does not exist." exit 1 fi -. + . for configuration.repository as _repository -. for configuration->templates.template as _template -. for _template.file as _file -mkdir -p ${result_dir}/$(_repository.name)/$(_file.destination) -. endfor -. endfor -. endfor +echo "'$(_repository.name)' file population..." +. new files as _files +. get_files(_files, _repository, configuration) . -. for configuration.repository as _repository -. for configuration->templates.template as _template -. for _template.file as _file +. for _files.file as _file +. if !defined(_files->encountered(this.path = _file.destination, this)) +. new _files.encountered as _encountered +. _encountered.path = _file.destination +. endnew + +mkdir -p ${result_dir}/$(_repository.name)/$(_file.destination) +. endif cp $(path_suffix)$(_file.source) ${result_dir}/$(_repository.name)/$(_file.destination) . endfor -. endfor +. endnew +echo "'$(_repository.name)' file population complete." + . endfor . .endmacro # generate_copy_script @@ -53,14 +68,6 @@ cp $(path_suffix)$(_file.source) ${result_dir}/$(_repository.name)/$(_file.desti ############################################################################### # Execution ############################################################################### -[global].root = ".." -[global].trace = 0 -[gsl].ignorecase = 0 - -# Note: expected context root libbitcoin-build directory -gsl from "lib/output.gsl" -gsl from "lib/sh-output.gsl" -gsl from "library/string.gsl" generate_copy_script() diff --git a/utilities.gsl b/utilities.gsl deleted file mode 100644 index dad397d8..00000000 --- a/utilities.gsl +++ /dev/null @@ -1,922 +0,0 @@ -.template 0 -############################################################################### -# Copyright (c) 2014-2026 libbitcoin developers (see COPYING). -# -# GSL libbitcoin 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 -############################################################################### - -#------------------------------------------------------------------------------ -# Node utilities. -#------------------------------------------------------------------------------ - -function global.match_name(element, name) - define my.element = match_name.element - require(my.element, "element", "name") - return my.element.name = my.name -endfunction - -function global.is_optional_element(element) - define my.element = is_optional_element.element - return defined(my.element.option) -endfunction - -function global.is_private_element(element) - define my.element = is_private_element.element - return is_true(my.element.private) -endfunction - -#------------------------------------------------------------------------------ -# Collection utilities. -#------------------------------------------------------------------------------ - -function global.set_cursor_begin(element) - define my.element = set_cursor_begin.element - for my.element as _element - new cursor as _cursor - move _cursor to _element - return _cursor - endnew - endfor - return set_cursor_end(my.element) -endfunction - -# We insert before a dummy element (cursor) at the end of the element. -# This provides a simple workaround for lack of reverse iteration in GSL, -# allowing order preservation and insertion at the end of the list. -# Fortunately extending a list while iterating it does not alter the iteration. -function global.set_cursor_end(element) - define my.element = set_cursor_end.element - new cursor as _cursor - move _cursor to my.element - return _cursor - endnew -endfunction - -function global.clear_cursor(cursor) - define my.cursor = clear_cursor.cursor - delete my.cursor -endfunction - -#------------------------------------------------------------------------------ -# I/O utilities. -#------------------------------------------------------------------------------ - -# Open and validate a directory. -function global.create_directory(folder) - define my.result = directory.create(my.folder) - if (my.result = 0) - return - endif - abort "Directory creation failure: $(error_text)" -endfunction - -# Open and validate a directory. -function global.open_directory(folder) - define my.directory = directory.open(my.folder, error_text)? - if (defined(my.directory)) - return my.directory - endif - abort "Directory open failure: $(error_text)" -endfunction - -# Test a directory and return the normalized path. -function global.normalize_directory(folder) - define my.directory = open_directory(my.folder) - return my.directory.path -endfunction - -function global.append_path(base, subdir) - if (!is_empty(my.base)) - if (!ends_with(my.base, "/") & !ends_with(my.base, "\\")) - return "$(my.base)/$(my.subdir)" - else - return "$(my.base)$(my.subdir)" - endif - endif - return "$(my.subdir)" -endfunction - -function global.make_windows_path(path) - return string.replace(my.path, "/|\\") -endfunction - -function global.make_prefix(path) - return string.replace(my.path, "/|_") -endfunction - -#------------------------------------------------------------------------------ -# Library utilities. -#------------------------------------------------------------------------------ - -function global.join_flags_name(container) - define my.container = join_flags_name.container - define my.result = "" - for my.container.flag as _flag where defined(_flag.name) & !is_empty(_flag.name) - my.result = join(my.result, "-$(_flag.name)", " ") - endfor - return my.result -endfunction - -function global.join_flags_value(container) - define my.container = join_flags_value.container - define my.result = "" - for my.container.flag as _flag where defined(_flag.value) & !is_empty(_flag.value) - my.result = join(my.result, "$(_flag.value)", " ") - endfor - return my.result -endfunction - -function global.canonical_path_name(repository) - define my.repository = canonical_path_name.repository - return defined(my.repository.path) ?? my.repository.path ?\ - my.repository.name -endfunction - -# Get the product with the given library name. -function global.find_library_product(name, make, repository) - define my.make = find_library_product.make - define my.repository = find_library_product.repository - define my.product_name = "lib$(my.name)" - return my.make->product(is_library(product) &\ - target_name(product, my.repository) = my.product_name) -endfunction - -# Accepts [lib]bitcoin[-include] and returns include. -function global.bitcoin_to_include(library) - define my.prefix = "bitcoin" - define my.libprefix = "lib$(my.prefix)" - if (my.library = my.prefix) | (my.library = my.libprefix) - return my.prefix - endif - my.prefix += "-" - if (starts_with(my.library, my.prefix)) - return difference(my.library, string.length(my.prefix)) - endif - my.libprefix += "-" - if (starts_with(my.library, my.libprefix)) - return difference(my.library, string.length(my.libprefix)) - endif - abort "The name is not a bitcoin library: $(my.library)" -endfunction - -# Accepts include and returns bitcoin[-include]. -function global.include_to_bitcoin(include) - define my.prefix = "bitcoin" - if (my.include = my.prefix) - return my.include - endif - return "$(my.prefix)-$(my.include)" -endfunction - -#------------------------------------------------------------------------------ -# Dependency utilities. -#------------------------------------------------------------------------------ - -# Get the dependency with the given name. -function global.find_dependency_by_name(name, configure) - define my.configure = find_dependency_by_name.configure - return my.configure->dependency(match_name(dependency, my.name)) -endfunction - -function global.is_function_dependency(dependency) - define my.dependency = is_function_dependency.dependency - return defined(my.dependency.function) -endfunction - -function global.is_package_dependency(dependency) - define my.dependency = is_package_dependency.dependency - return defined(my.dependency.version) &\ - !is_boost_dependency(my.dependency) &\ - !is_boost_lib_dependency(my.dependency) &\ - !is_python_dependency(my.dependency) -endfunction - -function global.is_boost_dependency(dependency) - define my.dependency = is_boost_dependency.dependency - return match_name(my.dependency, "boost") -endfunction - -function global.is_boost_lib_dependency(dependency) - define my.dependency = is_boost_lib_dependency.dependency - require(my.dependency, "dependency", "name") - return starts_with(my.dependency.name, "boost_") -endfunction - -function global.is_mbedtls_dependency(dependency) - define my.dependency = is_mbedtls_dependency.dependency - return match_name(my.dependency, "mbedtls") -endfunction - -function global.is_java_dependency(dependency) - define my.dependency = is_java_dependency.dependency - return match_name(my.dependency, "java") -endfunction - -function global.is_python_dependency(dependency) - define my.dependency = is_python_dependency.dependency - return match_name(my.dependency, "python") -endfunction - -function global.is_pthread_dependency(dependency) - define my.dependency = is_pthread_dependency.dependency - return match_name(my.dependency, "pthread") -endfunction - -function global.is_iconv_dependency(dependency) - define my.dependency = is_iconv_dependency.dependency - return match_name(my.dependency, "iconv") -endfunction - -function global.is_bitcoin_dependency(dependency) - define my.dependency = is_bitcoin_dependency.dependency - require(my.dependency, "dependency", "name") - return starts_with(my.dependency.name, "bitcoin") -endfunction - -function global.has_m4(dependency) - define my.dependency = has_m4.dependency - return !defined(my.dependency.m4) |\ - (defined(my.dependency.m4) & !(my.dependency.m4 = "none")) -endfunction - -# Test for a flag context. -function global.match_flag_context(flag, context) - define my.flag = match_flag_context.flag? - return (my.flag.context ? "") = my.context -endfunction - -# Test flag context value. -function global.is_ccc_flag(flag) - define my.flag = is_ccc_flag.flag? - return match_flag_context(my.flag, "c") -endfunction -function global.is_cxx_flag(flag) - define my.flag = is_cxx_flag.flag? - return match_flag_context(my.flag, "c++") -endfunction -function global.is_cpp_flag(flag) - define my.flag = is_cpp_flag.flag? - return match_flag_context(my.flag, "") |\ - match_flag_context(my.flag, "preprocessor") -endfunction -function global.is_link_flag(flag) - define my.flag = is_link_flag.flag? - return match_flag_context(my.flag, "link") -endfunction - -# Return CPPFLAGS|CFLAGS|CXXFLAGS|LDFLAGS -function get_flags_variable(flag) - define my.flag = get_flags_variable.flag - if (is_cpp_flag(my.flag)) - return "CPPFLAGS" - elsif (is_ccc_flag(my.flag)) - return "CFLAGS" - elsif (is_cxx_flag(my.flag)) - return "CXXFLAGS" - elsif (is_link_flag(my.flag)) - return "LDFLAGS" - endif - define my.context = my.flag.context ? "" - abort "Invalid flag context: '$(my.context)'." -endfunction - -#------------------------------------------------------------------------------ -# Option utilities. -#------------------------------------------------------------------------------ - -function global.get_option_symbol_generic(option, seperator, cstyle) - define my.option = get_option_symbol_generic.option - if (defined(my.option)) - require(my.option, "option", "type") - require(my.option, "option", "name") - define my.prefix = "" - define my.name = "$(my.option.name:lower)" - define my.type = "$(my.option.type:lower)" - - if (is_true(my.cstyle)) - my.name = "$(my.option.name:c)" - my.type = "$(my.option.type:c)" - endif - - if (!is_true(my.option.unprefixed)) - my.prefix = "$(my.type)$(my.seperator)" - endif - return "$(my.prefix)$(my.name)" - endif -endfunction - -function global.get_option_symbol(option) - define my.option = get_option_symbol.option - return get_option_symbol_generic(my.option, "_", "true") -endfunction - -function global.find_option_symbol_generic(element, configure, seperator, cstyle) - define my.element = find_option_symbol_generic.element - define my.configure = find_option_symbol_generic.configure - if (is_optional_element(my.element)) - define my.opt = my.configure->option(option.name = my.element.option)? - if (defined(my.opt)) - return get_option_symbol_generic(my.opt, my.seperator, my.cstyle) - endif - abort "Symbol not defined for option: $(my.element.option)" - endif -endfunction - -function global.find_option_symbol(element, configure) - define my.element = find_option_symbol.element - define my.configure = find_option_symbol.configure - return find_option_symbol_generic(my.element, my.configure, "_", "true") -endfunction - -#------------------------------------------------------------------------------ -# Matrix utilities. -#------------------------------------------------------------------------------ - -function global.is_coverage_job(job) - define my.job = is_coverage_job.job - return defined(my.job) & my.job.system = "linux" & my.job.compiler = "gcc" &\ - my.job.link = "static" & is_true(my.job.coverage) -endfunction - -function global.count_matrix_coverage_job(matrix) - define my.matrix = count_matrix_coverage_job.matrix? - if (defined(my.matrix)) - return count(my.matrix->job(system = "linux" & compiler = "gcc" &\ - link = "static" & is_true(coverage))) - endif -endfunction - -#------------------------------------------------------------------------------ -# Job utilities. -#------------------------------------------------------------------------------ - -# Get the value part of a standard form (e.g. "--prefix=value") job option. -function global.job_option(job, option) - define my.job = job_option.job - define my.assigner = "--$(my.option)=" - define my.option = my.job->option(starts_with(option.value, my.assigner))? - if defined(my.option) - return difference(my.option.value, string.length(my.assigner)) - endif -endfunction - -#------------------------------------------------------------------------------ -# Build utilities. -#------------------------------------------------------------------------------ - -function global.cumulative_dependencies(list, repositories, repository) - define my.list = cumulative_dependencies.list - define my.repositories = cumulative_dependencies.repositories - define my.repository = cumulative_dependencies.repository - - for my.repository->configure.dependency as _dependency - for my.repositories.repository as _repository - if (!(_repository.name = my.repository.name) &\ - (_repository->package.library = _dependency.name)) - new configure as _deps - cumulative_dependencies(_deps, my.repositories, _repository) - - for _deps.dependency as _subdep - if (count(my.list.dependency,\ - (count.name = _subdep.name)) = 0) - copy _subdep to my.list - endif - endfor - endnew - endif - endfor - - if (defined(my.list->dependency(name = _dependency.name))) - delete my.list->dependency(name = _dependency.name) - endif - - copy _dependency to my.list - endfor -endfunction - -function global.cumulative_install(list, repositories, repository) - define my.list = cumulative_install.list - define my.repositories = cumulative_install.repositories - define my.repository = cumulative_install.repository - - for my.repository->install.build as _build - for my.repositories.repository as _repository - if (!(_repository.name = my.repository.name) &\ - (_repository->package.library = _build.name)) - new install as _dep_steps - cumulative_install(_dep_steps, my.repositories, _repository) - - for _dep_steps.build as _step - if (count(my.list.build, (count.name = _step.name)) = 0) - copy _step to my.list - endif - endfor - endnew - endif - endfor - - if (defined(my.list->build(name = _build.name))) - delete my.list->build(name = _build.name) - endif - - copy _build to my.list - endfor -endfunction - -function global.have_build(install, name) - define my.install = have_build.install - return defined(my.install->build(starts_with(build.name, my.name))) -endfunction - -function global.is_icu_build(build) - define my.build = is_icu_build.build - return starts_with(my.build.name, "icu") -endfunction - -function global.is_zmq_build(build) - define my.build = is_zmq_build.build - return starts_with(my.build.name, "zmq") -endfunction - -function global.is_mbedtls_build(build) - define my.build = is_mbedtls_build.build - return starts_with(my.build.name, "mbedtls") -endfunction - -function global.is_boost_build(build) - define my.build = is_boost_build.build - return my.build.name = "boost" -endfunction - -function global.is_github_build(build) - define my.build = is_github_build.build - return !is_empty(my.build.github) -endfunction - -#------------------------------------------------------------------------------ -# Product utilities. -#------------------------------------------------------------------------------ - -function global.match_prefix(product, prefix) - define my.product = match_prefix.product - require(my.product, "product", "prefix") - return my.product.prefix = my.prefix -endfunction - -# Test prefix for primary type (this is a simplified mapping). -function global.is_data(product) - define my.product = is_data.product - return match_prefix(my.product, "bash_completion") |\ - match_prefix(my.product, "doc") |\ - match_prefix(my.product, "pkgconfig") |\ - match_prefix(my.product, "jarexec") |\ - match_prefix(my.product, "sysconf") -endfunction -function global.is_headers(product) - define my.product = is_headers.product - return match_prefix(my.product, "include") -endfunction -function global.is_info(product) - define my.product = is_info.product - return match_prefix(my.product, "info") -endfunction -function global.is_java(product) - define my.product = is_java.product - return match_prefix(my.product, "javaexec") -endfunction -function global.is_jar(product) - define my.product = is_jar.product - # jar uses DATA but we wire it up as a product. - return match_prefix(my.product, "jarexec") -endfunction -function global.is_library(product) - define my.product = is_library.product - return match_prefix(my.product, "lib") |\ - match_prefix(my.product, "pkgpyexec") -endfunction -function global.is_manual(product) - define my.product = is_manual.product - return match_prefix(my.product, "man") -endfunction -function global.is_program(product) - define my.product = is_program.product - return match_prefix(my.product, "bin") -endfunction -function global.is_python(product) - define my.product = is_python.product - return match_prefix(my.product, "pkgpython") -endfunction -function global.is_script(product) - define my.product = is_script.product - return match_prefix(my.product, "sbin") -endfunction - -function global.is_bitcoin_headers(product) - define my.product = is_bitcoin_headers.product - return is_headers(my.product) & ((my.product.container ? "") = "bitcoin") -endfunction - -# Is the product allowed to be active only once? -function global.is_singleton(product) - define my.product = is_singleton.product - return is_java(my.product) | is_jar(my.product) -endfunction - -# Does the product assign to the CLEANFILES variable. -function global.is_clean_files(product) - define my.product = is_clean_files.product - return is_java(my.product) | is_jar(my.product) -endfunction - -# Is the product built from c/c++? -function global.is_cpp(product) - define my.product = is_cpp.product - return is_program(my.product) | is_library(my.product) -endfunction - -# Is the product executable? -function global.is_executable(product) - define my.product = is_executable.product - return is_program(my.product) | is_script(my.product) -endfunction - -# Is the product compiled? -function global.is_compiled(product) - define my.product = is_compiled.product - return is_cpp(my.product) | is_java(my.product) -endfunction - -# Is the non-compiled product explicitly set to distribute? -function global.is_distribute(product) - define my.product = is_distribute.product - return defined(my.product.distribute) & is_true(my.product.distribute) -endfunction - -# Is the non-compiled product explicitly set to not distribute? -function global.is_no_distribute(product) - define my.product = is_no_distribute.product - return defined(my.product.distribute) & !is_true(my.product.distribute) -endfunction - -# Is the product explicitly set to not install? -function global.is_no_install(product) - define my.product = is_no_install.product - return defined(my.product.install) & !is_true(my.product.install) -endfunction - -# Is the product a test executable? -function global.is_test(product) - define my.product = is_test.product - if (!is_true(my.product.test) | is_executable(my.product)) - return is_true(my.product.test) - endif - abort "Tests must be executable: '$(my.product.prefix)'" -endfunction - -# Is the product a check target. -function global.is_not_covered(product) - define my.product = is_not_covered.product - return (is_test(my.product) | is_no_install(my.product)) &\ - is_cpp(my.product) -endfunction - -# Is the product a check target. -function global.is_check(product) - define my.product = is_check.product - return is_true(my.product.check) | is_test(my.product) -endfunction - -# Is the product a custom target. -function global.is_custom_target(product) - define my.product = is_custom_target.product - return is_optional_element(my.product) & !is_test(my.product) -endfunction - -# Is the path extension that of a c/c++ interface implementation file. -function global.is_cpp_implementation_file(path) - return ends_with(my.path, ".ipp") -endfunction - -# Is the path extension that of a c/c++ header file. -function global.is_cpp_header_file(path, use_implementation) - return ends_with(my.path, ".hpp") | ends_with(my.path, ".h") |\ - ((my.use_implementation ? 0) & is_cpp_implementation_file(my.path)) -endfunction - -# Is the path extension that of a c/c++ source file. -function global.is_cpp_source_file(path) - return ends_with(my.path, ".cpp") | ends_with(my.path, ".c") -endfunction - -# Does the file extension conform to the required prefix pattern? -function global.is_product_file(product, path, use_implementation) - define my.product = is_product_file.product - require(my.product, "product", "prefix") - - # doc expects no type and bash_completion and manual have no extension. - if (is_data(my.product)) - if (match_prefix(my.product, "bash_completion")) - return ends_with(my.path, "") - elsif (match_prefix(my.product, "doc")) - return ends_with(my.path, "") - elsif (match_prefix(my.product, "pkgconfig")) - return ends_with(my.path, ".pc") - elsif (match_prefix(my.product, "sysconf")) - return ends_with(my.path, ".cfg") - endif - elsif (is_cpp(my.product)) - return is_cpp_source_file(my.path) |\ - is_cpp_header_file(my.path, my.use_implementation) - elsif (is_headers(my.product)) - return is_cpp_header_file(my.path, my.use_implementation) - elsif (is_info(my.product)) - return ends_with(my.path, ".texi") - elsif (is_java(my.product)) - return ends_with(my.path, ".java") - elsif (is_manual(my.product)) - return ends_with(my.path, "") - elsif (is_python(my.product)) - return ends_with(my.path, ".py") - elsif (is_script(my.product)) - return ends_with(my.path, ".sh") - endif - abort "Unknown product type for prefix: '$(my.product.prefix)'" -endfunction - -# Get the relative files in the directory. -function global.get_product_files(files, folder, trim, product,\ - use_implementation) - define my.files = get_product_files.files - define my.product = get_product_files.product - define my.directory = open_directory(my.folder) - for my.directory.file as _file by _file.name\ - where is_product_file(my.product, _file.name, my.use_implementation) - define my.path = "$(_file.path)$(_file.name)" - define my.relative = difference(my.path, my.trim) - table_add(my.files, my.relative, "") - endfor -endfunction - -# Get the relative files in the directory hierarchy. -function global.get_all_product_files(files, folder, trim, product) - define my.files = get_all_product_files.files - define my.product = get_all_product_files.product - get_product_files(my.files, my.folder, my.trim, my.product, 1) - define my.directory = open_directory(my.folder) - for my.directory.directory as _directory by _directory.name - define my.subfolder = "$(_directory.path)$(_directory.name)" - get_all_product_files(my.files, my.subfolder, my.trim, my.product) - endfor -endfunction - -function global.get_files(files, directory, relative_path, tag, recurse,\ - ignore_hidden_dirs, ignore_hidden_files) - define my.files = get_files.files - define my.directory = get_files.directory - - if (!defined(my.recurse)) - abort("get_files: specify 'recurse' parameter") - endif - - if (!defined(my.ignore_hidden_dirs)) - abort("get_files: specify 'ignore_hidden_dirs' parameter") - endif - - if (!defined(my.ignore_hidden_files)) - abort("get_files: specify 'ignore_hidden_files' parameter") - endif - - for my.directory.file as _file by _file.name - if (!(is_true(my.ignore_hidden_files) & starts_with(_file.name, "."))) - new my.files.file as _element - _element.name = _file.name - _element.full_path = _file.path - _element.relative_path = my.relative_path - _element.relative_name = append_path(my.relative_path, _file.name) - _element.tag = my.tag - endnew - endif - endfor - - if (is_true(my.recurse)) - for my.directory.directory as _directory by _directory.name - define my.subdir_path = append_path(my.directory.path,\ - _directory.name) - define my.subdir = open_directory(my.subdir_path) - define my.sub_relative_path = append_path(my.relative_path,\ - _directory.name) - define my.sub_tag = append_path(my.tag, _directory.name) - - if (!(is_true(my.ignore_hidden_dirs) &\ - starts_with(_directory.name, "."))) - - get_files(my.files, my.subdir, my.sub_relative_path,\ - my.sub_tag, my.recurse, my.ignore_hidden_dirs,\ - my.ignore_hidden_files) - endif - endfor - endif -endfunction - -function global.has_uuid(product) - define my.product = has_uuid.product - return defined(my.product.uuid) & !is_empty(my.product.uuid) -endfunction - -function global.target_name(product, repository) - define my.product = target_name.product - define my.repository = target_name.repository - require(my.repository, "repository", "name") - - if (defined(my.product.target_name)) - return "$(my.product.target_name)" - elsif (defined(my.product.option)) - return "$(my.repository.name)-$(my.product.option)" - else - return "$(my.repository.name)" - endif -endfunction - -function global.project_name(product, repository) - define my.product = project_name.product - define my.repository = project_name.repository - - if (defined(my.product.project_name)) - return "$(my.product.project_name)" - else - return target_name(my.product, my.repository) - endif -endfunction - -#------------------------------------------------------------------------------ -# Package utilities. -#------------------------------------------------------------------------------ - -function global.get_package_name(package) - define my.package = get_package_name.package - require(my.package, "package", "library") - return "lib$(my.package.library)" -endfunction - -#------------------------------------------------------------------------------ -# Debugging utilities. -#------------------------------------------------------------------------------ - -function global.notify(filename) - echo "Generating $(my.filename)..." -endfunction - -function global.require(node, context, attribute) - if (!defined(require.node)) - abort "Required node undefined for $(my.context).$(my.attribute)." - endif - define my.node = require.node - if (!defined(my.node.$(my.attribute))) - abort "Required attribute missing: $(my.context).$(my.attribute)" - endif -endfunction - -function global.trace1(text) - trace(my.text, 1) -endfunction - -function global.trace2(text) - trace(my.text, 2) -endfunction - -function global.trace3(text) - trace(my.text, 3) -endfunction - -function global.trace(text, context) - if ((global.trace ? 0) = my.context ? 1) - echo defined(my.text) ?? "---> $(my.text)" ? "undefined trace" - endif -endfunction - -function global.shebang(interpreter) - write_line("#!/bin/$(my.interpreter)") -endfunction - -function global.batch_no_echo() - write_line("@echo off") -endfunction - -# Write one include. -function global.write_include(path) - write_line("#include <$(my.path)>") -endfunction - -#------------------------------------------------------------------------------ -# Version utilities. -#------------------------------------------------------------------------------ - -function split_version(version, version_string) - define my.version = split_version.version - - define my.position = string.locate(my.version_string, ".") - define my.version.major = left(my.version_string, my.position) - - define my.remainder = string.substr(my.version_string, my.position + 1) - define my.position = string.locate(my.remainder, ".") - define my.version.minor = left(my.remainder, my.position) - - define my.version.patch = string.substr(my.remainder, my.position + 1) -endfunction - -#------------------------------------------------------------------------------ -# CMake utilities. -#------------------------------------------------------------------------------ - -function calculate_presets(result, repository, presets) - define my.result = calculate_presets.result - define my.repository = calculate_presets.repository - define my.presets = calculate_presets.presets - - for my.repository->presets.configuration as _configuration - if (count(my.presets.configuration, count.name = _configuration.name) = 1) - copy my.presets->configuration(name = _configuration.name) to my.result - else - abort "Preset $(_configuration.name) absent from registry." - endif - endfor -endfunction - -############################################################################### -# Macros -############################################################################### -.endtemplate -.template 1 -. -.# Write a line to the template. -.macro global.write_line(text) -$(my.text ? "") -.endmacro -. -.# Write a single indented line to the template. -.macro global.write_line1(text) - $(my.text ? "") -.endmacro -. -.# Write a double indented line to the template. -.macro global.write_line2(text) - $(my.text ? "") -.endmacro -. -.macro global.heading1(text) - -# $(my.text) -#============================================================================== -.endmacro -. -.macro global.heading2(text) -# $(my.text) -#------------------------------------------------------------------------------ -.endmacro -. -.macro global.heading3(text) -# $(my.text) -.endmacro -. -.macro global.copyleft(name) -############################################################################### -# Copyright (c) 2014-2026 $(my.name) developers (see COPYING). -# -# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY -# -############################################################################### -.endmacro -. -.macro global.c_copyleft(name) -/////////////////////////////////////////////////////////////////////////////// -// Copyright (c) 2014-2026 $(my.name) developers (see COPYING). -// -// GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY -// -/////////////////////////////////////////////////////////////////////////////// -.endmacro -. -.macro global.bat_copyleft(name) -REM ########################################################################### -REM # Copyright (c) 2014-2026 $(my.name) developers (see COPYING). -REM # -REM # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY -REM # -REM ########################################################################### -.endmacro -. -.macro global.xml_copyleft(name) - -.endmacro -. -.endtemplate diff --git a/version4.xml b/version4.xml index f9964139..7150d08e 100644 --- a/version4.xml +++ b/version4.xml @@ -2492,12 +2492,11 @@ g and optimizations for size." hidden="false" display="*nix/GNU/Release/Static/S + +