-
Notifications
You must be signed in to change notification settings - Fork 25
/
gsl.copy_modules.cmd
147 lines (128 loc) · 4.47 KB
/
gsl.copy_modules.cmd
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
.template 0
###############################################################################
# Copyright (c) 2014-2023 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 [93m%~1[0m
exit /b 0
:success
echo [92m%~1[0m
exit /b 0
:failure
echo [91m%~1[0m
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