build: Use separate cmd to build DataStreamSuite/QueryAnalyzer.sln

The DataStreamSuite.sln builds the new webapp now, which will
(eventually) replace DSQA. We'll keep it around for now, but with a
clean separation from the main build.
This commit is contained in:
John Colvin committed 2024-10-21 13:29:57 +00:00
1 parent add3aa8bd3
commit a0029ed4c6
5 files changed
+204 -16

No files matched your search

+2 -2
View File
@@ -77,7 +77,7 @@
"name": "DataStreamQueryAnalyzer",
"type": "coreclr",
"request": "launch",
//"preLaunchTask": "Build DataStreamQueryAnalyzer (Debug)",
"preLaunchTask": "Build DataStreamQueryAnalyzer (Debug)",
"program": "",
"windows": {
"program": "DataStreamQueryAnalyzer.exe",
@@ -194,4 +194,4 @@
"default": "http://localhost:8000/config",
},
]
}
}
+54 -3
View File
@@ -121,6 +121,57 @@
"color": "terminal.ansiCyan"
},
},
{
"label": "Build DataStreamQueryAnalyzer",
"group": "build",
"type": "process",
"command": "",
"windows": {
"command": "tools/build_data_stream_query_analyzer.cmd",
},
"args": [
"--configuration",
"${input:buildConfiguration}",
],
"icon": {
"id": "terminal",
"color": "terminal.ansiCyan"
},
},
{
"label": "Build DataStreamQueryAnalyzer (Debug)",
"group": "build",
"type": "process",
"command": "",
"windows": {
"command": "tools/build_data_stream_query_analyzer.cmd",
},
"args": [
"--configuration",
"Debug",
],
"icon": {
"id": "terminal",
"color": "terminal.ansiCyan"
},
},
{
"label": "Build DataStreamQueryAnalyzer (Release)",
"group": "build",
"type": "process",
"command": "",
"windows": {
"command": "tools/build_data_stream_query_analyzer.cmd",
},
"args": [
"--configuration",
"Release",
],
"icon": {
"id": "terminal",
"color": "terminal.ansiCyan"
},
},
{
"label": "Build DataStream WebApp",
"group": "build",
@@ -409,7 +460,7 @@
},
{
"label": "Run DataStreamQueryAnalyzer",
"dependsOn": "Build DataStream",
"dependsOn": "Build DataStreamQueryAnalyzer",
"type": "process",
"command": "",
"windows": {
@@ -429,7 +480,7 @@
},
{
"label": "Run DataStreamQueryAnalyzer (Debug)",
"dependsOn": "Build DataStream (Debug)",
"dependsOn": "Build DataStreamQueryAnalyzer (Debug)",
"type": "process",
"command": "",
"windows": {
@@ -449,7 +500,7 @@
},
{
"label": "Run DataStreamQueryAnalyzer (Release)",
"dependsOn": "Build DataStream (Release)",
"dependsOn": "Build DataStreamQueryAnalyzer (Release)",
"type": "process",
"command": "",
"windows": {
@@ -0,0 +1,29 @@
@echo off
setlocal
set VS_DEV_CMD_BAT="C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\Tools\\VsDevCmd.bat"
if exist %VS_DEV_CMD_BAT% (
call %VS_DEV_CMD_BAT%
)
set NODEVARS_BAT="C:\\Program Files\\nodejs\\nodevars.bat"
if exist %NODEVARS_BAT% (
call %NODEVARS_BAT%
)
set TOOLS_DIR=%~dp0
set REPO_DIR=%~dp0..
set BUILD_PY=%TOOLS_DIR%\py\build_data_stream_query_analyzer.py
if DEFINED VIRTUAL_ENV (
@REM We're already in a venv, just run build_data_stream_query_analyzer.py (whether or not it is
@REM the 'right' venv is the caller's responsibility)
echo "Building in the current venv '%VIRTUAL_ENV'"
@call python %BUILD_PY% %*
) else (
@REM Ensure the (default) venv is created, then run build_data_stream_query_analyzer.py in it
@call %TOOLS_DIR%\ensure_venv.cmd
@call %TOOLS_DIR%\venv_exec.cmd python %BUILD_PY% %*
)
EXIT /B %ERRORLEVEL%
+1 -11
View File
@@ -80,16 +80,6 @@ def _cmake_build_preset(configuration):
raise ValueError(f'Unsupported platform {sys.platform}')
def _dotnet_sln_name():
match sys.platform:
case 'win32':
return 'DataStreamQueryAnalyzer'
case 'linux':
return 'DataStreamSuite'
case _:
raise ValueError(f'Unsupported platform {sys.platform}')
def _main():
parser = _get_arg_parser()
args = parser.parse_args()
@@ -104,7 +94,7 @@ def _main():
sln = SparkPaths.root().joinpath(
'src',
'DataStreamSuite',
f'{_dotnet_sln_name()}.sln',
'DataStreamSuite.sln',
)
return ' '.join([
f'dotnet {action} {sln}',
@@ -0,0 +1,118 @@
import argparse
import os
import subprocess
import sys
from core.file_utils import SparkPaths
from core.iter_utils import at_bounded
def _get_arg_parser():
parser = argparse.ArgumentParser(description="Build DataStreamQueryAnalyzer.sln")
parser.add_argument(
"--configuration",
metavar="debug|release",
help="The build configuration",
)
parser.add_argument(
"--clean",
action="store_true",
help="Perform a clean build (remove artifacts from previous build)",
)
parser.add_argument(
"--verbosity",
metavar="{0-5}",
choices=range(0, 6),
type=int,
help="The output verbosity level",
)
parser.add_argument(
"--dry-run",
action="store_true",
help="Preview the build commands without running them",
)
parser.set_defaults(
configuration="debug",
clean=False,
verbosity=1,
)
return parser
def _dotnet_verbosity(level):
names = ["quiet", "minimal", "normal", "detailed", "diagnostic"]
return at_bounded(names, level)
def _cmake_verbosity(level):
# Skip 'WARNING' and 'NOTICE' levels, since the default CMake verbosity,
# 'STATUS', doesn't produce that much output. This also better normalizes
# numeric representation of verbosity w/ dotnet, which only has 5 levels.
names = [
"ERROR",
# 'WARNING',
# 'NOTICE',
"STATUS",
"VERBOSE",
"DEBUG",
"TRACE",
]
return at_bounded(names, level)
def _cmake_preset():
match sys.platform:
case "win32":
return "data-stream-suite-windows"
case "linux":
return "data-stream-suite-linux"
case _:
raise ValueError(f"Unsupported platform {sys.platform}")
def _cmake_build_preset(configuration):
match sys.platform:
case "win32":
return f"data-stream-suite-windows-{configuration}"
case "linux":
return f"data-stream-suite-linux-{configuration}"
case _:
raise ValueError(f"Unsupported platform {sys.platform}")
def _main():
parser = _get_arg_parser()
args = parser.parse_args()
def run(cmd):
print(cmd)
if args.dry_run:
return
subprocess.run(cmd, shell=True).check_returncode()
def dotnet_cmd(action):
sln = SparkPaths.root().joinpath(
"src", "DataStreamSuite", "DataStreamQueryAnalyzer.sln"
)
cfg = args.configuration.title()
verbosity = _dotnet_verbosity(args.verbosity)
return f"dotnet {action} {sln} --configuration {cfg} --verbosity {verbosity}"
os.chdir(SparkPaths.root())
cmake_configure_cmd = f"cmake --preset {_cmake_preset()} -DCMAKE_MESSAGE_LOG_LEVEL={_cmake_verbosity(args.verbosity)}"
cmake_build_cmd = (
f"cmake --build --preset {_cmake_build_preset(args.configuration.lower())}"
)
if args.clean:
run(f"{cmake_build_cmd} --target clean")
run(dotnet_cmd("clean"))
run(cmake_configure_cmd)
run(cmake_build_cmd)
run(dotnet_cmd("build"))
if __name__ == "__main__":
try:
_main()
except Exception as e:
print(f"build_data_stream_query_analyzer.py failed: {e}")