-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathgsl.copy_properties.cmd
163 lines (140 loc) · 5.44 KB
/
gsl.copy_properties.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
.template 0
###############################################################################
# Copyright (c) 2014-2025 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 [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_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