-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathgsl.copy_modules.sh
130 lines (113 loc) · 4.05 KB
/
gsl.copy_modules.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
.template 0
###############################################################################
# Copyright (c) 2014-2025 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="[93m"
local DEFAULT_COLOR="[0m"
printf "$YELLOW_COLOR%b$DEFAULT_COLOR\\n" "$1";
}
print_success()
{
local GREEN_COLOR="[92m"
local DEFAULT_COLOR="[0m"
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