From 6f3dab0a0949128ecd58a14cd7fef7ce45d6d135 Mon Sep 17 00:00:00 2001 From: Huidae Cho Date: Sat, 20 Sep 2025 14:25:57 -0600 Subject: [PATCH] CMake: Create grass.bat and add scripts to PATH --- lib/init/CMakeLists.txt | 13 +++++++++++-- python/grass/app/runtime.py | 10 +++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/init/CMakeLists.txt b/lib/init/CMakeLists.txt index 6155848d1e9..180543827dc 100644 --- a/lib/init/CMakeLists.txt +++ b/lib/init/CMakeLists.txt @@ -13,7 +13,7 @@ endif() # START_UP is the variable used in grass.py, grass.sh.in and grass.bat.in set(START_UP ${PROJECT_NAME_LOWER}) if(WIN32) - set(START_UP "${START_UP}.py") + set(START_UP "${START_UP}${GRASS_VERSION_NUMBER}.py") set(script_file_name "grass.bat") set(script_input_file_name ${script_file_name}.in) else() @@ -36,7 +36,11 @@ list(APPEND DLL_PATH_LIST ${DEPS_DLL_PATH}) # configure and install grass.py set(GRASS_PYDIR ${GRASS_INSTALL_PYDIR_RUNTIME_PATH}) -configure_file(grass.py ${OUTDIR}/${CMAKE_INSTALL_BINDIR}/${START_UP} @ONLY) +if(WIN32) + configure_file(grass.py ${OUTDIR}/${GRASS_INSTALL_ETCDIR}/${START_UP} @ONLY) +else() + configure_file(grass.py ${OUTDIR}/${CMAKE_INSTALL_BINDIR}/${START_UP} @ONLY) +endif() set(GRASS_PYDIR ${GRASS_INSTALL_PYDIR_PATH}) configure_file(grass.py ${CMAKE_CURRENT_BINARY_DIR}/${START_UP} @ONLY) @@ -47,6 +51,11 @@ install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${START_UP} file(TO_NATIVE_PATH "${OUTDIR}/${GISBASE_DIR}" gisbase_init_dir) +if(WIN32) + set(GRASS_PYTHON ${PYTHON_EXECUTABLE}) + configure_file(${script_input_file_name} ${OUTDIR}/${CMAKE_INSTALL_BINDIR}/${script_file_name} @ONLY) +endif() + file(TO_NATIVE_PATH ${OUTDIR}/${GRASS_INSTALL_BINDIR} grass_dll_dir) set(DLL_PATH_LIST) list(APPEND DLL_PATH_LIST ${grass_dll_dir}) diff --git a/python/grass/app/runtime.py b/python/grass/app/runtime.py index a1df09659ed..b225aabafff 100644 --- a/python/grass/app/runtime.py +++ b/python/grass/app/runtime.py @@ -131,11 +131,11 @@ def append_left_main_executable_paths(paths, install_path): path = os.path.join(install_path, "extrabin") if os.path.exists(path): paths.appendleft(path) - else: - # Without FHS, scripts are separated like in the source code. - path = os.path.join(install_path, "scripts") - if os.path.exists(path): - paths.appendleft(path) + + # Without FHS, scripts are separated like in the source code. + path = os.path.join(install_path, "scripts") + if os.path.exists(path): + paths.appendleft(path) def append_left_addon_paths(paths, config_dir, env):