Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refresh the installer, use a newer version of findlib, use a cleaner …

…strategy for installer a proper topfind.
  • Loading branch information...
commit 205d7a2cae426051f8dafe2b0c8860e977fb7298 1 parent a6d00ab
@protz authored
Showing with 132 additions and 13 deletions.
  1. +1 −1  Makefile
  2. +10 −0 README.md
  3. +69 −0 ReplaceInFile.nsh
  4. +11 −12 install.nsi
  5. +41 −0 topfind
View
2  Makefile
@@ -5,7 +5,7 @@ OCAMLROOTW=c:/ocamlmgw/
.PHONY: version
-all: util version
+all: util version topfind
$(NSIS) $(SCRIPT)
# Regenerate if gen_files.ml changed or there's a new ocaml version (and
View
10 README.md
@@ -43,6 +43,8 @@ for another.
3. Checkout a copy of OCamlWin from the OCaml forge, edit Makefile.local and
`make && make install`.
3. Add `c:\ocamlmgw\bin` to your path, `configure` and `make` findlib.
+3. Copy findlib's `src/findlib/topfind.p` to `topfind` in the OCaml Installer
+ directory.
4. Install NSIS, grab `nsisunz.dll` somewhere on the interwebs and put it NSIS's
`Plugins` directory.
5. Make sure `/cygdrive/c/ocamlmgw/bin` is in your path.
@@ -56,6 +58,14 @@ for another.
should all generate an installer. The installer is quite big (thank you
camlp4).
+Things to test for
+------------------
+
+1. `rlwrap ocaml`, then `#use "topfind";;`
+2. `ocamlfind ocamlc -package unix -linkpkg test.ml` where `test.ml` uses the
+ `Unix` module, of course.
+3. `odb` on a sample package (e.g. `lwt`)
+
Bugs, issues
------------
View
69 ReplaceInFile.nsh
@@ -0,0 +1,69 @@
+Function RIF
+
+ ClearErrors ; want to be a newborn
+
+ Exch $0 ; REPLACEMENT
+ Exch
+ Exch $1 ; SEARCH_TEXT
+ Exch 2
+ Exch $2 ; SOURCE_FILE
+
+ Push $R0 ; SOURCE_FILE file handle
+ Push $R1 ; temporary file handle
+ Push $R2 ; unique temporary file name
+ Push $R3 ; a line to sar/save
+ Push $R4 ; shift puffer
+
+ IfFileExists $2 +1 RIF_error ; knock-knock
+ FileOpen $R0 $2 "r" ; open the door
+
+ GetTempFileName $R2 ; who's new?
+ FileOpen $R1 $R2 "w" ; the escape, please!
+
+ RIF_loop: ; round'n'round we go
+ FileRead $R0 $R3 ; read one line
+ IfErrors RIF_leaveloop ; enough is enough
+ RIF_sar: ; sar - search and replace
+ Push "$R3" ; (hair)stack
+ Push "$1" ; needle
+ Push "$0" ; blood
+ Call StrRep ; do the bartwalk
+ StrCpy $R4 "$R3" ; remember previous state
+ Pop $R3 ; gimme s.th. back in return!
+ StrCmp "$R3" "$R4" +1 RIF_sar ; loop, might change again!
+ FileWrite $R1 "$R3" ; save the newbie
+ Goto RIF_loop ; gimme more
+
+ RIF_leaveloop: ; over'n'out, Sir!
+ FileClose $R1 ; S'rry, Ma'am - clos'n now
+ FileClose $R0 ; me 2
+
+ Delete "$2.old" ; go away, Sire
+ Rename "$2" "$2.old" ; step aside, Ma'am
+ Rename "$R2" "$2" ; hi, baby!
+
+ ClearErrors ; now i AM a newborn
+ Goto RIF_out ; out'n'away
+
+ RIF_error: ; ups - s.th. went wrong...
+ SetErrors ; ...so cry, boy!
+
+ RIF_out: ; your wardrobe?
+ Pop $R4
+ Pop $R3
+ Pop $R2
+ Pop $R1
+ Pop $R0
+ Pop $2
+ Pop $0
+ Pop $1
+
+FunctionEnd
+
+
+!macro _ReplaceInFile SOURCE_FILE SEARCH_TEXT REPLACEMENT
+ Push "${SOURCE_FILE}"
+ Push "${SEARCH_TEXT}"
+ Push "${REPLACEMENT}"
+ Call RIF
+!macroend
View
23 install.nsi
@@ -1,5 +1,6 @@
; NSIS Installer script for OCaml
;
+;
; Original Author:
; Jonathan Protzenko <jonathan.protzenko@ens-lyon.org>
;
@@ -40,6 +41,7 @@
!include "EnvVarUpdate.nsh"
!include "IfKeyExists.nsh"
!include "MultiUser.nsh"
+!include "ReplaceInFile.nsh"
Name "OCaml"
OutFile "ocaml-${MUI_VERSION}-i686-mingw64.exe"
@@ -67,7 +69,7 @@ right packages pre-checked, so that all you have to do is click through the wiza
and clunky.$\n\
- You can also run Emacs, if you chose to install it. Once in Emacs, just hit \
Alt-X, type run-caml, hit enter, and start playing with the toplevel.$\n\
- - If you installed Cygwin, there should be a $\"Cygwin Shell$\" shortcut on your \
+ - If you installed Cygwin, there should be a $\"Cygwin Terminal$\" shortcut on your \
desktop. You can open up a shell, and use ocamlfind, or ocamlopt from the \
command line.$\n$\n\
Enjoy!"
@@ -182,18 +184,15 @@ Section "OCaml" SecOCaml
FileWrite $1 "$INSTDIR\lib\stublibs$\n"
FileClose $1
+ ; Use the topfind template that's present in the ocaml-installer directory.
+ Delete "$INSTDIR\lib\topfind"
+ SetOutPath "$INSTDIR\lib"
+ File topfind
+
; Escape the install directory with the OCaml syntax (fingers crossed)
${StrRep} $0 "$INSTDIR" "\" "\\"
-
- Delete "$INSTDIR\lib\topfind"
- FileOpen $1 "$INSTDIR\lib\topfind" w
- FileWrite $1 "#load $\"$0\\lib\\site-lib\\findlib\\findlib.cma$\";;$\n"
- FileWrite $1 "#load $\"$0\\lib\\site-lib\\findlib\\findlib_top.cma$\";;$\n"
- FileWrite $1 "#directory $\"$0\\lib\\site-lib\\findlib$\";;$\n"
- FileWrite $1 "Topfind.add_predicates [ $\"byte$\"; $\"toploop$\" ];$\n"
- FileWrite $1 "Topfind.don't_load [ $\"findlib$\" ];$\n"
- FileWrite $1 "Topfind.announce();;$\n"
- FileClose $1
+ ; Replace the template with the right directory
+ !insertmacro _ReplaceInFile "$INSTDIR\lib\topfind" "@SITELIB@" "$0/lib/site-lib"
Delete "$INSTDIR\etc\findlib.conf"
FileOpen $1 "$INSTDIR\etc\findlib.conf" w
@@ -327,7 +326,7 @@ Section "Cygwin" SecCygwin
ExecWait "$DESKTOP\cygwin-setup.exe --quiet-mode \
--local-package-dir=c:\cygtmp\ \
--site=http://cygwin.cict.fr \
- --packages=make,mingw64-i686-gcc-g++,mingw64-i686-gcc,patch,rlwrap,libreadline6,diffutils,wget,vim \
+ --packages=curl,make,mingw64-i686-gcc-g++,mingw64-i686-gcc,patch,rlwrap,libreadline6,diffutils,wget,vim \
>NUL 2>&1"
end:
View
41 topfind
@@ -0,0 +1,41 @@
+(* $Id: topfind.p 152 2012-04-16 16:08:47Z gerd $ -*- tuareg -*- *)
+
+(* For Ocaml-3.03 and up, so you can do: #use "topfind" and get a
+ * working findlib toploop.
+ *)
+
+#directory "@SITELIB@/findlib";;
+#directory "+compiler-libs";;
+ (* OCaml-4.00 requires to have #directory before we load anything *)
+
+(* First test whether findlib_top is already loaded. If not, load it now.
+ * The test works by executing the toplevel phrase "Topfind.reset" and
+ * checking whether this causes an error.
+ *)
+let exec_test s =
+ let l = Lexing.from_string s in
+ let ph = !Toploop.parse_toplevel_phrase l in
+ let fmt = Format.make_formatter (fun _ _ _ -> ()) (fun _ -> ()) in
+ try
+ Toploop.execute_phrase false fmt ph
+ with
+ _ -> false
+in
+
+if not(exec_test "Topfind.reset;;") then (
+ Topdirs.dir_load Format.err_formatter "@SITELIB@/findlib/findlib.cma";
+ Topdirs.dir_load Format.err_formatter "@SITELIB@/findlib/findlib_top.cma";
+);;
+
+(* Old: *)
+(* #load "@SITELIB@/findlib/findlib.cma";; *)
+(* #load "@SITELIB@/findlib/findlib_top.cma";; *)
+
+
+(* The following is always executed. It is harmless if findlib was already
+ * initialized
+ *)
+
+Topfind.add_predicates [ "byte"; "toploop" ];
+Topfind.don't_load ["findlib"];
+Topfind.announce();;
Please sign in to comment.
Something went wrong with that request. Please try again.