Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide opam during build #4387

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ New option/command/subcommand are prefixed with ◈.

## Install
* The stdout of `pre-` and `post-session` hooks is now propagated to the user [#4382 @AltGr - fix #4359]
* A PACKAGE.opam file is provided during build in the build/ directory [@lefessan]
lefessan marked this conversation as resolved.
Show resolved Hide resolved

## Remove
*
Expand Down
3 changes: 3 additions & 0 deletions src/client/opamAction.ml
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@ let prepare_package_source st nv dir =
(OpamStd.Format.itemize OpamFilename.to_string bad_hash)));
in
OpamFilename.mkdir dir;
OpamFile.OPAM.write
(OpamFile.make (OpamPath.Switch.build_opam ~build_dir:dir))
opam;
rjbou marked this conversation as resolved.
Show resolved Hide resolved
get_extra_sources_job @@+ function Some _ as err -> Done err | None ->
check_extra_files |> function Some _ as err -> Done err | None ->
let opam = OpamSwitchState.opam st nv in
Expand Down
6 changes: 4 additions & 2 deletions src/client/opamSolution.ml
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,10 @@ let parallel_apply t ~requested ?add_roots ~assume_built ?(force_remove=false)
when not (OpamPackage.has_name t.pinned nv.name) ->
let build_dir =
OpamPath.Switch.build t.switch_global.root t.switch nv in
if not OpamClientConfig.(!r.keep_build_dir) then
OpamFilename.rmdir build_dir
if not OpamClientConfig.(!r.keep_build_dir) then begin
OpamFilename.rmdir build_dir;
OpamFilename.remove ( OpamPath.Switch.build_opam ~build_dir )
lefessan marked this conversation as resolved.
Show resolved Hide resolved
end
| `Remove _ | `Install _ | `Build _ | `Fetch _ -> ()
| _ -> assert false)
graph
Expand Down
3 changes: 3 additions & 0 deletions src/format/opamPath.ml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ module Switch = struct

let build t a nv = build_dir t a / OpamPackage.to_string nv

let build_opam ~build_dir =
OpamFilename.of_string ( OpamFilename.Dir.to_string build_dir ^ ".opam" )
lefessan marked this conversation as resolved.
Show resolved Hide resolved

let remove_dir t a = meta t a / "remove"

let remove t a nv = remove_dir t a / OpamPackage.to_string nv
Expand Down
30 changes: 17 additions & 13 deletions src/format/opamPath.mli
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ module Switch: sig
{i $meta/build/$packages} *)
val build: t -> switch -> package -> dirname

(** Temporary copy of the opam description of the package during
the build/install process *)
val build_opam: build_dir:dirname -> filename
lefessan marked this conversation as resolved.
Show resolved Hide resolved

(** Temporary folders used to decompress the corresponding archives, used only
for package removal {i $meta/remove/$packages} *)
val remove: t -> switch -> package -> dirname
Expand Down Expand Up @@ -251,32 +255,32 @@ module Switch: sig
a switch's layout in non-switch contexts *)
module DefaultF : functor (L:LAYOUT) -> sig
val lib: t -> L.ctx -> name -> dirname

val lib_dir: t -> L.ctx -> dirname

val stublibs: t -> L.ctx -> dirname

val toplevel: t -> L.ctx -> dirname

val doc: t -> L.ctx -> name -> dirname

val doc_dir: t -> L.ctx -> dirname

val share_dir: t -> L.ctx -> dirname

val share: t -> L.ctx -> name -> dirname

val etc_dir: t -> L.ctx -> dirname

val etc: t -> L.ctx -> name -> dirname

val man_dir: ?num:string -> t -> L.ctx -> dirname

val bin: t -> L.ctx -> dirname

val sbin: t -> L.ctx -> dirname
end


(** Actual config handling the global-config.config indirections *)

Expand Down