Skip to content

Commit

Permalink
[enhance] build: replace Pathname.pwd with source_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Ye committed Nov 22, 2012
1 parent b68da32 commit 0ca337f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
34 changes: 17 additions & 17 deletions tools/build/build_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ rule "buildinfos: compiler/buildinfos/* -> compiler/buildinfos/buildInfos.ml"
let post_prod = env post_buildinfos in
Seq[
Cmd(S[Sh "cat" ; P pre_prod ; Sh ">" ; P prod]);
Cmd(S([P "bash"; A "-e"; P generate_buildinfos; P Pathname.pwd;
Cmd(S([P "bash"; A "-e"; P generate_buildinfos; P source_dir;
if Config.is_release then A "--release" else N;
A "--version" ; P version ] @ (
try
Expand Down Expand Up @@ -280,8 +280,8 @@ rule "launchHelper: tools/dependencies/launch_helper.sh -> compiler/qml2js/launc
(fun env build ->
Seq[
Cmd(S[Sh"mkdir"; A"-p"; P dependencies_path]);
cp (Pathname.pwd/launch_helper_script) (build_dir/launch_helper_script);
cp (Pathname.pwd/launch_helper_js) (build_dir/launch_helper_js);
cp (source_dir/launch_helper_script) (build_dir/launch_helper_script);
cp (source_dir/launch_helper_js) (build_dir/launch_helper_js);
Cmd(S[Sh"mkdir"; A"-p"; P qml2js_path]);
Cmd(S([Sh"echo let script = \\\" > "; P launchHelper]));
Cmd(S([Sh"cat"; P launch_helper_script]
Expand Down Expand Up @@ -474,7 +474,7 @@ rule "Client lib JS validation"
Needs to access lots of files. Cf jsdocdir/README.txt
*)
let jsdocdir =
Pathname.pwd/"tools"/"jsdoc-toolkit"
source_dir/"tools"/"jsdoc-toolkit"
in

let jsdoc_target = "doc.jsbsl" in
Expand Down Expand Up @@ -748,7 +748,7 @@ let plugin_building
match Tags.mem "with_mlstate_debug" (tags_of_pathname mlfile) with
| true ->
A"--pp-file"
:: P (Printf.sprintf "%s:%s" mlfile (Pathname.pwd/opalang_prefix/"tools"/"utils"/"ppdebug.pl"))
:: P (Printf.sprintf "%s:%s" mlfile (source_dir/(prefix_me "tools"/"utils"/"ppdebug.pl")))
:: options
| false -> options
) options (List.rev mlfiles)
Expand Down Expand Up @@ -865,8 +865,8 @@ let node_plugins =
Command.execute ~quiet:true ~pretend:false
(Cmd (S[
Sh"mkdir"; A"-p"; P (build_dir / stdlib_packages_dir); Sh"&&";
P (Pathname.pwd/stdlib_packages_dir/"all_plugins.sh");
P (Pathname.pwd/stdlib_packages_dir);
P (source_dir/stdlib_packages_dir/"all_plugins.sh");
P (source_dir/stdlib_packages_dir);
Sh">"; P all_plugins_file;
])) ;
string_list_of_file all_plugins_file
Expand Down Expand Up @@ -915,12 +915,12 @@ in
let module RuleFailure = struct exception E end in
let files_of_package pkg =
let aux_files pkdir =
let opack = dir_ext_files "opack" (Pathname.pwd / pkdir) in
let files = dir_ext_files "opa" (Pathname.pwd / pkdir) in
let opack = dir_ext_files "opack" (source_dir / pkdir) in
let files = dir_ext_files "opa" (source_dir / pkdir) in
let files = files @ opack in
(* return relative filenames *)
let files =
let len = String.length Pathname.pwd + 1 in (* the additional '/' *)
let len = String.length source_dir + 1 in (* the additional '/' *)
let relative_part s = String.sub s len (String.length s - len) in
List.map relative_part files
in
Expand All @@ -930,9 +930,9 @@ let files_of_package pkg =
List.sort String.compare files
in
let pkdir = prefix_me ("lib" / package_to_dir pkg) in
if not (Pathname.is_directory (Pathname.pwd / pkdir)) then
if not (Pathname.is_directory (source_dir / pkdir)) then
let pkdir = "lib" / package_to_dir pkg in
if not (Pathname.is_directory (Pathname.pwd / pkdir)) then
if not (Pathname.is_directory (source_dir / pkdir)) then
let () = Printf.eprintf "Error: can not find sources for package %s (directory %s does not exist)\n" pkg pkdir in
raise RuleFailure.E
else aux_files pkdir
Expand All @@ -952,9 +952,9 @@ let all_packages_building =
~prod
(fun env build ->
Cmd(S[
P (Pathname.pwd/stdlib_packages_dir/"all_packages.sh");
P (Pathname.pwd/stdlib_packages_dir/packages_exclude_node);
P (Pathname.pwd/stdlib_packages_dir);
P (source_dir/stdlib_packages_dir/"all_packages.sh");
P (source_dir/stdlib_packages_dir/packages_exclude_node);
P (source_dir/stdlib_packages_dir);
Sh">"; P (build_dir/prod);
])
)
Expand Down Expand Up @@ -1052,7 +1052,7 @@ let packages_building ~name ~stamp ~core_only ~rebuild
(* A"--verbose-build"; *)
A"--conf";P "conf";
A"--slicer-check"; A "low";
A"--project-root"; P (Pathname.pwd/opalang_prefix); (* because the @static_resource in the stdlib expect this *)
A"--project-root"; P (source_dir/opalang_prefix); (* because the @static_resource in the stdlib expect this *)
A"--no-stdlib";
A"-I"; A prefixed_plugins_dir;
opaopt;
Expand Down Expand Up @@ -1121,7 +1121,7 @@ rule name
A"-o"; P opa_create_dst; P opa_create_src;
A"--opx-dir"; A app_opx_dir;
A"--no-server";
A"--project-root"; P (Pathname.pwd/opalang_prefix); (* because the @static_resource in the stdlib expect this *)
A"--project-root"; P (source_dir/opalang_prefix); (* because the @static_resource in the stdlib expect this *)
A"-I"; A prefixed_plugins_dir
] @ more_app_opts));
unset_mlstatelibs
Expand Down
8 changes: 5 additions & 3 deletions tools/build/myocamlbuild_prefix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ let clear_backslashes s =
String.iteri (fun i c -> if c = '\\' then s.[i] <- '/') s;
s

let source_dir = clear_backslashes Pathname.pwd

let build_dir =
clear_backslashes (
if (Pathname.is_relative !Options.build_dir)
Expand Down Expand Up @@ -209,7 +211,7 @@ let trx_build_aux ~just_binary src dst ext ops = fun env build ->
| _ -> assert false)
@ (if trx_cache_tag
then [Cmd(S[Sh"cp ";P(env dst);P(env dst -.- "cache")]);
Cmd(S[Sh"cp ";P(env dst);P(Pathname.pwd / env dst -.- "cache")])]
Cmd(S[Sh"cp ";P(env dst);P(source_dir / env dst -.- "cache")])]
else []))
in
let get_tool_trx_file () =
Expand All @@ -220,7 +222,7 @@ let trx_build_aux ~just_binary src dst ext ops = fun env build ->
match Outcome.wrap build [tool_deps trx_tool] with
| Outcome.Good _ -> do_build ()
| Outcome.Bad _ ->
let cache = Pathname.pwd / env dst -.- "cache" in
let cache = source_dir / env dst -.- "cache" in
if Sys.file_exists (get_tool_trx_file ()) then (
do_build ()
) else if trx_cache_tag && Sys.file_exists cache then (
Expand All @@ -238,7 +240,7 @@ let trx_build ?(just_binary = false) pattern cmd =
List.fold_left combine Nop exts

let dirlist dir =
let searchdir = if Pathname.is_relative dir then Pathname.pwd / dir else dir in
let searchdir = if Pathname.is_relative dir then source_dir / dir else dir in
List.map (fun d -> dir/d) (Array.to_list (Pathname.readdir searchdir))

let dir_ext_files ext dir =
Expand Down
4 changes: 2 additions & 2 deletions tools/build/myocamlbuild_suffix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
(* pp_script *)

let mlstate_debug, mlstate_nodebug, pa_ulex =
S [ P "perl"; P (Pathname.pwd/(prefix_me "tools"/"utils"/"ppdebug.pl"))],
S [ P "perl"; P (Pathname.pwd/(prefix_me "tools"/"utils"/"ppdebug.pl")); A "-r" ],
S [ P "perl"; P (source_dir/(prefix_me "tools"/"utils"/"ppdebug.pl"))],
S [ P "perl"; P (source_dir/(prefix_me "tools"/"utils"/"ppdebug.pl")); A "-r" ],
S [ P Config.camlp4o;
(match Config.Libdir.ulex with
| Some dir -> S [A "-I"; P dir]
Expand Down

0 comments on commit 0ca337f

Please sign in to comment.