Skip to content

Commit

Permalink
Merge pull request #2280 from ygrek/expose
Browse files Browse the repository at this point in the history
OpamState: pass variables to add_to_env
  • Loading branch information
AltGr committed Aug 11, 2015
2 parents dccddae + da47ca2 commit 2b4b416
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/state/opamState.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1931,9 +1931,9 @@ let source t ~shell ?(interactive_only=false) f =
Printf.sprintf "if tty -s >/dev/null 2>&1; then\n %sfi\n" s
else s

let expand_env t ?opam (env: env_updates) : env =
let expand_env t ?opam (env: env_updates) variables : env =
let fenv v =
try resolve_variable t ?opam OpamVariable.Map.empty v
try resolve_variable t ?opam variables v
with Not_found ->
log "Undefined variable: %s" (OpamVariable.Full.to_string v);
None
Expand Down Expand Up @@ -1972,10 +1972,10 @@ let expand_env t ?opam (env: env_updates) : env =
| _ -> failwith (Printf.sprintf "expand_env: %s is an unknown symbol" symbol)
) env

let add_to_env t ?opam (env: env) (updates: env_updates) =
let add_to_env t ?opam (env: env) ?(variables=OpamVariable.Map.empty) (updates: env_updates) =
let env =
List.filter (fun (k,_) -> List.for_all (fun (u,_,_) -> u <> k) updates) env in
env @ expand_env t ?opam updates
env @ expand_env t ?opam updates variables

let env_updates ~opamswitch ?(force_path=false) t =
let comp = compiler_comp t t.compiler in
Expand Down
3 changes: 2 additions & 1 deletion src/state/opamState.mli
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ val get_full_env: force_path:bool -> ?opam:OpamFile.OPAM.t -> state -> env
val get_opam_env: force_path:bool -> state -> env

(** Update an environment. *)
val add_to_env: state -> ?opam:OpamFile.OPAM.t -> env -> (string * string * string) list -> env
val add_to_env: state -> ?opam:OpamFile.OPAM.t -> env ->
?variables:(variable_contents option) OpamVariable.Map.t -> (string * string * string) list -> env

(** Check if the shell environment is in sync with the current OPAM switch *)
val up_to_date_env: state -> bool
Expand Down

0 comments on commit 2b4b416

Please sign in to comment.