/usr/lib/ocaml/oasis/OCamlbuildCommon.ml is in liboasis-ocaml-dev 0.3.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | (******************************************************************************)
(* OASIS: architecture for building OCaml libraries and applications *)
(* *)
(* Copyright (C) 2008-2010, OCamlCore SARL *)
(* *)
(* This library is free software; you can redistribute it and/or modify it *)
(* under the terms of the GNU Lesser General Public License as published by *)
(* the Free Software Foundation; either version 2.1 of the License, or (at *)
(* your option) any later version, with the OCaml static compilation *)
(* exception. *)
(* *)
(* This library is distributed in the hope that it will be useful, but *)
(* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *)
(* or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more *)
(* details. *)
(* *)
(* You should have received a copy of the GNU Lesser General Public License *)
(* along with this library; if not, write to the Free Software Foundation, *)
(* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *)
(******************************************************************************)
(** Functions common to OCamlbuild build and doc plugin
*)
open OASISGettext
open BaseEnv
open BaseStandardVar
let ocamlbuild_clean_ev =
"ocamlbuild-clean"
let ocamlbuildflags =
var_define
~short_desc:(fun () -> "OCamlbuild additional flags")
"ocamlbuildflags"
(fun () -> "")
(** Fix special arguments depending on environment *)
let fix_args args extra_argv =
List.flatten
[
if (os_type ()) = "Win32" then
[
"-classic-display";
"-no-log";
"-no-links";
"-install-lib-dir";
(Filename.concat (standard_library ()) "ocamlbuild")
]
else
[];
if not (bool_of_string (is_native ())) || (os_type ()) = "Win32" then
[
"-byte-plugin"
]
else
[];
args;
if bool_of_string (debug ()) then
["-tag"; "debug"]
else
[];
if bool_of_string (profile ()) then
["-tag"; "profile"]
else
[];
OASISString.nsplit (ocamlbuildflags ()) ' ';
Array.to_list extra_argv;
]
(** Run 'ocamlbuild -clean' if not already done *)
let run_clean extra_argv =
let extra_cli =
String.concat " " (Array.to_list extra_argv)
in
(* Run if never called with these args *)
if not (BaseLog.exists ocamlbuild_clean_ev extra_cli) then
begin
OASISExec.run ~ctxt:!BaseContext.default
(ocamlbuild ()) (fix_args ["-clean"] extra_argv);
BaseLog.register ocamlbuild_clean_ev extra_cli;
at_exit
(fun () ->
try
BaseLog.unregister ocamlbuild_clean_ev extra_cli
with _ ->
())
end
(** Run ocamlbuild, unregister all clean events *)
let run_ocamlbuild args extra_argv =
(* TODO: enforce that target in args must be UNIX encoded i.e. toto/index.html
*)
OASISExec.run ~ctxt:!BaseContext.default
(ocamlbuild ()) (fix_args args extra_argv);
(* Remove any clean event, we must run it again *)
List.iter
(fun (e, d) -> BaseLog.unregister e d)
(BaseLog.filter [ocamlbuild_clean_ev])
(** Determine real build directory *)
let build_dir extra_argv =
let rec search_args dir =
function
| "-build-dir" :: dir :: tl ->
search_args dir tl
| _ :: tl ->
search_args dir tl
| [] ->
dir
in
search_args "_build" (fix_args [] extra_argv)
(* END EXPORT *)
open OASISTypes
let fix_build_tools tool pkg =
let fix_build_tools' sct bs =
if not (List.mem tool bs.bs_build_tools) then
{bs with bs_build_tools = tool :: bs.bs_build_tools}
else
bs
in
let sections =
List.fold_left
(fun acc sct ->
let sct =
match sct with
| Executable (cs, bs, exec) ->
let bs = fix_build_tools' sct bs in
Executable (cs, bs, exec)
| Library (cs, bs, lib) ->
let bs = fix_build_tools' sct bs in
Library (cs, bs, lib)
| Flag _ | SrcRepo _ | Test _ | Doc _ as sct ->
sct
in
sct :: acc)
[]
pkg.sections
in
{pkg with sections = List.rev sections}
module Tag =
struct
(** [filename_concat fn1 fn2] Concat filename, using semantic of _tags
[fn1] must be a real filename whereas fn2 can contains wildcards.
*)
let filename_concat fn1 fn2 =
OASISUnixPath.concat (OASISUnixPath.reduce fn1) fn2
end
|