[Omake] Making sure we do not get .PHONY nodes in "random" places.

Jason Hickey jyh at cs.caltech.edu
Sun Jan 22 04:59:20 PST 2006


I haven't had a chance yet, I'll look tomorrow.

Question, what is the semantics of phony nodes (meaning, when is a name 
considered to be phony)?  The branch 0.9.7 just scopes it.  So the 
question is this: is scoping inadequate?  If so, why, and is a 3-valued 
logic the simplest ill-scoped solution?

Jason

Aleksey Nogin wrote:
> I would like to change the Node API in OMake, adding a flag that 
> specifies whether PHONY nodes are allowed, or not (the flag has 3 values 
> - phonies allowed, phonies allowed only when an explicit .PHONY/... 
> syntax is used and phonies are not allowed). I have made the changes in 
> my local working copy and both MetaPRL and OMake compile fine, while 
> some of the known PHONY-related bugs have disappeared.
> 
> I would like to get some feedback before committing this. The patch is 
> attached. What do you think?
> 
> 
> ------------------------------------------------------------------------
> 
> Index: src/main/omake_shell.ml
> ===================================================================
> --- src/main/omake_shell.ml	(revision 8552)
> +++ src/main/omake_shell.ml	(working copy)
> @@ -4,7 +4,7 @@
>   * ----------------------------------------------------------------
>   *
>   * @begin[license]
> - * Copyright (C) 2004 Mojave Group, Caltech
> + * Copyright (C) 2004-2006 Mojave Group, Caltech
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License
> @@ -32,6 +32,7 @@
>  open Omake_env
>  open Omake_eval
>  open Omake_exec
> +open Omake_node_sig
>  open Omake_node
>  open Omake_value
>  open Omake_state
> @@ -332,7 +333,7 @@
>  
>     let loc = bogus_loc scriptname in
>     let pos = string_pos "shell_targets" (loc_exp_pos loc) in
> -   let node = venv_intern venv scriptname in
> +   let node = venv_intern venv PhonyProhibited scriptname in
>  
>     (* Add the command line to the environment *)
>     let argv = scriptname :: args in
> Index: src/eval/omake_value.ml
> ===================================================================
> --- src/eval/omake_value.ml	(revision 8552)
> +++ src/eval/omake_value.ml	(working copy)
> @@ -28,6 +28,7 @@
>  
>  open Omake_ir
>  open Omake_env
> +open Omake_node_sig
>  open Omake_node
>  open Omake_lexer
>  open Omake_parser
> @@ -237,7 +238,7 @@
>         | ValInt _
>         | ValFloat _ ->
>              let name = string_of_value venv pos v in
> -            let node = venv_intern venv name in
> +            let node = venv_intern venv PhonyExplicit name in
>              let cache = venv_cache venv in
>                 if Omake_cache.is_dir cache node then
>                    ValDir (venv_intern_dir venv name)
> @@ -371,7 +372,7 @@
>                 if is_channel_string s then
>                    prim_channel_of_string venv pos s, false
>                 else
> -                  let node = venv_intern venv s in
> +                  let node = venv_intern venv PhonyProhibited s in
>                    let name = Node.fullname node in
>                    let fd =
>                       try Lm_unix_util.openfile name [Unix.O_RDONLY] 0 with
> @@ -420,7 +421,7 @@
>                 if is_channel_string s then
>                    prim_channel_of_string venv pos s, false
>                 else
> -                  let node = venv_intern venv s in
> +                  let node = venv_intern venv PhonyProhibited s in
>                    let name = Node.fullname node in
>                    let fd =
>                       try Lm_unix_util.openfile name [Unix.O_WRONLY; Unix.O_CREAT; Unix.O_TRUNC] 0o666 with
> Index: src/eval/omake_eval.ml
> ===================================================================
> --- src/eval/omake_eval.ml	(revision 8552)
> +++ src/eval/omake_eval.ml	(working copy)
> @@ -245,11 +245,11 @@
>     let cache = venv_cache venv in
>        if not (Filename.is_relative filename) || not (Filename.is_implicit filename) then
>           let fullname = filename ^ omake_file_suffix in
> -         let node1 = venv_intern venv fullname in
> +         let node1 = venv_intern venv PhonyProhibited fullname in
>              if Omake_cache.exists cache node1 then
>                 node1
>              else
> -               let node2 = venv_intern venv filename in
> +               let node2 = venv_intern venv PhonyProhibited filename in
>                    if Omake_cache.exists cache node2 then
>                       node2
>                    else
> @@ -650,14 +650,15 @@
>        match file with
>           ValNode node ->
>              node
> -       | ValDir _
> +       | ValDir dir ->
> +            Node.node_of_dir dir
>         | ValData _
>         | ValString _
>         | ValSequence _
>         | ValQuote _
>         | ValInt _
>         | ValFloat _ ->
> -            venv_intern venv (string_of_value venv pos file)
> +            venv_intern venv PhonyProhibited (string_of_value venv pos file)
>         | ValArray _
>         | ValNone
>         | ValKey _
> @@ -1598,7 +1599,7 @@
>   * Project compiler.
>   *)
>  let compile venv =
> -   let node = venv_intern venv makeroot_name in
> +   let node = venv_intern venv PhonyProhibited makeroot_name in
>     let venv = venv_add_file venv node in
>     let loc = bogus_loc (Node.fullname node) in
>     let pos = string_pos "compile" (loc_exp_pos loc) in
> Index: src/env/omake_env.mli
> ===================================================================
> --- src/env/omake_env.mli	(revision 8552)
> +++ src/env/omake_env.mli	(working copy)
> @@ -284,8 +284,8 @@
>  val venv_add_explicit_dir : venv -> Dir.t -> unit
>  val venv_remove_explicit_dir : venv -> Dir.t -> unit
>  val venv_add_file         : venv -> Node.t -> venv
> -val venv_intern           : venv -> string -> Node.t
> -val venv_intern_cd        : venv -> Dir.t -> string -> Node.t
> +val venv_intern           : venv -> phony_ok -> string -> Node.t
> +val venv_intern_cd        : venv -> phony_ok -> Dir.t -> string -> Node.t
>  val venv_intern_dir       : venv -> string -> Dir.t
>  
>  val venv_mount       : venv -> mount_option list -> Dir.t -> Dir.t -> venv
> Index: src/env/omake_env.ml
> ===================================================================
> --- src/env/omake_env.ml	(revision 8552)
> +++ src/env/omake_env.ml	(working copy)
> @@ -1632,14 +1632,14 @@
>  (*
>   * Convert a filename to a node.
>   *)
> -let venv_intern venv name =
> -   Node.intern venv.venv_inner.venv_mount venv.venv_inner.venv_dir name
> +let venv_intern venv phony_flag name =
> +   Node.intern venv.venv_inner.venv_mount phony_flag venv.venv_inner.venv_dir name
>  
> -let venv_intern_cd venv dir name =
> -   Node.intern venv.venv_inner.venv_mount dir name
> +let venv_intern_cd venv phony_flag dir name =
> +   Node.intern venv.venv_inner.venv_mount phony_flag dir name
>  
>  let venv_intern_target venv multiple name =
> -   let node = Node.intern venv.venv_inner.venv_mount venv.venv_inner.venv_dir name in
> +   let node = Node.intern venv.venv_inner.venv_mount PhonyOK venv.venv_inner.venv_dir name in
>        match multiple with
>           RuleScannerSingle
>         | RuleScannerMultiple ->
> @@ -1657,12 +1657,12 @@
>  let node_set_of_list nodes =
>     List.fold_left NodeSet.add NodeSet.empty nodes
>  
> -let node_set_add_names venv nodes names =
> +let node_set_add_names venv phony_flag nodes names =
>     List.fold_left (fun nodes name ->
> -         NodeSet.add nodes (venv_intern venv name)) nodes names
> +         NodeSet.add nodes (venv_intern venv phony_flag name)) nodes names
>  
> -let node_set_of_names venv names =
> -   node_set_add_names venv NodeSet.empty names
> +let node_set_of_names venv phony_flag names =
> +   node_set_add_names venv phony_flag NodeSet.empty names
>  
>  (*
>   * Add a mount point.
> @@ -1690,7 +1690,7 @@
>     if is_wild s then
>        SourceWild (wild_compile s)
>     else
> -      SourceNode (venv_intern venv s)
> +      SourceNode (venv_intern venv PhonyOK s)
>  
>  let compile_source venv (kind, s) =
>     kind, compile_source_core venv s
> @@ -1702,7 +1702,7 @@
>     match source with
>        SourceWild wild ->
>           let s = wild_subst subst wild in
> -            venv_intern venv s
> +            venv_intern venv PhonyOK s
>      | SourceNode node ->
>           node
>  
> @@ -1713,7 +1713,7 @@
>   * No wildcard matching.
>   *)
>  let intern_source venv (kind, source) =
> -   Node.escape kind (venv_intern venv source)
> +   Node.escape kind (venv_intern venv PhonyOK source)
>  
>  (*
>   * For variables, try to look them up as 0-arity functions first.
> @@ -2123,7 +2123,7 @@
>     let venv = venv_add_phony venv (Lm_location.bogus_loc makeroot_name) [".PHONY"] in
>     let venv = venv_add_var_dynamic venv cwd_sym (ValDir cwd) in
>     let venv = venv_add_var_dynamic venv stdlib_sym (ValDir Dir.lib) in
> -   let venv = venv_add_var_dynamic venv stdroot_sym (ValNode (Node.intern mount Dir.lib "OMakeroot")) in
> +   let venv = venv_add_var_dynamic venv stdroot_sym (ValNode (Node.intern mount PhonyProhibited Dir.lib "OMakeroot")) in
>     let venv = venv_add_var_dynamic venv ostype_sym (ValString Sys.os_type) in
>     let venv = venv_add_wild_match venv wild_string in
>     let omakepath =
> Index: src/Makefile.nt
> ===================================================================
> --- src/Makefile.nt	(revision 8552)
> +++ src/Makefile.nt	(working copy)
> @@ -378,13 +378,13 @@
>  ALLFILES_magic = omake_gen_magic.ml
>  
>  
> -CMOFILES_ir = omake_options_type.cmo omake_symbol.cmo omake_state.cmo omake_node_type.cmo omake_node_sig.cmo omake_node.cmo omake_virtual_id.cmo omake_install.cmo omake_command_type.cmo omake_command.cmo omake_cache_type.cmo omake_cache.cmo omake_ir.cmo omake_ir_util.cmo omake_ir_print.cmo
> +CMOFILES_ir = omake_options_type.cmo omake_symbol.cmo omake_state.cmo omake_node_type.cmo omake_node_sig.cmo omake_node.cmo omake_virtual_id.cmo omake_install.cmo omake_ir.cmo omake_ir_util.cmo omake_ir_print.cmo omake_command_type.cmo omake_command.cmo omake_cache_type.cmo omake_cache.cmo
>  OCAML_LIB_FLAGS_ir =
>  
>  ir.cma: $(CMOFILES_ir)
>  	$(OCAMLC) $(OCAMLFLAGS) $(OCAML_LIB_FLAGS_ir) -a -o $@ $(CMOFILES_ir)
>  
> -omake_options_type.cmo omake_symbol.cmo omake_state.cmo omake_node_type.cmo omake_node_sig.cmo omake_node.cmo omake_virtual_id.cmo omake_install.cmo omake_command_type.cmo omake_command.cmo omake_cache_type.cmo omake_cache.cmo omake_ir.cmo omake_ir_util.cmo omake_ir_print.cmo omake_state.cmi omake_node.cmi omake_virtual_id.cmi omake_install.cmi omake_command.cmi omake_cache.cmi omake_ir_util.cmi omake_ir_print.cmi: magic.cma
> +omake_options_type.cmo omake_symbol.cmo omake_state.cmo omake_node_type.cmo omake_node_sig.cmo omake_node.cmo omake_virtual_id.cmo omake_install.cmo omake_ir.cmo omake_ir_util.cmo omake_ir_print.cmo omake_command_type.cmo omake_command.cmo omake_cache_type.cmo omake_cache.cmo omake_state.cmi omake_node.cmi omake_virtual_id.cmi omake_install.cmi omake_ir_util.cmi omake_ir_print.cmi omake_command.cmi omake_cache.cmi: magic.cma
>  
>  SRC_ir = ..$(slash)src$(slash)ir
>  
> @@ -460,7 +460,7 @@
>  ALLFILES_ir = omake_ir.ml omake_node.ml omake_cache.ml omake_node.mli omake_state.ml omake_cache.mli omake_state.mli omake_symbol.ml omake_command.ml omake_install.ml omake_ir_util.ml omake_command.mli omake_install.mli omake_ir_print.ml omake_ir_util.mli omake_node_sig.ml omake_ir_print.mli omake_node_type.ml omake_cache_type.ml omake_virtual_id.ml omake_virtual_id.mli omake_command_type.ml omake_options_type.ml
>  
>  
> -CMOFILES_exec = omake_exec_type.cmo omake_exec_util.cmo omake_exec_print.cmo omake_exec_id.cmo omake_exec_local.cmo omake_exec_remote.cmo omake_exec_notify.cmo omake_exec.cmo
> +CMOFILES_exec = omake_exec_util.cmo omake_exec_id.cmo omake_exec_type.cmo omake_exec_print.cmo omake_exec_local.cmo omake_exec_remote.cmo omake_exec_notify.cmo omake_exec.cmo
>  OCAML_LIB_FLAGS_exec =
>  
>  exec.cma: $(CMOFILES_exec)
> @@ -551,7 +551,7 @@
>  omake_gen_parse$(EXE): $(CMOFILES_omake_gen_parse) $(OCAML_LIBS_omake_gen_parse) $(OCAML_CLIBS_omake_gen_parse)
>  	$(OCAMLC) $(OCAMLFLAGS) -custom -o $@ $(OCAML_CCLIBS_omake_gen_parse) $(OCAML_OTHER_LIBS_omake_gen_parse) $(THREADSLIB) $(OCAML_LIBS_omake_gen_parse) $(CMOFILES_omake_gen_parse)
>  
> -CMOFILES_env = omake_lexer.cmo omake_parser.cmo omake_env.cmo omake_exn_print.cmo omake_ast_parse.cmo omake_ast_lex.cmo omake_ir_ast.cmo omake_ir_semant.cmo omake_ir_free_vars.cmo omake_command_digest.cmo
> +CMOFILES_env = omake_lexer.cmo omake_parser.cmo omake_ir_free_vars.cmo omake_env.cmo omake_exn_print.cmo omake_ast_parse.cmo omake_ast_lex.cmo omake_ir_ast.cmo omake_ir_semant.cmo omake_command_digest.cmo
>  OCAML_LIB_FLAGS_env =
>  
>  env.cma: $(CMOFILES_env)
> @@ -573,7 +573,7 @@
>  omake_ast_parse.input: ..$(slash)src$(slash)env$(slash)omake_ast_parse.input
>  	$(LN) ..$(slash)src$(slash)env$(slash)omake_ast_parse.input omake_ast_parse.input
>  
> -omake_lexer.cmo omake_parser.cmo omake_env.cmo omake_exn_print.cmo omake_ast_parse.cmo omake_ast_lex.cmo omake_ir_ast.cmo omake_ir_semant.cmo omake_ir_free_vars.cmo omake_command_digest.cmo omake_env.cmi omake_exn_print.cmi omake_ast_parse.cmi omake_ast_lex.cmi omake_ir_ast.cmi omake_ir_semant.cmi omake_ir_free_vars.cmi omake_command_digest.cmi: magic.cma
> +omake_lexer.cmo omake_parser.cmo omake_ir_free_vars.cmo omake_env.cmo omake_exn_print.cmo omake_ast_parse.cmo omake_ast_lex.cmo omake_ir_ast.cmo omake_ir_semant.cmo omake_command_digest.cmo omake_ir_free_vars.cmi omake_env.cmi omake_exn_print.cmi omake_ast_parse.cmi omake_ast_lex.cmi omake_ir_ast.cmi omake_ir_semant.cmi omake_command_digest.cmi: magic.cma
>  
>  Makefile.dep: omake_ast_lex.ml omake_ast_parse.mly omake_ast_parse.mli omake_ast_parse.ml
>  
> Index: src/build/omake_build.ml
> ===================================================================
> --- src/build/omake_build.ml	(revision 8552)
> +++ src/build/omake_build.ml	(working copy)
> @@ -11,7 +11,7 @@
>   * ----------------------------------------------------------------
>   *
>   * @begin[license]
> - * Copyright (C) 2003 Jason Hickey, Caltech
> + * Copyright (C) 2003-2006 Mojave Group, Caltech
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License
> @@ -27,8 +27,8 @@
>   * along with this program; if not, write to the Free Software
>   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>   *
> - * Author: Jason Hickey
> - * @email{jyh at cs.caltech.edu}
> + * Author: Jason Hickey @email{jyh at cs.caltech.edu}
> + * Modified by: Aleksey Nogin @email{nogin at cs.caltech.edu}
>   * @end[license]
>   *)
>  open Lm_printf 
> @@ -1075,11 +1075,11 @@
>        List.fold_left (fun table (targets, sources) ->
>              let sources =
>                 List.fold_left (fun set s ->
> -                     let node = venv_intern venv s in
> +                     let node = venv_intern venv PhonyOK s in
>                          NodeSet.add set node) NodeSet.empty sources
>              in
>                 List.fold_left (fun table target ->
> -                     let target = venv_intern venv target in
> +                     let target = venv_intern venv PhonyOK target in
>                          NodeTable.filter_add table target (fun set ->
>                                match set with
>                                   Some set ->
> @@ -1808,7 +1808,7 @@
>           notify_name = name
>         } = event
>     in
> -   let node = venv_intern_cd venv cwd name in
> +   let node = venv_intern_cd venv PhonyProhibited cwd name in
>     let () =
>        if !debug_notify then
>           eprintf "Omake_build.invalidate_event_core: received event for node: %a at ." pp_print_node node
> @@ -2616,8 +2616,8 @@
>           end
>     in
>  
> -   let targets = List.map (Node.intern no_mount_points dir) targets in
> -   let () = List.iter (fun s -> print_node_dependencies env (Node.intern no_mount_points dir s)) options.opt_show_dependencies in
> +   let targets = List.map (Node.intern no_mount_points PhonyOK dir) targets in
> +   let () = List.iter (fun s -> print_node_dependencies env (Node.intern no_mount_points PhonyOK dir s)) options.opt_show_dependencies in
>     let options = env_options env in
>        build_targets env true start_time false options.opt_print_dependencies targets;
>        print_stats env "done" start_time;
> Index: src/build/omake_builtin.ml
> ===================================================================
> --- src/build/omake_builtin.ml	(revision 8552)
> +++ src/build/omake_builtin.ml	(working copy)
> @@ -160,7 +160,7 @@
>   *)
>  let venv_include_rc_file venv name =
>     if Sys.file_exists name then
> -      let node = venv_intern venv name in
> +      let node = venv_intern venv PhonyProhibited name in
>           try
>              let loc = bogus_loc (Filename.basename name) in
>              let pos = string_pos "create_venv" (loc_exp_pos loc) in
> Index: src/build/omake_rule.ml
> ===================================================================
> --- src/build/omake_rule.ml	(revision 8553)
> +++ src/build/omake_rule.ml	(working copy)
> @@ -4,7 +4,7 @@
>   * ----------------------------------------------------------------
>   *
>   * @begin[license]
> - * Copyright (C) 2003 Jason Hickey, Caltech
> + * Copyright (C) 2003-2006 Mojave Group, Caltech
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License
> @@ -678,7 +678,7 @@
>     in
>     let cwd = venv_dir venv in
>     let venv' = venv_chdir_dir venv loc dir in
> -   let node = venv_intern venv' makefile_name in
> +   let node = venv_intern venv' PhonyProhibited makefile_name in
>     let name = Node.fullname node in
>     let result =
>        (*
> @@ -736,9 +736,9 @@
>           [source] -> source
>         | _ -> raise (OmakeException (pos, StringError ".INCLUDE must have a single source"))
>     in
> -   let target = venv_intern venv source in
> +   let target = venv_intern venv PhonyProhibited source in
>     let venv = venv_add_file venv target in
> -   let deps = List.map (fun (_, dep) -> venv_intern venv dep) deps in
> +   let deps = List.map (fun (_, dep) -> venv_intern venv PhonyOK dep) deps in
>  
>     (* Convert the command list *)
>     let commands =
> @@ -873,7 +873,7 @@
>        else
>           CommandValues (List.map (eval_prim_value venv pos) values) :: commands
>     in
> -   let target = venv_intern venv target in
> +   let target = venv_intern venv PhonyOK target in
>     let dir = venv_dir venv in
>        parse_commands venv dir target loc commands
>  
> @@ -1186,14 +1186,14 @@
>     let stdin =
>        match stdin with
>           Some stdin ->
> -            Some (Node.fullname (venv_intern venv stdin))
> +            Some (Node.fullname (venv_intern venv PhonyProhibited stdin))
>         | None ->
>              None
>     in
>     let stdout =
>        match stdout with
>           Some stdout ->
> -            Some (Node.fullname (venv_intern venv stdout))
> +            Some (Node.fullname (venv_intern venv PhonyProhibited stdout))
>         | None ->
>              None
>     in
> @@ -1221,14 +1221,14 @@
>     let stdin =
>        match stdin with
>           Some stdin ->
> -            Some (Node.fullname (venv_intern venv stdin))
> +            Some (Node.fullname (venv_intern venv PhonyProhibited stdin))
>         | None ->
>              None
>     in
>     let stdout =
>        match stdout with
>           Some stdout ->
> -            Some (Node.fullname (venv_intern venv stdout))
> +            Some (Node.fullname (venv_intern venv PhonyProhibited stdout))
>         | None ->
>              None
>     in
> Index: src/builtin/omake_builtin_shell.ml
> ===================================================================
> --- src/builtin/omake_builtin_shell.ml	(revision 8552)
> +++ src/builtin/omake_builtin_shell.ml	(working copy)
> @@ -8,7 +8,7 @@
>   * ----------------------------------------------------------------
>   *
>   * @begin[license]
> - * Copyright (C) 2003 Jason Hickey, Caltech
> + * Copyright (C) 2003-2006 Jason Hickey, Caltech
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License
> @@ -33,6 +33,7 @@
>  
>  open Omake_ir
>  open Omake_env
> +open Omake_node_sig
>  open Omake_node
>  open Omake_value
>  open Omake_state
> @@ -413,7 +414,7 @@
>  
>  let () =
>     let builtin_vars =
> -      ["history-file",   (fun _ -> ValNode (Node.intern no_mount_points Dir.root (Omake_state.history_file ())));
> +      ["history-file",   (fun _ -> ValNode (Node.intern no_mount_points PhonyProhibited Dir.root (Omake_state.history_file ())));
>         "history-length", (fun _ -> ValInt 100);
>         "CDPATH",         (fun _ -> ValArray [ValString "."])]
>     in
> Index: src/builtin/omake_builtin_file.ml
> ===================================================================
> --- src/builtin/omake_builtin_file.ml	(revision 8552)
> +++ src/builtin/omake_builtin_file.ml	(working copy)
> @@ -8,7 +8,7 @@
>   * ----------------------------------------------------------------
>   *
>   * @begin[license]
> - * Copyright (C) 2003 Jason Hickey, Caltech
> + * Copyright (C) 2003-2006 Mojave Group, Caltech
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License
> @@ -153,7 +153,7 @@
>         | _ ->
>              raise (OmakeException (loc_pos loc pos, ArityMismatch (ArityRange (1, 2), List.length args)))
>     in
> -      ValNode (venv_intern venv (Filename.temp_file prefix suffix))
> +      ValNode (venv_intern venv PhonyProhibited (Filename.temp_file prefix suffix))
>  
>  (*
>   * Display something from a different directory.
> @@ -236,7 +236,7 @@
>                          Not_found ->
>                             raise (OmakeException (loc_pos loc pos, StringStringError ("command not found", s)))) args
>              in
> -            let args = List.map (fun s -> ValNode (venv_intern venv s)) args in
> +            let args = List.map (fun s -> ValNode (venv_intern venv PhonyProhibited s)) args in
>                 concat_array args
>         | _ ->
>              raise (OmakeException (loc_pos loc pos, ArityMismatch (ArityExact 1, List.length args)))
> @@ -270,7 +270,7 @@
>                             raise (OmakeException (loc_pos loc pos, (**)
>                                StringStringError ("where: path separators do not make sense", arg)))
>                    in
> -                  let res = List.map (fun s -> ValNode (venv_intern venv s)) res in
> +                  let res = List.map (fun s -> ValNode (venv_intern venv PhonyProhibited s)) res in
>                    let res =
>                       try
>                          let obj = venv_find_var_exn venv ScopeGlobal shell_object_sym in
> @@ -880,7 +880,7 @@
>     let cwd_name = Dir.name root cwd in
>     let dirs, names = glob options cwd_name dirs in
>     let dirs = List.map (fun dir -> ValDir (Dir.chdir cwd dir)) dirs in
> -   let nodes = List.map (fun name -> ValNode (venv_intern venv name)) names in
> +   let nodes = List.map (fun name -> ValNode (venv_intern venv PhonyProhibited name)) names in
>     let nodes = dirs @ nodes in
>        ValArray (sort_val_nodes nodes)
>  
> @@ -949,7 +949,7 @@
>     let files1 = List.map (Filename.concat cwd) files1 in
>     let dirs, files2 = ls_fun options "" dirs in
>     let dirs  = List.map (fun dir -> ValDir (Dir.chdir root dir)) dirs in
> -   let nodes = List.map (fun name -> ValNode (venv_intern_cd venv root name)) (files1 @ files2) in
> +   let nodes = List.map (fun name -> ValNode (venv_intern_cd venv PhonyProhibited root name)) (files1 @ files2) in
>     let nodes = dirs @ nodes in
>        ValArray (sort_val_nodes nodes)
>  
> @@ -1844,7 +1844,7 @@
>                          let dir = Node.dir node in
>                          let name = Node.fullname node in
>                          let name = Unix.readlink name in
> -                           ValNode (venv_intern_cd venv dir name)) args
> +                           ValNode (venv_intern_cd venv PhonyProhibited dir name)) args
>                 with
>                    Unix.Unix_error _ as exn ->
>                       raise (UncaughtException (pos, exn))
> @@ -2328,7 +2328,7 @@
>     let src_name = Dir.fullname src in
>     let dst_name = Dir.name src dst in
>     let _, files = list_dirs_rec [GlobIgnore [dst_name]] src_name ["."] in
> -      List.iter (fun name -> ignore (venv_intern_cd venv dst name)) files
> +      List.iter (fun name -> ignore (venv_intern_cd venv PhonyProhibited dst name)) files
>  
>  (*
>   * Add the mount.
> Index: src/shell/omake_shell_job.ml
> ===================================================================
> --- src/shell/omake_shell_job.ml	(revision 8553)
> +++ src/shell/omake_shell_job.ml	(working copy)
> @@ -4,7 +4,7 @@
>   * ----------------------------------------------------------------
>   *
>   * @begin[license]
> - * Copyright (C) 2004-2005 Mojave Group, Caltech
> + * Copyright (C) 2004-2006 Mojave Group, Caltech
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License
> @@ -20,8 +20,8 @@
>   * along with this program; if not, write to the Free Software
>   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>   *
> - * Author: Jason Hickey
> - * @email{jyh at cs.caltech.edu}
> + * Author: Jason Hickey @email{jyh at cs.caltech.edu}
> + * Modified by: Aleksey Nogin @email{nogin at cs.caltech.edu}
>   * @end[license]
>   *)
>  open Lm_printf
> @@ -30,6 +30,7 @@
>  
>  open Omake_ir
>  open Omake_env
> +open Omake_node_sig
>  open Omake_node
>  open Omake_symbol
>  open Omake_value
> @@ -585,17 +586,17 @@
>     let cache = venv_cache venv in
>     let node =
>        if not (Filename.is_relative exe) || Lm_string_util.contains_any exe Lm_filename_util.separators then
> -         let node = venv_intern venv exe in
> +         let node = venv_intern venv PhonyProhibited exe in
>              if Omake_cache.exists cache node then
>                 node
>              else if (Sys.os_type = "Win32" || Sys.os_type = "Cygwin")
>                 && not (Filename.check_suffix exe ".exe" || Filename.check_suffix exe ".bat")
>              then
> -               let node = venv_intern venv (exe ^ ".exe") in
> +               let node = venv_intern venv PhonyProhibited (exe ^ ".exe") in
>                    if Omake_cache.exists cache node then
>                       node
>                    else
> -                     let node = venv_intern venv (exe ^ ".bat") in
> +                     let node = venv_intern venv PhonyProhibited (exe ^ ".bat") in
>                          if Omake_cache.exists cache node then
>                             node
>                          else
> Index: src/ir/omake_cache.ml
> ===================================================================
> --- src/ir/omake_cache.ml	(revision 8552)
> +++ src/ir/omake_cache.ml	(working copy)
> @@ -894,7 +894,7 @@
>           DirEntryCore entry ->
>              entry
>         | LazyEntryCore (dir, s) ->
> -            let node = Node.intern no_mount_points dir s in
> +            let node = Node.intern no_mount_points PhonyProhibited dir s in
>              let entry =
>                 if is_dir cache node then
>                    DirEntry (Dir.chdir dir s)
> @@ -977,7 +977,7 @@
>  let rec search_exe_win32 cache entries =
>     match entries with
>        (dir, s) :: entries ->
> -         let node = Node.intern no_mount_points dir s in
> +         let node = Node.intern no_mount_points PhonyProhibited dir s in
>              if is_dir cache node then
>                 search_exe_win32 cache entries
>              else
> @@ -988,7 +988,7 @@
>  let rec search_exe_unix cache entries =
>     match entries with
>        (dir, s) :: entries ->
> -         let node = Node.intern no_mount_points dir s in
> +         let node = Node.intern no_mount_points PhonyProhibited dir s in
>              if is_exe_file cache node then
>                 node
>              else
> @@ -999,7 +999,7 @@
>  let rec search_exe_cygwin cache entries =
>     match entries with
>        (dir, s) :: entries ->
> -         let node = Node.intern no_mount_points dir s in
> +         let node = Node.intern no_mount_points PhonyProhibited dir s in
>              if Filename.check_suffix s ".exe" || Filename.check_suffix s ".bat" || is_exe_file cache node then
>                 node
>              else
> Index: src/ir/omake_install.ml
> ===================================================================
> --- src/ir/omake_install.ml	(revision 8552)
> +++ src/ir/omake_install.ml	(working copy)
> @@ -4,7 +4,7 @@
>   * ----------------------------------------------------------------
>   *
>   * @begin[license]
> - * Copyright (C) 2004 Mojave Group, Caltech
> + * Copyright (C) 2004-2006 Mojave Group, Caltech
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License
> @@ -27,6 +27,7 @@
>  open Lm_printf
>  open Lm_glob
>  
> +open Omake_node_sig
>  open Omake_node
>  
>  (*
> @@ -60,8 +61,8 @@
>  (*
>   * Names of the standard files.
>   *)
> -let omakeroot = Node.fullname (Node.intern no_mount_points Dir.lib "OMakeroot.default")
> -let omakefile = Node.fullname (Node.intern no_mount_points Dir.lib "OMakefile.default")
> +let omakeroot = Node.fullname (Node.intern no_mount_points PhonyProhibited Dir.lib "OMakeroot.default")
> +let omakefile = Node.fullname (Node.intern no_mount_points PhonyProhibited Dir.lib "OMakefile.default")
>  
>  (*
>   * Install just into the current directory.
> Index: src/ir/omake_node.ml
> ===================================================================
> --- src/ir/omake_node.ml	(revision 8552)
> +++ src/ir/omake_node.ml	(working copy)
> @@ -8,7 +8,7 @@
>   * ----------------------------------------------------------------
>   *
>   * @begin[license]
> - * Copyright (C) 2003 Jason Hickey, Caltech
> + * Copyright (C) 2003-2006 Mojave Group, Caltech
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License
> @@ -24,8 +24,8 @@
>   * along with this program; if not, write to the Free Software
>   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>   *
> - * Author: Jason Hickey
> - * @email{jyh at cs.caltech.edu}
> + * Author: Jason Hickey <jyh at cs.caltech.edu>
> + * Modified by: Aleksey Nogin <nogin at cs.caltech.edu>
>   * @end[license]
>   *)
>  open Lm_hash
> @@ -1053,13 +1053,13 @@
>      * Intern a string with no escapes.
>      * This version ignores mount points.
>      *)
> -   let intern_simple dir name =
> +   let intern_simple phony_ok dir name =
>        let { base_nodes = nodes } = base in
>  
>        (* Parse the .PHONY syntax *)
>        let name = Lm_filename_util.unescape_string name in
> -         match parse_phony_name name with
> -            PhonyDirString name ->
> +         match parse_phony_name name, phony_ok with
> +            PhonyDirString name, (PhonyOK | PhonyExplicit) ->
>                 (* Name is .PHONY/... *)
>                 let hash, dir, key, name = new_file dir name in
>                 let node = NodePhonyDir (hash, dir, key, name) in
> @@ -1068,7 +1068,7 @@
>                           base.base_nodes <- NodeTable.add nodes node node;
>                           node)
>  
> -          | PhonyGlobalString name ->
> +          | PhonyGlobalString name, (PhonyOK | PhonyExplicit) ->
>                 (* Name is /.PHONY/name *)
>                 let hash = Hash.hash_global_phony name in
>                 let node = NodePhonyGlobal (hash, name) in
> @@ -1077,7 +1077,10 @@
>                           base.base_nodes <- NodeTable.add nodes node node;
>                           node)
>  
> -          | PhonySimpleString ->
> +          | (PhonyDirString _| PhonyGlobalString _), PhonyProhibited ->
> +               raise (Invalid_argument "Omake_node.Node.intern: NodePhony is not allowed");
> +
> +          | PhonySimpleString, PhonyOK ->
>                 (* Name is simple, without path separators *)
>                 let key  = Lm_filename_util.normalize_string name in
>                 let hash = Hash.hash_file dir key in
> @@ -1096,7 +1099,8 @@
>                                             base.base_nodes <- NodeTable.add nodes node node;
>                                             node)
>  
> -          | PhonyPathString ->
> +          | PhonySimpleString, (PhonyExplicit | PhonyProhibited)
> +          | PhonyPathString, _ ->
>                 (* Otherwise, it is a normal file *)
>                 let hash, dir, key, name = new_file dir name in
>                 let node = NodeFile (hash, dir, key, name) in
> @@ -1385,7 +1389,7 @@
>        else
>           symlink_file_unix
>  
> -   let intern mount dir name =
> +   let intern mount phony_ok dir name =
>        let { mount_info = mount_info;
>              mount_points = mounts
>            } = mount
> @@ -1394,7 +1398,7 @@
>              mount_file_reset = reset_file
>            } = mount_info
>        in
> -      let node = intern_simple dir name in
> +      let node = intern_simple phony_ok dir name in
>        let rec search mounts =
>           match mounts with
>              (dir_dst, dir_src, options) :: mounts ->
> Index: src/ir/omake_node_sig.ml
> ===================================================================
> --- src/ir/omake_node_sig.ml	(revision 8552)
> +++ src/ir/omake_node_sig.ml	(working copy)
> @@ -140,6 +140,11 @@
>   | NodeScanner
>   | NodeNormal
>  
> +type phony_ok =
> +   PhonyOK (* It is OK to return a phony node *)
> + | PhonyExplicit (* It is OK to return a phony node only when an explicit syntax was used *)
> + | PhonyProhibited (* Returning phony nodes is not allowed *)
> +
>  (*
>   * A file node.  There are two kinds of nodes.
>   * "Phony" nodes do not correspond to files.
> @@ -163,7 +168,7 @@
>      * Build a regular filename from a directory and string.
>      * It is legal for the string to contain / chars.
>      *)
> -   val intern : mount -> dir -> string -> t
> +   val intern : mount -> phony_ok -> dir -> string -> t
>  
>     (*
>      * Escape a node.
> Index: src/Makefile
> ===================================================================
> --- src/Makefile	(revision 8552)
> +++ src/Makefile	(working copy)
> @@ -380,13 +380,13 @@
>  ALLFILES_magic = omake_gen_magic.ml
>  
>  
> -CMOFILES_ir = omake_options_type.cmo omake_symbol.cmo omake_state.cmo omake_node_type.cmo omake_node_sig.cmo omake_node.cmo omake_virtual_id.cmo omake_install.cmo omake_command_type.cmo omake_command.cmo omake_cache_type.cmo omake_cache.cmo omake_ir.cmo omake_ir_util.cmo omake_ir_print.cmo
> +CMOFILES_ir = omake_options_type.cmo omake_symbol.cmo omake_state.cmo omake_node_type.cmo omake_node_sig.cmo omake_node.cmo omake_virtual_id.cmo omake_install.cmo omake_ir.cmo omake_ir_util.cmo omake_ir_print.cmo omake_command_type.cmo omake_command.cmo omake_cache_type.cmo omake_cache.cmo
>  OCAML_LIB_FLAGS_ir =
>  
>  ir.cma: $(CMOFILES_ir)
>  	$(OCAMLC) $(OCAMLFLAGS) $(OCAML_LIB_FLAGS_ir) -a -o $@ $(CMOFILES_ir)
>  
> -omake_options_type.cmo omake_symbol.cmo omake_state.cmo omake_node_type.cmo omake_node_sig.cmo omake_node.cmo omake_virtual_id.cmo omake_install.cmo omake_command_type.cmo omake_command.cmo omake_cache_type.cmo omake_cache.cmo omake_ir.cmo omake_ir_util.cmo omake_ir_print.cmo omake_state.cmi omake_node.cmi omake_virtual_id.cmi omake_install.cmi omake_command.cmi omake_cache.cmi omake_ir_util.cmi omake_ir_print.cmi: magic.cma
> +omake_options_type.cmo omake_symbol.cmo omake_state.cmo omake_node_type.cmo omake_node_sig.cmo omake_node.cmo omake_virtual_id.cmo omake_install.cmo omake_ir.cmo omake_ir_util.cmo omake_ir_print.cmo omake_command_type.cmo omake_command.cmo omake_cache_type.cmo omake_cache.cmo omake_state.cmi omake_node.cmi omake_virtual_id.cmi omake_install.cmi omake_ir_util.cmi omake_ir_print.cmi omake_command.cmi omake_cache.cmi: magic.cma
>  
>  SRC_ir = ..$(slash)src$(slash)ir
>  
> @@ -462,7 +462,7 @@
>  ALLFILES_ir = omake_ir.ml omake_node.ml omake_cache.ml omake_node.mli omake_state.ml omake_cache.mli omake_state.mli omake_symbol.ml omake_command.ml omake_install.ml omake_ir_util.ml omake_command.mli omake_install.mli omake_ir_print.ml omake_ir_util.mli omake_node_sig.ml omake_ir_print.mli omake_node_type.ml omake_cache_type.ml omake_virtual_id.ml omake_virtual_id.mli omake_command_type.ml omake_options_type.ml
>  
>  
> -CMOFILES_exec = omake_exec_type.cmo omake_exec_util.cmo omake_exec_print.cmo omake_exec_id.cmo omake_exec_local.cmo omake_exec_remote.cmo omake_exec_notify.cmo omake_exec.cmo
> +CMOFILES_exec = omake_exec_util.cmo omake_exec_id.cmo omake_exec_type.cmo omake_exec_print.cmo omake_exec_local.cmo omake_exec_remote.cmo omake_exec_notify.cmo omake_exec.cmo
>  OCAML_LIB_FLAGS_exec =
>  
>  exec.cma: $(CMOFILES_exec)
> @@ -553,7 +553,7 @@
>  omake_gen_parse$(EXE): $(CMOFILES_omake_gen_parse) $(OCAML_LIBS_omake_gen_parse) $(OCAML_CLIBS_omake_gen_parse)
>  	$(OCAMLC) $(OCAMLFLAGS) -custom -o $@ $(OCAML_CCLIBS_omake_gen_parse) $(OCAML_OTHER_LIBS_omake_gen_parse) $(THREADSLIB) $(OCAML_LIBS_omake_gen_parse) $(CMOFILES_omake_gen_parse)
>  
> -CMOFILES_env = omake_lexer.cmo omake_parser.cmo omake_env.cmo omake_exn_print.cmo omake_ast_parse.cmo omake_ast_lex.cmo omake_ir_ast.cmo omake_ir_semant.cmo omake_ir_free_vars.cmo omake_command_digest.cmo
> +CMOFILES_env = omake_lexer.cmo omake_parser.cmo omake_ir_free_vars.cmo omake_env.cmo omake_exn_print.cmo omake_ast_parse.cmo omake_ast_lex.cmo omake_ir_ast.cmo omake_ir_semant.cmo omake_command_digest.cmo
>  OCAML_LIB_FLAGS_env =
>  
>  env.cma: $(CMOFILES_env)
> @@ -575,7 +575,7 @@
>  omake_ast_parse.input: ..$(slash)src$(slash)env$(slash)omake_ast_parse.input
>  	$(LN) ..$(slash)src$(slash)env$(slash)omake_ast_parse.input omake_ast_parse.input
>  
> -omake_lexer.cmo omake_parser.cmo omake_env.cmo omake_exn_print.cmo omake_ast_parse.cmo omake_ast_lex.cmo omake_ir_ast.cmo omake_ir_semant.cmo omake_ir_free_vars.cmo omake_command_digest.cmo omake_env.cmi omake_exn_print.cmi omake_ast_parse.cmi omake_ast_lex.cmi omake_ir_ast.cmi omake_ir_semant.cmi omake_ir_free_vars.cmi omake_command_digest.cmi: magic.cma
> +omake_lexer.cmo omake_parser.cmo omake_ir_free_vars.cmo omake_env.cmo omake_exn_print.cmo omake_ast_parse.cmo omake_ast_lex.cmo omake_ir_ast.cmo omake_ir_semant.cmo omake_command_digest.cmo omake_ir_free_vars.cmi omake_env.cmi omake_exn_print.cmi omake_ast_parse.cmi omake_ast_lex.cmi omake_ir_ast.cmi omake_ir_semant.cmi omake_command_digest.cmi: magic.cma
>  
>  Makefile.dep: omake_ast_lex.ml omake_ast_parse.mly omake_ast_parse.mli omake_ast_parse.ml
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> OMake-Devel mailing list
> OMake-Devel at metaprl.org
> https://lists.metaprl.org/mailman/listinfo/omake-devel

-- 
Jason Hickey                  http://www.cs.caltech.edu/~jyh
Caltech Computer Science      Tel: 626-395-6568 FAX: 626-792-4257



More information about the OMake-Devel mailing list