-
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
bindirectory. - Ensures the presence of matching file types and names between
x64andx86subfolders. - Verifies DLL naming conventions.
- Compresses the validated
binfolder into a ZIP archive in thedist/rawBinaryZippeddirectory. - Creates a SHA256 checksum file for the ZIP archive.
- PowerShell 5.1 or higher (for
Compress-ArchiveandGet-FileHashcmdlets). - The script should be run from a directory such that
../pyCTools/binrefers to your binary folder, or you can input a custom path when prompted. - The script expects that
compilerHelper.ps1has been executed previously to create the bin directory. - Write permission to create a
dist/rawBinaryZippedfolder 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$debugis$true.
-
Set-Location ..Moves the current working directory one level up.
- Attempts to find a
binfolder within thepyCToolsdirectory. - If not found, prompts the user to enter a full path to the
binfolder, asking if they have executedcompilerHelper.ps1. - Exits with error if the path is invalid or missing.
-
Checks for two mandatory subdirectories inside
bin:x64x86
-
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
x64andx86. - 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
_x64or_x86for 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 (
x64orx86) 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/rawBinaryZippeddirectory 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
binintodist/rawBinaryZipped/bin.zipusingCompress-Archive. - Outputs success or failure message accordingly.
-
Defines function
SHA256Filewhich:-
Computes SHA256 hash of the given file.
-
Creates a
.sha256file 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.ps1to create thebinfolder structured as follows:bin/ ├─ x64/ │ ├─ *.dll, *.exp, *.lib, *.obj files └─ x86/ ├─ *.dll, *.exp, *.lib, *.obj files -
The DLL filenames must include
_x64or_x86suffix corresponding to their folder. -
Run the script from a directory such that moving one directory up (
..) leads to the location containing thepyCTools/binfolder. -
If no
binfolder 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
binintodist/rawBinaryZipped/bin.zipand 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.ps1script. - 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 = $trueat 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