make/src/rule.h

60 lines
2.2 KiB
C
Raw Normal View History

1994-03-23 22:12:55 +08:00
/* Definitions for using pattern rules in GNU Make.
2020-01-03 13:13:02 +08:00
Copyright (C) 1988-2020 Free Software Foundation, Inc.
1989-06-12 06:44:40 +09:00
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
1989-06-12 06:44:40 +09:00
GNU Make 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 GNU General Public License for more details.
1989-06-12 06:44:40 +09:00
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>. */
1989-06-12 06:44:40 +09:00
/* Structure used for pattern (implicit) rules. */
1989-06-12 06:44:40 +09:00
struct rule
{
struct rule *next;
const char **targets; /* Targets of the rule. */
unsigned int *lens; /* Lengths of each target. */
const char **suffixes; /* Suffixes (after '%') of each target. */
struct dep *deps; /* Dependencies of the rule. */
struct commands *cmds; /* Commands to execute. */
[SV 61042] Enhance logging of implicit rule search Logging of implicit rule search gives limited information as to why a given implicit rule was rejected, and if no implicit rule is found we get the confusing "No rule to make target" result when the real issue is that some prerequisite of some implicit rule could not be built. Enhance logging around implicit rule search as follows: 1. The messages which refer to a rule print a description (the targets and prerequisites) of the rule. 2. A new message tells when a rule is rejected, along with the reason. 3. The 'Looking for an implicit rule...' message is printed for every prerequisite, not just the top-level target. 4. "Trying harder" message is printed, when intermediate prerequisites are going to be searched. 5. The 'No rule found...' and 'Found implicit rule...' messages are printed for every prerequisite, not just the top-level target. 6. "Ought to exist...", "Found..." or "Not found..." message is printed for each prerequisite. * src/rule.h (struct rule): Remember the definition of the rule. * src/rule.c (get_rule_defn): Compute the definition of a rule. (install_pattern_rule): Initialize the definition to empty. (create_pattern_rule): Ditto. (freerule): Free the definition. (print_rule): Use the definition when printing rules. * src/remake.c (update_file_1): Push debug output down into try_implicit_rule(). * src/implicit.c (try_implicit_rule): Add debugging (pattern_search): Show the rule definition in various debug output. Add new debug messages for implicit rule search. Additional changes by Paul Smith <psmith@gnu.org>: Since we usually don't need the rule definition, defer computing it until we do. * bootstrap.conf: Include the mempcpy Gnulib module. * src/makeint.h (mempcpy): Declare mempcpy if not available. * src/misc.c (mempcpy): Define mempcpy if not available. * src/config.h-vms.template: Don't set HAVE_MEMPCPY. * src/config.h.W32.template: Ditto. * src/rule.h (get_rule_defn): Return the definition of a rule. * src/rule.c (get_rule_defn): If we don't have a definition compute it; either way return it. * src/implicit.c (pattern_search): Rework the handling of explicit prerequisites to pattern rules to be more clear. There is no change in behavior.
2021-10-18 06:03:04 +08:00
char *_defn; /* Definition of the rule. */
unsigned short num; /* Number of targets. */
char terminal; /* If terminal (double-colon). */
char in_use; /* If in use by a parent pattern_search. */
1989-06-12 06:44:40 +09:00
};
/* For calling install_pattern_rule. */
struct pspec
{
const char *target, *dep, *commands;
1989-06-12 06:44:40 +09:00
};
extern struct rule *pattern_rules;
extern struct rule *last_pattern_rule;
extern unsigned int num_pattern_rules;
extern unsigned int max_pattern_deps;
1993-07-01 06:42:37 +08:00
extern unsigned int max_pattern_targets;
extern size_t max_pattern_dep_length;
1989-06-12 06:44:40 +09:00
extern struct file *suffix_file;
Support the .EXTRA_PREREQS special variable Initial implementation by Christof Warlich <cwarlich@gmx.de> * NEWS: Announce the new feature. * doc/make.texi (Other Special Variables): Document .EXTRA_PREREQS. * src/dep.h (struct dep): New flag to note extra prereq deps. * src/filedef.h (expand_extra_prereqs): Declare a function to expand the value of .EXTRA_PREREQS. * src/file.c (expand_extra_prereqs): Given a struct variable lookup of .EXTRA_PREREQS, convert it into a list of deps and for each one make sure it has a struct file and has the new flag set. (snap_file): A new function invoked by hash_map that will perform per-file operations: set up second expansion, intermediate, and also .EXTRA_PREREQS. Manage circular dependencies by ignoring them. (snap_deps): Defer per-file operations until the end. Look up the global .EXTRA_PREREQS and pass it along to snap_file for each file. * src/implicit.c (struct patdeps): Remember the extra prereqs flag. (pattern_search): Transfer extra prereqs flag settings into the matched pattern rule. * src/rule.h (snap_implicit_rules): Rename count_implicit_rules to snap_implicit_rules since we now do more than count. * src/rule.c (snap_implicit_rules): As we walk through all the pattern rules, add in any global .EXTRA_PREREQS to the dep list. Ensure we take them into account for the max number of prereqs and name length. * src/main.c (main): Add extra-prereqs to .FEATURES. Call the renamed snap_implicit_rules. * tests/scripts/variables/EXTRA_PREREQS: Add tests.
2020-01-02 18:08:06 +08:00
void snap_implicit_rules (void);
void convert_to_pattern (void);
void install_pattern_rule (struct pspec *p, int terminal);
void create_pattern_rule (const char **targets, const char **target_percents,
unsigned short num, int terminal, struct dep *deps,
struct commands *commands, int override);
[SV 61042] Enhance logging of implicit rule search Logging of implicit rule search gives limited information as to why a given implicit rule was rejected, and if no implicit rule is found we get the confusing "No rule to make target" result when the real issue is that some prerequisite of some implicit rule could not be built. Enhance logging around implicit rule search as follows: 1. The messages which refer to a rule print a description (the targets and prerequisites) of the rule. 2. A new message tells when a rule is rejected, along with the reason. 3. The 'Looking for an implicit rule...' message is printed for every prerequisite, not just the top-level target. 4. "Trying harder" message is printed, when intermediate prerequisites are going to be searched. 5. The 'No rule found...' and 'Found implicit rule...' messages are printed for every prerequisite, not just the top-level target. 6. "Ought to exist...", "Found..." or "Not found..." message is printed for each prerequisite. * src/rule.h (struct rule): Remember the definition of the rule. * src/rule.c (get_rule_defn): Compute the definition of a rule. (install_pattern_rule): Initialize the definition to empty. (create_pattern_rule): Ditto. (freerule): Free the definition. (print_rule): Use the definition when printing rules. * src/remake.c (update_file_1): Push debug output down into try_implicit_rule(). * src/implicit.c (try_implicit_rule): Add debugging (pattern_search): Show the rule definition in various debug output. Add new debug messages for implicit rule search. Additional changes by Paul Smith <psmith@gnu.org>: Since we usually don't need the rule definition, defer computing it until we do. * bootstrap.conf: Include the mempcpy Gnulib module. * src/makeint.h (mempcpy): Declare mempcpy if not available. * src/misc.c (mempcpy): Define mempcpy if not available. * src/config.h-vms.template: Don't set HAVE_MEMPCPY. * src/config.h.W32.template: Ditto. * src/rule.h (get_rule_defn): Return the definition of a rule. * src/rule.c (get_rule_defn): If we don't have a definition compute it; either way return it. * src/implicit.c (pattern_search): Rework the handling of explicit prerequisites to pattern rules to be more clear. There is no change in behavior.
2021-10-18 06:03:04 +08:00
const char *get_rule_defn (struct rule *rule);
void print_rule_data_base (void);