Skip to content

Commit

Permalink
Fix a couple of bugs, fix missing build targets, pin to 1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Holland committed Jul 20, 2018
1 parent d36b4ef commit aafedeb
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 22 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
*.a
*.o
*.cma
*.cmi
*.cmo
*.cmx
*.cmxa
*.cmxs
*.o
*.byte
*.out
oUnit-*
Expand Down
21 changes: 12 additions & 9 deletions Generator.ml
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ module Templates = struct
let pa_app a b = PaApp (_loc, a, b)
let ex_int n = ExInt (_loc, n)

let typedef name body = StTyp (_loc, TyDcl (_loc, name, [], body, []))
let typedef name body = StTyp (_loc, ReRecursive, TyDcl (_loc, name, [], body, []))

(* Ast Concatenation *)
let rec join_ast join = function
Expand Down Expand Up @@ -738,7 +738,10 @@ let build_enum_value_fn (name, (ty, parameterization), enumerants) =
in
let (flag, ops) = List.fold_left combine_split_flags (0l, []) (List.map split flags) in
flag :: ops
>> module StaticElements = struct let open_definitions = [ <:str_item< open Batteries >> ]
>>

module StaticElements = struct
let open_definitions = [ <:str_item< open Batteries >> ]

let module_definitions = [
<:str_item< module IdMap = Map.Make(Int32) >>
Expand Down Expand Up @@ -836,7 +839,7 @@ let build_enum_value_fn (name, (ty, parameterization), enumerants) =
if i = len then
()
else begin
buffer.(i / 4) <- add_char_to_word (String.get str i) (i mod 4) buffer.(i / 4);
buffer.(i / 4) <- add_char_to_word (String.get str i) (abs @@ (i mod 4) - 3) buffer.(i / 4);
add_char_to_buffer (i + 1)
end
in
Expand Down Expand Up @@ -918,13 +921,13 @@ let pack_version (major, minor) =
let minor_mask = shift_left (logand minor_i32 0x03l) 8 in
logor major_mask minor_mask

let st_typ x = StTyp (_loc, x)
let sg_typ x = SgTyp (_loc, x)
let st_typ x = StTyp (_loc, ReRecursive, x)
let sg_typ x = SgTyp (_loc, ReRecursive, x)

let join_typedefs typedefs wrapper =
let rec cons_typedefs = function
| [StTyp (_, dcl)] -> dcl
| StTyp (_, dcl) :: t -> TyAnd (_loc, dcl, cons_typedefs t)
| [StTyp (_, _, dcl)] -> dcl
| StTyp (_, _, dcl) :: t -> TyAnd (_loc, dcl, cons_typedefs t)
| [] -> failwith "cannot join_typedefs on empty list"
| _ -> failwith "non typedef str_item in join_typedefs"
in
Expand Down Expand Up @@ -975,8 +978,8 @@ let generate_implementation output info =
List.iter output StaticElements.interfaces

let cast_sig = function
| StTyp (loc, t) -> SgTyp (loc, t)
| StOpn (loc, i) -> SgOpn (loc, i)
| StTyp (loc, re, t) -> SgTyp (loc, re, t)
| StOpn (loc, ov, i) -> SgOpn (loc, ov, i)
| StExc (loc, t, _) -> SgExc (loc, t)
| _ -> failwith "unhandled case in cast_sig"

Expand Down
9 changes: 5 additions & 4 deletions META
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name = "spirv"
version = "1.1.1"
version = "1.1.2"
description = "SPIR-V compiler library for OCaml"
requires = "batteries"
archive(byte) = "SpirV.cmo"
archive(native) = "SpirV.cmx"
archive(native,plugin) = "SpirV.cmxs"
plugin(byte) = "SpirV.cma"
plugin(native) = "SpirV.cmxs"
archive(byte) = "SpirV.cma"
archive(native) = "SpirV.cmxa"
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ifexists=$(if $(wildcard $(1)),$(1),)

all: SpirV.cmi SpirV.cmo
all: SpirV.cmi SpirV.cmo SpirV.cma SpirV.cmxa

test: SpirVTest.byte
./SpirVTest.byte -output-html-dir test_results
Expand All @@ -18,8 +18,11 @@ install:
ocamlfind install spirv META \
SpirV.cmi \
$(call ifexists,SpirV.cmo) \
$(call ifexists,SpirV.cma) \
$(call ifexists,SpirV.cmx) \
$(call ifexists,SpirV.cmxa) \
$(call ifexists,SpirV.cmxs) \
$(call ifexists,SpirV.a)

uninstall:
ocamlfind remove spirv
Expand All @@ -42,15 +45,16 @@ Generator.byte: Generator.ml

SpirV.cmi: SpirV.mli
ocamlfind ocamlc -package batteries -g -c SpirV.mli

SpirV.cmo: SpirV.ml SpirV.cmi
ocamlfind ocamlc -package batteries -g -c SpirV.ml

SpirV.cma: SpirV.cmo
ocamlfind ocamlc -a -o SpirV.cma SpirV.cmo
SpirV.cmx: SpirV.ml SpirV.cmi
ocamlfind ocamlopt -package batteries -g -c SpirV.ml

SpirV.cmxa: SpirV.cmx
ocamlfind ocamlopt -a -o SpirV.cmxa SpirV.cmx
SpirV.cmxs: SpirV.cmx
ocamlfind ocamlopt -shared -linkall -I . -o SpirV.cmxs SpirV.cmx
ocamlfind ocamlopt -shared -o SpirV.cmxs SpirV.cmx

SpirVTest.byte: SpirV.cmi SpirV.cmo SpirVTest.ml
ocamlfind ocamlc -linkpkg -package oUnit -package batteries -g -o SpirVTest.byte SpirV.cmo SpirVTest.ml
3 changes: 2 additions & 1 deletion SpirV.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,8 @@ let words_of_string (str : string) =
then ()
else
(buffer.(i / 4) <-
add_char_to_word (String.get str i) (i mod 4) buffer.(i / 4);
add_char_to_word (String.get str i) (abs @@ ((i mod 4) - 3))
buffer.(i / 4);
add_char_to_buffer (i + 1))
in (add_char_to_buffer 0; Array.to_list buffer);;
let list_of_option (opt : 'a option) =
Expand Down
2 changes: 1 addition & 1 deletion SpirVTest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ let build_binary_comparison_test (name, fn) =
name >:: fun _ -> begin
let op_words = compile_to_words ops in
(* let (in_ch, out_ch) = Unix.open_process (Printf.sprintf "echo '%s'spirv-as -o - -" asm_source) in *)
let in_ch = Unix.open_process_in (Printf.sprintf "echo '%s' | spirv-as -o - -" asm_source) in
let in_ch = Unix.open_process_in (Printf.sprintf "echo '%s' | spirv-as --target-env spv1.1 -o - -" asm_source) in
(* IO.write_string out_ch asm_source; *)
let asm_words = read_all_with IO.read_real_i32 in_ch in
check_status @@ Unix.close_process_in in_ch;
Expand Down
4 changes: 3 additions & 1 deletion opam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
opam-version: "1.2"
name: "spirv"
version: "1.1.1"
version: "1.1.2"
maintainer: "Nathan Holland <nholland94@gmail.com>"
author: "Nathan Holland <nholland94@gmail.com>"
homepage: "https://github.com/nholland94/spirv-ocaml"
Expand All @@ -9,7 +9,9 @@ license: "MIT"
dev-repo: "https://github.com/nholland94/spirv-ocaml"
build: [
[make "SpirV.cmo"] {!ocaml-native}
[make "SpirV.cma"] {!ocaml-native}
[make "SpirV.cmx"] {ocaml-native}
[make "SpirV.cmxa"] {ocaml-native}
[make "SpirV.cmxs"] {ocaml-native}
]
install: [
Expand Down

0 comments on commit aafedeb

Please sign in to comment.