Skip to content

Commit 556ec7e

Browse files
committed
[CI] bump up
1 parent 4c89483 commit 556ec7e

14 files changed

Lines changed: 163 additions & 138 deletions

File tree

.github/workflows/build.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [push, pull_request]
55
jobs:
66
check:
77
name: build
8-
runs-on: ubuntu-20.04
8+
runs-on: ubuntu-22.04
99
steps:
1010
- name: Checkout code
1111
uses: actions/checkout@v2
@@ -29,21 +29,21 @@ jobs:
2929
${{ env.cache-name }}-build-${{ hashFiles('opam', 'build.sh') }}
3030
${{ env.cache-name }}-build-
3131
32+
- name: Install deps
33+
run: |
34+
sudo apt-get update
35+
sudo apt-get install -y libmpfr-dev llvm-15-dev libclang-15-dev
36+
3237
- name: Install ocamlformat
3338
run: opam install ocamlformat.0.24.1
3439

3540
- name: Check format
3641
run: |
37-
eval $(opam env)
38-
script/check-format
39-
- name: Install deps
40-
run: |
41-
sudo apt-get update
42-
sudo apt-get install -y libmpfr-dev llvm-12-dev pkg-config libclang-12-dev
42+
opam exec -- script/check-format
4343
4444
- name: Build Sparrow
4545
run: |
46-
./build.sh || eval $(opam env) && make -j
46+
opam exec -- ./build.sh --user-opam-switch
4747
48-
- name: Run test (regression)
49-
run: eval $(opam env) && make test
48+
- name: Run test
49+
run: opam exec -- make test

build.sh

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,62 @@ NCPU="$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)"
77
OCAML_VERSION="4.13.1"
88
SPARROW_OPAM_SWITCH=sparrow-"$OCAML_VERSION"+flambda
99
SPARROW_OPAM_SWITCH_OPTION="--package=ocaml-variants.${OCAML_VERSION}+options,ocaml-option-flambda"
10-
opam init --reinit --bare --no-setup
1110

12-
switch_exists=no
13-
for installed_switch in $(opam switch list --short); do
14-
if [[ "$installed_switch" == "$SPARROW_OPAM_SWITCH" ]]; then
15-
switch_exists=yes
16-
break
17-
fi
11+
USER_OPAM_SWITCH=no
12+
13+
function usage() {
14+
echo "Usage: $0 [options]"
15+
echo
16+
echo " options:"
17+
echo " -h,--help show this message"
18+
echo " --user-opam-switch use the current opam switch to install haechi (default: $OPAM_SWITCH)"
19+
echo
20+
echo " examples:"
21+
echo " $0 # build haechi with default options"
22+
echo " $0 --user-opam-switch # build haechi in the current opam switch (e.g., for Github CI)"
23+
}
24+
25+
while [[ $# -gt 0 ]]; do
26+
opt_key="$1"
27+
case $opt_key in
28+
--user-opam-switch)
29+
USER_OPAM_SWITCH=yes
30+
shift
31+
continue
32+
;;
33+
esac
1834
done
19-
if [ "$switch_exists" = "no" ]; then
20-
opam switch create $SPARROW_OPAM_SWITCH_OPTION $SPARROW_OPAM_SWITCH
21-
else
22-
opam switch $SPARROW_OPAM_SWITCH
35+
36+
function setup_opam() {
37+
opam init --reinit --bare --no-setup
38+
39+
switch_exists=no
40+
for installed_switch in $(opam switch list --short); do
41+
if [[ "$installed_switch" == "$SPARROW_OPAM_SWITCH" ]]; then
42+
switch_exists=yes
43+
break
44+
fi
45+
done
46+
if [ "$switch_exists" = "no" ]; then
47+
opam switch create $SPARROW_OPAM_SWITCH_OPTION $SPARROW_OPAM_SWITCH
48+
else
49+
opam switch $SPARROW_OPAM_SWITCH
50+
fi
51+
52+
eval $(SHELL=bash opam config env --switch=$SPARROW_OPAM_SWITCH)
53+
}
54+
55+
if [ "$USER_OPAM_SWITCH" == "no" ]; then
56+
setup_opam
2357
fi
2458

25-
eval $(SHELL=bash opam config env --switch=$SPARROW_OPAM_SWITCH)
2659
echo -e "\e[31m[NOTE]\e[0m If you are not a sudo user, press Ctrl+D and skip installing system libraries. Contact the sysadmin, if they are not installed."
27-
opam install apron clangml || echo "Skip system library install"
60+
opam install apron || echo "Skip system library install"
2861
opam pin add prosys-cil https://github.com/prosyslab/cil.git -n
2962
opam pin add claml https://github.com/prosyslab/claml.git -n
3063
opam pin add sparrow . -n
3164
opam install -j $NCPU sparrow --deps-only
3265
opam pin remove sparrow
66+
# development packages
67+
opam install -j $NCPU ocamlformat.0.24.1 merlin ocp-index ocp-indent ocaml-lsp-server
3368
make

script/apply-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env bash
22

33
find src test -name "*.ml" | xargs ocamlformat -i
4-
find test -name "*.c" | xargs clang-format -i
4+
find test -name "*.c" | xargs clang-format-15 -i

src/core/clamlFrontend.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,8 @@ and trans_binary_operator scope fundec_opt loc kind lhs rhs =
11691169
match (rhs_expr, rhs_sl) with
11701170
| ( Cil.Lval _,
11711171
[
1172-
({ Cil.skind = Cil.Instr [ Cil.Call (Some _, f, el, loc) ]; _ } as s);
1172+
({ Cil.skind = Cil.Instr [ Cil.Call (Some _, f, el, loc) ]; _ } as
1173+
s);
11731174
] ) ->
11741175
let stmt =
11751176
{ s with skind = Cil.Instr [ Cil.Call (Some lval, f, el, loc) ] }

src/core/main.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ let print_pgm_info global =
7676

7777
let print_il file =
7878
(if
79-
!Options.inline = []
80-
&& BatSet.is_empty !Options.unsound_loop
81-
&& not !Options.cut_cyclic_call
82-
then Cil.dumpFile !Cil.printerForMaincil stdout "" (transform_simple file)
83-
else
84-
let global = init_analysis file in
85-
Cil.dumpFile !Cil.printerForMaincil stdout "" global.file);
79+
!Options.inline = []
80+
&& BatSet.is_empty !Options.unsound_loop
81+
&& not !Options.cut_cyclic_call
82+
then Cil.dumpFile !Cil.printerForMaincil stdout "" (transform_simple file)
83+
else
84+
let global = init_analysis file in
85+
Cil.dumpFile !Cil.printerForMaincil stdout "" global.file);
8686
exit 0
8787

8888
let print_cfg global =

src/datalog/relDUGraph.ml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,16 +1321,16 @@ let print_patron analysis global dug alarms =
13211321
let dug = G.copy dug in
13221322
let aexp = alarm.Report.exp in
13231323
(if AexpSet.mem aexp visited |> not then
1324-
let alarms = [ alarm ] in
1325-
let dug = optimize ~verbose:false alarms dug in
1326-
if G.mem_node alarm.Report.node dug then (
1327-
let dirname =
1328-
F.sprintf "%s/datalog/%d" (FileManager.analysis_dir analysis) i
1329-
in
1330-
FileManager.mkdir dirname;
1331-
print_fact_patron dirname global.Global.icfg dug global.mem;
1332-
print_taint_alarm_in_dir dirname alarms;
1333-
print_sems dirname dug));
1324+
let alarms = [ alarm ] in
1325+
let dug = optimize ~verbose:false alarms dug in
1326+
if G.mem_node alarm.Report.node dug then (
1327+
let dirname =
1328+
F.sprintf "%s/datalog/%d" (FileManager.analysis_dir analysis) i
1329+
in
1330+
FileManager.mkdir dirname;
1331+
print_fact_patron dirname global.Global.icfg dug global.mem;
1332+
print_taint_alarm_in_dir dirname alarms;
1333+
print_sems dirname dug));
13341334
G.clear dug;
13351335
(i + 1, AexpSet.add aexp visited))
13361336
else (i, visited)

src/domain/prodDom.mli

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212

1313
open AbsDom
1414

15-
module Make
16-
(A : CPO)
17-
(B : CPO) : sig
15+
module Make (A : CPO) (B : CPO) : sig
1816
include AbsDom.CPO
1917

2018
val make : A.t -> B.t -> t
@@ -23,12 +21,7 @@ module Make
2321
end
2422
with type t = A.t * B.t
2523

26-
module Make5
27-
(A : CPO)
28-
(B : CPO)
29-
(C : CPO)
30-
(D : CPO)
31-
(E : CPO) : sig
24+
module Make5 (A : CPO) (B : CPO) (C : CPO) (D : CPO) (E : CPO) : sig
3225
include AbsDom.CPO
3326

3427
val make : A.t * B.t * C.t * D.t * E.t -> t

src/dune

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
batteries
1212
prosys-cil
1313
prosys-cil.all-features
14-
clangml
15-
clangml.printer
1614
claml
1715
lymp
1816
ocamlgraph
@@ -30,8 +28,6 @@
3028
batteries
3129
prosys-cil
3230
prosys-cil.all-features
33-
clangml
34-
clangml.printer
3531
claml
3632
lymp
3733
memtrace

src/instance/itvAnalysis.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,8 @@ let do_analysis global =
489489
stat locset;
490490
let dug = Analysis.generate_dug spec global in
491491
(if !Options.marshal_in then marshal_in global
492-
else if !Options.skip_main_analysis then
493-
(global, dug, Table.empty, Table.empty)
494-
else Analysis.perform spec global dug)
492+
else if !Options.skip_main_analysis then
493+
(global, dug, Table.empty, Table.empty)
494+
else Analysis.perform spec global dug)
495495
|> opt !Options.marshal_out marshal_out
496496
|> post_process spec

src/instance/octAnalysis.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ let do_analysis (global, itvinputof) =
290290
in
291291
let dug = Analysis.generate_dug spec global in
292292
(if !Options.marshal_in then marshal_in global
293-
else Analysis.perform spec global dug)
293+
else Analysis.perform spec global dug)
294294
|> opt !Options.marshal_out marshal_out
295295
|> StepManager.stepf true "Generate Alarm Report"
296296
(fun (global, _, inputof, outputof) ->

0 commit comments

Comments
 (0)