|
#1
|
|||
|
|||
Does saving a project macro modify it?
My build stores a project macro with the (multi line) output of a Perforce command and compares it with that same command the next time it is run. When I run the build from inside VBPro things work correctly, but when I run it from the command line the compare always returns that the macros are different -- even though they look exactly the same when I dump them to the output log.
I am saving the project, so that is not the problem. Does VBPro do anything like strip newlines or invisible characters? Below is a copy of the log from two builds from within the IDE (sans my personal information). --------------------Starting Build: 'p4_monitor'-------------------- Building project step 'Project steps'... Building project step 'Perforce'... Performing requested command... Change 555 on 2005/08/05 by xxx@yyyy 'Adding some test data ' Building project step 'Set Macro'... Created Temporary macro 'P4_LAST_CHANGE' Building project step 'Log Message'... ***** P4_LAST_CHANGE IS: Performing requested command... Change 555 on 2005/08/05 by xxx@yyyy 'Adding some test data ' === P4_STORED_LAST_CHANGE IS: Performing requested command... Change 555 on 2005/08/05 by xxx@yyyy 'Adding some test data ' ***** P4_LAST_CHANGE in script: Performing requested command... Change 555 on 2005/08/05 by xxx@yyyy 'Adding some test data ' P4_STORED_LAST_CHANGE in script: Performing requested command... Change 555 on 2005/08/05 by xxx@yyyy 'Adding some test data ' Expression evaluates to: -1 Building project step 'if last_change != stored_change'... Building project step 'Set Macro'... Updated Project macro 'P4_STORED_LAST_CHANGE' Building project step 'Save file'... Build successfully completed. Registered to: **** --------------------Starting Build: 'p4_monitor'-------------------- Building project step 'Project steps'... Building project step 'Perforce'... Performing requested command... Change 555 on 2005/08/05 by xxx@yyyy 'Adding some test data ' Building project step 'Set Macro'... Created Temporary macro 'P4_LAST_CHANGE' Building project step 'Log Message'... ***** P4_LAST_CHANGE IS: Performing requested command... Change 555 on 2005/08/05 by xxx@yyyy 'Adding some test data ' === P4_STORED_LAST_CHANGE IS: Performing requested command... Change 555 on 2005/08/05 by xxx@yyyy 'Adding some test data ' ***** P4_LAST_CHANGE in script: Performing requested command... Change 555 on 2005/08/05 by xxx@yyyy 'Adding some test data ' P4_STORED_LAST_CHANGE in script: Performing requested command... Change 555 on 2005/08/05 by xxx@yyyy 'Adding some test data ' Expression evaluates to: 0 Building project step 'if last_change != stored_change'... Step 'if last_change != stored_change' build rule evaluates false: [Trim(vbld_AllMacros()("P4_LAST_CHANGE").Value) <> Trim(vbld_AllMacros()("P4_STORED_LAST_CHANGE").Val ue)] is true Step skipped Building project step 'Set Macro'... Step 'if last_change != stored_change' build rule evaluates false: [Trim(vbld_AllMacros()("P4_LAST_CHANGE").Value) <> Trim(vbld_AllMacros()("P4_STORED_LAST_CHANGE").Val ue)] is true Step skipped Building project step 'Save file'... Step 'if last_change != stored_change' build rule evaluates false: [Trim(vbld_AllMacros()("P4_LAST_CHANGE").Value) <> Trim(vbld_AllMacros()("P4_STORED_LAST_CHANGE").Val ue)] is true Step skipped Build successfully completed. |
#2
|
|||
|
|||
A couple of further notes after rereading this --
1) The build always executes the steps the first time it is run in the IDE. Further runs work correctly. 2) The evaluation of the expression in the log message is actually a strcompare, not exactly the same as in the next step (though this makes no difference) Running this further makes me think it's a newline issue; when I look at the macros tab in the IDE, when I first load it there are two squares in the saved macro where the newline would be it but only one square after it runs the first time. |
#3
|
|||
|
|||
When VBP writes a file (.bld, .macros, etc.) to disk, any newlines will be normalized to Windows-standard newline format (CR/LF). So if a macro value contains only CR, after saving and reloading, the value will contain CR/LF instead. You may want to ensure that your macro value is created with CR/LF for newlines, or formulate your comparison to strip all newline characters first.
|
#4
|
|||
|
|||
Thanks for the info. I am now using a script command to grab just the part of the string that I need to compare, which is all on one line. The continuous integration sample code was very helpful as I have little experience with VBScript.
|
#5
|
|||
|
|||
Note that you can use JScript or other scripting languages such as Perl rather than VBScript.
|
|
|