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