Code Monkey home page Code Monkey logo

blenderaddondeployutils's Introduction

Utils for deploying Blender addons

Useful utils for deploying blender addons

BlenderAddonAutoIncrement.exe

Utility for auto-incrementing Blender addon version

Command line arguments:

  • -path - path to __init__.py in the root of addon folder
  • -index - version (0,0,0) index to increment: 0 or 1 or 2 etc. Default: last index
  • -encoding - file encoding (UTF-8, SYSTEM). Default: UTF-8

Examples:

__init__.py

bl_info = {
    "name": "My Script",    
    "version": (1, 0, 0)
}

1. Default (Increment last version index)

  • Command:
BlenderAddonAutoIncrement.exe -path Path\To\__init__.py
  • Result:
bl_info = {
    "name": "My Script",    
    "version": (1, 0, 1)
}

2. Increment major version number

  • Command:
BlenderAddonAutoIncrement.exe -path Path\To\__init__.py -index 0
  • Result:
bl_info = {
    "name": "My Script",    
    "version": (2, 0, 0)
}

BlenderAddonZip.exe

Utility for deploying addon source as a valid Blender addon zip package

Program Actions:

  • Copies addon src folder to temporary directory, ignoring python cache files etc.

WARNING!!! Copy algorithm is based on robocopy mirror folder command. Be sure that you've filled target directory correctly!

  • Packs temporary addon folder as Blender addon zip package
  • Gives version number name prefix

Command line arguments:

  • -addonDir - path to addon directory
  • -addonName - addon name. Default: name of 'addonDir'
  • -tempDir - temporary directory for creating zip content. Default: User Temp Dir
  • -targetZipDir - path to output zip dir
  • -targetZipName - addon zip literal name or variable: AUTO_GENERATE (Default)
  • -copyParams - params for using in robocopy. Default: /MIR /XD .git .svn __pycache* /XF *.log *.md /R:3 /W:3
  • -onBeforeZipCMD - path to batch script that will be executed before packing temp folder into zip file

Examples:

1. Default (use addon version in naming and addon folder name matches addon name)

  • Command:
BlenderAddonZip.exe -addonDir C:\blender\blender-addons\magic_uv -targetZipDir c:\addons\build
  • Result:

c:\addons\build\magic_uv_6_5_0.zip

2. Zip from another folder

  • Command:
BlenderAddonZip.exe -addonDir C:\GitHub\MyAddon\Src -addonName MyAddon -targetZipDir C:\GitHub\MyAddon\Build
  • Result:

C:\GitHub\MyAddon\Build\MyAddon_1_0_0.zip

3. Exclude custom files and folders

WARNING! Check target folder because it is based on robocopy mirror function

  • Command:
BlenderAddonZip.exe -addonDir C:\GitHub\MyAddon\Src -copyParams "/MIR /XD .git .svn __pycache* ico /XF *.log *.md *.dll /R:3 /W:3" -targetZipDir C:\GitHub\MyAddon\Build
  • Result: Folders: .git, .svn, __pycache*, ico and files *.log, *.md, *.dll are excluded

C:\GitHub\MyAddon\Build\MyAddon_1_0_0.zip

4. Change temp folder contents before packing into zip file

Suppose that you want to change file content in temporary folder before it will be packed into zip folder. In this case you may create batch script and pass its path as parameter -onBeforeZipCMD.

  • Command:
BlenderAddonZip.exe -addonDir C:\blender\blender-addons\magic_uv -targetZipDir c:\addons\build -onBeforeZipCMD c:\Scripts\beforeZipCMD.script 
  • Example: c:\Scripts\beforeZipCMD.script

First parameter in batch script is the path to temporary folder!

echo 'Before Zip %1'
set _dir=%~1
powershell -Command "(gc -Path '%_dir%/vlog.py') -replace 'ENABLE_DEBUG = True', 'ENABLE_DEBUG = False' | sc -Path '%_dir%/vlog.py'"

This command will replace text ENABLE_DEBUG = True by ENABLE_DEBUG = False in the file Path\To\AddonTempDir\vlog.py

Configure in VSCode as POST-BUILD task

Expected: after hit build command Shift+Ctrl+B:

  • increment addon version number
  • pack as zip in build folder

Actions:

  • put BlenderAddonAutoIncrement.exe, BlenderAddonZip.exe to any system path location or use full path to them
  • create tasks.json in .vscode folder

image

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Increment Build",
            "command": "BlenderAddonAutoIncrement.exe",
            "args": [
                "-path",
                "${workspaceFolder}/Src/__init__.py"
            ],
            "type": "shell"
        },
        {
            "label": "Deploy Build",
            "command": "BlenderAddonZip.exe",
            "args": [
                "-addonDir",
                "${workspaceFolder}/Src",
                "-addonName",
                "MyAddon",
                "-targetZipDir",
                "${workspaceFolder}/Build"
            ],
            "type": "shell"
        },
        {
            "label": "Build",
            "dependsOrder": "sequence",
            "dependsOn": [
                "Increment Build",
                "Deploy Build"
            ],
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

blenderaddondeployutils's People

Contributors

alexzhornyak avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.