-
Notifications
You must be signed in to change notification settings - Fork 15
/
generate_readme
401 lines (306 loc) · 15 KB
/
generate_readme
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
#!/usr/bin/env bash
#########################################################################
#########################################################################
function get_version_git {
current_rev=$(git rev-parse HEAD)
if [[ "$(git show-ref --tags | fgrep $current_rev)" == *releases* ]]; then
git show-ref --tags | fgrep $current_rev | fgrep releases | cut -d '/' -f 3-4
elif [[ "$(git show-ref --heads | fgrep $current_rev)" == *stable* ]]; then
git show-ref --heads | fgrep $current_rev | fgrep stable | cut -d '/' -f 3-4
elif [ "$(git show-ref --heads | fgrep $current_rev)" != "" ]; then
git show-ref --heads | fgrep $current_rev | cut -d '/' -f 3
else
echo $current_rev
fi
}
#########################################################################
#########################################################################
function parse_yaml {
local yaml_file=$1
local prefix=
local s
local w
local fs
s='[[:space:]]*'
w='[a-zA-Z0-9_.-]*'
fs="$(echo @|tr @ '\034')"
(
sed -e '/- [^\“]'"[^\']"'.*: /s|\([ ]*\)- \([[:space:]]*\)|\1-\'$'\n'' \1\2|g' |
sed -ne '/^--/s|--||g; s|\"|\\\"|g; s/[[:space:]]*$//g;' \
-e "/#.*[\"\']/!s| #.*||g; /^#/s|#.*||g;" \
-e "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)${s}[:-]$s\(.*\)$s\$|\1$fs\2$fs\3|p" |
awk -F"$fs" '{
indent = length($1)/2;
if (length($2) == 0) { conj[indent]="+";} else {conj[indent]="";}
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
if (length($3) > 0) {
vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
printf("%s%s%s%s=(\"%s\")\n", "'"$prefix"'",vn, $2, conj[indent-1],$3);
}
}' |
sed -e 's/_=/+=/g' |
awk 'BEGIN {
FS="=";
OFS="="
}
/(-|\.).*=/ {
gsub("-|\\.", "_", $1)
}
{ print }'
) < "$yaml_file"
}
#########################################################################
#########################################################################
function create_variables {
local yaml_file="$1"
eval "$(parse_yaml "$yaml_file")"
lower_case=$(echo $Description_Slug | tr '[:upper:]' '[:lower:]')
case $Description_ShortName in
BiCePS)
Coinbrew_ShortName=Bcps
;;
*)
Coinbrew_ShortName=$Description_ShortName
;;
esac
if [ x"${COIN_VERSION_OVERRIDE-}" != x ];then
version=$COIN_VERSION_OVERRIDE
else
version=$(get_version_git)
fi
version_num=$(echo $version | cut -d '/' -f 2)
}
#########################################################################
#########################################################################
function make_header {
if [ $version = master ]; then
echo "# $Description_ShortName"
else
echo "# $Description_ShortName $version_num"
fi
echo "
[![A COIN-OR Project](https://coin-or.github.io/coin-or-badge.png)](https://www.coin-or.org)
Projects such as this one are maintained by a small group of volunteers under
the auspices of the non-profit [COIN-OR Foundation](https://www.coin-or.org)
and we need your help! Please consider [sponsoring our
activities](https://github.com/sponsors/coin-or) or [volunteering](mailto:volunteer@coin-or.org) to help!
[![Latest Release](https://img.shields.io/github/v/release/coin-or/$Description_Slug?sort=semver)](https://github.com/coin-or/$Description_Slug/releases)
_This file is auto-generated from [config.yml](.coin-or/config.yml) using the
[generate_readme](.coin-or/generate_readme) script.
To make changes, please edit [config.yml](.coin-or/config.yml) or the generation scripts
[here](.coin-or/generate_readme) and [here](https://github.com/coin-or/coinbrew/blob/master/scripts/generate_readme)._
"
}
#########################################################################
#########################################################################
function make_build_info {
echo "
$Description_ShortName is written in $Description_Language and is released as open source under the [$Description_License]($Description_LicenseURL).
It is distributed under the auspices of the [COIN-OR Foundation](https://www.coin-or.org).
The $Description_ShortName development site is https://github.com/coin-or/$Description_Slug.
## CITE
Code: [![DOI](https://zenodo.org/badge/$Description_Zenodo.svg)](https://zenodo.org/badge/latestdoi/$Description_Zenodo)
"
if [ x"${Description_PaperCite-}" != x ]; then
echo "Paper: $Description_PaperCite
"
fi
echo "## CURRENT BUILD STATUS
[![Windows Builds](https://github.com/coin-or/$Description_Slug/actions/workflows/windows-ci.yml/badge.svg?branch=$version)](https://github.com/coin-or/$Description_Slug/actions/workflows/windows-ci.yml?query=branch%3A$version)
[![Linux and MacOS Builds](https://github.com/coin-or/$Description_Slug/actions/workflows/linux-ci.yml/badge.svg?branch=$version)](https://github.com/coin-or/$Description_Slug/actions/workflows/linux-ci.yml?query=branch%3A$version)
## DOWNLOAD
What follows is a quick start guide for obtaining or building
$Description_ShortName on common platforms. More detailed information is
available [here](https://coin-or.github.io/user_introduction.html).
### Docker image
There is a Docker image that provides $Description_ShortName, as well as other projects
in the [COIN-OR Optimization
Suite](https://github.com/coin-or/COIN-OR-OptimizationSuite) [here](https://hub.docker.com/repository/docker/coinor/coin-or-optimization-suite)
### Binaries
For newer releases, binaries will be made available as assets attached to
releases in Github
[here](https://github.com/coin-or/$Description_Slug/releases). Older binaries
are archived as part of $Description_IncludedIn_Package
[here](https://www.coin-or.org/download/binary/$Description_IncludedIn_Package).
* *Linux* (see https://repology.org/project/coin-or-$lower_case/versions for a complete listing):
* arch:
\`\`\`
$ sudo pacman -S coin-or-$lower_case
\`\`\`
* Debian/Ubuntu:
\`\`\`
$ sudo apt-get install coinor-$lower_case coinor-lib$lower_case-dev
\`\`\`
* Fedora/Redhat/CentOS:
\`\`\`
$ sudo yum install coin-or-$Description_Slug coin-or-$Description_Slug-devel
\`\`\`
* freebsd:
\`\`\`
$ sudo pkg install math/$lower_case
\`\`\`
* linuxbrew:
\`\`\`
$ brew install $lower_case
\`\`\`
* *Windows*: The easiest way to get $Description_ShortName on Windows is to download an archive as described above.
* *Mac OS X*: The easiest way to get $Description_ShortName on Mac OS X is through [Homebrew](https://brew.sh).
\`\`\`
$ brew tap coin-or-tools/coinor
$ brew install coin-or-tools/coinor/$lower_case
\`\`\`
"
if [ "${1-}" != "no_conda" ]; then
echo "* *conda* (cross-platform, no Windows for now):
\`\`\`
$ conda install coin-or-$lower_case
\`\`\`
"
fi
echo "Due to license incompatibilities, pre-compiled binaries lack some
functionality. If binaries are not available for your platform for the latest
version and you would like to request them to be built and posted, feel free
to let us know on the mailing list.
### Source
Source code can be obtained either by
* Downloading a snapshot of the source code for the latest release version of $Description_ShortName from the
[releases](https://github.com/coin-or/$Description_Slug/releases) page,
* Cloning this repository from [Github](https://github.com/coin-or/$Description_Slug), or
* Using the [coinbrew](https://github.com/coin-or/coinbrew) script to get the project and all dependencies (recommended, see below).
### Dependencies
$Description_ShortName has a number of dependencies, which are detailed in
[config.yml](.coin-or/config.yml). Dependencies on other COIN-OR projects are
automatically downloaded when obtaining the source with \`coinbrew\`. For some
of the remaining third-party dependencies, automatic download scripts and
build wrappers are provided (and will also be automatically run for required
and recommended dependencies), while other libraries that are aeasy to obtain
must be installed using an appropriate package manager (or may come with your
OS by default).
## BUILDING from source
These quick start instructions assume you are in a bash shell.
### Using \`coinbrew\`
To download and build $Description_ShortName from source, execute the
following on the command line.
\`\`\`
wget https://raw.githubusercontent.com/coin-or/coinbrew/master/coinbrew
chmod u+x coinbrew
./coinbrew fetch $Coinbrew_ShortName@$version_num
./coinbrew build $Coinbrew_ShortName
\`\`\`
For more detailed instructions on coinbrew, see https://coin-or.github.io/coinbrew.
The \`coinbrew\` script will fetch the additional projects specified in the Dependencies section of [config.yml](.coin-or/config.yml).
### Without \`coinbrew\` (Expert users)
* Download the source code, e.g., by cloning the git repo https://github.com/coin-or/$Description_Slug
* Download and install the source code for the dependencies listed in [config.yml](.coin-or/config.yml)
* Build the code as follows (make sure to set PKG_CONFIG_PTH to install directory for dependencies).
\`\`\`
./configure -C
make
make test
make install
\`\`\`
"
}
#########################################################################
#########################################################################
function make_build_info_no_packages {
echo "
$Description_ShortName is written in $Description_Language and is released as open source under the [$Description_License]($Description_LicenseURL).
It is distributed under the auspices of the [COIN-OR Foundation](https://www.coin-or.org)
The $Description_ShortName development site is https://github.com/coin-or/$Description_Slug.
## CITE
Code: [![DOI](https://zenodo.org/badge/$Description_Zenodo.svg)](https://zenodo.org/badge/latestdoi/$Description_Zenodo)
"
if [ x"${Description_PaperCite-}" != x ]; then
echo "Paper: $Description_PaperCite
"
fi
echo "## CURRENT BUILD STATUS
[![Windows Builds](https://github.com/coin-or/$Description_Slug/actions/workflows/windows-ci.yml/badge.svg?branch=$version)](https://github.com/coin-or/$Description_Slug/actions/workflows/windows-ci.yml?query=branch%3A$version)
[![Linux and MacOS Builds](https://github.com/coin-or/$Description_Slug/actions/workflows/linux-ci.yml/badge.svg?branch=$version)](https://github.com/coin-or/$Description_Slug/actions/workflows/linux-ci.yml?query=branch%3A$version)
## DOWNLOAD
### Docker image
There is a Docker image that provides $Description_ShortName, as well as other projects
in the [COIN-OR Optimization
Suite](https://github.com/coin-or/COIN-OR-OptimizationSuite) [here](https://hub.docker.com/repository/docker/coinor/coin-or-optimization-suite)
### Binaries
For newer releases, binaries will be made available as assets attached to
releases in Github
[here](https://github.com/coin-or/$Description_Slug/releases). Older binaries
are archived as part of $Description_IncludedIn_Package
[here](https://www.coin-or.org/download/binary/$Description_IncludedIn_Package).
Due to license incompatibilities, pre-compiled binaries may lack some
functionality. If binaries are not available for your platform for the latest
version and you would like to request them to be built and posted, feel free
to let us know in the discussion formum.
### Source
Source code can be obtained either by
* Downloading a snapshot of the source code for the latest release version of $Description_ShortName from the
[releases](https://github.com/coin-or/$Description_Slug/releases) page.
* Cloning this repository from [Github](https://github.com/coin-or/$Description_Slug) or
* Using the [coinbrew](https://github.com/coin-or/coinbrew) script to get the project and all dependencies (recommended, see below).
Below is a quick start guide for building on common platforms. More detailed
build instructions are
[here](https://coin-or.github.io/user_introduction.html).
### Dependencies
$Description_ShortName has a number of dependencies, which are detailed in
[config.yml](.coin-or/config.yml). Dependencies on other COIN-OR projects are
automatically downloaded when obtaining the source with \`coinbrew\`. For some
of the remaining third-party dependencies, automatic download scripts and
build wrappers are provided (and will also be automatically run for required
and recommended dependencies), while other libraries that are aeasy to obtain
must be installed using an appropriate package manager (or may come with your
OS by default).
## BUILDING from source
The quick start assumes you are in a bash shell.
### Using \`coinbrew\`
To download and build $Description_ShortName from source, execute the
following on the command line.
\`\`\`
wget https://raw.githubusercontent.com/coin-or/coinbrew/master/coinbrew
chmod u+x coinbrew
./coinbrew fetch $Coinbrew_ShortName@$version_num
./coinbrew build $Coinbrew_ShortName
\`\`\`
For more detailed instructions on coinbrew, see https://coin-or.github.io/coinbrew.
The \`coinbrew\` script will fetch the additional projects specified in the Dependencies section of [config.yml](.coin-or/config.yml).
### Without \`coinbrew\` (Expert users)
* Download the source code, e.g., by cloning the git repo https://github.com/coin-or/$Description_Slug
* Download and install the source code for the dependencies listed in [config.yml](.coin-or/config.yml)
* Build the code as follows (make sure to set PKG_CONFIG_PTH to install directory for dependencies).
\`\`\`
./configure -C
make
make test
make install
\`\`\`
"
}
#########################################################################
#########################################################################
function make_doxygen_info {
echo "## Doxygen Documentation
If you have \`Doxygen\` available, you can build a HTML documentation by typing
\`make doxydoc\`
in the build directory. If $Description_ShortName was built via \`coinbrew\`, then the build
directory will be \`./build/$Description_Slug/$version_num\` by default. The doxygen documentation main file
is found at \`<build-dir>/doxydoc/html/index.html\`.
If you don't have \`doxygen\` installed locally, you can use also find the
documentation [here](http://coin-or.github.io/$Description_Slug/Doxygen).
"
}
#########################################################################
#########################################################################
function make_links {
echo "
## Project Links
* [Code of Conduct](https://www.coin-or.org/code-of-conduct/)
* [COIN-OR Web Site](http://www.coin-or.org/)
* [COIN-OR general discussion forum](https://github.com/orgs/coin-or/discussions)
* [$Description_ShortName Discussion forum](https://github.com/coin-or/$Description_Slug/discussions)
* [Report a bug](https://github.com/coin-or/$Description_Slug/issues/new)
* [Doxygen generated documentation](http://coin-or.github.io/$Description_Slug/Doxygen)
"
}