Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved QMake $${LITERAL_DOLLAR}0 not expanded to command line at compile - Qt Creator, MacOS

    General and Desktop
    qt creator qmake dollar literal macosx
    1
    2
    980
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      trevorS last edited by trevorS

      I am trying to pass $0 to the command line without success. While the qmake message function properly expands LITERAL_DOLLAR, it is not expanded on the command line at compile.

      You can see in the qmake code and compile output below that both the LITERAL_DOLLAR and proceeding 0 are omitted from the awk command.

      [QMake Code]

      MY_DIR = MyDir=/Library/mydir
      
      message("COMMAND awk 'NR==2 {$${LITERAL_DOLLAR}0=\"$${MY_DIR}\"} 1' myrc.sample > .myrc")
      
      myrcupdate.target   = .myrc
      myrcupdate.depends  = myrcupdateMessage
      myrcupdate.commands = awk \'NR==2 {$${LITERAL_DOLLAR}0=\"$${MY_DIR}\"} 1\' myrc.sample > .myrc
      
      myrcupdateMessage.commands = @echo Updating myrc entry $${MY_DIR}
      
      QMAKE_EXTRA_TARGETS += myrcupdate myrcupdateMessage
      PRE_TARGETDEPS      += .myrc
      

      [Compile Output]

      Project MESSAGE: COMMAND awk 'NR==2 {$0="MyDir=/Library/mydir"} 1' myrc.sample > .myrc
      Updating myrc entry MyDir=/Library/mydir
      awk: syntax error at source line 1
       context is
      	NR==2 >>>  {= <<< "MyDir=/Library/mydir"} 1
      awk: illegal statement at source line 1
      make[1]: *** [.myrc] Error 2
      make: *** [sub-MY_SUB_PROJECT-make_first-ordered] Error 2
      awk 'NR==2 {=MyDir=/Library/mydir} 1' myrc.sample > .myrc
      13:40:08: The process "/usr/bin/make" exited with code 2.
      Error while building/deploying project MY_PROJECT (kit: Desktop Qt 5.7.1 clang 64bit static)
      The kit Desktop Qt 5.7.1 clang 64bit static has configuration issues which might be the root cause for this problem.
      When executing step "Make"
      

      Is this qmake behaviour intentional ?

      1 Reply Last reply Reply Quote 0
      • T
        trevorS last edited by

        While I'm still not successful to expand $${LITERAL_DOLLAR}0 to the command line at compile, I did resolve the generated compile error by changing from awk to sed.

        [Work around]

        Change...

        myrcupdate.commands = awk \'NR==2 {$${LITERAL_DOLLAR}0=\"$${MY_DIR}\"} 1\' myrc.sample > .myrc
        

        to...

        myrcupdate.commands = sed -i \'\' \'2s%.*%$${MY_DIR}%\'  .myrc
        
        1 Reply Last reply Reply Quote 0
        • T
          trevorS last edited by

          While I'm still not successful to expand $${LITERAL_DOLLAR}0 to the command line at compile, I did resolve the generated compile error by changing from awk to sed.

          [Work around]

          Change...

          myrcupdate.commands = awk \'NR==2 {$${LITERAL_DOLLAR}0=\"$${MY_DIR}\"} 1\' myrc.sample > .myrc
          

          to...

          myrcupdate.commands = sed -i \'\' \'2s%.*%$${MY_DIR}%\'  .myrc
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post