bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem setting a variable inside a target


From: Martin Dorey
Subject: Re: Problem setting a variable inside a target
Date: Tue, 26 Sep 2023 01:00:26 +0000

Because the ifeq was evaluated during the first phase but the eval was deferred to the second.



From: Ed L Wolf <e.l.wolf@cummins.com>
Sent: Monday, September 25, 2023 03:32
To: Martin Dorey <Martin.Dorey@hitachivantara.com>; bug-make@gnu.org <bug-make@gnu.org>
Subject: RE: Problem setting a variable inside a target
 
***** EXTERNAL EMAIL *****

One more comment. For some reason SUPLLIER_A2l is blank

 

Ed L Wolf
Technical Advisor - Embedded Software
e.l.wolf@cummins.com
Cummins Inc.
Mail Code: C7004
1460 National Road
Columbus, Indiana 47201
United States

 

From: Ed L Wolf
Sent: Monday, September 25, 2023 6:10 AM
To: Martin Dorey <Martin.Dorey@hitachivantara.com>; bug-make@gnu.org
Subject: RE: Problem setting a variable inside a target

 

The following code response was

 

           Supplier folder detected

 

           Supplier folder detected but no a2l files present

 

but the response should have been

 

           Supplier folder detected

 

           Supplier a2l files found  since the folder DIR_SUPPLIER did exist and DIR_A2LGEN_SUPPLIER did have a file called Rte.a2l

 

 

 

 

 

Ed L Wolf
Technical Advisor - Embedded Software
e.l.wolf@cummins.com
Cummins Inc.
Mail Code: C7004
1460 National Road
Columbus, Indiana 47201
United States

 

From: Martin Dorey <Martin.Dorey@hitachivantara.com>
Sent: Sunday, September 24, 2023 6:02 PM
To: Ed L Wolf <e.l.wolf@cummins.com>; bug-make@gnu.org
Subject: Re: Problem setting a variable inside a target

 

EXTERNAL SENDER: This email originated outside of Cummins. Do not click links or open attachments unless you verify the sender and know the content is safe.

 

> The eval statement below highlighted in red is not working

 

Perhaps you'd expect to see "BADGER is wombat" from:

 

mad@shuttle:~/tmp/wolf-2023-09-24$ cat Makefile

default:

      $(eval BADGER = wombat)

ifeq ($(BADGER),wombat)

      echo BADGER is wombat

else

      echo BADGER is not wombat

endif

mad@shuttle:~/tmp/wolf-2023-09-24$ make

echo BADGER is not wombat

BADGER is not wombat

mad@shuttle:~/tmp/wolf-2023-09-24$ 

 

If that wasn't what you were trying to convey, then perhaps you could concoct a similarly small example, including what you typed, what the computer said in response and what your expectation was.

 

If we look at the results of the first phase of Make described in:

 

 

mad@shuttle:~/tmp/wolf-2023-09-24$ make -p nothing 2>&1 | grep -B2 -A1 BADGER

#  File has not been updated.

#  recipe to execute (from 'Makefile', line 2):

      $(eval BADGER = wombat)

      echo BADGER is not wombat

 

mad@shuttle:~/tmp/wolf-2023-09-24$

 

... then we see that the "BADGER is wombat" arm of the conditional is not even there to be run when it comes to executing the recipe in the second phase.  The ifeq was "immediate" but the $(eval) was "deferred".

 

It's a separate matter, but I fear your second red line might be expecting this behavior:

 

mad@shuttle:~/tmp/wolf-2023-09-24$ echo *.a2l

*.a2l

mad@shuttle:~/tmp/wolf-2023-09-24$ 

 

... which I doubt you're going to get from find(1):

 

mad@shuttle:~/tmp/wolf-2023-09-24$ find -name "*.a2l"

mad@shuttle:~/tmp/wolf-2023-09-24$

 


From: bug-make-bounces+martin.dorey=hds.com@gnu.org <bug-make-bounces+martin.dorey=hds.com@gnu.org> on behalf of Ed L Wolf <e.l.wolf@cummins.com>
Sent: Sunday, September 24, 2023 10:23

Subject: Problem setting a variable inside a target

 

***** EXTERNAL EMAIL *****

Hello

 

I am having some trouble trying to set a variable inside a target. When reading the variable, it comes up blank. Below is my make file code. The eval statement below highlighted in red is not working. Can you provide some assistance please? I am using GNU Make 4.1

 

$(DIR_A2LGEN_SETUP)/McData-setup.a2l: $(BSW_A2LS)  $(DIR_SCRIPTS)/update_mcdata_a2l.py $(DIR_SCRIPTS)/update_copyright_info.py $(DIR_SCRIPTS)/merge_a2l_files.py $(DIR_TARGET)/$(PROJECT).odx-f $(DIR_A2L)/Merger.ini

            @echo "A2L        $@"

 

            @rm -rf $(DIR_A2LGEN)

            @rm -rf $(DIR_A2LLOGS)

            @rm -rf $(DIR_A2LGEN_SETUP)

            @rm -rf $(DIR_A2LGEN_UPDATE)

            @rm -rf $(DIR_A2LGEN_MODIFY)

            @rm -rf $(DIR_A2LGEN_CHECK)

            @rm -rf $(DIR_A2LGEN_SUPPLIER)

            @mkdir -p $(DIR_A2LGEN)

            @mkdir -p $(DIR_A2LLOGS)

            @mkdir -p $(DIR_A2LGEN_SETUP)

            @mkdir -p $(DIR_A2LGEN_UPDATE)

            @mkdir -p $(DIR_A2LGEN_MODIFY)

            @mkdir -p $(DIR_A2LGEN_CHECK)

            @mkdir -p $(DIR_A2LGEN_SUPPLIER)

           

           

            @find $(DIR_BSWPROJECT) -type f -name "*.a2l" | xargs -i cp {} $(DIR_A2LGEN_SETUP)

 

 

           

#TODO: IS this still needed

            @cp $(DIR_A2L)/_Master*.a2l $(DIR_A2LGEN_SETUP)

 

            @python $(DIR_SCRIPTS)/update_mcdata_a2l.py $(DIR_A2LGEN_SETUP)

 

            @python $(DIR_SCRIPTS)/update_copyright_info.py \

        -a $(DIR_A2LGEN_SETUP)/McData.a2l.patched \

        -o $(DIR_A2LGEN_SETUP)/McData-copyright.a2l

                       

 

            @python $(DIR_SCRIPTS)/merge_two_files.py \

                        -f1 $(CAN_A2L) \

                        -f2 $(DIR_A2LGEN_SETUP)/McData-copyright.a2l  \

                        -sp '/end DAQ'   \

                        -ep '/end IF_DATA'  \

                        -op $(DIR_A2LGEN_SETUP)/McData-copyright-can.a2l

                       

# When there are no supplier a2l files then the merge process doesn't need to be done.

 

ifneq ($(wildcard $(DIR_SUPPLIER)),)

            @find $(DIR_SUPPLIER) -type f -name "*.a2l" | xargs -i cp {} $(DIR_A2LGEN_SUPPLIER)

            $(eval SUPPLIER_A2l := $(sort $(shell find $(DIR_A2LGEN_SUPPLIER) -type f -name "*.a2l")))

            @echo "A2L        Supplier folder detected"

            @echo "Supplier a2l         $(SUPPLIER_A2l)"

 

 

# Just becuase there is a supplier folder does not mean it has a2l files.

ifeq ($(SUPPLIER_A2l),"*.a2l")

            @echo "A2L        Supplier a2l files found"

 

            @python $(DIR_SCRIPTS)/merge_a2l_files.py \

                        -s $(DIR_A2LGEN_SUPPLIER) \

                        -b a2l_file_list_supplier.opt \

                        -P $(DIR_A2L)/Merger.ini \

                        -M $(DIR_A2LGEN_SETUP)/McData-copyright-can.a2l \

                        -O $(DIR_A2LGEN_SETUP)/McData-setup.a2l \

                        -L $(DIR_A2LLOGS)/Log0-A2LMerger.log \

                        -g $(DIR_BUILDGEN)

 

            @ASAP2Merger.exe \

                        @$(DIR_BUILDGEN)/a2l_file_list_supplier.opt \

                        > $(subst $(DIR_A2LGEN_SETUP),$(DIR_A2LLOGS),$(@:.a2l=.log)) \

                        || echo "A2L        $(DIR_A2LLOGS)/Log0-A2L-Supplier-Merger.log - Check for warnings/errors!"

                       

           

else

            @cp $(DIR_A2LGEN_SETUP)/McData-copyright-can.a2l $(DIR_A2LGEN_SETUP)/McData-setup.a2l

            @echo "A2L        Supplier folder detected but no a2l files present"

endif

 

else    

            @cp $(DIR_A2LGEN_SETUP)/McData-copyright-can.a2l $(DIR_A2LGEN_SETUP)/McData-setup.a2l

            @echo "A2L        Supplier folder not available"

endif

 

Ed L Wolf
Technical Advisor - Embedded Software
e.l.wolf@cummins.com
Cummins Inc.
Mail Code: C7004
1460 National Road
Columbus, Indiana 47201
United States

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]