Skip to content

Commit

Permalink
Merge pull request #350 from verified-network-toolchain/version-const…
Browse files Browse the repository at this point in the history
…raints

add version constraints to opam file
  • Loading branch information
hackedy authored Jul 19, 2022
2 parents e9232e4 + 726d52b commit fbdc1b6
Show file tree
Hide file tree
Showing 35 changed files with 51 additions and 98 deletions.
22 changes: 1 addition & 21 deletions .github/scripts/build-petr4-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,14 @@ set -x # Make command execution verbose
export PETR4_DEPS="m4 \
gmp"

export PETR4_DEPS_OPAM="ANSITerminal \
alcotest \
bignum \
cstruct-sexp \
pp \
ppx_deriving \
ppx_deriving_yojson \
yojson \
js_of_ocaml \
js_of_ocaml-lwt \
js_of_ocaml-ppx"

# install dependencies
brew update
brew install \
${PETR4_DEPS}
opam update
opam upgrade
opam uninstall menhir
opam install menhir.20211128
# install p4pp
# opam switch create 4.09.1
opam pin add p4pp 0.1.7
# opam pin add p4pp https://github.com/cornell-netlab/p4pp.git
eval $(opam env)
#dune external-lib-deps --missing @install
opam install \
${PETR4_DEPS_OPAM}
opam install . --deps-only

# build petr4
dune build --profile release
Expand Down
24 changes: 1 addition & 23 deletions .github/scripts/build-petr4-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,14 @@ set -x # Make command execution verbose
export PETR4_DEPS="m4 \
libgmp-dev"

export PETR4_DEPS_OPAM="ANSITerminal \
alcotest \
bignum \
cstruct-sexp \
pp \
ppx_deriving \
ppx_deriving_yojson \
yojson \
js_of_ocaml \
js_of_ocaml-lwt \
js_of_ocaml-ppx"

# install deps
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
${PETR4_DEPS}
opam update
opam upgrade
opam uninstall menhir
opam install menhir.20211128
# opam install menhir.20211230
# install p4pp
# opam switch create 4.09.1
opam pin add p4pp 0.1.7
# opam pin add p4pp https://github.com/cornell-netlab/p4pp.git
eval $(opam env)
#export PATH="/usr/local/opt/dune/bin:$PATH"
#dune external-lib-deps --missing @install
opam install \
${PETR4_DEPS_OPAM}
opam install . --deps-only

# build petr4
dune build --profile release
Expand Down
2 changes: 1 addition & 1 deletion bin/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

open Petr4
module P4Info = Info
open Core_kernel
open Core
module Info = P4Info
module Env = Prog.Env

Expand Down
8 changes: 4 additions & 4 deletions bin/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
(public_name petr4)
(name main)
(modules common main)
(libraries ANSITerminal core p4pp petr4 p4stf alcotest)
(preprocess (pps ppx_jane -allow-unannotated-ignores)))
(libraries ANSITerminal core core_unix core_unix.command_unix p4pp petr4 p4stf alcotest)
(preprocess (pps ppx_jane)))

(executable
(name test)
(modules test)
(libraries ANSITerminal core p4pp petr4 p4stf alcotest)
(preprocess (pps ppx_jane -allow-unannotated-ignores)))
(libraries ANSITerminal core core_unix core_unix.command_unix p4pp petr4 p4stf alcotest)
(preprocess (pps ppx_jane)))
6 changes: 3 additions & 3 deletions bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ module Conf: Parse_config = struct
(["cc"] @
(List.map include_dirs ~f:(Printf.sprintf "-I%s") @
["-undef"; "-nostdinc"; "-E"; "-x"; "c"; p4file])) in
let in_chan = Unix.open_process_in cmd in
let in_chan = Core_unix.open_process_in cmd in
let str = In_channel.input_all in_chan in
let _ = Unix.close_process_in in_chan in
let _ = Core_unix.close_process_in in_chan in
str

(* let env = P4pp.Eval.empty "" include_dirs [] in
Expand Down Expand Up @@ -102,4 +102,4 @@ let command =
"run", eval_command;
"stf", stf_command ]

let () = Command.run ~version: "0.1.2" command
let () = Command_unix.run ~version: "0.1.2" command
1 change: 0 additions & 1 deletion ci-test/testdata/p4_16_samples/ipv4-actions_ubpf.p4

This file was deleted.

1 change: 0 additions & 1 deletion ci-test/testdata/p4_16_samples/ipv6-actions_ubpf.p4

This file was deleted.

1 change: 0 additions & 1 deletion ci-test/testdata/p4_16_samples/simple-actions_ubpf.p4

This file was deleted.

1 change: 0 additions & 1 deletion ci-test/testdata/p4_16_samples/simple-firewall_ubpf.p4

This file was deleted.

1 change: 0 additions & 1 deletion ci-test/testdata/p4_16_samples/tunneling_ubpf.p4

This file was deleted.

2 changes: 1 addition & 1 deletion lib/bitstring.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Core_kernel
open Core
open Prog.Value

type t = Bigint.t
Expand Down
2 changes: 1 addition & 1 deletion lib/checker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open Prog.Env
(* hack *)
module Petr4Error = Error
module Petr4Info = Info
open Core_kernel
open Core
open Petr4Error
module Error = Petr4Error
module Info = Petr4Info
Expand Down
2 changes: 1 addition & 1 deletion lib/context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* under the License.
*)

open Core_kernel
open Core
open Util

type t = (bool StringMap.t) list [@@deriving sexp]
Expand Down
2 changes: 1 addition & 1 deletion lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
(public_name petr4)
(name petr4)
(libraries core_kernel bignum ppx_deriving_yojson.runtime yojson cstruct-sexp pp)
(preprocess (pps ppx_jane -allow-unannotated-ignores ppx_deriving_yojson ppx_deriving.show)))
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_deriving.show)))
2 changes: 1 addition & 1 deletion lib/ebpf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ open Target
open Prog
open Env
open Value
open Core_kernel
open Core
open Typed
module Info = I
let (=) = Stdlib.(=)
Expand Down
2 changes: 1 addition & 1 deletion lib/elaborate.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(* adds type variable at various places. check with Ryan. *)

module I = Info
open Core_kernel
open Core
open Prog.Env
open Util
open Types
Expand Down
4 changes: 2 additions & 2 deletions lib/eval.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module I = Info
open Core_kernel
open Core
open Prog
open Env
open Typed
Expand Down Expand Up @@ -779,7 +779,7 @@ module MakeInterpreter (T : Target) = struct
else eval_expr env st SContinue r in
match op with
| And _ -> shortcircuit env st l r not
| Or _ -> shortcircuit env st l r ident
| Or _ -> shortcircuit env st l r Fn.id
| _ ->
let (st',s,l) = eval_expr env st SContinue l in
let (st'',s',r) = eval_expr env st' SContinue r in
Expand Down
4 changes: 2 additions & 2 deletions lib/hash.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Core_kernel
open Core
open Bitstring

let crc16_table = [|
Expand Down Expand Up @@ -105,4 +105,4 @@ let hash (algo : string) : (Bigint.t * Bigint.t) -> Bigint.t =
| "identity" -> hash_identity
| "csum16" -> hash_csum16
| "xor16" -> hash_xor16
| _ -> failwith "unknown hash algorithm"
| _ -> failwith "unknown hash algorithm"
2 changes: 1 addition & 1 deletion lib/info.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* under the License.
*)

open Core_kernel
open Core
open Sexplib.Conv

type t =
Expand Down
2 changes: 1 addition & 1 deletion lib/ops.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module I = Info
open Core_kernel
open Core
module V = Prog.Value
module Op = Typed.Op
open Bitstring
Expand Down
2 changes: 1 addition & 1 deletion lib/p4core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open Target
open Bitstring
open Prog.Env
module I = Info
open Core_kernel
open Core
module Info = I
let (=) = Stdlib.(=)
let (<>) = Stdlib.(<>)
Expand Down
2 changes: 1 addition & 1 deletion lib/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
%{
module P4Info = Info

open Core_kernel
open Core
open Context
open Types

Expand Down
2 changes: 1 addition & 1 deletion lib/pretty.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Core_kernel
open Core
open StdLabels
open List
open Util
Expand Down
4 changes: 2 additions & 2 deletions lib/prog.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module I = Info
open Util
open Core_kernel
open Core
module Info = I

open Typed
Expand Down Expand Up @@ -1876,7 +1876,7 @@ end = struct

(* TODO: for the purpose of testing expressions and simple statements only*)
let print_env (e:t) : unit =
let open Core_kernel in
let open Core in
print_endline "First environment value mappings:";
let f (name, value) =
print_string " ";
Expand Down
2 changes: 1 addition & 1 deletion lib/target.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open Prog
open Value
open Env
open Bitstring
open Core_kernel
open Core
open Util
module Info = I
let (=) = Stdlib.(=)
Expand Down
2 changes: 1 addition & 1 deletion lib/up4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ open Target
open Prog
open Env
open Value
open Core_kernel
open Core
open Typed
module Info = I
let (=) = Stdlib.(=)
Expand Down
2 changes: 1 addition & 1 deletion lib/util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*)
open Core_kernel
open Core

module StringMap = Map.Make(String)

Expand Down
2 changes: 1 addition & 1 deletion lib/util.mli
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* under the License.
*)

module StringMap : Core_kernel.Map.S with type Key.t = string
module StringMap : Core.Map.S with type Key.t = string

type ('a,'b) alternative =
Left of 'a
Expand Down
2 changes: 1 addition & 1 deletion lib/v1model.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ open Target
open Error
module I = Info
module H = Hash
open Core_kernel
open Core
module Info = I
module Hash = H

Expand Down
4 changes: 2 additions & 2 deletions p4stf/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

(library
(name p4stf)
(libraries core ANSITerminal alcotest petr4)
(preprocess (pps ppx_jane -allow-unannotated-ignores ppx_deriving_yojson ppx_deriving.show)))
(libraries core core_unix core_unix.sys_unix ANSITerminal alcotest petr4)
(preprocess (pps ppx_jane ppx_deriving_yojson ppx_deriving.show)))
8 changes: 4 additions & 4 deletions p4stf/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ struct
(["cc"] @
(List.map include_dirs ~f:(Printf.sprintf "-I%s") @
["-undef"; "-nostdinc"; "-E"; "-x"; "c"; p4file])) in
let in_chan = Unix.open_process_in cmd in
let in_chan = Core_unix.open_process_in cmd in
let str = In_channel.input_all in_chan in
let _ = Unix.close_process_in in_chan in
let _ = Core_unix.close_process_in in_chan in
str
end

Expand Down Expand Up @@ -113,7 +113,7 @@ module MakeRunner (C : RunnerConfig) = struct
let action_name' = convert_qualified action_name in
let add' = update add tbl_name' (priority, match_list, (action_name', args), id) in
run_test prog tl (add',set_def) results expected env st
| Wait -> Unix.sleep 1; run_test prog tl (add,set_def) results expected env st
| Wait -> Core_unix.sleep 1; run_test prog tl (add,set_def) results expected env st
| Set_default (tbl_name, (action_name, args)) ->
let tbl_name' = convert_qualified tbl_name in
let action_name' = convert_qualified action_name in
Expand Down Expand Up @@ -141,7 +141,7 @@ module Up4RunnerConfig = MakeConfig(Eval.Up4Interpreter)
module Up4Runner = MakeRunner(Up4RunnerConfig)

let get_stf_files path =
Sys.ls_dir path |> Base.List.to_list |>
Sys_unix.ls_dir path |> Base.List.to_list |>
List.filter ~f:(fun x -> Core.Filename.check_suffix x ".stf")

let run_stf stf_file p4prog =
Expand Down
14 changes: 7 additions & 7 deletions petr4.opam
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ build: [
depends: [
"alcotest"
"bignum"
"ocaml" {>= "4.09.1"}
"ocaml" {>= "4.12.0"}
"dune" {>= "1.2"}
"cstruct"
"cstruct-sexp"
"menhir"
"menhir" {<= "20211128"}
"ANSITerminal"
"core" {>= "0.13.0"}
"core" {>= "0.15.0"}
"ppx_deriving_yojson"
"ppx_jane" {>= "0.13.0" }
"ppx_js_style" {>= "0.13.0" }
"ppx_jane" {>= "0.15.0" }
"ppx_js_style" {>= "0.14444.0" }
"yojson" {>= "1.7.0"}
"js_of_ocaml"
"js_of_ocaml-lwt"
"js_of_ocaml-ppx"
"p4pp" {>= "0.1.8"}
"p4pp" {>= "0.1.12"}
"odoc"
"ppx_expect" {>= "0.15.0"}
"pp" {>= "1.0.1"}
"zarith" {= "1.11"}
"zarith" {= "1.12"}
]
2 changes: 1 addition & 1 deletion test/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(tests
(names test)
(libraries core p4pp petr4 alcotest)
(libraries core core_unix core_unix.sys_unix p4pp petr4 alcotest)
(deps (source_tree ../examples))
(action (run %{test} -e)))
Loading

0 comments on commit fbdc1b6

Please sign in to comment.