From 25379b2c4f5cb26a41febcf2692680ea859ecb66 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sun, 4 Nov 2018 05:02:18 +0100 Subject: [PATCH] radiant: strip .[ExecutableType] entirely (including preceding dot) outside of Windows keep backward compatibility with existing build menus --- CMakeLists.txt | 17 +---------------- radiant/build.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ radiant/map.cpp | 7 ++++++- radiant/qe3.cpp | 4 ++++ 4 files changed, 58 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e4bafca..05c9092c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -215,13 +215,7 @@ endif () if (CMAKE_EXECUTABLE_SUFFIX) string(REGEX REPLACE "^[.]" "" RADIANT_EXECUTABLE ${CMAKE_EXECUTABLE_SUFFIX}) -else () - execute_process( - COMMAND uname -m - OUTPUT_VARIABLE RADIANT_EXECUTABLE - OUTPUT_STRIP_TRAILING_WHITESPACE - ) -endif () +endif() macro(radiant_tool name) add_executable(${name} ${ARGN}) @@ -229,15 +223,6 @@ macro(radiant_tool name) TARGETS ${name} RUNTIME DESTINATION ${RADIANT_BIN_SUBDIR}/. ) - if (NOT (CMAKE_EXECUTABLE_SUFFIX STREQUAL ".${RADIANT_EXECUTABLE}")) - add_custom_command(TARGET ${name} POST_BUILD - COMMAND ln -f -s "$" "${PROJECT_BINARY_DIR}/${name}.${RADIANT_EXECUTABLE}" - VERBATIM - ) - install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink - ${name}${CMAKE_EXECUTABLE_SUFFIX} ${CMAKE_INSTALL_PREFIX}/${RADIANT_BIN_SUBDIR}/${name}.${RADIANT_EXECUTABLE}) - ") - endif () endmacro() if (BUILD_RADIANT) diff --git a/radiant/build.cpp b/radiant/build.cpp index 6462e382..d9d4e404 100644 --- a/radiant/build.cpp +++ b/radiant/build.cpp @@ -76,6 +76,53 @@ void setString( const char* string ){ m_string = string; } void evaluate( StringBuffer& output ){ + #if !(GDEF_OS_WINDOWS) + // strip .[ExecutableType] entirely (including preceding dot) on Mac and Linux + { + StringBuffer output; + StringBuffer variable; + bool found_dot = false; + bool in_variable = false; + for (const char *i = m_string.c_str(); *i != '\0'; ++i) { + if (!found_dot && !in_variable) { + switch (*i) { + case '.': + found_dot = true; + break; + default: + output.push_back(*i); + break; + } + } else if (found_dot && !in_variable) { + switch (*i) { + case '[': + in_variable = true; + break; + default: + found_dot = false; + output.push_back(*i); + break; + } + } else { + switch (*i) { + case ']': + found_dot = false; + in_variable = false; + if ( strncmp("ExecutableType", variable.c_str(), sizeof(variable.c_str())) == 0 ) { + output.push_string(""); + variable.clear(); + } + break; + default: + variable.push_back(*i); + break; + } + } + } + setString(output.c_str()); + } + #endif // !(GDEF_OS_WINDOWS) + StringBuffer variable; bool in_variable = false; for ( const char* i = m_string.c_str(); *i != '\0'; ++i ) diff --git a/radiant/map.cpp b/radiant/map.cpp index 6603279f..7e66831a 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -1580,8 +1580,13 @@ tryDecompile: if ( n && ( extension_equal( path_get_extension( filename ), "bsp" ) || extension_equal( path_get_extension( filename ), "map" ) ) ) { StringBuffer output; output.push_string( AppPath_get() ); - output.push_string( "q3map2." ); + output.push_string( "q3map2" ); + + #if GDEF_OS_WINDOWS + output.push_string( "." ); output.push_string( RADIANT_EXECUTABLE ); + #endif // GDEF_OS_WINDOWS + output.push_string( " -v -game " ); output.push_string( ( type && *type ) ? type : "quake3" ); output.push_string( " -fs_basepath \"" ); diff --git a/radiant/qe3.cpp b/radiant/qe3.cpp index b0737521..230fa154 100644 --- a/radiant/qe3.cpp +++ b/radiant/qe3.cpp @@ -174,7 +174,11 @@ bool ConfirmModified( const char* title ){ void bsp_init(){ build_set_variable( "RadiantPath", AppPath_get() ); + + #if GDEF_OS_WINDOWS build_set_variable( "ExecutableType", RADIANT_EXECUTABLE ); + #endif // GDEF_OS_WINDOWS + build_set_variable( "EnginePath", EnginePath_get() ); build_set_variable( "UserEnginePath", g_qeglobals.m_userEnginePath.c_str() ); build_set_variable( "MonitorAddress", ( g_WatchBSP_Enabled ) ? "127.0.0.1:39000" : "" ); -- 2.39.2