radiant/buildmenu: rename ".[ExecutableType]" as "[ExecutableExt]"
authorThomas Debesse <dev@illwieckz.net>
Fri, 27 Mar 2020 18:11:38 +0000 (19:11 +0100)
committerThomas Debesse <dev@illwieckz.net>
Sat, 28 Mar 2020 02:09:03 +0000 (03:09 +0100)
- introduce GDEF_OS_EXE_EXT
- no need for RADIANT_EXECUTABLE anymore
- keep "[ExecutableType]" parsing but it looks useless

CMakeLists.txt
Makefile
libs/globaldefs.h
radiant/build.cpp
radiant/map.cpp
radiant/qe3.cpp

index fb00a21..6d82b5c 100644 (file)
@@ -282,10 +282,6 @@ endif ()
 #-----------------------------------------------------------------------
 
 if (BUILD_BINARIES)
-    if (CMAKE_EXECUTABLE_SUFFIX)
-        string(REGEX REPLACE "^[.]" "" RADIANT_EXECUTABLE ${CMAKE_EXECUTABLE_SUFFIX})
-    endif ()
-
     macro (radiant_tool name)
         add_dependencies(binaries ${name})
 
@@ -305,9 +301,6 @@ if (BUILD_BINARIES)
 
     if (BUILD_RADIANT)
         add_subdirectory(radiant)
-        set_target_properties(${RADIANT_BASENAME} PROPERTIES
-        COMPILE_DEFINITIONS RADIANT_EXECUTABLE="${RADIANT_EXECUTABLE}"
-    )
     endif ()
 endif ()
 
index ff8161f..4f1fc2e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -264,16 +264,13 @@ RADIANT_VERSION_NUMBER = $(RADIANT_MAJOR_VERSION).$(RADIANT_MINOR_VERSION).$(RAD
 RADIANT_VERSION = $(RADIANT_VERSION_NUMBER)n
 Q3MAP_VERSION = 2.5.17n
 
-# Executable extension
-RADIANT_EXECUTABLE := $(EXE)
-
 GIT_VERSION := $(shell $(GIT) rev-parse --short HEAD $(STDERR_TO_DEVNULL))
 ifneq ($(GIT_VERSION),)
        RADIANT_VERSION := $(RADIANT_VERSION)-git-$(GIT_VERSION)
        Q3MAP_VERSION := $(Q3MAP_VERSION)-git-$(GIT_VERSION)
 endif
 
-CPPFLAGS += -DRADIANT_VERSION="\"$(RADIANT_VERSION)\"" -DRADIANT_VERSION_STRING="\"$(RADIANT_VERSION_STRING)\"" -DRADIANT_ABOUTMSG="\"$(RADIANT_ABOUTMSG)\"" -DRADIANT_NAME="\"${RADIANT_NAME}\"" -DRADIANT_BASENAME="\"${RADIANT_BASENAME}\"" -DQ3MAP_VERSION="\"$(Q3MAP_VERSION)\"" -DRADIANT_EXECUTABLE="\"$(RADIANT_EXECUTABLE)\""
+CPPFLAGS += -DRADIANT_VERSION="\"$(RADIANT_VERSION)\"" -DRADIANT_VERSION_STRING="\"$(RADIANT_VERSION_STRING)\"" -DRADIANT_ABOUTMSG="\"$(RADIANT_ABOUTMSG)\"" -DRADIANT_NAME="\"${RADIANT_NAME}\"" -DRADIANT_BASENAME="\"${RADIANT_BASENAME}\"" -DQ3MAP_VERSION="\"$(Q3MAP_VERSION)\""
 CPPFLAGS += -DGTK_TARGET=2
 
 .PHONY: all
index 5d17052..7f6b304 100644 (file)
 #define GDEF_OS_XDG 0
 #endif
 
+// EXECUTABLE EXTENSION
+
+#if GDEF_OS_WINDOWS
+#define GDEF_OS_EXE_EXT ".exe"
+#else
+#define GDEF_OS_EXE_EXT ""
+#endif
+
 // COMPILER
 
 #if defined(_MSC_VER)
index c060d08..7090b98 100644 (file)
@@ -76,8 +76,7 @@ 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
+       // replace ".[ExecutableType]" with "[ExecutableExt]"
        {
                StringBuffer output;
                const char *pattern = ".[ExecutableType]";
@@ -85,7 +84,7 @@ void evaluate( StringBuffer& output ){
                {
                        if ( strncmp( pattern, i, sizeof( pattern ) ) == 0 )
                        {
-                               output.push_string("");
+                               output.push_string("[ExecutableExt]");
                                i += strlen( pattern ) - 1;
                        }
                        else
@@ -95,7 +94,6 @@ void evaluate( StringBuffer& output ){
                }
                setString(output.c_str());
        }
-       #endif // !(GDEF_OS_WINDOWS)
 
        StringBuffer variable;
        bool in_variable = false;
index 7e66831..de6c6d1 100644 (file)
@@ -1581,11 +1581,7 @@ tryDecompile:
                StringBuffer output;
                output.push_string( AppPath_get() );
                output.push_string( "q3map2" );
-
-               #if GDEF_OS_WINDOWS
-               output.push_string( "." );
-               output.push_string( RADIANT_EXECUTABLE );
-               #endif // GDEF_OS_WINDOWS
+               output.push_string( GDEF_OS_EXE_EXT );
 
                output.push_string( " -v -game " );
                output.push_string( ( type && *type ) ? type : "quake3" );
index 38028e7..bc1b6ed 100644 (file)
@@ -173,15 +173,18 @@ bool ConfirmModified( const char* title ){
 }
 
 void bsp_init(){
+       // this is expected to not be used since
+       // ".[ExecutableType]" is replaced by "[ExecutableExt]"
+       const char *exe_ext = GDEF_OS_EXE_EXT;
+       build_set_variable( "ExecutableType", exe_ext[0] == '\0' ? exe_ext : exe_ext + 1 );
+       
+       build_set_variable( "ExecutableExt", GDEF_OS_EXE_EXT );
        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" : "" );
+
        build_set_variable( "GameName", gamename_get() );
 
        StringBuffer ExtraQ3map2Args;