-
Notifications
You must be signed in to change notification settings - Fork 0
Helper Tools ‐ DLL Distribution
This PowerShell script performs the following tasks:
- Validates the folder structure and file consistency inside a
bin
directory. - Ensures the presence of matching file types and names between
x64
andx86
subfolders. - Verifies DLL naming conventions.
- Compresses the validated
bin
folder into a ZIP archive in thedist/rawBinaryZipped
directory. - Creates a SHA256 checksum file for the ZIP archive.
- PowerShell 5.1 or higher (for
Compress-Archive
andGet-FileHash
cmdlets). - The script should be run from a directory such that
../pyCTools/bin
refers to your binary folder, or you can input a custom path when prompted. - The script expects that
compilerHelper.ps1
has been executed previously to create the bin directory. - Write permission to create a
dist/rawBinaryZipped
folder and to write files inside it.
-
$debug
(Boolean): Controls verbose error output. When$true
, detailed error messages are shown.
A helper function to display errors consistently in red. Parameters:
-
$Message
(string): Main error message to display. -
$Details
(string, optional): Additional debug info displayed only if$debug
is$true
.
-
Set-Location ..
Moves the current working directory one level up.
- Attempts to find a
bin
folder within thepyCTools
directory. - If not found, prompts the user to enter a full path to the
bin
folder, asking if they have executedcompilerHelper.ps1
. - Exits with error if the path is invalid or missing.
-
Checks for two mandatory subdirectories inside
bin
:x64
x86
-
If either is missing, the script exits with an error.
- Considers the file extensions:
dll
,exp
,lib
, andobj
. - Retrieves filenames (just names, no paths) for each extension from both
x64
andx86
. - Checks if both subfolders have the same number of files for each extension.
- If counts differ, it outputs an error showing counts for each folder.
- Extracts the base filename (without extension) for each file.
- For DLL files, removes platform suffixes
_x64
or_x86
for fair comparison. - Sorts both sets of base names.
- Checks if the sorted lists match exactly.
- If mismatched, outputs the differing filenames for both folders.
- For each DLL file in both folders, checks if the filename contains the folder name (
x64
orx86
) in any case. - If a DLL file does not contain the folder name, the script throws an error.
- If all validations pass, it outputs:
"bin folder validated successfully."
- Creates a
dist/rawBinaryZipped
directory to store the output files if it doesn't already exist. - Outputs a message confirming the directory was created or noting that it already exists.
- Defines a path for the ZIP file at
dist/rawBinaryZipped/bin.zip
. - Removes any existing ZIP file with the same name.
- Compresses the entire contents of
bin
intodist/rawBinaryZipped/bin.zip
usingCompress-Archive
. - Outputs success or failure message accordingly.
-
Defines function
SHA256File
which:-
Computes SHA256 hash of the given file.
-
Creates a
.sha256
file next to the archive. -
File format:
Algorithm : SHA256 Hash : <computed_hash>
-
-
Generates SHA256 checksum for
bin.zip
. -
Outputs confirmation on success or error message on failure.
- Any uncaught exceptions during the script execution are caught.
- Displays a consistent error message using
Write-CustomError
. - Terminates the script with exit code
1
.
-
Place this script somewhere inside your project directory.
-
Ensure you've run
compilerHelper.ps1
to create thebin
folder structured as follows:bin/ ├─ x64/ │ ├─ *.dll, *.exp, *.lib, *.obj files └─ x86/ ├─ *.dll, *.exp, *.lib, *.obj files
-
The DLL filenames must include
_x64
or_x86
suffix corresponding to their folder. -
Run the script from a directory such that moving one directory up (
..
) leads to the location containing thepyCTools/bin
folder. -
If no
bin
folder is found, the script will ask you to enter its full path. -
The script will validate folder structure, file counts, and naming conventions.
-
On successful validation, it will compress
bin
intodist/rawBinaryZipped/bin.zip
and generate a SHA256 checksum file.
bin folder validated successfully.
Created rawBinaryZipped folder at C:\Path\To\dist\rawBinaryZipped
ZIP archive created at C:\Path\To\dist\rawBinaryZipped\bin.zip
SHA256 file created: C:\Path\To\dist\rawBinaryZipped\bin.zip.sha256
All done.
- The script assumes you have already compiled your binaries using the
compilerHelper.ps1
script. - ZIP compression is handled entirely via PowerShell's native
Compress-Archive
. - The SHA256 format was chosen to be human-readable and simple.
- You can toggle
$debug = $true
at the top to get more detailed error information during development or troubleshooting.
This has been updated for version 0.2.0-beta
(or 0.2.0b0
for python) on 13/08/2025