59
# Helper functions for building configurations
62
selOcamlDefault = orig: orig.ocamlPackages;
63
selOcaml400 = orig: orig.ocamlPackages_4_00_0;
64
selOcaml312 = orig: orig.ocamlPackages_3_12_1;
65
selOcaml311 = orig: orig.ocamlPackages_3_11_2;
66
selOcaml310 = orig: orig.ocamlPackages_3_10_0;
68
selCommonOcamlPkgs = ocamlPackages: with ocamlPackages; [
69
findlib menhir ocaml_sexplib
72
selMinimalOcamlPkgs = ocamlPackages: with ocamlPackages; [
76
selAllOcamlPkgs = ocamlPackages: with ocamlPackages; [
77
findlib menhir ocaml_sexplib ocaml_pcre pycaml
80
selCommonInputs = pkgs: [ pkgs.pkgconfig pkgs.pcre ];
82
selDefaultShell = pkgs: pkgs.stdenv.shell;
84
selPythonNone = pkgs: [];
85
selPythonDefault = pkgs: [ pkgs.python ];
86
selPython2 = pkgs: [ pkgs.python27 ];
87
selPython3 = pkgs: [ pkgs.python3 ];
89
# creates a configuration for a given python version
90
mkCfgPython = f: pkgs: with (f pkgs); {
91
inherit name pythons flags;
93
ocamls = selCommonOcamlPkgs pkgs.ocamlPackages ++ [ pkgs.ocamlPackages.pycaml ];
94
selOcaml = selOcamlDefault;
95
extras = selCommonInputs pkgs;
96
shell = selDefaultShell pkgs;
100
# creates a configuration for a given ocaml version
101
mkCfgOcaml = { name, selOcaml, flags }: pkgs: {
102
inherit flags selOcaml;
104
name = "ocaml-${name}";
105
pythons = selPythonDefault pkgs;
106
ocamls = selMinimalOcamlPkgs pkgs.ocamlPackages;
107
extras = selCommonInputs pkgs;
108
shell = selDefaultShell pkgs;
112
# creates a default configuration with additional flags
113
mkCfgDefault = { name, flags, extra ? {} }: pkgs: {
115
pythons = selPythonDefault pkgs;
116
ocamls = selAllOcamlPkgs pkgs.ocamlPackages;
117
selOcaml = selOcamlDefault;
118
extras = selCommonInputs pkgs;
119
shell = selDefaultShell pkgs;
123
# creates a minimal configuration with additional flags
124
mkCfgMinimal = { name, flags }: pkgs: {
128
selOcaml = selOcamlDefault;
130
shell = selDefaultShell pkgs;
134
# creates a configuration for the given ocaml packages
135
mkCfgPackage = { name, ocamls, flags }: pkgs: {
137
pythons = selPythonDefault pkgs;
138
ocamls = selMinimalOcamlPkgs pkgs.ocamlPackages ++ ocamls pkgs.ocamlPackages;
139
selOcaml = selOcamlDefault;
140
extras = selCommonInputs pkgs;
141
shell = selDefaultShell pkgs;
145
# build the project using the given shell
146
# it takes a minimal configuration, but then with all the
147
# libraries that trigger features of coccinelle to be enabled.
148
mkCfgShell = { name, selShell }: pkgs: {
150
pythons = selPythonDefault pkgs;
151
ocamls = selMinimalOcamlPkgs pkgs.ocamlPackages;
152
selOcaml = selOcamlDefault;
154
extras = [ pkgs.pcre ];
155
shell = selShell pkgs;
159
# creates a configuration with multiple ocaml versions: this gives
160
# conflicts. This is just a test to see whether our build system is
161
# not too much confused in this case. It seems at least that ocamlfind
162
# cannot be used in this setting.
165
selOcaml = pkgs: ocamlPkgSel: with (ocamlPkgSel pkgs); ocaml;
166
selPkgs = pkgs: ocamlPkgSel: with (ocamlPkgSel pkgs); [ menhir ];
170
ocamls = pkgs.lib.concatMap (selPkgs pkgs) sels;
171
selOcaml = selOcamlDefault;
173
extras = selCommonInputs pkgs ++ map (selOcaml pkgs) sels;
174
shell = selDefaultShell pkgs;
183
defaultCfg = mkCfgDefault { name = "default"; flags = []; };
184
debugCfg = mkCfgDefault { name = "debug"; flags = [ "--enable-release=no" ]; };
185
wrappersCfg = mkCfgDefault { name = "wrappers"; flags = [ "--enable-python" "--enable-ocaml" "--without-pkg-config" "--without-ocamlfind" ]; };
186
manyOcamlCfg = mkCfgManyOcaml [ selOcaml400 selOcaml312 selOcaml311 selOcaml310 ];
188
minimalCfgs = map mkCfgMinimal [
189
{ name = "minimal"; flags = []; }
190
{ name = "noocamlscripting"; flags = [ "--disable-ocaml" ]; }
193
# Several configurations testing different python versions.
194
# We exlicitly pass the "--enable-python" flag so that the
195
# build should fail if no suitable python can be detected.
198
( _ : { name = "no-python"; pythons = []; flags = []; })
201
name = "python2-local";
202
pythons = selPython2 pkgs;
203
flags = [ "--enable-python" "--disable-pycaml" ];
207
name = "python3-local";
208
pythons = selPython3 pkgs;
209
flags = [ "--enable-python" "--disable-pycaml" ];
213
name = "python3-global";
214
pythons = selPython3 pkgs;
215
flags = [ "--enable-python" ];
219
name = "python-nopkgconfig";
220
pythons = selPython2 pkgs;
221
flags = [ "--enable-python" "--without-pkg-config" ];
224
# disabled because this combination does not work in NixOS
226
# name = "many-pythons";
227
# pythons = selPython3 pkgs ++ selPython2 pkgs;
228
# flags = [ "--with-python=python3" ];
232
# Several configurations testing different OCaml versions.
233
# These versions ship with minimal global packages in order
234
# to thest the bundled packages with these ocaml versions.
235
ocamlCfgs = map mkCfgOcaml [
236
{ name = "400nat"; selOcaml = selOcaml400; flags = [ "--enable-release=yes" ]; }
237
{ name = "400byt"; selOcaml = selOcaml400; flags = []; }
238
{ name = "312"; selOcaml = selOcaml312; flags = []; }
239
{ name = "311"; selOcaml = selOcaml311; flags = [ "--enable-release=yes" ]; }
240
{ name = "310"; selOcaml = selOcaml310; flags = []; }
243
# Several configurations testing different available
245
pkgCfgs = map mkCfgPackage [
246
{ name = "pcre"; ocamls = ps: [ ps.ocaml_pcre ]; flags = [ "--enable-pcre-syntax" ]; }
247
{ name = "sexplib"; ocamls = ps: [ ps.ocaml_sexplib ]; flags = [ "--enable-sexplib" ]; }
248
{ name = "pycaml"; ocamls = ps: [ ps.pycaml ]; flags = [ "--enable-pycaml" ]; }
251
shellCfgs = map mkCfgShell [
252
{ name = "bash"; selShell = pkgs: "${pkgs.bash}/bin/bash"; }
253
{ name = "dash"; selShell = pkgs: "${pkgs.dash}/bin/dash"; }
254
{ name = "zsh"; selShell = pkgs: "${pkgs.zsh}/bin/zsh"; }
256
# the configure script is not compatible with tcsh
257
# { name = "tcsh"; selShell = pkgs: "${pkgs.tcsh}/bin/tcsh"; }
261
[ debugCfg manyOcamlCfg ]
263
++ ocamlCfgs ++ pythonCfgs
264
++ pkgCfgs ++ shellCfgs;
59
268
# Builds for specific configurations
89
303
make all 2> >(tee -a "$out/nix-support/make.log" >&2)
306
# changes the shell in some of the scripts to the configured one
308
echo "patching the shell in scripts to: ${cfg.shell}"
309
for script in configure scripts/spatch.sh.in scripts/genversion.sh \
310
setup/fake-subst.sh setup/fake-menhir.sh setup/fake-pdflatex.sh; do
311
substituteInPlace $script --replace '#! /bin/sh' '#! ${cfg.shell}'
314
} // cfg.extraAttrs);
93
316
build = mkBuild defaultCfg;
94
defaultCfg = pkgs: with pkgs; {
96
pythons = [ python3 ];
97
ocamls = with ocamlPackages; [
98
findlib menhir ocaml_sexplib ocaml_extlib ocaml_pcre pycaml
101
selOcaml = orig: orig.ocamlPackages;
317
altBuilds = map mkBuild altCfgs;
318
allBuilds = [ build ] ++ altBuilds;
320
# compile with ocaml profiling turned on and then running the
321
# test suite to collect results.
322
profileCfg = mkCfgDefault {
324
flags = [ "--enable-release=profile" ];
327
mkdir -p "$out/nix-support"
328
cp ocamlprof.dump "$out/ocamlprof.dump"
329
echo "file binary $out/ocamlprof.dump" >> "$out/nix-support/hydra-build-products"
106
# selects which version of ocaml and ocamlPackages to use in nixpkgs.
108
{ ocaml = pkgs.ocaml_3_12_1;
109
ocamlPackages = pkgs.ocamlPackages_3_12_1;
112
{ ocaml = pkgs.ocaml_3_10_0;
113
ocamlPackages = pkgs.ocamlPackages_3_10_0;
116
# builds an environment with the ocaml packages needed to build coccinelle
117
# the mkList function selects which additional packages to include
118
mkOcamlEnv = mkList: pkgs:
120
name = "cocci-ocamlenv";
121
paths = with pkgs.ocamlPackages; [ pkgs.ocaml findlib menhir ] ++ mkList pkgs.ocamlPackages;
124
# selections of ocaml libraries
125
libs_full = mkOcamlEnv (libs: with libs; [ ocaml_pcre ocaml_sexplib ocaml_extlib pycaml ]);
126
libs_rse = mkOcamlEnv (libs: with libs; [ ocaml_pcre ocaml_sexplib ocaml_extlib ]);
127
libs_se = mkOcamlEnv (libs: with libs; [ ocaml_sexplib ocaml_extlib ]);
128
libs_null = mkOcamlEnv (libs: []);
130
# different configurations of coccinelle builds based on different ocamls/available libraries
131
build = mkBuild { name = "coccinelle"; ocamlVer = selOcaml312; mkEnv = libs_full; inclPython = true; };
132
build_rse = mkBuild { name = "coccinelle_config1"; ocamlVer = selOcaml312; mkEnv = libs_rse; inclPython = true; };
133
build_se = mkBuild { name = "coccinelle_config2"; ocamlVer = selOcaml312; mkEnv = libs_se; inclPython = true; };
134
build_null_12 = mkBuild { name = "coccinelle_config3"; ocamlVer = selOcaml312; mkEnv = libs_null; inclPython = true; };
135
# build_null_10 = mkBuild { name = "coccinelle_config4"; ocamlVer = selOcaml310; mkEnv = libs_null; inclPython = true; };
136
build_null_12_np = mkBuild { name = "coccinelle_config5"; ocamlVer = selOcaml312; mkEnv = libs_null; inclPython = false; };
137
# build_null_10_np = mkBuild { name = "coccinelle_config6"; ocamlVer = selOcaml310; mkEnv = libs_null; inclPython = false; };
138
build_rse_np = mkBuild { name = "coccinelle_config7"; ocamlVer = selOcaml312; mkEnv = libs_rse; inclPython = false; };
333
profile = mkBuild profileCfg {};
202
396
} // args // { inherit name; });
204
mkReport = inputs: mkTask (pkgs: _: with pkgs; {
206
builds = map (i: i {}) inputs;
209
echo "collecting logs"
210
for build in $builds; do
211
echo "$build/nix-support/make.log"
212
cat "$build/nix-support/make.log"
215
echo "grepping OCaml warnings"
216
if grep -2 "Warning " "$TMPDIR/result.log"
218
echo "found warnings!"
221
echo "there are apparently no significant warnings"
226
description = "Analysis of the coccinelle build reports";
227
schedulingPriority = 5;
231
report = mkReport [ build ];
232
# build_rse build_se build_null_12 build_null_12_np build_rse_np
398
mkReport = inputs: mkTask (pkgs: _: with pkgs;
399
let builds = map (i: i { inherit (pkgs.stdenv) system; }) inputs; in {
403
echo "collecting logs"
404
for build in ${lib.concatStringsSep " " builds}; do
405
echo "log: $build/nix-support/make.log"
406
cat "$build/nix-support/make.log"
409
echo "grepping OCaml warnings"
410
if grep -2 "Warning " "$TMPDIR/result.log"
412
echo "found warnings!"
415
echo "there are apparently no significant warnings"
420
description = "Analysis of the coccinelle build reports";
421
schedulingPriority = 5;
425
report = mkReport allBuilds;
252
445
# as this directory contains large
253
446
# files, we'll create links to the
254
447
# individual files.
255
ensureDir "$TMPDIR/tests"
448
mkdir -p "$TMPDIR/tests"
256
449
cp -rs ${testsSrc}/* "$TMPDIR/tests/"
257
450
chmod -R u+w "$TMPDIR/tests/"
258
451
cd "$TMPDIR/tests"
260
453
# initialize essential environment variables
261
454
# for the makefile
455
export COCCINELLE_HOME=${coccinelle}/share/coccinelle
262
456
export COCCIDIR=$TMPDIR
263
457
export SPATCH=${coccinelle}/bin/spatch.opt
264
458
export ISO=${coccinelle}/share/coccinelle/standard.iso
265
459
export DEFS=${coccinelle}/share/coccinelle/standard.h
267
# generate the test outcomes
461
# generate the test outcomes using a parallel build
462
make -e all -j$NIX_BUILD_CORES -l$NIX_BUILD_CORES
270
464
# collect the results
271
465
# note: the tarball is likely to contain useless
272
# symbolic links to files in the nix store. So be it.
466
# symbolic links to files in the nix store. We therefore
467
# delete these symlinks. As a result, you should be able
468
# to unpack the tarball in the tests directory.
469
find "$TMPDIR/tests" -depth -type l -delete
274
471
tar -czf "$out/results.tar.gz" ./tests
275
472
echo "file binary-dist $out/results.tar.gz" >> "$out/nix-support/hydra-build-products"