Skip to content

Commit

Permalink
Got ocamlc working ocamlfind ocamlc -custom -package ocaml-libgit2 te…
Browse files Browse the repository at this point in the history
…st.ml -linkpkg -cclib -lgit2 -o Foo
  • Loading branch information
fxfactorial committed May 30, 2015
1 parent 48e8a92 commit 3fce9a8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PACKAGES := ctypes.foreign,uri
CCLIB := libgit2.0.22.0.dylib
SRC := git.ml

.PHONY: clean
.PHONY: clean distclean uninstall

all:install

Expand All @@ -12,8 +12,10 @@ native:libgit set_meta
-cclib `ocamlfind query ocaml-libgit2`/$(CCLIB) -linkpkg $(SRC)

bytecode:libgit set_meta
ocamlfind ocamlc -package $(PACKAGES) \
-cclib `ocamlfind query ocaml-libgit2`/$(CCLIB) -linkpkg $(SRC)
# ocamlfind ocamlc -package $(PACKAGES) \
# -cclib `ocamlfind query ocaml-libgit2`/$(CCLIB) -linkpkg $(SRC)
ocamlfind ocamlc -custom -package ctypes.foreign,uri \
-linkpkg -cclib -L$(shell ocamlfind query ocaml-libgit2) -cclib -lgit2 git.ml

libgit:
# Not sure why this doesn't work with opam yet.
Expand All @@ -22,7 +24,7 @@ libgit:
ocamlfind install ocaml-libgit2 META
# The trick is the ; since cd is done in a separate shell
cd `ocamlfind query ocaml-libgit2`; \
cmake $(ROOT)/libgit2 -DBUILD_CLAR=OFF; \
cmake $(ROOT)/libgit2 -DBUILD_CLAR=OFF -DCMAKE_MACOSX_RPATH=. ;\
cmake --build .; \
find . -not -name "*.dylib" -not -name "META" -delete

Expand All @@ -33,6 +35,9 @@ set_meta:

install:native bytecode
ocamlfind install ocaml-libgit2 -add git.cmo git.cmi git.cmt git.o git.cmx

distclean:clean uninstall

uninstall:
ocamlfind remove ocaml-libgit2
clean:
Expand Down
12 changes: 10 additions & 2 deletions git.ml
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ module Repository = struct
let git_repository_open_ext =
foreign
"git_repository_open_ext"
((ptr (ptr Types.git_repository)) @->
string @-> int @-> string @-> returning int)
((ptr_opt (ptr Types.git_repository)) @->
string @-> int @-> string_opt @-> returning int)

let git_repository_open_bare =
foreign
Expand Down Expand Up @@ -1086,3 +1086,11 @@ let find_repo ~path:p =
let result = getf root Buffer.ptr_ in
let length = getf root Buffer.size_ |> Unsigned.Size_t.to_int in
string_from_ptr result length

let is_a_repo ~path:p =
try
Repository.git_repository_open_ext None p 0 None |> git_cont;
true
with
Git_Errored _ -> false

2 changes: 1 addition & 1 deletion libgit2
Submodule libgit2 updated 1 files
+1 −1 README.md

0 comments on commit 3fce9a8

Please sign in to comment.