Skip to content
This repository
tree: 77fc29d9fa
Fetching contributors…

Cannot retrieve contributors at this time

file 237 lines (212 sloc) 6.262 kb
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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA 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 GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)

(* depends *)
module Arg = Base.Arg
module String = Base.String

type makefile_rule =
  | Bytecode
  | Native
  | Bytecode_and_native
  | Bytecode_or_native

(**
Command-line options for the Qml to OCaml compiler.


@author Mathieu Barbin
@author David Rajchenbach-Teller (Additional options)
*)

(** STATICS PARAMETERS *)

module StaticParameters =
struct
  (** the other values are not mutable -- cf opa options -I -x to add some more libraries *)
  let options_compiler =
    ["-w a"]

  let options_linker =
    ["-w a"]
    @ (if Base.is_windows then
         ["-cclib"; "Dnsapi.lib"; "-cclib"; "libeay32.lib"; "-cclib"; "ssleay32.lib" (*; "ssl_stubs.obj" *)]
       else [])

  (**
Absolute path for include directory, will be passed with the option -I to the ocaml compiler.
*)
  let server_include_dir = [
    "+zip" ; "+site-lib/zip" ; "+site-lib/camlzip" ;
    "+ssl" ; "+site-lib/ssl" ;
    "+cryptokit"; "+site-lib/cryptokit" ;
    "+ulex" ; "+site-lib/ulex" ;
  ] @ (
    if Config.has_dbm then [
      "+dbm" ; "+site-lib/dbm" ;
    ] else []
  )

  (**
Like [server_include_dir] but the path is not absolute, but relative to MLSTATELIBS directory.
The following directories will be prefixed by MLSTATELIBS before passing to ocaml compiler with -I
*)
  let server_include_mlstate_dir =
    InstallDir.lib_opa ::
    (
      if Base.is_windows
      then
        (*
FIXME
What is the purpose of this ?
This will be concatenated with a Filename.concat anyway
*)
        if BuildInfos.is_release
        then ["windows_libs/openssl/lib"]
        else ["/windows_libs/openssl/lib"]
      else []
    )

  (**
The list of ocaml libraries. Will be suffixed by ".cma" or ".cmxa" depending of the option --bytecode.
Theses libraries should be installed in one of the directory reachable by option -I (server_include_dir & server_include_mlstate_dir)
*)
  let common_server_libraries = [
    "str" ;
    "unix" ;
    "bigarray";
    "ssl" ;
#<Ifstatic:HAS_DBM 1>
    "dbm" ;
#<End>
    "zip" ;
    "nums" ;
    "ulexing" ;
    "buildinfos" ;
    "libbase" ;
    "libtrx" ;
    "libruntime" ;
    "appruntime" ;
    "libtools" ;
    "libsecurity" ;
    "libnet" ;
    "libirc" ;
    "database" ;
    "oparuntime";
    "libsession" ;
  ]

  let qml_server_libraries = [
    "qmlflat", common_server_libraries @ [ "qmlcpsserver" ; "qmlflatserver"; "opabsl_for_server" ];
    "qmlfake", common_server_libraries @ [ "qmlcpsserver" ; "qmlfakeserver"; "opabsl_for_server" ];
  ]

  let opa_server_libraries =
    [ "cryptokit" ; "opabsl_for_server" ]

  (** the 2 following options will be used only in the case of resp bytecode / native *)
  let extra_bytecode_options = [ "-g" ]
  let extra_native_options = [ "-g" (* "-compact" *) ]
end

type input_file = QmlFile of string | OpaFile of string
let input_filename = function
  | QmlFile f
  | OpaFile f -> f

(*
TODO
for historic reasons, this used to be the options for the OPA compiler.
now, this correspond only to the options used by the ocaml back-end.
The current status is messy:
-lots of these options are unused (never set, never read).
-lots of these options are override by opa/passes.ml/pass_OpaOptionsToQmlOptions
a big clean-up is expected
*)
type argv_options = {
  (*
1) Options used by passes after qmlcompilation
*)
  camlp4o : bool ;
  check_lib : bool ;
  compilation_directory : string ;
  compile_via_makefile : bool ;
  exe_run : bool ;
  exe_argv : string list ;
  extra_lib : string list ;
  extra_path : string list ;
  hacker_mode : bool ;
  makefile_max_jobs : int ;
  makefile_rule : makefile_rule;
  mlcopt : string list ;
  mllopt : string list ;
  no_move : bool ;
  ocamlc : string ;
  ocamlopt : string ;
  profile : bool ;
  show_compilation : bool ;
  target : string ;

  (*
2) Options used by the pass qmlcompilation
*)
  cps : bool ;
  no_assert: bool;
  qml_closure: bool;
  top_magic : bool ;

  (*
3) Used by the command line tool qmljs
This should be refactored, somehow
*)
  bypass_plugin : string list ;
  cps_toplevel_concurrency : bool ;
  constant_sharing : bool ;
  input_files : input_file list ;
  lambda_lifting : bool ;
  no_stdlib : bool ;

  (*
4) trash
*)
  display_schema : string option ;
  server_side : bool ;
  split_ocaml_value : int ;
}

module ArgvOptions :
sig
  val default : string -> argv_options
end
  =
struct

  let default backend = {
    bypass_plugin = [] ;
    camlp4o = false ;
    check_lib = false ;
    compilation_directory = "" ; (* set by opa *)
    compile_via_makefile = false ;
    constant_sharing = false ;
    cps = false ;
    cps_toplevel_concurrency = false ;
    server_side = true ;
    display_schema = None ;
    exe_argv = [] ;
    exe_run = false ;
    extra_lib = (
      let qml = List.assoc backend StaticParameters.qml_server_libraries in
      let opa = StaticParameters.opa_server_libraries in
      qml@opa
    ) ;
    extra_path = [] ;
    hacker_mode = false ;
    input_files = [] ;
    lambda_lifting = false ;
    makefile_max_jobs = 7 ;
    makefile_rule = Native ;
    mlcopt = StaticParameters.options_compiler ;
    mllopt = StaticParameters.options_linker ;
    no_assert = false ;
    no_stdlib = false ;
    no_move = false ;
    ocamlc = "" ; (* set by opa *)
    ocamlopt = "" ; (* set by opa *)
    profile = false ;
    qml_closure = false ;
    show_compilation = false ; (* set by opa *)
    split_ocaml_value = 100 ; (* set by opa *)
    target = "" ; (* set by opa *)
    top_magic = true ; (* set by opa *)
  }
end
Something went wrong with that request. Please try again.