Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file InternalConfigurePlugin.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295(******************************************************************************)(* OASIS: architecture for building OCaml libraries and applications *)(* *)(* Copyright (C) 2011-2016, Sylvain Le Gall *)(* Copyright (C) 2008-2011, 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 *)(******************************************************************************)(** Configure using internal scheme
@author Sylvain Le Gall
*)openBaseEnvopenOASISTypesopenOASISUtilsopenOASISGettextopenBaseMessage(** Configure build using provided series of check to be done
and then output corresponding file.
*)letconfigure~ctxt:_pkgargv=letvar_ignore_evalvar=let_s:string=var()in()inleterrors=refSetString.emptyinletbuff=Buffer.create13inletadd_errorsfmt=Printf.kbprintf(funb->errors:=SetString.add(Buffer.contentsb)!errors;Buffer.clearb)bufffmtinletwarn_exceptione=warning"%s"(Printexc.to_stringe)in(* Check tools *)letcheck_toolslst=List.iter(function|ExternalTooltool->begintryvar_ignore_eval(BaseCheck.progtool)withe->warn_exceptione;add_errors(f_"Cannot find external tool '%s'")toolend|InternalExecutablenm1->(* Check that matching tool is built *)List.iter(function|Executable({cs_name=nm2;_},{bs_build=build;_},_)whennm1=nm2->ifnot(var_choosebuild)thenadd_errors(f_"Cannot find buildable internal executable \
'%s' when checking build depends")nm1|_->())pkg.sections)lstinletbuild_checkssctbs=ifvar_choosebs.bs_buildthenbeginifbs.bs_compiled_object=Nativethenbegintryvar_ignore_evalBaseStandardVar.ocamloptwithe->warn_exceptione;add_errors(f_"Section %s requires native compilation")(OASISSection.string_of_sectionsct)end;(* Check tools *)check_toolsbs.bs_build_tools;(* Check depends *)List.iter(function|FindlibPackage(findlib_pkg,version_comparator)->begintryvar_ignore_eval(BaseCheck.package?version_comparatorfindlib_pkg)withe->warn_exceptione;matchversion_comparatorwith|None->add_errors(f_"Cannot find findlib package %s")findlib_pkg|Somever_cmp->add_errors(f_"Cannot find findlib package %s (%s)")findlib_pkg(OASISVersion.string_of_comparatorver_cmp)end|InternalLibrarynm1->(* Check that matching library is built *)List.iter(function|Library({cs_name=nm2;_},{bs_build=build;_},_)whennm1=nm2->ifnot(var_choosebuild)thenadd_errors(f_"Cannot find buildable internal library \
'%s' when checking build depends")nm1|_->())pkg.sections)bs.bs_build_dependsendin(* Parse command line *)BaseArgExt.parseargv(BaseEnv.args());(* OCaml version *)beginmatchpkg.ocaml_versionwith|Somever_cmp->begintryvar_ignore_eval(BaseCheck.version"ocaml"ver_cmpBaseStandardVar.ocaml_version)withe->warn_exceptione;add_errors(f_"OCaml version %s doesn't match version constraint %s")(BaseStandardVar.ocaml_version())(OASISVersion.string_of_comparatorver_cmp)end|None->()end;(* Findlib version *)beginmatchpkg.findlib_versionwith|Somever_cmp->begintryvar_ignore_eval(BaseCheck.version"findlib"ver_cmpBaseStandardVar.findlib_version)withe->warn_exceptione;add_errors(f_"Findlib version %s doesn't match version constraint %s")(BaseStandardVar.findlib_version())(OASISVersion.string_of_comparatorver_cmp)end|None->()end;(* Make sure the findlib version is fine for the OCaml compiler. *)beginletocaml_ge4=OASISVersion.version_compare(OASISVersion.version_of_string(BaseStandardVar.ocaml_version()))(OASISVersion.version_of_string"4.0.0")>=0inifocaml_ge4thenletfindlib_lt132=OASISVersion.version_compare(OASISVersion.version_of_string(BaseStandardVar.findlib_version()))(OASISVersion.version_of_string"1.3.2")<0iniffindlib_lt132thenadd_errors"OCaml >= 4.0.0 requires Findlib version >= 1.3.2"end;(* FlexDLL *)ifBaseStandardVar.os_type()="Win32"||BaseStandardVar.os_type()="Cygwin"thenbegintryvar_ignore_evalBaseStandardVar.flexlinkwithe->warn_exceptione;add_errors(f_"Cannot find 'flexlink'")end;(* Check build depends *)List.iter(function|Executable(_,bs,_)|Library(_,bs,_)assct->build_checkssctbs|Doc(_,doc)->ifvar_choosedoc.doc_buildthencheck_toolsdoc.doc_build_tools|Test(_,test)->ifvar_choosetest.test_runthencheck_toolstest.test_tools|_->())pkg.sections;(* Check if we need native dynlink (presence of libraries that compile to
native)
*)beginlethas_cmxa=List.exists(function|Library(_,bs,_)->var_choosebs.bs_build&&(bs.bs_compiled_object=Native||(bs.bs_compiled_object=Best&&bool_of_string(BaseStandardVar.is_native())))|_->false)pkg.sectionsinifhas_cmxathenvar_ignore_evalBaseStandardVar.native_dynlinkend;(* Check errors *)ifSetString.empty!=!errorsthenbeginList.iter(fune->error"%s"e)(SetString.elements!errors);failwithf(fn_"%d configuration error""%d configuration errors"(SetString.cardinal!errors))(SetString.cardinal!errors)end(* END EXPORT *)openOASISPluginopenInternalIdletplugin=`Configure,name,Someversionletinit()=letself_id,_=Configure.createplugininletdoitplugin_ctxt_=plugin_ctxt,{chng_moduls=[InternalData.internalsys_ml];chng_clean=None;chng_distclean=None;chng_main=(OASISDataNotation.funcconfigure"InternalConfigurePlugin.configure");}inInternalId.init();Configure.register_actself_iddoit