Home | History | Annotate | Line # | Download | only in unit-tests
make-exported.mk revision 1.2
      1  1.2  rillig # $NetBSD: make-exported.mk,v 1.2 2020/10/03 09:48:40 rillig Exp $
      2  1.1  rillig #
      3  1.1  rillig # As of 2020-08-09, the code in Var_Export is shared between the .export
      4  1.1  rillig # directive and the .MAKE.EXPORTED variable.  This leads to non-obvious
      5  1.1  rillig # behavior for certain variable assignments.
      6  1.1  rillig 
      7  1.2  rillig -env=		make-exported-value-env
      8  1.2  rillig -literal=	make-exported-value-literal
      9  1.1  rillig UT_VAR=		${UNEXPANDED}
     10  1.1  rillig 
     11  1.1  rillig # The following behavior is probably not intended.
     12  1.2  rillig .MAKE.EXPORTED=		-env		# behaves like .export-env
     13  1.2  rillig 
     14  1.2  rillig # If the value of .MAKE.EXPORTED starts with "-literal", make behaves like
     15  1.2  rillig # a mixture of .export-literal and a regular .export.
     16  1.2  rillig # XXX: This is due to a sloppy implementation, reusing code in places where
     17  1.2  rillig # it is not appropriate.
     18  1.2  rillig #
     19  1.2  rillig # In Parse_DoVar, the code path for MAKE_EXPORTED is taken, calling Var_Export
     20  1.2  rillig # in turn.  There, the code path for .export-literal is taken, and the
     21  1.2  rillig # environment variable UT_VAR is set to ${UNEXPANDED}, as expected.
     22  1.2  rillig # Later, in Compat_RunCommand, in the child process after vfork,
     23  1.2  rillig # Var_ExportVars is called, which treats "-literal" as an ordinary variable
     24  1.2  rillig # name, therefore exports it and also overwrites the previously exported
     25  1.2  rillig # UT_VAR with the expanded value.
     26  1.2  rillig .MAKE.EXPORTED=		-literal UT_VAR
     27  1.1  rillig 
     28  1.1  rillig all:
     29  1.1  rillig 	@env | sort | grep -E '^UT_|make-exported-value' || true
     30