diff --git a/obuild/build.ml b/obuild/build.ml index 9ac9c9e..66e742c 100644 --- a/obuild/build.ml +++ b/obuild/build.ml @@ -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 ( @@ -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 = diff --git a/obuild/dependencies.ml b/obuild/dependencies.ml index c46317e..15049b8 100644 --- a/obuild/dependencies.ml +++ b/obuild/dependencies.ml @@ -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,_,_) -> diff --git a/obuild/prepare.ml b/obuild/prepare.ml index 5549476..07d5394 100644 --- a/obuild/prepare.ml +++ b/obuild/prepare.ml @@ -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) = @@ -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; );