1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283(**************************************************************************)(* *)(* Copyright 2020 OCamlPro & Origin Labs *)(* *)(* All rights reserved. This file is distributed under the terms of the *)(* GNU Lesser General Public License version 2.1, with the special *)(* exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)openEz_file.V1openEzcmd.V2openEzFile.OPopenTypesletcmd_name="build"letaction~args()=let(p:Types.project)=Build.build~args()inletn=ref0inList.iter(funpackage->matchpackage.kindwith|Library->()|Virtual->()|Program->ifSys.file_existspackage.namethenSys.removepackage.name;letsrc="_build/default"//package.dir//"main.exe"inifSys.file_existssrcthen(lets=EzFile.read_filesrcinEzFile.write_filepackage.names;incrn;Unix.chmodpackage.name0o755))p.packages;if!Globals.verbosity>0thenPrintf.eprintf"\nBuild OK%s\n%!"(if!n>0thenPrintf.sprintf" ( %d command%s generated )"!n(if!n>1then"s"else"")else"")letcmd=letargs,specs=Build.build_args()inEZCMD.subcmd_name(fun()->action~args())~args:specs~doc:"Build a project"~man:[`S"DESCRIPTION";`Blocks[`P"This command performs the following actions:";`I("1.","Create a local opam switch. The argument $(b,--switch SWITCH) \
can be used to make the local switch a link to a global \
switch. The argument $(b,--local) can be used to force a \
local switch to be created.");`I("2.","Check that the OCaml version is at least the $(b,min-edition) \
specified in the project. If OCaml is not installed, use the \
$(b,--edition VERSION) argument or the $(b,edition) field \
specified in the project to install OCaml.");`I("3.","Install all the dependencies in the opam switch. If the \
argument $(b,--locked) was specified, use the \
$(b,${package}-deps.opam.locked) file in the project to get \
exact dependencies.");`I("4.","Build the project by calling $(b,opam exec -- dune build \
@install)");`I("5.","If build was ok, copy executable in the top directory of the \
project")]]