On 07/05/2011, Gerd Stolpmann <[email protected]> wrote:
> Am Samstag, den 07.05.2011, 16:59 +0200 schrieb Adrien:
>> Hi,
>>
>> I've been preparing new godi packages and I'm facing a build error for
>> one but I can't reproduce it outside of godi.
>>
>> I've tried copying godi's make invocation but without success: I can't
>> make it fail.
>>
>> The build process uses OCamlMakefile and ocamldsort. It looks like
>> ocamldsort doesn't run properly and that the modules aren't built in the
>> right order, making some being not found.
>>
>> Does godi change some environment variables before calling make? (with
>> putenv, not with 'foo=bar make')
>> Or does it do other things I might have not noticed?
>
> It sets a number of environment variables. A way to debug that would be
> to call "printenv" early in your build, e.g. add a "pre-build" rule to
> your package Makefile:
>
> pre-build:
> printenv
>
> You should especially watch out for PATH, OCAMLPATH, CC, CFLAGS.
>
> Just looking at the ocamldsort sources, I don't see any dependency on
> the environment (except PATH maybe, it is calling ocamldep). There is,
> however, one strangeness: ocamldsort checks whether stdin is a tty.
> Well, in GODI it isn't (so far I remember it is usually set to /dev/null
> - you cannot read input in GODI). When I understand the code right, this
> is meant as a check whether ocamldsort is called as part of a pipe, and
> it reads input then from stdin. Unix does not work this way, though.
>
> For debugging you could call ocamldsort (or the surrounding program)
> from "screen". This gives you temporarily a tty. But be careful,
> "screen" does not pass through stdin/stdout/stderr.
I've been able to move the call to ocamldsort earlier before the source
archive is created and the build succeeded.
I then took ocamldsort's source and removed the check and changed the
value of PATH to use that one. The package built.
I also believe that it reads from stdin if it doesn't find a tty. It's a
pretty weird behaviour. I've put my "patch" inline at the end of the
message for reference.
Thanks for the help, I probably wouldn't have found it without a lot of
pain.
Regards,
Adrien Nader
diff --git a/main.ml b/main.ml
index ce0f61d..07c40e6 100644
--- a/main.ml
+++ b/main.ml
@@ -35,13 +35,6 @@ let usage = "Usage: ocamldsort [options] <files>"
let version = "ocamldsort 0.15.0"
let print_version () = print_endline version; exit 0
-let is_input_a_tty () =
- try
- ignore (Unix.tcgetattr Unix.stdin);
- true
- with _ ->
- false
-
let speclist = [
"-I", Arg.String (fun dir -> load_path := !load_path @ [dir]),
" <dir>\tadd <dir> to the list of include directories";
@@ -73,10 +66,7 @@ let _ =
filenames :=
List.filter (fun x -> not (String.contains x '*')) !filenames;
let input_param =
- if is_input_a_tty () then
- Params.new_ocamldep_input_param !ocamldep !load_path !preprocessor
- else
- Params.Stdin in
+ Params.new_ocamldep_input_param !ocamldep !load_path !preprocessor in
let param = Params.new_param input_param !filenames !sort_strat !output in
let deps = Dependencies.get_dependencies param in
let sorted = Dep_sort.sort_dependencies deps param in
_______________________________________________
Godi-list mailing list
[email protected]
https://godirepo.camlcity.org/mailman/listinfo/godi-list