Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes #179

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions obuild/build.ml
Original file line number Diff line number Diff line change
Expand Up @@ -302,21 +302,9 @@ let compile_module task_index task is_intf h bstate task_context dag =
(if reason <> "" then " ( " ^ reason ^ " )" else "");
Scheduler.AddTask (task, all_fun_lists)

let wait_for_files cdep_files =
List.for_all (fun f ->
let test = Filesystem.exists f in
if not test then
verbose Debug "warning: (temporarily?) missing file %s" (fp_to_string f);
test
) cdep_files

let link_c cstate clib_name =
let lib_name = cstate.compilation_builddir_c </> fn clib_name in
let cdep_files = List.map (fun x -> cstate.compilation_builddir_c </> o_from_cfile x) cstate.compilation_csources in
(* Not sure why it is necessary ... gcc seems to return before the files are ready. *)
while not (wait_for_files cdep_files) do
ignore (Unix.select [] [] [] 0.02) (* sleep 1/50 second *)
done;
if gconf.ocamlmklib then
[[(fun () -> runCLinking LinkingShared cdep_files lib_name)]]
else (
Expand Down Expand Up @@ -451,11 +439,11 @@ let sanity_check build_dir target =
let allOK = List.for_all (fun f ->
let test = Filesystem.exists (build_dir </> f) in
if not test then
verbose Debug "warning: missing file %s" (fp_to_string (build_dir </> f));
verbose Debug "warning: missing file %s\n" (fp_to_string (build_dir </> f));
test
) files in
if not allOK
then verbose Report "warning: some target file appears to be missing";
then verbose Report "warning: some target file appears to be missing\n";
()

let check task_index task task_context dag =
Expand Down
4 changes: 2 additions & 2 deletions obuild/dependencies.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ let joinLines s =
in
bytes_to_string (replace 0)

let runCCdep srcDir files : (filename * filepath list) list =
let args = [Prog.getCC (); "-MM"] @ List.map (fun fn -> fp_to_string (srcDir </> fn)) files in
let runCCdep srcDir clibpaths files : (filename * filepath list) list =
let args = [Prog.getCC (); "-MM"] @ (Utils.to_include_path_options clibpaths) @ List.map (fun fn -> fp_to_string (srcDir </> fn)) files in
match Process.run args with
| Process.Failure err -> raise (BuildCDepAnalyzeFailed err)
| Process.Success (out,_,_) ->
Expand Down
10 changes: 7 additions & 3 deletions obuild/prepare.ml
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,11 @@ let prepare_target_ bstate buildDir target toplevelModules =
List.iter (Hashtbl.remove h) freeModules;
done;

(* just append each C sources as single node in the stepsDag *)
(* Append each C sources as single node in the stepsDag, making them dependencies
* of the final linking target.
*)
if cbits.target_csources <> [] then (
let objDeps = runCCdep cbits.target_cdir cbits.target_csources in
let objDeps = runCCdep cbits.target_cdir cbits.target_clibpaths cbits.target_csources in

List.iter (fun cSource ->
let (fps : filepath list) =
Expand All @@ -520,7 +522,9 @@ let prepare_target_ bstate buildDir target toplevelModules =
Dag.addChildrenEdges oNode hFiles filesDag;

(* add C source compilation task into the step DAG *)
Dag.addNode (CompileC cSource) stepsDag
let ccNode = CompileC cSource in
Dag.addNode ccNode stepsDag;
Dag.addEdge (LinkTarget target) ccNode stepsDag;
) cbits.target_csources;
);

Expand Down