slynch8 / 10x

10x IDE/Editor
190 stars 34 forks source link

Custom Build Commands under Visual Studio Solutions #1560

Open Sharlock93 opened 1 year ago

Sharlock93 commented 1 year ago

Currently Custom Build Commands are only available under workspaces, would be awesome if we could have these:

1) Script API to interface with the build system. i.e: I want to write a python script that can set the current working dir or check the current opened solutions working dir and run commands from that location, printing strings to the build output etc.

2) Setting a custom batch file as the current command to run when building.

Motivation: At work while we use visual studio as the editor we have specific extensions that intercept the build process and run commands. These commands are not stored in the solution files.

slynch8 commented 1 year ago

you can override the build using the python API:

# Add a function to be called when the project is about to be
# built : AddProjectBuildFunction(function) : bool function(filename)
# - return True to cancel build

def MyBuildFunction():
    print("building")
    return True

N10X.Editor.AddProjectBuildFunction(MyBuildFunction)

https://10xeditor.com/10xDocumentation/PythonFunctions.htm

Sharlock93 commented 1 year ago

https://10xeditor.com/10xDocumentation/PythonFunctions.htm

I tried this, for some reason its not working, the function never gets called.

slynch8 commented 1 year ago

did you put your python script in %appdata%\10x\PythonScripts?

Sharlock93 commented 1 year ago

I did indeed, screenshot. I build the project via right click -> build on the project. image

Sharlock93 commented 1 year ago

I investigated this further, the provided solution works, however only if you build via F7 or (Build Active Workspace), it doesn't work if you right click -> build projects