radiant: strip .[ExecutableType] entirely (including preceding dot) outside of Windows
authorThomas Debesse <dev@illwieckz.net>
Sun, 4 Nov 2018 04:02:18 +0000 (05:02 +0100)
committerThomas Debesse <dev@illwieckz.net>
Sat, 18 May 2019 20:47:42 +0000 (22:47 +0200)
keep backward compatibility with existing build menus

CMakeLists.txt
radiant/build.cpp
radiant/map.cpp
radiant/qe3.cpp

index 4e4bafc..05c9092 100644 (file)
@@ -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 "$<TARGET_FILE_NAME:${name}>" "${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)
index 6462e38..d9d4e40 100644 (file)
@@ -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 )
index 6603279..7e66831 100644 (file)
@@ -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 \"" );
index b073752..230fa15 100644 (file)
@@ -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" : "" );