]> git.ipfire.org Git - thirdparty/make.git/commit
Support "unexport" in target-specific variables.
authorPaul Smith <psmith@gnu.org>
Sat, 28 Nov 2020 17:30:08 +0000 (12:30 -0500)
committerPaul Smith <psmith@gnu.org>
Sun, 29 Nov 2020 22:57:33 +0000 (17:57 -0500)
commit2dc0280d82dd11bc6bb06363f27dd7739ee8a371
tree017b43eac595635e7a3de307a5886adf6489a57b
parent90959b8b70be9d81bb559f51a3a894d80dc5d469
Support "unexport" in target-specific variables.

Rewrite the environment variable algorithm to correctly inherit
export settings from parent variable sets.  The new algorithm
for computing the table of environment variables is:

- Start with the most local variable set and proceed to global.
- If the variable already exists in the table and we don't know
  its export status, update it with the current variable's status.
- If the variable is not in the table and it's not global, add it
  regardless of its status so if it's unexported we remember that.
- If the variable is not in the table and is global, check its
  export status and don't add it if we won't export it.

Then when generating the environment variables, check the export
status of each variable in case it was a target-specific variable
and we have determined it should not be exported.

Rework SHELL handling to check at the end whether we added it or
not and if we didn't, add the value from the environment.

* NEWS: Announce support for target-specific "unexport"."
* doc/make.texi (Target-specific): Document the support.
* src/variable.h (enum variable_export): Make into a global type.
* src/read.c (struct vmodifiers): Use enum variable_export rather
than individual booleans.
(parse_var_assignment): Parse the "unexport" keyword.
(eval): Remember the vmodifier value in the variable.
(record_target_var): Ditto.
* src/variable.c (should_export): Check if the variable should be
exported.
(target_environment): Implement the above algorithm.
* tests/scripts/features/export: Test export/unexport with variable
assignments on the same line.
* tests/scripts/features/targetvars: Add a comprehensive suite of
tests for different types of target-specific export / unexport.
* tests/scripts/variables/SHELL: Update the comment.
NEWS
doc/make.texi
src/read.c
src/variable.c
src/variable.h
tests/scripts/features/export
tests/scripts/features/targetvars
tests/scripts/variables/SHELL