Skip to content

Commit

Permalink
switch to Async
Browse files Browse the repository at this point in the history
  • Loading branch information
trefis authored and Jeremie Dimino committed Sep 2, 2013
1 parent 3f02aa1 commit cd9b90a
Show file tree
Hide file tree
Showing 18 changed files with 1,011 additions and 4,218 deletions.
16 changes: 4 additions & 12 deletions _oasis
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Homepage: http://ocsigen.org/lwt/
BuildTools: ocamlbuild
Plugins: DevFiles (0.3), META (0.3)
XDevFilesEnableMakefile: false
PostConfCommand: ocaml discover.ml -ocamlc $ocamlc -ext-obj $ext_obj -exec-name $default_executable_name -use-libev $libev -os-type $os_type -use-glib $glib -ccomp-type $ccomp_type -use-pthread $pthread -use-unix $unix -android-target $android_target -libev_default $libev_default
PostConfCommand: ocaml discover.ml -ocamlc $ocamlc -ext-obj $ext_obj -exec-name $default_executable_name -os-type $os_type -use-glib $glib -ccomp-type $ccomp_type -use-pthread $pthread -use-unix $unix -android-target $android_target
PostDistCleanCommand: $rm src/unix/lwt_config.h src/unix/lwt_config.ml src/unix/lwt_unix_jobs_generated.ml src/unix/jobs-unix/*

Synopsis: Lightweight thread library for Objective Caml
Expand Down Expand Up @@ -81,14 +81,6 @@ Flag toplevel
Description: Enhanced toplevel
Default$: flag(all)

Flag libev
Description: Compile with libev support
Default$: !os_type(Win32) && !flag(android_target)

Flag libev_default
Description: Use the libev backend by default
Default$: system(linux) || system(linux_elf) || system(linux_aout) || system(linux_eabi) || system(linux_eabihf)

Flag pthread
Description: Use pthread
Default$: !os_type(Win32)
Expand Down Expand Up @@ -118,6 +110,7 @@ Library "lwt"
Lwt_switch,
Lwt_util,
Lwt_pqueue
BuildDepends: async, threads
XMETADescription: Lightweight thread library for OCaml (core library)

Library "lwt-log"
Expand Down Expand Up @@ -146,17 +139,16 @@ Library "lwt-unix"
Lwt_timeout,
Lwt_unix,
Lwt_sys,
Lwt_engine,
Lwt_bytes
InternalModules:
Lwt_unix_jobs_generated
BuildDepends: lwt, lwt.log, unix, bigarray
BuildDepends: lwt, lwt.log, unix, bigarray, core, sexplib.syntax, threads, async
XMETARequires: lwt, lwt.log, unix, bigarray, core, threads, async
XMETADescription: Unix support for lwt
CSources:
lwt_config.h,
lwt_unix.h,
lwt_unix_stubs.c,
lwt_libev_stubs.c,
lwt_process_stubs.c,
jobs-unix/lwt_unix_job_access.c,
jobs-unix/lwt_unix_job_chdir.c,
Expand Down
54 changes: 2 additions & 52 deletions discover.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ open Printf
| Search path |
+-----------------------------------------------------------------+ *)

(* List of search paths for header files, mostly for MacOS
users. libev is installed by port systems into non-standard
locations by default on MacOS.
(* List of search paths for header files, mostly for MacOS users.
We use a hardcorded list of path + the ones from C_INCLUDE_PATH and
LIBRARY_PATH.
Expand Down Expand Up @@ -94,17 +92,6 @@ CAMLprim value lwt_test()
}
"

let libev_code = "
#include <caml/mlvalues.h>
#include <ev.h>
CAMLprim value lwt_test()
{
ev_default_loop(0);
return Val_unit;
}
"

let fd_passing_code = "
#include <caml/mlvalues.h>
#include <sys/types.h>
Expand Down Expand Up @@ -226,14 +213,12 @@ CAMLprim value lwt_test()
let ocamlc = ref "ocamlc"
let ext_obj = ref ".o"
let exec_name = ref "a.out"
let use_libev = ref true
let use_glib = ref false
let use_pthread = ref true
let use_unix = ref true
let os_type = ref "Unix"
let android_target = ref false
let ccomp_type = ref "cc"
let libev_default = ref true

let log_file = ref ""
let caml_file = ref ""
Expand Down Expand Up @@ -405,14 +390,12 @@ let () =
"-ocamlc", Arg.Set_string ocamlc, "<path> ocamlc";
"-ext-obj", Arg.Set_string ext_obj, "<ext> C object files extension";
"-exec-name", Arg.Set_string exec_name, "<name> name of the executable produced by ocamlc";
"-use-libev", arg_bool use_libev, " whether to check for libev";
"-use-glib", arg_bool use_glib, " whether to check for glib";
"-use-pthread", arg_bool use_pthread, " whether to use pthread";
"-use-unix", arg_bool use_unix, " whether to build lwt.unix";
"-os-type", Arg.Set_string os_type, "<name> type of the target os";
"-android-target", arg_bool android_target, "<name> compiles for Android";
"-ccomp-type", Arg.Set_string ccomp_type, "<ccomp-type> C compiler type";
"-libev_default", arg_bool libev_default, " whether to use the libev backend by default";
] in
Arg.parse args ignore "check for external C libraries and available features\noptions are:";

Expand Down Expand Up @@ -440,32 +423,14 @@ let () =
let setup_data = ref [] in

(* Test for pkg-config. *)
test_feature ~do_check:(!use_libev || !use_glib) "pkg-config" ""
test_feature ~do_check:!use_glib "pkg-config" ""
(fun () ->
ksprintf Sys.command "pkg-config --version > %s 2>&1" !log_file = 0);

(* Not having pkg-config is not fatal. *)
let have_pkg_config = !not_available = [] in
not_available := [];

let test_libev () =
let opt, lib =
lib_flags "LIBEV"
(fun () ->
match if have_pkg_config then pkg_config_flags "libev" else None with
| Some (opt, lib) ->
(opt, lib)
| None ->
match search_header "ev.h" with
| Some (dir_i, dir_l) ->
(["-I" ^ dir_i], ["-L" ^ dir_l; "-lev"])
| None ->
([], ["-lev"]))
in
setup_data := ("libev_opt", opt) :: ("libev_lib", lib) :: !setup_data;
test_code (opt, lib) libev_code
in

let test_pthread () =
let opt, lib =
if !android_target then ([], []) else
Expand Down Expand Up @@ -495,7 +460,6 @@ let () =
test_code (opt, lib) glib_code
in

test_feature ~do_check:!use_libev "libev" "HAVE_LIBEV" test_libev;
test_feature ~do_check:!use_pthread "pthread" "HAVE_PTHREAD" test_pthread;
test_feature ~do_check:!use_glib "glib" "" test_glib;

Expand All @@ -507,13 +471,6 @@ The following recquired C libraries are missing: %s.
Please install them and retry. If they are installed in a non-standard location
or need special flags, set the environment variables <LIB>_CLFAGS and <LIB>_LIBS
accordingly and retry.
For example, if libev is installed in /opt/local, you can type:
export LIBEV_CLFAGS=-I/opt/local/include
export LIBEV_LIBS=-L/opt/local/lib
To compile without libev support, use ./configure --disable-libev ...
" (String.concat ", " !not_available);
exit 1
end;
Expand Down Expand Up @@ -576,18 +533,11 @@ Lwt can use pthread or the win32 API.
end else begin
output_string config_ml "#let android=false\n"
end;
if !libev_default then begin
output_string config_ml "#let libev_default=true\n"
end else begin
output_string config_ml "#let libev_default=false\n"
end;

fprintf config "#endif\n";

(* Our setup.data keys. *)
let setup_data_keys = [
"libev_opt";
"libev_lib";
"pthread_lib";
"pthread_opt";
"glib_opt";
Expand Down
1 change: 0 additions & 1 deletion myocamlbuild.ml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ let () =
disabled. *)
if BaseEnvLight.var_get "unix" env = "true" then begin
define_c_library "glib" env;
define_c_library "libev" env;
define_c_library "pthread" env;

flag ["c"; "compile"; "use_lwt_headers"] & S [A"-ccopt"; A"-Isrc/unix"];
Expand Down
Loading

0 comments on commit cd9b90a

Please sign in to comment.