LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using pre-build action to display svn version number

Solved!
Go to solution

Hi Folks.

 

I was thinking of using a pre build action to display the current svn number on the front panel. I have a vi that can get the current svn number. The problem however is how to link it to the application. Is there a way the pre-build can give the data to the executable or do I have to write it to a file and then have the executable read it each time it starts up.

 

Thanks,

 

Mark.

0 Kudos
Message 1 of 25
(3,404 Views)

You should be able to use Scripting functions to alter a VI of your choice to change the version. Just make sure your scripting functions don't break anything, or else the executable build will fail.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 2 of 25
(3,395 Views)

Do you have any links you can provide which detail how to set up scripting functions?

0 Kudos
Message 3 of 25
(3,381 Views)

Yup this has been done before.

 

http://forums.ni.com/t5/LabVIEW/Pre-Build-EXE-and-Installer-Set-Version/td-p/3149028

 

The main issue is you can't write the version to the project in the prebuild and have it apply to the build it is performing.  So the work around is to set the build number, abort that build, then ask the user to invoke another build.

Message 4 of 25
(3,378 Views)

Another way to do this would be to make a Post-Build VI that adds your version info to the executable's INI file as your own custom tag. You can then pull that config value during run-time without needing to make a new file just for this functionality.

 


@Hooovahh wrote:

The main issue is you can't write the version to the project in the prebuild and have it apply to the build it is performing.  So the work around is to set the build number, abort that build, then ask the user to invoke another build.


This seems like the main reason someone would want to do a Pre-Build action, so maybe something NI should have taken in to account when allowing Pre-Build actions.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 5 of 25
(3,368 Views)

I think writing to a config file is much simpler. All the other work arounds seem to be a great ordeal.

0 Kudos
Message 6 of 25
(3,358 Views)

Yes, I think I'm the one that discovered (and reported, and ask to have fixed) that the Version Number in the Build is cached before the Pre-Build Action, so you need to "build twice" to get this to work.  I'm doing this routinely in all of my LabVIEW 2014 (and higher) Builds.  [I actually developed this in LabVIEW 2012, but new functions added in LabVIEW 2014 make it much simpler].  I also have incorporated a modification of Hooovahh's suggestion to error-abort the Build if it fails to update the Version.

 

This uses the 2014 Get/Set Build Specification Version functions.  I have an internal Version function that provides the Major, Minor, and Patch/Fix parts of the Build, and wrote a function that queries the SVN Revision Number associated with the Project Path to return the Build.  In case the Project is not (yet) in Subversion (or is otherwise "disconnected" from the Repository), the SVN Build returns 0.  I combine all four numbers in the format that Set Build Specification Version wants, and Set it.  I then compare the Build from SVN with the Build obtained from Get Build Specification Version -- if they are the same, then the Build in the Version Spec was "correct" before I (re)set it, so the "Pre-Build Feature/Bug" won't matter.  Otherwise, I abort the Build before it starts and say "Do it again ...".

 

Pre-Build Action.png Bob Schor

Message 7 of 25
(3,330 Views)

It seens like a quite involved way to extract the number. I thought the pre/post build actions were added to Labview for this reason.

0 Kudos
Message 8 of 25
(3,326 Views)

 


@MarkGreally wrote:

It seens like a quite involved way to extract the number. I thought the pre/post build actions were added to Labview for this reason.


Yes, they can definitely be used for this purpose.  The concept of a "Build" is something that Subversion (not LabVIEW) knows about, so you need to get this "external" information into LabVIEW (which I do through my SVN Build function).  The other elements of the Version Number (Major, Minor, Patch/Fix) are up to the User -- I'm using a Constant Function in my program that I update when I make a new Release.  Alternatively, I could have written an "Increment Minor" function and maybe called it outside the context of the Pre-Build Action, but the Get/Set Build Version Spec functions require Project Path, Build Spec Name, and Target Name, and those are automatically supplied to the Pre-Build Action, so it becomes much simpler to do this here.

 

And if NI ever gets around to making sure that the Pre-Build Action is actually done before the Build, and therefore before the Version Number is cached, the hoops that I'm jumping through to ensure that the Build part of the Version is the current SVN Build will no longer be necessary.

 

So, OK, it's a little complicated, but it works, and the same code will work for all of the Builds in your Project(s).

 

BS 

Message 9 of 25
(3,316 Views)

I may ineed give it a go.

 

Thanks.

0 Kudos
Message 10 of 25
(3,306 Views)