forked from zeromq/zproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zproject_projects.gsl
229 lines (204 loc) · 8.68 KB
/
zproject_projects.gsl
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# Resolve standard CLASS projects
#
# This is a code generator built using the iMatix GSL code generation
# language. See https://github.com/zeromq/gsl for details.
#
# Copyright (c) the Contributors as noted in the AUTHORS file.
# This file is part of zproject.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
function resolve_project_dependency (use)
my.known_projects = XML.load_file ("zproject_known_projects.xml")
# Use known values to fill in gaps if it is a known project
for my.known_projects.use as known where known.project = my.use.project
my.use.repository ?= known.repository?
my.use.test ?= known.test?
my.use.header ?= known.header?
my.use.prefix ?= known.prefix?
my.use.linkname ?= known.linkname?
my.use.libname ?= known.libname?
my.use.pkgconfig ?= known.pkgconfig?
my.use.release ?= known.release?
my.use.draft ?= known.draft?
my.use.debian_name ?= known.debian_name?
my.use.brew_name ?= known.brew_name?
# The spec_name is only transitional - I assume it wasn't widely used
# maybe trigger a warning if used?
my.use.redhat_name ?= known.spec_name?
my.use.redhat_name ?= known.redhat_name?
my.use.min_major ?= known.min_major?
my.use.min_minor ?= known.min_minor?
my.use.min_patch ?= known.min_patch?
my.use.min_version ?= known.min_version?
my.use.max_major ?= known.max_major?
my.use.max_minor ?= known.max_minor?
my.use.max_patch ?= known.max_patch?
my.use.max_version ?= known.max_version?
my.use.next_incompatible_major ?= known.next_incompatible_major?
my.use.next_incompatible_minor ?= known.next_incompatible_minor?
my.use.next_incompatible_patch ?= known.next_incompatible_patch?
my.use.next_incompatible_version ?= known.next_incompatible_version?
# Copy known implied dependencies into this dependency
for known.use as implied_use
if !count (my.use.use, use.project = implied_use.project)
move implied_use to my.use as use
endif
endfor
# Copy known alternate pkg-config metadata and library link-names
# to help search for the dependencies
for known.pkgconfig as implied_pkgconfig
if !count (my.use.pkgconfig, pkgconfig = implied_pkgconfig)
move implied_pkgconfig to my.use as pkgconfig
endif
endfor
for known.linkname as implied_linkname
if !count (my.use.linkname, linkname = implied_linkname)
move implied_linkname to my.use as linkname
endif
endfor
# Copy known additional CONFIG_OPTS
for known.add_config_opts as implied_add_config_opts
if !count (my.use.add_config_opts, add_config_opts = implied_add_config_opts)
move implied_add_config_opts to my.use as add_config_opts
endif
endfor
endfor
# Use reasonable fallback values to fill in any remaining gaps
my.use.prefix ?= my.use.project
my.use.linkname ?= my.use.prefix
my.use.header ?= my.use.prefix + ".h"
my.use.libname ?= my.use.project
my.use.pkgconfig ?= my.use.libname
my.use.am_lib_macro ?= my.use.libname
my.use.optional ?= 0
my.use.implied ?= 0
my.use.private ?= 0
my.use.draft ?= 0
my.use.min_major ?= 0
my.use.min_minor ?= 0
my.use.min_patch ?= 0
# The "use" tags may also define a "max_version" (<= comparison)
# and/or "next_incompatible_version" (< comparison) explicitly
# or using the major/minor/patch scheme named values to bump
# partial version values compared to respective "min" fields.
# If not set, these limits are empty and so are not considered.
# If both are set, they all apply by common mathematics rules:
# "version >= min && <= max && < next" - so ensure the numbers
# make sense.
# For values with no reasonable fallback, print error
if !defined (my.use.test)
echo "Project $(my.use.project) needs a 'test' attribute"
endif
# Calculate all non-model values from model values (defaults
# to "0.0.0" if not set in project.xml:
if !defined(my.use.min_version)
my.use.min_version = "$(min_major).$(min_minor).$(min_patch)"
endif
# Note: Logic below would produce a bump in only one field, if one is
# passed, e.g. when min == "3.0.2" and next_incompatible_major == "4"
# then the next_incompatible := "4.0.2" (4.0.0 might be more reasonable
# but spelling out the comparisons below would be complicated - TODO
# later, when someone steps on this as a practical problem); same for max.
if !defined(my.use.max_version)
if defined(my.use.max_major) | defined(my.use.max_minor) | defined(my.use.max_patch)
my.use.max_major ?= my.use.min_major
my.use.max_minor ?= my.use.min_minor
my.use.max_patch ?= my.use.min_patch
my.use.max_version = "$(max_major).$(max_minor).$(max_patch)"
endif
endif
if !defined(my.use.next_incompatible_version)
if defined(my.use.next_incompatible_major) | defined(my.use.next_incompatible_minor) | defined(my.use.next_incompatible_patch)
my.use.next_incompatible_major ?= my.use.min_major
my.use.next_incompatible_minor ?= my.use.min_minor
my.use.next_incompatible_patch ?= my.use.min_patch
my.use.next_incompatible_version = "$(next_incompatible_major).$(next_incompatible_minor).$(next_incompatible_patch)"
endif
endif
# Copy all dependencies implied by this one into the project
for my.use.use as implied_use
if !count (project.use, use.project = implied_use.project)
move implied_use before my.use as use
implied_use.implied = "1"
resolve_project_dependency (implied_use)
else
echo "[WARNING] Ignoring implied use definition '$(implied_use.project)' at '$(my.use.project)' because there is a non-implied definition."
endif
endfor
endfunction
function resolve_scope (item)
if my.item.private ?= 1
my.item.scope = "private"
else
my.item.scope = "public"
endif
endfunction
project.has_czmq = 0
for use
resolve_project_dependency (use)
if use.prefix = "czmq"
project.has_czmq = 1
endif
endfor
for main
resolve_scope (main)
endfor
if count (actor) > 0 & project.has_czmq = 0
abort "E: Cannot use actors without czmq dependency"
endif
if !defined(project.unique_class_name)
# TODO: A sane default would be "1" to enforce this check
# However some projects are known to really use classes named
# same as project and do somehow survive, so enforcing this
# check right now would break them. So we'll issue warnings
# for now and enable it in a year or so :)
#project.unique_class_name = 1
project.unique_class_name = 0
endif
for actor
actor.selftest ?= 1
new class to project
class.name = actor.name
class.private = actor.private?
class.description = actor.description?
class.selftest = actor.selftest
if defined(actor.state)
class.state = actor.state
endif
endnew
resolve_scope (actor)
if actor.name ?= project.name
if project.unique_class_name ?= 1
abort "E: actors should be named differently from the project itself; set project.unique_class_name=0 to let generate this project, or better yet - fix it"
else
echo "WARNING: actors should be named differently from the project itself; set project.unique_class_name=0 to let generate this project, or better yet - fix it"
endif
endif
endfor
for class
resolve_scope (class)
class.selftest ?= 1
if class.name ?= project.name
if project.unique_class_name ?= 1
abort "E: classes should be named differently from the project itself; set project.unique_class_name=0 to let generate this project, or better yet - fix it"
else
echo "WARNING: classes should be named differently from the project itself; set project.unique_class_name=0 to let generate this project, or better yet - fix it"
endif
endif
endfor
for constant
resolve_scope (constant)
endfor
for header
resolve_scope (header)
endfor
# All projects with classes contain a selftest main
if count (project.class)
new main to project
main.name = "$(prefix)_selftest"
main.test = 1
main.scope = "private"
endnew
endif