Skip to content

Commit bb3334e

Browse files
committed
stop relying on config scripts
1 parent fd47c35 commit bb3334e

File tree

13 files changed

+54
-34
lines changed

13 files changed

+54
-34
lines changed

bin/opt.ml

+2-4
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ let eval dir params query =
6767
Fmt.str "-p %s:%a" n Prim_type.pp t)
6868
|> String.concat ~sep:" "
6969
in
70-
sprintf
71-
"$CASTOR_ROOT/../_build/default/castor/bin/compile.exe -o %s %s %s > \
72-
%s/compile.log 2>&1"
73-
dir params query_fn dir
70+
sprintf "castor-compile -o %s %s %s > %s/compile.log 2>&1" dir params
71+
query_fn dir
7472
in
7573
let%map out = command_out compile_cmd in
7674
Logs.info (fun m -> m "Compile output: %s" out)

castor.opam

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license: "MIT"
77
homepage: "https://github.com/jfeser/castor"
88
bug-reports: "https://github.com/jfeser/castor/issues"
99
depends: [
10-
"dune" {build & >= "1.10"}
10+
"dune" {>= "3.1" & >= "1.10"}
1111
"menhir" {build}
1212
"core" {>= "v0.12"}
1313
"postgresql" {>= "4.4"}
@@ -25,19 +25,22 @@ depends: [
2525
"ppx_let" {>= "v0.12"}
2626
"visitors" {>= "20180513"}
2727
"yojson"
28+
"odoc" {with-doc}
2829
]
2930
build: [
30-
["dune" "subst"] {pinned}
31+
["dune" "subst"] {dev}
3132
[
3233
"dune"
3334
"build"
3435
"-p"
3536
name
3637
"-j"
3738
jobs
39+
"--promote-install-files=false"
3840
"@install"
3941
"@runtest" {with-test}
4042
"@doc" {with-doc}
4143
]
44+
["dune" "install" "-p" name "--create-install-files" name]
4245
]
4346
dev-repo: "git+https://github.com/jfeser/castor.git"

castor_test.opam

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ license: "MIT"
77
homepage: "https://github.com/jfeser/castor"
88
bug-reports: "https://github.com/jfeser/castor/issues"
99
depends: [
10-
"dune" {build & >= "1.10"}
10+
"dune" {>= "3.1" & build & >= "1.10"}
1111
"castor"
1212
"postgresql" {>= "4.4"}
1313
"bos" {>= "0.2"}
@@ -24,19 +24,22 @@ depends: [
2424
"visitors" {>= "20180513"}
2525
"ounit"
2626
"expect_test_helpers_core" {>= "v0.12"}
27+
"odoc" {with-doc}
2728
]
2829
build: [
29-
["dune" "subst"] {pinned}
30+
["dune" "subst"] {dev}
3031
[
3132
"dune"
3233
"build"
3334
"-p"
3435
name
3536
"-j"
3637
jobs
38+
"--promote-install-files=false"
3739
"@install"
3840
"@runtest" {with-test}
3941
"@doc" {with-doc}
4042
]
43+
["dune" "install" "-p" name "--create-install-files" name]
4144
]
4245
dev-repo: "git+https://github.com/jfeser/castor.git"

config-sample.sh

-6
This file was deleted.

dune-project

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(lang dune 2.0)
1+
(lang dune 3.1)
22

33
(name castor)
44
(source (github jfeser/castor))
@@ -11,7 +11,7 @@
1111
(name castor)
1212
(synopsis "A deductive database synthesizer")
1313
(depends
14-
(dune (and :build (>= 1.10)))
14+
(dune (>= 1.10))
1515
(menhir :build)
1616

1717
(core (>= v0.12))
@@ -29,7 +29,8 @@
2929
(ppx_hash (>= v0.12))
3030
(ppx_let (>= v0.12))
3131
(visitors (>= 20180513))
32-
yojson))
32+
yojson)
33+
(sites (share code)))
3334

3435
(package
3536
(name castor_test)
@@ -56,6 +57,7 @@
5657
(expect_test_helpers_core (>= v0.12))))
5758

5859
(using menhir 2.0)
60+
(using dune_site 0.1)
5961
(generate_opam_files true)
6062

6163
; Local Variables:

etc/dune

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(install
22
(package castor)
3-
(section etc)
3+
(section (site (castor code)))
44
(files date.c date.h castorlib.c castorlib.h load_bool.c load_date.c
55
load_float.c load_int.c load_string.c perf.c))
66

lib/codegen.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ let c_template fn args =
10141014
Util.command_out_exn ([ "clang"; "-E" ] @ args_strs @ [ fn ])
10151015

10161016
let from_fn fn n i =
1017-
let template = Global.build_root () ^ "/etc/" ^ fn in
1017+
let template = Global.find_file fn in
10181018
let func =
10191019
c_template template [ ("PARAM_NAME", n); ("PARAM_IDX", Int.to_string i) ]
10201020
in
@@ -1028,8 +1028,8 @@ let compile ?out_dir ?layout_log ?(debug = false) ~gprof ~params layout =
10281028
(match Sys_unix.is_directory out_dir with
10291029
| `No -> Core_unix.mkdir out_dir
10301030
| _ -> ());
1031-
let stdlib_fn = Global.build_root () ^ "/etc/castorlib.c" in
1032-
let date_fn = Global.build_root () ^ "/etc/date.c" in
1031+
let stdlib_fn = Global.find_file "castorlib.c" in
1032+
let date_fn = Global.find_file "date.c" in
10331033
let main_fn = out_dir ^ "/main.c" in
10341034
let ir_fn = out_dir ^ "/scanner.ir" in
10351035
let module_fn = out_dir ^ "/scanner.ll" in
@@ -1093,7 +1093,7 @@ let compile ?out_dir ?layout_log ?(debug = false) ~gprof ~params layout =
10931093
let header_str = "#include \"scanner.h\"" in
10941094
let funcs_str = String.concat (header_str :: funcs) ~sep:"\n" in
10951095
let calls_str = String.concat calls ~sep:"\n" in
1096-
let perf_template = Global.build_root () ^ "/etc/perf.c" in
1096+
let perf_template = Global.find_file "perf.c" in
10971097
let perf_c =
10981098
let open In_channel in
10991099
with_file perf_template ~f:(fun ch ->

lib/dune

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
(libraries core core_unix.time_unix core_unix.bigstring_unix
1414
core_unix.filename_unix lwt lwt.unix postgresql llvm llvm.analysis
1515
llvm.target llvm.all_backends logs visitors.runtime fmt fmt.tty genhash
16-
iter yojson ocamlgraph combinat)
16+
iter yojson ocamlgraph combinat dune-site)
1717
(inline_tests)
1818
(preprocess
1919
(pps ppx_sexp_conv ppx_compare ppx_hash ppx_expect ppx_let visitors.ppx
2020
ppx_variants_conv lwt_ppx ppx_sexp_message)))
21+
22+
(generate_sites_module
23+
(module sites)
24+
(sites castor))

lib/global.ml

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
open Core
22

33
let fresh = Fresh.create ()
4-
let build_root () = Sys.getenv_exn "CASTOR_ROOT"
4+
5+
let find_file fn =
6+
let dirs = Sites.Sites.code in
7+
let m_fn =
8+
List.find_map dirs ~f:(fun dir ->
9+
let fn = Filename.concat dir fn in
10+
match Sys_unix.file_exists fn with `Yes -> Some fn | _ -> None)
11+
in
12+
match m_fn with
13+
| Some fn -> fn
14+
| None ->
15+
raise_s
16+
[%message "could not find file" (fn : string) "in" (dirs : string list)]
17+
518
let enable_redshift_dates = ref false

test/dune

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
(env
2+
(_ (env-vars
3+
(CASTOR_TPCH_TEST_DB postgresql:///tpch_1k))))
4+
15
(rule
26
(alias test_db)
37
(action

test/lib/dune

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
(flags -open Core -open Castor)
55
(inline_tests
66
(deps
7-
(alias ../test_db)))
7+
(alias ../test_db)
8+
(env_var CASTOR_TPCH_TEST_DB)))
89
(preprocess
910
(pps ppx_sexp_conv ppx_compare ppx_expect ppx_sexp_message)))

test/lib/test_util.ml

+5-6
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ ahashidx(dedup(
4949
alist(select([p_counter, c_counter],
5050
join(p_counter < c_counter && c_counter < p_succ,
5151
filter(p_id = k.p_id,
52-
select([id as p_id, counter as p_counter, succ as p_succ], %s)),
52+
select([id as p_id, counter as p_counter, succ as p_succ], %s)),
5353
filter(c_id = k.c_id,
5454
select([id as c_id, counter as c_counter], %s)))) as lk,
5555
atuple([ascalar(lk.p_counter), ascalar(lk.c_counter)], cross)),
@@ -63,14 +63,14 @@ ahashidx(dedup(
6363
select([p_counter, c_counter],
6464
depjoin(
6565
ahashidx(dedup(select([id as p_id], %s)) as hk,
66-
alist(select([counter, succ], filter(hk.p_id = id && counter < succ, %s)) as lk1,
67-
atuple([ascalar(lk1.counter as p_counter), ascalar(lk1.succ as p_succ)], cross)),
66+
alist(select([counter, succ], filter(hk.p_id = id && counter < succ, %s)) as lk1,
67+
atuple([ascalar(lk1.counter as p_counter), ascalar(lk1.succ as p_succ)], cross)),
6868
id_p) as dk,
6969
select([dk.p_counter, c_counter],
7070
filter(c_id = id_c,
71-
aorderedidx(select([counter], %s) as ok,
71+
aorderedidx(select([counter], %s) as ok,
7272
alist(filter(counter = ok.counter, %s) as lk2,
73-
atuple([ascalar(lk2.id as c_id), ascalar(lk2.counter as c_counter)], cross)),
73+
atuple([ascalar(lk2.id as c_id), ascalar(lk2.counter as c_counter)], cross)),
7474
dk.p_counter, dk.p_succ)))))
7575
|}
7676
log log log log
@@ -81,4 +81,3 @@ let sum_complex =
8181
ATuple([AScalar(k.f), AScalar((k.g - k.f) as v)], cross)))"
8282

8383
let tpch_conn = lazy (Db.create @@ Sys.getenv_exn "CASTOR_TPCH_TEST_DB")
84-
let tpch_full_conn = lazy (Db.create @@ Sys.getenv_exn "CASTOR_TPCH_DB")

test/type/dune

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
(include dune.inc)
22

33
(rule
4-
(with-stdout-to
5-
dune.inc.gen
6-
(run ./gen_dune.py)))
4+
(action (with-stdout-to dune.inc.gen (run ./gen_dune.py)))
5+
(deps (env_var CASTOR_TPCH_TEST_DB)))
76

87
(rule
98
(alias runtest)

0 commit comments

Comments
 (0)