Download
(2 Kb)
Download
Updated: 09/23/17 02:38 AM
Pictures
File Info
Compatibility:
Clockwork City (3.2)
Horns of the Reach (3.1)
Updated:09/23/17 02:38 AM
Created:08/15/15 07:28 AM
Monthly downloads:44
Total downloads:5,820
Favorites:9
MD5:
Categories:ESO Tools & Utilities, Developer Utilities
ESO Addon Validation - fighting global namespace pollution  Popular! (More than 5000 hits)
Version: 1.2.9
by: votan [More]
This is NOT an addon
This is for addon developers
Description
This is a powershell script to check addon source for syntax errors and search for leaking global symbols. (Including a simple XML scan)
All credits for the idea go to @merlight. This is a portation* to Windows. *Perl is not mine and I don't want to install ActivePerl "just for that".

The main objective is finding variables going to global namespace unintended. This can cause strange side-effects and crashes. Hard to find, because one has to track down who conflicts with whom, first.
Global variables are slower than local variables. Finding unintended global variables may mean finding unexpected slow-downs, too. And finally: It happens really easy, even if you know about it and take care.

A secondary objective is a validation of the manifest file, the XML- and Lua files including localization files.
The script supports the subtitutes $(language) and $(APIVersion) and shows you wrong paths, normally silently ignored by ESO: You may think you have included a library and checked it more than once, until you realized that you have typed "lib" and not "libs".
By probing languages you normally do not select, the compiler will find missing quotes or commas for you.
All happend in addons already.

Setup
Before you can use the powershell script you need to download a Lua compiler for Windows. e.g. from here: http://sourceforge.net/projects/luab...20Executables/
Select your CPU architecture (most likely x64 = lua-5.1.5_Win64_bin.zip). The CPU architecture of the ESO client does not matter, we want to check the addon source only.

Copy the luac5.1.exe to the location of the script. All you need is this executable. Optional the VC++ 2005 Redistributables (also included in the luabinaries zip)
At the end your folder should look like this:
Code:
Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---        15.08.2015     14:02       6889 ESOGlobals.ps1
-a---        15.08.2015     14:02     229376 luac5.1.exe
If you use powershell scripts for the first time on your machine, you probably have to change the execution policy (as admin):
Run powershell with admin rights and type*: (*Hint: Powershell has auto-complete with TAB-Key.)
Code:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
If the .NET security still resists to execute the script, you have to change it to unrestricted:
Code:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
Windows 10 users reported that, but I would try RemoveSigned first.

Script Usage
Code:
.\ESOGlobals.ps1 -Path "Z:\liveeu\AddOns\LibAddonMenu-2.0" -ParseXml -OmitReferences
-Path: Required: Path to "AddOns" folder or single addon. (Don't forget to quote the path, if it includes whitespaces. It normally does.)
-ParseXML: Optional: Parse XML, too. Default: Off
-OmitReferences: Optional: Show declaration of globals, only. Default: Off
-Compiler: Optional: Relative or absolute path to the luac executable of your choise.

Output
The script prints hints, warnings and compile errors (hopefully not ) and lines like this:
Code:
LibAddonMenu-2.0/LibAddonMenu-2.0.lua
+       30 LAMCompatibilityWarning
+      216 LAMCreateControl
+      802 LAMAddonSettingsFragment
?        8 LibStub
...
+ = new global
? = using global
Followed by line number and symbol name. The line number is the last line of declaration, which is most times the first line, too. But for tables you may need to follow the lines up.
Not all these declarations (new globals) are basically wrong, but you will recognize unintended globals, because they don't look like they should be globals: short, not really unique name, starting lowercase, no prefix or suffix which has something to do with the addon, etc.

Using a global may means using an undefined (nil) value. It could be an overseen typo, e.g. itemlink instead of itemLink.

To Do
- None
version 1.2.9:
- probe APIVersion 100020 and 100021

version 1.2.8:
- probe APIVersion 100019 and 100020 (for next time)

version 1.2.7:
- probe APIVersion 100017 and 100018

version 1.2.6:
- probe APIVersion 100016 and 100017

version 1.2.5:
- Allow Lua compiler without version in its name.
- Added optional parameter -Compiler to specify the path to the Lua compiler, if in another location.

version 1.2.4:
- probe APIVersion 100015 and 100016
- added language jp

version 1.2.3:
- probe APIVersion 100014 and 100015

version 1.2.2:
- Probing APIVersion 100013 and 100014
- Language add: zh

version 1.2.1:
- Probing APIVersion 100013

version 1.2.0:
- Added language br
- Parse XML: Generate different code for GUI-XML and Key-Binding-XML. Add line numbers to generated source output.

- renamed the title for better description of what this script actually does.

version 1.1.0:
- Support substitute $(APIVersion)

version 1.0.0
- initial version
Optional Files (0)


Archived Files (11)
File Name
Version
Size
Uploader
Date
1.2.8
2kB
votan
05/27/17 08:30 AM
1.2.7
2kB
votan
01/26/17 12:54 PM
1.2.6
2kB
votan
09/11/16 12:20 PM
1.2.5
2kB
votan
06/29/16 10:56 AM
1.2.4
2kB
votan
06/27/16 02:58 PM
1.2.3
2kB
votan
05/02/16 11:25 AM
1.2.2
2kB
votan
02/13/16 02:56 AM
1.2.1
2kB
votan
11/06/15 12:23 AM
1.2.0
2kB
votan
09/19/15 03:40 AM
1.1.0
2kB
votan
08/18/15 11:08 PM
1.0.0
2kB
votan
08/15/15 07:28 AM


Post A Reply Comment Options
Unread 01/27/17, 05:11 PM  
Elephant
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 65
Uploads: 1
Originally Posted by votan
Which version of Powershell?
Use the -Compiler parameter to explicitly specify the path to the compiler:
In your case:
-Compiler C:\util\lua\luac5.1.exe
Was running PS v2, installing management framework 4 updated PS to v4 and fixed the problems.

Thanks.
Report comment to moderator  
Reply With Quote
Unread 01/27/17, 12:08 AM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 577
File comments: 1667
Uploads: 40
Which version of Powershell?
Use the -Compiler parameter to explicitly specify the path to the compiler:
In your case:
-Compiler C:\util\lua\luac5.1.exe
Report comment to moderator  
Reply With Quote
Unread 01/26/17, 05:32 PM  
Elephant
AddOn Author - Click to view AddOns

Forum posts: 0
File comments: 65
Uploads: 1
Code:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>powershell
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Windows\system32> Set-ExecutionPolicy -ExecutionPolicy Unrestricted
PS C:\Windows\system32> c:
PS C:\Windows\system32> cd \util\lua
PS C:\util\lua> dir


    Directory: C:\util\lua


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----        27/01/2017   8:27 AM            Microsoft.VC80.CRT
-a---         6/05/2014   5:54 AM      81408 bin2c5.1.exe
-a---        26/01/2017   3:45 AM       6889 ESOGlobals.ps1
-a---         6/05/2014   5:47 AM     314880 lua5.1.dll
-a---         6/05/2014   5:47 AM        384 lua5.1.dll.manifest
-a---         6/05/2014   5:54 AM      17920 lua5.1.exe
-a---         6/05/2014   5:54 AM        384 lua5.1.exe.manifest
-a---         6/05/2014   5:57 AM      11264 lua51.dll
-a---         6/05/2014   5:57 AM        145 lua51.dll.manifest
-a---         6/05/2014   5:54 AM     229376 luac5.1.exe
-a---         6/05/2014   5:54 AM      18432 wlua5.1.exe
-a---        26/03/2009   6:38 AM        929 wlua5.1.exe.manifest


PS C:\util\lua> .\ESOGlobals.ps1 -Path "C:\Users\Steve\Documents\Elder Scrolls Online\live\AddOns" -ParseXml -OmitReferences
Get-Item : Cannot bind argument to parameter 'Path' because it is null.
At C:\util\lua\ESOGlobals.ps1:10 char:27
+     $root = Get-Item -Path <<<<  $PSScriptRoot
    + CategoryInfo          : InvalidData: (:) [Get-Item], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetItemCommand

You cannot call a method on a null-valued expression.
At C:\util\lua\ESOGlobals.ps1:11 char:27
+     $luac = $root.GetFiles <<<< ("luac*.exe")
    + CategoryInfo          : InvalidOperation: (GetFiles:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Lua compiler not found in
PS C:\util\lua>
Report comment to moderator  
Reply With Quote
Unread 06/29/16, 11:11 AM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 577
File comments: 1667
Uploads: 40
Ok. New version is out.
I updated the addon-info. So, the description will hopefully help Windows 10 users
Report comment to moderator  
Reply With Quote
Unread 06/29/16, 09:31 AM  
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view AddOns

Forum posts: 1019
File comments: 1531
Uploads: 31
Originally Posted by votan
Originally Posted by Ayantir
Originally Posted by votan
Ok. I add a lua compiler not found check and change the search pattern.

"RemoteSigned" means scripts from network drives must be signed. I assume my script is from local harddisk. Maybe have to do with OneDrive?
Script is on my local hard disk
Is your "MyDocument" just a soft-link to OneDrive? Like a lot Minion users have trouble with?
If not, win10 may increased security restriction. I'm on win8.1Pro.
I will update the addon-info text.
No, it's my local ssd (and I'm on Win10 pro).
Last edited by Ayantir : 06/29/16 at 09:34 AM.
Report comment to moderator  
Reply With Quote
Unread 06/29/16, 09:27 AM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 577
File comments: 1667
Uploads: 40
Originally Posted by Ayantir
Originally Posted by votan
Ok. I add a lua compiler not found check and change the search pattern.

"RemoteSigned" means scripts from network drives must be signed. I assume my script is from local harddisk. Maybe have to do with OneDrive?
Script is on my local hard disk
Is your "MyDocument" just a soft-link to OneDrive? Like a lot Minion users have trouble with?
If not, win10 may increased security restriction. I'm on win8.1Pro.
I will update the addon-info text.
Report comment to moderator  
Reply With Quote
Unread 06/29/16, 09:14 AM  
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view AddOns

Forum posts: 1019
File comments: 1531
Uploads: 31
Originally Posted by votan
Ok. I add a lua compiler not found check and change the search pattern.

"RemoteSigned" means scripts from network drives must be signed. I assume my script is from local harddisk. Maybe have to do with OneDrive?
Script is on my local hard disk
Report comment to moderator  
Reply With Quote
Unread 06/29/16, 09:04 AM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 577
File comments: 1667
Uploads: 40
Originally Posted by Ayantir
Hey votan, same error here.

My Lua compiler works fine (declared and accessible throught system variables).
but the script don't work. I'm on W10.

../Libs/LibStub/LibStub/LibStub.lua
L’expression située après «*&*» dans un élément de pipeline a généré un objet non valide. Elle doit générer un nom de commande, un bloc de script ou un objet CommandInfo.
Au caractère C:\Users\Loup\Documents\Elder Scrolls Online\dev\ESOGlobals\ESOGlobals.ps1:46 : 11
+ $o = &$luac $args 2>&1
+ ~~~~~
+ CategoryInfo : InvalidOperation : ( [], RuntimeException
+ FullyQualifiedErrorId : BadExpression


The error come from the line 8:
You have :
Lua Code:
  1. $luac = $root.GetFiles("luac5.1.*exe").FullName
It should be :
Lua Code:
  1. $luac = $root.GetFiles("luac*.exe").FullName


That is because I use the Lua machine from LuaForWindows which include several libraries compiled for Windows, very useful.



PS :

Lua Code:
  1. Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

is not enought. Your script is not signed. It should be :

Lua Code:
  1. Set-ExecutionPolicy -ExecutionPolicy Unrestricted
Ok. I add a lua compiler not found check and change the search pattern.

"RemoteSigned" means scripts from network drives must be signed. I assume my script is from local harddisk. Maybe have to do with OneDrive?
Last edited by votan : 06/29/16 at 09:07 AM.
Report comment to moderator  
Reply With Quote
Unread 06/29/16, 08:17 AM  
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view AddOns

Forum posts: 1019
File comments: 1531
Uploads: 31
Hey votan, same error here.

My Lua compiler works fine (declared and accessible throught system variables).
but the script don't work. I'm on W10.

../Libs/LibStub/LibStub/LibStub.lua
L’expression située après «*&*» dans un élément de pipeline a généré un objet non valide. Elle doit générer un nom de commande, un bloc de script ou un objet CommandInfo.
Au caractère C:\Users\Loup\Documents\Elder Scrolls Online\dev\ESOGlobals\ESOGlobals.ps1:46 : 11
+ $o = &$luac $args 2>&1
+ ~~~~~
+ CategoryInfo : InvalidOperation : ( [], RuntimeException
+ FullyQualifiedErrorId : BadExpression


The error come from the line 8:
You have :
Lua Code:
  1. $luac = $root.GetFiles("luac5.1.*exe").FullName
It should be :
Lua Code:
  1. $luac = $root.GetFiles("luac*.exe").FullName


That is because I use the Lua machine from LuaForWindows which include several libraries compiled for Windows, very useful.



PS :

Lua Code:
  1. Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

is not enought. Your script is not signed. It should be :

Lua Code:
  1. Set-ExecutionPolicy -ExecutionPolicy Unrestricted
Report comment to moderator  
Reply With Quote
Unread 03/21/16, 04:53 PM  
Solinur
AddOn Author - Click to view AddOns

Forum posts: 78
File comments: 706
Uploads: 8
Re: Re: Errors

Originally Posted by votan
Originally Posted by decay2
I'm probably doing something wrong, I get a lot of lines like this:

Code:
lib/LibStub/LibStub.lua
The expression after '&' in a pipeline element produced an invalid object. It must result in a command name, script blo
ck or CommandInfo object.
At C:\ESOGlobals\ESOGlobals.ps1:46 char:11
+     $o = & <<<< $luac $args 2>&1
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : BadExpression
It seems that the lua compiler is missing or not working:
Do you have downloaded the lua compiler and copied to the location as written in the description?
Which CPU architecture (x64, x86) and is the matching VC++ 2005 redist installed?
In the meantime I reinstalled my PC for Win10 (Was Win7 x64 before) and now it works flawless.
I tested quickly without the lua file and it gave the exact same error messages.
I had the luac5.1.exe in the folder, but didn't check if I had the VC++ 2005 redist installed (I also didn't this time).
Maybe the problem also was, that after the script ran trough, in PowerShell the folder had changed to the target addon folder, so maybe it was looking for the lua file there? In Win 10 this has now changed and it remains in the ESOGlobals folder.
Sorry for your troubles , and thanks for this Tool
Last edited by Solinur : 03/21/16 at 04:58 PM.
Report comment to moderator  
Reply With Quote
Unread 03/20/16, 03:10 AM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 577
File comments: 1667
Uploads: 40
Re: Errors

Originally Posted by decay2
I'm probably doing something wrong, I get a lot of lines like this:

Code:
lib/LibStub/LibStub.lua
The expression after '&' in a pipeline element produced an invalid object. It must result in a command name, script blo
ck or CommandInfo object.
At C:\ESOGlobals\ESOGlobals.ps1:46 char:11
+     $o = & <<<< $luac $args 2>&1
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : BadExpression
It seems that the lua compiler is missing or not working:
Do you have downloaded the lua compiler and copied to the location as written in the description?
Which CPU architecture (x64, x86) and is the matching VC++ 2005 redist installed?
Report comment to moderator  
Reply With Quote
Unread 03/19/16, 05:32 PM  
Solinur
AddOn Author - Click to view AddOns

Forum posts: 78
File comments: 706
Uploads: 8
Errors

I'm probably doing something wrong, I get a lot of lines like this:

Code:
lib/LibStub/LibStub.lua
The expression after '&' in a pipeline element produced an invalid object. It must result in a command name, script blo
ck or CommandInfo object.
At C:\ESOGlobals\ESOGlobals.ps1:46 char:11
+     $o = & <<<< $luac $args 2>&1
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : BadExpression
Report comment to moderator  
Reply With Quote
Unread 11/06/15, 12:27 AM  
votan
 
votan's Avatar
AddOn Author - Click to view AddOns

Forum posts: 577
File comments: 1667
Uploads: 40
Re: Awesome

Originally Posted by antihax
Just ran this over my addon and cleaned up a few loose ends I didn't notice.
Awesome work!
Thank You.
Report comment to moderator  
Reply With Quote
Unread 11/05/15, 10:21 PM  
antihax
AddOn Author - Click to view AddOns

Forum posts: 23
File comments: 17
Uploads: 4
Awesome

Just ran this over my addon and cleaned up a few loose ends I didn't notice.
Awesome work!
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: