Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ocp-build: update with most recent version

Conflicts:

	Makefile
  • Loading branch information...
commit 8d1116aa0273e8be36d21a9c1563f6dd4df7b7b1 1 parent 57256c4
@OCamlPro-FabriceLeFessant OCamlPro-FabriceLeFessant authored
View
1  .gitignore
@@ -17,3 +17,4 @@ ocp-build.root
ocp-build.root.old
ocp-get
ocp-get-server
+ocp-build.root.old.old
View
25 Makefile
@@ -1,35 +1,32 @@
BIN = /usr/local/bin
-OCPBUILD ?= ./_obuild/unixrun ./boot/ocp-build.boot
+LOCAL_OCPBUILD=./ocp-build/ocp-build
+OCPBUILD ?= $(LOCAL_OCPBUILD)
OCAMLC=ocamlc
SRC_EXT=src_ext
TARGETS = opam opam-mk-repo opam-repo-convert-0.3
.PHONY: all
-all: ./_obuild/unixrun
+all: $(LOCAL_OCPBUILD)
$(MAKE) clone
$(MAKE) compile
-scan: ./_obuild/unixrun
+scan: $(LOCAL_OCPBUILD)
$(OCPBUILD) -scan
-sanitize: ./_obuild/unixrun
+sanitize: $(LOCAL_OCPBUILD)
$(OCPBUILD) -sanitize
-byte: ./_obuild/unixrun
+byte: $(LOCAL_OCPBUILD)
$(OCPBUILD) -byte
-opt: ./_obuild/unixrun
+opt: $(LOCAL_OCPBUILD)
$(OCPBUILD) -asm
-./_obuild/unixrun:
- mkdir -p ./_obuild
- $(OCAMLC) -o ./_obuild/unixrun -make-runtime unix.cma str.cma
-bootstrap: _obuild/unixrun _obuild/opam/opam.byte
- rm -f boot/opam.boot
- ocp-bytehack -static _obuild/opam/opam.byte -o boot/opam.boot
+$(LOCAL_OCPBUILD): ocp-build/ocp-build.boot ocp-build/win32_c.c
+ $(MAKE) -C ocp-build
-compile: ./_obuild/unixrun
+compile: $(LOCAL_OCPBUILD)
$(OCPBUILD) -init -scan -sanitize $(TARGET)
-clone:
+clone:
$(MAKE) -C $(SRC_EXT)
clean:
View
6 ocp-build/.gitignore
@@ -0,0 +1,6 @@
+ocp-build
+ocp-build.run
+primitives.cm*
+primitives.cmo
+primitives.ml
+win32_c.o
View
15 ocp-build/Makefile
@@ -0,0 +1,15 @@
+PREFIX=/usr/local/
+
+ocp-build: primitives ocp-build.boot win32_c.c
+ awk '{ print "external "$$1": unit -> unit = \"" $$1 "\"" }' primitives > primitives.ml
+ ocamlc -o ocp-build.run -custom -make-runtime win32_c.c primitives.ml unix.cma -cclib -lunix
+ cat ocp-build.run ocp-build.boot >> ocp-build
+ chmod +x ocp-build
+ ./ocp-build -help
+
+install: ocp-build
+ cp ocp-build $(PREFIX)/bin/ocp-build
+
+clean:
+ rm -f *~ ocp-build ocp-build.run primitives.cm? win32_c.o win32_c.obj primitives.ml
+
View
33 ocp-build/README.md
@@ -0,0 +1,33 @@
+# ocp-build
+
+ocp-build is a simple tool to compile a project containing OCaml
+sources. ocp-build uses a simple declarative language to describe the
+project. A project is composed of packages (libraries and
+executables), and packages are composed of source files and depend on
+other packages.
+
+ocp-build is able to do incremental and parallel compilation. The
+descriptions of the packages can be stored in different files, so that
+it is easy to move directories around without changing the description
+of the project.
+
+## Build and Installation
+
+In this directory, just do "make". This will create an "ocp-build"
+binary for your platform. Then, copy this file in your favorite places
+for development programs (/usr/local/bin/, for example).
+
+## Sources
+
+We have not yet released the sources of this version (although the
+sources of an old version are available in TypeRex version 1), because
+it depends on many of our internal libraries, and we need to clean the
+code of these libraries before releasing them.
+
+## The Project Description Language
+
+### A simple example of library
+
+### A simple example of program
+
+## ocp-build options
View
2  ocaml-libs.ocp → ocp-build/ocaml-libs.ocp
@@ -18,6 +18,7 @@
begin
generated = true
+ dirname = [ "%{OCAMLLIB}%" ]
begin library "unix"
has_byte = true
@@ -47,6 +48,7 @@ begin
end
begin library "threads"
+ dirname = [ "%{OCAMLLIB}%/threads" ]
has_byte = true
has_asm = true
end
View
BIN  ocp-build/ocp-build.boot
Binary file not shown
View
2  ocp-build/primitives
@@ -0,0 +1,2 @@
+win32_waitpids_ml
+win32_getFileInformationByName_ml
View
181 ocp-build/win32_c.c
@@ -0,0 +1,181 @@
+#ifdef __CYGWIN__
+#define _WIN32
+#endif
+
+#ifdef _WIN32
+
+#include <windows.h>
+#include <sys/types.h>
+
+
+#endif
+
+#include <caml/mlvalues.h>
+#include <caml/alloc.h>
+#include <caml/unixsupport.h>
+#include <caml/memory.h>
+#include <caml/signals.h>
+
+#ifdef _WIN32
+static value alloc_process_status(HANDLE pid, int status)
+{
+ value res, st;
+
+ st = alloc(1, 0);
+ Field(st, 0) = Val_int(status);
+ Begin_root (st);
+ res = alloc_small(2, 0);
+ Field(res, 0) = Val_long((intnat) pid);
+ Field(res, 1) = st;
+ End_roots();
+ return res;
+}
+
+enum { CAML_WNOHANG = 1, CAML_WUNTRACED = 2 };
+
+static int wait_flag_table[] = { CAML_WNOHANG, CAML_WUNTRACED };
+
+CAMLprim value win32_waitpids_ml(value ncount_v, value pid_reqs_v)
+{
+ int flags,i;
+ DWORD status, retcode;
+ DWORD err = 0;
+ int ncount = Int_val(ncount_v);
+ HANDLE* pid_reqs;
+ HANDLE pid_req;
+
+ pid_reqs = malloc(sizeof(HANDLE) * ncount);
+ for(i=0; i < ncount; i++){
+ pid_reqs[i] = (HANDLE) Long_val(Field(pid_reqs_v,i));
+ }
+ enter_blocking_section();
+ retcode = WaitForMultipleObjects(ncount, pid_reqs, FALSE,INFINITE);
+ if (retcode == WAIT_FAILED) err = GetLastError();
+ leave_blocking_section();
+ if (err) {
+ free(pid_reqs);
+ win32_maperr(err);
+ uerror("waitpids", Nothing);
+ }
+ pid_req = pid_reqs[retcode - WAIT_OBJECT_0];
+ free(pid_reqs);
+ if (! GetExitCodeProcess(pid_req, &status)) {
+ win32_maperr(GetLastError());
+ uerror("waitpids", Nothing);
+ }
+ if (status == STILL_ACTIVE)
+ return alloc_process_status((HANDLE) 0, 0);
+ else {
+ CloseHandle(pid_req);
+ return alloc_process_status(pid_req, status);
+ }
+}
+
+#else
+
+CAMLprim value win32_waitpids_ml(value ncount_v, value pid_reqs_v){
+ uerror("win32_waitpids_ml", Nothing);
+}
+
+#endif
+#ifdef __CYGWIN__
+#define _WIN32
+#endif
+
+
+#ifdef _WIN32
+
+#include <windows.h>
+#include <sys/types.h>
+
+
+#endif
+
+#include <caml/mlvalues.h>
+#include <caml/alloc.h>
+#include <caml/unixsupport.h>
+#include <caml/memory.h>
+#include <caml/signals.h>
+
+#ifdef _WIN32
+
+DOUBLE FileTime_to_POSIX(FILETIME ft)
+{
+ ULARGE_INTEGER date, adjust;
+ date.HighPart = ft.dwHighDateTime;
+ date.LowPart = ft.dwLowDateTime;
+
+ // 100-nanoseconds = milliseconds * 10000
+ adjust.QuadPart = 11644473600000ULL * 10000;
+ // removes the diff between 1970 and 1601
+ date.QuadPart -= adjust.QuadPart;
+ // converts back from 100-nanoseconds to seconds
+ return date.QuadPart / 1e7;
+}
+
+
+value win32_getFileInformationByHandle_ml(value handle_v)
+{
+ HANDLE handle = (HANDLE)handle_v;
+ BY_HANDLE_FILE_INFORMATION fileInfo;
+ CAMLparam0 ();
+ CAMLlocal1 (v);
+ ULARGE_INTEGER size, index;
+
+ if( !GetFileInformationByHandle(handle, &fileInfo) ){
+ DWORD err = GetLastError();
+ win32_maperr(err);
+ uerror("GetFileInformationByHandle", Nothing);
+ }
+
+ size.HighPart = fileInfo.nFileSizeHigh;
+ size.LowPart = fileInfo.nFileSizeLow;
+ index.HighPart = fileInfo.nFileIndexHigh;
+ index.LowPart = fileInfo.nFileIndexLow;
+
+ v = caml_alloc (8, 0);
+ Store_field(v,0, Val_int(fileInfo.dwFileAttributes));
+ Store_field(v, 1,
+ caml_copy_double(FileTime_to_POSIX(fileInfo.ftCreationTime)));
+ Store_field(v, 2,
+ caml_copy_double(FileTime_to_POSIX(fileInfo.ftLastAccessTime)));
+ Store_field(v, 3,
+ caml_copy_double(FileTime_to_POSIX(fileInfo.ftLastWriteTime)));
+ Store_field(v, 4, Val_int(fileInfo.dwVolumeSerialNumber));
+ Store_field(v, 5, caml_copy_int64(size.QuadPart));
+ Store_field(v, 6, Val_int(fileInfo.nNumberOfLinks));
+ Store_field(v, 7, caml_copy_int64(index.QuadPart));
+
+ CAMLreturn (v);
+}
+
+value win32_getFileInformationByName_ml(value filename_v)
+{
+ HANDLE hfile = CreateFile(String_val(filename_v), 0,
+ FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+ NULL, OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ value res;
+
+ if( hfile == INVALID_HANDLE_VALUE ){
+ DWORD err = GetLastError();
+ win32_maperr(err);
+ uerror("GetFileInformationByName", Nothing);
+ }
+ res = win32_getFileInformationByHandle_ml((value)hfile);
+ CloseHandle(hfile);
+ return res;
+}
+
+#else
+
+value win32_getFileInformationByHandle_ml(value handle_v)
+{
+ uerror("win32_getFileInformationByHandle_ml", Nothing);
+}
+
+value win32_getFileInformationByName_ml(value filename_v)
+{
+ uerror("win32_getFileInformationByName_ml", Nothing);
+}
+#endif
Please sign in to comment.
Something went wrong with that request. Please try again.