Skip to content

Commit

Permalink
Move gitignore to task package for portability, update readme, bump v…
Browse files Browse the repository at this point in the history
…ersion
  • Loading branch information
tmatijevich committed Jun 29, 2023
1 parent 746b1b2 commit ef3c4ee
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
1 change: 0 additions & 1 deletion .gitignore

This file was deleted.

1 change: 1 addition & 0 deletions BuildVer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Variables.var
1 change: 1 addition & 0 deletions BuildVer/ANSIC.prg
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<Program SubType="ANSIC" xmlns="http://br-automation.co.at/AS/Program">
<Files>
<File Description="Initialization code">Main.c</File>
<File Description="Ignore Variables.var">.gitignore</File>
<File Description="Local variables" Private="true">Variables.var</File>
</Files>
</Program>
2 changes: 1 addition & 1 deletion BuildVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ END_VAR
# Register Variables.var in package definition
if([System.IO.File]::Exists($PackageFile)) {
$Content = Get-Content -Raw $PackageFile
$Regex = "Variables\.var"
$Regex = ">\s*Variables\.var\s*<"
$Match = [regex]::Match($Content, $Regex)
if(-not $Match.Success) {
$Regex = "(?x) <Files> ((?:.|\n)*) </Files>"
Expand Down
3 changes: 1 addition & 2 deletions Package.pkg
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<?AutomationStudio FileVersion="4.9"?>
<Package Version="0.00.7" xmlns="http://br-automation.co.at/AS/Package">
<Package Version="0.00.8" xmlns="http://br-automation.co.at/AS/Package">
<Objects>
<Object Type="Program" Language="ANSIC" Description="Version information">BuildVer</Object>
<Object Type="File" Description="Structure declarations">BuildVersion.typ</Object>
<Object Type="File" Description="Pre-build script">BuildVersion.ps1</Object>
<Object Type="File" Description="Ignore files">.gitignore</Object>
<Object Type="File" Description="Documentation">README.md</Object>
<Object Type="File" Description="License">LICENSE</Object>
</Objects>
Expand Down
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# BuildVersion [![Made For B&R](https://github.com/hilch/BandR-badges/blob/main/Made-For-BrAutomation.svg)](https://www.br-automation.com)
# BuildVersion [![Made For B&R](https://raw.githubusercontent.com/hilch/BandR-badges/main/Made-For-BrAutomation.svg)](https://www.br-automation.com)

[BuildVersion](https://github.com/br-na-pm/BuildVersion#readme) is a software package for Automation Studio projects.
The package includes a PowerShell script to automatically capture version information during a build.
[BuildVersion](https://github.com/br-na-pm/BuildVersion#readme) is a software package for [Automation Studio](https://www.br-automation.com/en/products/software/automation-software/automation-studio/) projects.
The package includes a [PowerShell](https://learn.microsoft.com/en/powershell/) script to automatically capture version information during a build.
The script is intended for use with the version control system [git](https://git-scm.com/).
The information captured is automatically initialized to a local and/or global variable in the project.
**NOTE:** This is not an official package. BuildVersion is provided as-is under the GNU GPL v3.0 license agreement.

![Initialize build version 2022-03-31_12 27 13](https://user-images.githubusercontent.com/33841634/161134786-7ea1422b-55c4-4f49-a427-3e261ded259d.png)

## Features

- Read git information (only if git repository is detected)
- Branch, tag, hash, date, etc.
- Git initialization values remain unmodified if no repository is detected
- Read project information
- Configuration, build, date, etc.
- Update local and/or global variable initialization
- `BuildVersion` variable in the BuildVer program is automatically initialized
- The first variable of type `BuildVersionType` in Global.var is automatically initialized
- Use with and without git
- Git version information will only be updated if a git repository is detected
- PowerShell script will not error the Automation Studio build
- A pre-build event is required to run the PowerShell script
- Capture git repository information and Automation Studio project information
- Initialize local variable
- **Variables.var** in **BuildVer** task located anywhere in **Logical** folder
- Initialize global variable
- First variable of **BuildVersionType** in **Global.var** located anywhere in **Logical** folder
- mappView widget integration
- See [BuildVersion Widget Library](https://github.com/br-na-pm/BuildVersionWidget#readme)

Expand All @@ -26,21 +26,22 @@ The information captured is automatically initialized to a local and/or global v
#### 1. Add Package to Project

- [Download](https://github.com/br-na-pm/BuildVersion/releases/latest/download/BuildVersion.zip) and extract the BuildVersion package
- Select Existing Package from the Automation Studio toolbox to import BuildVersion into logical view
- Logical View -> select project folder -> Toolbox -> Existing Package -> import BuildVersion

![Step 1 2022-04-10_13-37-35](https://user-images.githubusercontent.com/33841634/162637472-ddf53ad9-52b9-4f34-935c-5416d5bc9a55.gif)

#### 2. Create Pre-Build Event

- Under the active configuration, right-click the CPU object and select properties
- Find the build events tab and populate the pre-build field with the following prompt
- The pre-build event must be set for each configuration seeking version information
- Physical View -> active configuration -> right-click CPU object -> Properties
- Build Events -> Configuration Pre-Build Event -> Insert the following call

```powershell
PowerShell -ExecutionPolicy ByPass -File $(WIN32_AS_PROJECT_PATH)\Logical\BuildVersion\BuildVersion.ps1 $(WIN32_AS_PROJECT_PATH) "$(AS_VERSION)" "$(AS_USER_NAME)" "$(AS_PROJECT_NAME)" "$(AS_CONFIGURATION)" "$(AS_BUILD_MODE)"
```

**NOTE**: The first variable argument after the file path, `$(WIN32_AS_PROJECT_PATH)`, is without quotes because it will resolve with quotes. *For paths with spaces* (e.g. "C:\My Projects\WireBender") this call will fail when expicitely including quotes on the `$(WIN32_AS_PROJECT_PATH)` argument.
The first argument `$(WIN32_AS_PROJECT_PATH)` omits surrounding quotes because it will resolve with quotes. If extra quotes are added to this argument, project paths with spaces will fail to be read ("C:\My Projects\CoffeeMachine").

The Pre-Build Step will have to be set for all desired configurations.

![Step 2 2022-04-10_13-49-32](https://user-images.githubusercontent.com/33841634/162637534-a7b174c9-fff3-4a81-9096-b1335f0e7f23.gif)

Expand Down

0 comments on commit ef3c4ee

Please sign in to comment.