Entry Scripts
Every batch file of the build system runs one Python script from Scripts/Python. These are the entry scripts.
Each one checks its arguments, sets up the environment and then calls the ot_dev package next to it,
which does the actual work.
The lists below show every entry script, which batch file starts it and what it does.
[...] marks optional arguments. Without them, BOTH and REBUILD are used.
Projects
These are started by the four project batches in every project folder.
<PROJECT> is the project key.
Script |
What it does |
|---|---|
|
Configures and builds the project with CMake. Started by |
|
Runs the tests of the project. Started by |
|
Deletes the build output of the project. Started by |
|
Opens the project in an editor. Instead of a key it also takes a full folder path. Started by |
All projects
Started from Scripts/BuildAndTest. The logs and the build summary go to that folder.
Script |
What it does |
|---|---|
|
Builds every project in |
|
Runs the tests of every project that has a |
|
Cleans every project. Started by |
|
Builds only the Rust framework in |
|
Builds only the admin panel in |
Deployment and installers
The deployment scripts run the plans in DeploymentManifest.
Script |
What it does |
|---|---|
|
Replaces the OpenTwin binaries in |
|
Builds |
|
Collects the files of the frontend installer. Started by |
|
Builds everything, then collects the debug files. Started by |
|
Writes the build date and the git revisions to |
|
Builds the NSIS installers ( |
Documentation and build server
Script |
What it does |
|---|---|
|
Builds this documentation ( |
|
The jobs of the build server. |
Other
Script |
What it does |
|---|---|
|
Creates the local certificates in |
|
Stops all running OpenTwin processes. Started by |
|
Small tools, one command each, see below. Mostly started by the batch files in |
The helpers.py commands:
compress-file <file> <archive> pack a file with 7-Zip CompressFile.bat
decompress-file <archive> <folder> unpack a 7-Zip archive DecompressFile.bat
compress-all pack the large ThirdParty files
decompress-all unpack the large ThirdParty files
update-file-headers [ARGS...] run the FileHeaderUpdater UpdateFileHeaders.bat
run-qtcreator Qt Creator with the environment set
cmake-gui-qt / cmake-gui-qt6 cmake-gui with the Qt folders set
run-cmake [ARGS...] cmake-gui with the environment set RunCMakeWithEnvSet.bat
run-devenv [ARGS...] Visual Studio with the environment set RunDevEnv2022WithEnvSet.bat
build-solution <sln> [ARGS...] build a Visual Studio solution
run-python [ARGS...] the ThirdParty Python RunPython.bat
check-failed-builds report failed builds of BuildAll CheckForFailedBuilds.bat, BuildAll.bat
register-scheme register the opentwin:// URL protocol RegisterOpenTwinScheme_py.bat
The start scripts in Scripts/Launcher do not use these entry scripts. They run the ot_launcher package
with the Python of the Deployment, because they also have to work on machines without the repository.
Writing a new script
Before writing a new entry script, check if the job fits as a new helpers.py command.
Each command is one line in the COMMANDS table at the top of helpers.py, which is less work for small tools.
A new entry script needs two files: the Python script in Scripts/Python and a batch file that starts it.
The batch file always looks the same. Keep the OPENTWIN_DEV_ROOT check and the set_python.bat call:
@ECHO OFF
IF "%OPENTWIN_DEV_ROOT%" == "" (
ECHO Please specify the following environment variables: OPENTWIN_DEV_ROOT
PAUSE
EXIT /B 1
)
CALL "%OPENTWIN_DEV_ROOT%\Scripts\Python\set_python.bat"
"%OT_PYTHON%" "%OPENTWIN_DEV_ROOT%\Scripts\Python\my_script.py" %1 %2
IF ERRORLEVEL 1 PAUSE
For the Python side, copy an existing entry script of the same kind and change it. build.py is a good start:
import sys
from pathlib import Path
from typing import Sequence
# Needed: the ThirdParty Python does not add this folder by itself
sys.path.insert(0, str(Path(__file__).resolve().parent))
from ot_dev import build_project, cli
def main(argv: Sequence[str]) -> int:
# Check the arguments, SystemExit prints the text and ends with exit code 1
if not 1 <= len(argv) <= 3:
raise SystemExit("usage: build.py <PROJECT> [DEBUG|RELEASE|BOTH] [BUILD|REBUILD]")
# The environment of SetupEnvironment.py and the folder of the project key
env, target = cli.prepare(argv[0])
configurations = cli.configurations(cli.argument(argv, 1))
rebuild = cli.build_type(cli.argument(argv, 2))
return build_project(env, target, configurations, rebuild)
if __name__ == "__main__":
# Ctrl+C ends the script cleanly instead of with a traceback
sys.exit(cli.run(main, sys.argv[1:]))