Permalink
Browse files

Windows support

  • Loading branch information...
alavrik committed Jun 26, 2011
1 parent 1438435 commit e8bcfe05dc0144ffc9b7bbb1382160a668dd49fc
View
11 INSTALL
@@ -1,18 +1,19 @@
SUPPORTED PLATFORMS
===================
+Piqi has been tested on Linux (Debian Lenny and Squeeze, i386 and amd64
+architectures) and on Mac OS X 10.6.4. It is also known to work on Windows and
+Solaris.
+
Piqi is written in OCaml language so in theory it should work on platforms and
hardware architectures supported by OCaml. See the page below for the list of
supported platforms:
http://caml.inria.fr/ocaml/portability.en.html
-So far, Piqi has been tested on Debian Linux (Lenny and Squeeze, i386 and amd64
-architectures) and on Mac OS X 10.6.4.
-
-Current build procedure is likely not going to work on Windows out of the box,
-but it shouldn't be hard to adapt it.
+The rest of this file describes the process of building Piqi on Unix platforms.
+Instructions for building Piqi on Windows are provided in INSTALL.windows file.
PREREQUISITES
View
@@ -0,0 +1,165 @@
+
+This file contains instructions for building Piqi on Windows platform.
+
+Windows build described in this documented relies on MinGW/Msys. Building Piqi
+using other methods (Cygwin/Gcc or Microsoft toolchain) has not been tested.
+
+
+INSTALLATION INSTRUCTIONS
+=========================
+
+1. Download and install prerequisites
+
+1.1. MinGW and Msys
+
+ Install MinGW and Msys using automated installer which can be downloaded
+ from here:
+
+ http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/
+
+ Refer to MinGW website for additional information if necessary:
+
+ http://www.mingw.org
+
+ If you choose to install MinGW to non-default location (c:\mingw), make
+ sure the location doesn't contain spaces in directory names.
+
+
+1.2. OCaml compiler suite
+
+ Download and install binary OCaml distribution for Windows from the
+ official website:
+
+ http://caml.inria.fr/download.en.html
+
+ The website offers two kinds of binary distributions for Windows: the
+ first one is based on MinGW and the second one relies on Microsoft
+ compiler toolchain.
+
+ It is critical that the one that is based on MinGW is installed.
+
+ The latest OCaml version, distributed through the official website, that
+ is known to work can be downloaded using this URL:
+
+ http://caml.inria.fr/pub/distrib/ocaml-3.11/ocaml-3.11.0-win-mgw.exe
+
+
+1.3. Flexdll
+
+ Download and run self-extracting Flexdll installer from here:
+
+ http://alain.frisch.fr/flexdll.html#download
+
+
+1.4. Ocamlfind/Findlib -- library manager for OCaml
+
+ Download findlib sources (but don't build it yet!):
+
+ http://projects.camlcity.org/projects/findlib.html
+
+ Put the tarball to some filesystem location, for example, to
+ "c:\build\".
+
+
+1.5. Piqi source code distribution
+
+ Download Piqi sources (but don't try to build it!):
+
+ http://piqi.org/downloads/
+
+ Put the Piqi tarball to the same filesystem location where you've put
+ the findlib archive (e.g. "c:\build\").
+
+
+2. Build Findlib and Piqi
+
+
+2.1. Start MinGW shell
+
+ Start MinGW/Msys shell. The MinGW installer usually creates a desktop
+ shortcut for it.
+
+ Go to your build directory:
+
+ cd c:/build
+
+
+2.2. Unpack Findlib
+
+ tar -xzf findlib-*
+
+
+2.3. Unpack Piqi sources
+
+ tar -xzf piqi-*
+
+
+2.4. Configure Windows-specific build parameters
+
+ Note: this step is not necessary if MinGW, OCaml and Flexdll are
+ installed to the default locations suggested by their installers.
+
+ Use your favorite editor to setup environment variables in
+
+ c:\build\piqi\setenv-mingw.sh
+
+
+2.5. Apply build parameters
+
+ Go back to the opened MinGW shell and type the following commands:
+
+ cd piqi
+
+ . setenv-mingw.sh
+
+
+2.6. Build and install Findlib
+
+ Now, go to the unpacked findlib source code directory:
+
+ cd ..
+
+ cd findlib-<version>
+
+
+ And do the following:
+
+ ./configure
+
+ make all
+
+ make opt
+
+ make install
+
+ Note: once you've build and installed Findlib, you will no longer need
+ to repeat this step for subsequent Piqi builds.
+
+
+2.7. Build Piqi
+
+ Go back to the unpacked Piqi source code directory:
+
+ cd ..
+
+ cd piqi
+
+
+ Run the following commands:
+
+ make deps
+
+ make
+
+
+ Successful build will produce two stand-alone Windows executables:
+
+ piqi-tools/piqi.exe
+
+ piqic/piqic.exe
+
+
+3. Further actions that are not specific to Windows
+
+ Refer to general instructions provided in INSTALL file.
+
View
2 README
@@ -59,7 +59,9 @@ FILES
README this file
INSTALL installation instructions
+ INSTALL.windows instructions for building Piqi on Windows
setenv.sh installation configuration file
+ setenv-mingw.sh build configuration file for Windows/MinGW
LICENSE license
NOTICE copyright notice
AUTHORS Piqi authors
@@ -1042,6 +1042,8 @@ endif
-c $(THREAD_FLAG) $(ANNOT_FLAG) \
$(OCAMLFLAGS) $(INCFLAGS) $<; \
else \
+ pp=`eval echo $$pp`; \
+ pp=`echo $$pp | sed -e 's!:\\/!:\\\\!'`; \
$(ECHO) $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
-c -pp \"$$pp $(PPFLAGS)\" $(THREAD_FLAG) $(ANNOT_FLAG) \
$(OCAMLFLAGS) $(INCFLAGS) $<; \
@@ -1058,6 +1060,8 @@ endif
$(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
-c $(ALL_OCAMLCFLAGS) $<; \
else \
+ pp=`eval echo $$pp`; \
+ pp=`echo $$pp | sed -e 's!:\\/!:\\\\!'`; \
$(ECHO) $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
-c -pp \"$$pp $(PPFLAGS)\" $(ALL_OCAMLCFLAGS) $<; \
$(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
@@ -1130,6 +1134,8 @@ $(MLDEPDIR)/%.d: %.ml
$(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \
$(DINCFLAGS) $< > $@; \
else \
+ pp=`eval echo $$pp`; \
+ pp=`echo $$pp | sed -e 's!:\\/!:\\\\!'`; \
$(ECHO) $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \
-pp \"$$pp $(PPFLAGS)\" $(DINCFLAGS) $< \> $@; \
$(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \
@@ -79,7 +79,7 @@ let _ =
let address_book =
try
(* Read the existing address book. *)
- let ch = open_in Sys.argv.(1) in
+ let ch = open_in_bin Sys.argv.(1) in
let buf = Piqirun.init_from_channel ch in
let res = A.parse_address_book buf in
close_in ch;
@@ -97,7 +97,7 @@ let _ =
let address_book = prompt_for_address address_book in
(* Write the new address book back to disk. *)
- let och = open_out Sys.argv.(1) in
+ let och = open_out_bin Sys.argv.(1) in
(* NOTE: specifying -1 as the field code has a special meaning: it tells
* generator not to generate the header (code/tag/len) -- just generate the
* contents *)
@@ -13,7 +13,7 @@ let _ =
);
(* Read the existing address book in binary Protocol Buffers format *)
- let ch = open_in Sys.argv.(1) in
+ let ch = open_in_bin Sys.argv.(1) in
let buf = Piqirun.init_from_channel ch in
let address_book = Addressbook_piqi.parse_address_book buf in
close_in ch;
@@ -41,7 +41,7 @@ let _ =
exit (-1)
);
(* Read the existing address book. *)
- let ch = open_in Sys.argv.(1) in
+ let ch = open_in_bin Sys.argv.(1) in
let buf = Piqirun.init_from_channel ch in
let address_book = parse_address_book buf in
close_in ch;
View
@@ -17,7 +17,7 @@ test "$2"
BASE=`$OCAMLFIND printconf destdir`
# create a pointing from the piqi library to the initial library
-rm -f "$BASE/$2"
+rm -rf "$BASE/$2"
ln -s "$BASE/$1" "$BASE/$2"
View
@@ -65,8 +65,9 @@ let _ =
if !Sys.interactive
then ()
else
- match Sys.argv.(0) with
- | "./piqi_boot" -> boot ()
- | "./piqi_boot2" -> boot2 ()
+ let name = Filename.basename (Piqi_file.chop_extension Sys.argv.(0)) in
+ match name with
+ | "piqi_boot" -> boot ()
+ | "piqi_boot2" -> boot2 ()
| _ -> assert false
View
@@ -27,7 +27,7 @@ open Iolist
let read_file fname =
- let ch = Pervasives.open_in fname in
+ let ch = Pervasives.open_in_bin fname in
let len = Pervasives.in_channel_length ch in
let res = String.create len in
Pervasives.really_input ch res 0 len;
View
@@ -500,7 +500,7 @@ let read_piqi_string fname content :T.ast =
let open_piqi fname =
- try Pervasives.open_in fname
+ try Pervasives.open_in_bin fname
with Sys_error s ->
piqi_error ("error opening piqi file: " ^ s)
View
@@ -234,7 +234,7 @@ let parse_name_arg s =
let read_file filename =
- let ch = open_in filename in
+ let ch = open_in_bin filename in
let len = in_channel_length ch in
let buf = Buffer.create len in
Buffer.add_channel buf ch len;
View
@@ -35,7 +35,7 @@ let open_input = function
| "-" | "" -> stdin
| f ->
try
- let c = open_in f in
+ let c = open_in_bin f in
ifile := f;
ich := c; c
with Sys_error s ->
@@ -46,7 +46,7 @@ let open_output = function
| "-" | "" -> stdout
| f ->
try
- let c = open_out f in
+ let c = open_out_bin f in
ofile := f;
och := c; c
with Sys_error s ->
View
@@ -0,0 +1,28 @@
+#
+# Edit these variables if MinGW or OCaml are installed to other directories
+#
+# NOTE: "/c/" in the paths below is used instead of Windows "c:/" drive
+# letter specification.
+#
+
+MINGW_INSTALL_PATH="/c/MinGW"
+
+OCAML_INSTALL_PATH="/c/Program Files/Objective Caml"
+
+FLEXDLL_INSTALL_PATH="/c/Program Files/flexdll"
+
+
+#
+# don't change the settings below -- they are necessary for the build process
+#
+
+export OCAMLLIB="$OCAML_INSTALL_PATH/lib"
+
+# XXX: alternatively, we could do this:
+# export FLEXLINKFLAGS="-nocygpath -L $MINGW_INSTALL_PATH/lib"
+export OCAMLLDFLAGS="-I $MINGW_INSTALL_PATH/lib"
+
+export PATH="$FLEXDLL_INSTALL_PATH:$OCAML_INSTALL_PATH/bin:$MINGW_INSTALL_PATH/bin:$PATH"
+
+. setenv.sh
+
@@ -1,11 +1,11 @@
let t () =
print_endline "testing Piqi repeated fields and Piqi lists represented as OCaml arrays";
- let ich = open_in "test-all.piq.pb" in
+ let ich = open_in_bin "test-all.piq.pb" in
let buf = Piqirun.init_from_channel ich in
let piqi = Packed_piqi.parse_r_all buf in
- let och = open_out "test-all.piq.pb.array" in
+ let och = open_out_bin "test-all.piq.pb.array" in
let data = Packed_piqi.gen_r_all piqi in
Piqirun.to_channel och data;
@@ -1,11 +1,11 @@
let t () =
print_endline "testing packed repeated fields";
- let ich = open_in "test-all.piq.pb" in
+ let ich = open_in_bin "test-all.piq.pb" in
let buf = Piqirun.init_from_channel ich in
let piqi = Packed_piqi.parse_r_all buf in
- let och = open_out "test-all.piq.pb.packed" in
+ let och = open_out_bin "test-all.piq.pb.packed" in
let data = Packed_piqi.gen_r_all piqi in
Piqirun.to_channel och data;
Oops, something went wrong.

0 comments on commit e8bcfe0

Please sign in to comment.