Changing exe name for GLFW build
Monkey Targets Forums/Desktop/Changing exe name for GLFW build
| ||
Hi all, is there a way to change the .exe/.app name for windows/MacOS? I've checked out the config file in the build folder but it only has: GLFW_WINDOW_TITLE="Monkey Game" I want to make the exe name match the source code main build file. This is so that my level editor can use the app path to find the source .data folder and change files in it (not the build data folder). Currently the app path always returns monkeygame on the end of course. Thanks! |
| ||
For GLFW, it's in the project file (vc2010 win, xcodeproj mac). BUT the "trans.exe" when executing build-and-run, has the run part hardcoded as MonkeyGame. So that won't work if you change the output filename. |
| ||
Oh bummer. Seems it's a bit impractical then. It would be great if Mark could streamline this process. |
| ||
Yeah i wished there was a way to do this also but I've since gotten to use to just changing the executable filename in the release folder whenever i need to :). |
| ||
BUT the "trans.exe" when executing build-and-run, has the run part hardcoded as MonkeyGame. So that won't work if you change the output filename. Unless you modify trans to change the project files on the fly. Easy enough to do with a Visual Studio project not sure about a mac yet. |
| ||
I can add this to monkey-ext if you like. I need to finish the v64 merge first though. |
| ||
I can add this to monkey-ext if you like. I need to finish the v64 merge first though. Could do. I'm surprised nobody hasn't had a go at doing it already. The easiest way I could think of doing it was to trap my own preprocessor directive (#PROJECT_NAME="My Game") and alter the GLFW monkey target so it would load the default MonkeyGame project files, find and change all instances of MonkeyGame in those files. Then to solve the problem of any alteration to the new project name I used a small text file to store the name that was currently used.I've also been playing around with the Visual studio templates the other day. I've modified the VS Project template to include a resource file so I could add an icon to the finished executable. |
| ||
Look's like I've got something working for both Xcode and Visual Studio (GLFW). Just need to figure out how to replace the default icon that OS X uses. Then I'll post what to add and where. |
| ||
In OSX the icon file is included inside the app (it's just a folder). The setting what this icon should be is configured in the Info.plist file. I think CFBundleIconFile is the property you are looking for. |
| ||
In OSX the icon file is included inside the app (it's just a folder). It's a bit more complex than that (the first thing I checked was the plist). For it to be added to the bundle, the xcode project file must also be modified to include the icon. Unfortunately apple in all there wisdom don't store the project.pbxproj as an xml file with easily recognisable tags, but use their own format where each file that is added to the project gets a GUID. Now it is possible to modify it but if the default template is change there is a high risk of it breaking the project or not working at all.The setting what this icon should be is configured in the Info.plist file. I think CFBundleIconFile is the property you are looking for. At the moment I've got all three possible GLFW builds working, with the possibility of adding a icon on the fly if a default icon file is detected, the easiest to do was the MINGW. Currently I'm reorganising the code so that it will be it's own class as at the moment it's a kludge fix to target just to see if it could be done. This will then make it a little easier to maintain and add additional targets. |
| ||
OK as promised here's the code still a WIP but usable. This is for v64 Back up and modify src/trans/targets/glfw.monkey At the top of the file under "Import target" add "Import modify" Change the methods MakeMingw, MakeVc2010 and MakeXcode to read.. Method MakeMingw() CreateDir "mingw/"+CASED_CONFIG CreateDataDir "mingw/"+CASED_CONFIG+"/data" Local main$=LoadString( "main.cpp" ) main=ReplaceBlock( main,"TRANSCODE",transCode ) main=ReplaceBlock( main,"CONFIG",Config() ) '#### DAWLANE CHANGE 'Change the projects back-end build files Local project:String = AlterBackEnd.Project() main = AlterBackEnd.Main(main) '##### CHANGE END SaveString main,"main.cpp" If OPT_ACTION >= ACTION_BUILD ChangeDir "mingw" Local ccopts:="" Select ENV_CONFIG Case "release" ccopts="-O3 -DNDEBUG" Case "debug" End '#### DAWLANE CHANGE Execute "mingw32-make CCOPTS=~q" + ccopts + "~q OUT=~q" + CASED_CONFIG + "/" + project + "~q" '##### CHANGE END If OPT_ACTION>=ACTION_RUN ChangeDir CASED_CONFIG '#### DAWLANE CHANGE Execute project '##### CHANGE END Endif Endif End Method MakeVc2010() CreateDir "vc2010/"+CASED_CONFIG CreateDataDir "vc2010/"+CASED_CONFIG+"/data" Local main$=LoadString( "main.cpp" ) main=ReplaceBlock( main,"TRANSCODE",transCode ) main=ReplaceBlock( main,"CONFIG",Config() ) '#### DAWLANE CHANGE 'Change the projects back-end build files Local project:String = AlterBackEnd.Project() main = AlterBackEnd.Main(main) '##### CHANGE END SaveString main,"main.cpp" If OPT_ACTION>=ACTION_BUILD ChangeDir "vc2010" '#### DAWLANE CHANGE Execute MSBUILD_PATH + " /p:Configuration=" + CASED_CONFIG + ";Platform=~qwin32~q " + project + ".sln" '##### CHANGE END If OPT_ACTION>=ACTION_RUN ChangeDir CASED_CONFIG Execute project Endif Endif End Method MakeXcode() CreateDataDir "xcode/data" Local main$=LoadString( "main.cpp" ) main=ReplaceBlock( main,"TRANSCODE",transCode ) main=ReplaceBlock( main,"CONFIG",Config() ) '#### DAWLANE CHANGE 'Change the projects back-end build files Local project:String = AlterBackEnd.Project() main = AlterBackEnd.Main(main) '##### CHANGE END SaveString main, "main.cpp" If OPT_ACTION>=ACTION_BUILD ChangeDir "xcode" Execute "xcodebuild -configuration " + CASED_CONFIG '#### DAWLANE CHANGE 'Remove the extra icon from the app bundle AlterBackEnd.RemoveExtras() '##### CHANGE END If OPT_ACTION>=ACTION_RUN ChangeDir "build/" + CASED_CONFIG '#### DAWLANE CHANGE ChangeDir project + ".app/Contents/MacOS" Execute "./" + project '##### CHANGE END Endif Endif End For src/trans/targets/stdcpp.monkey Add Import modify to the top of the file under "Import target" And change Local out$="main_" + HostOSto Local out:String = AlterBackEnd.Project() + "_" + HostOS Now make a new file and name it as modify.monkey and save it in src/trans/targets then copy and paste the code below. With that done open src/trans/trans.monkey and compile it, when that's done copy the file main_winnt or main_macos in src/trans/trans.build/stdcpp folder to monkeys bin folder. Back up the trans executable by renaming it, then rename the main_winnt or main_macos to trans_winnt or trans_macos. Now to use it add at the top of your main monkey project source code: #PROJECT_NAME="My Game" then compile your code you should find in the .build folder that the projects compiler files have changed and your executable has been renamed. Opening up the main.cpp file and looking at the LoadState functions, you should see .mygamestate instead of .monkeystate. To add a icon on the fly. You can use Import or put the icon in the .data folder but you must add #IMAGE_FILES="*.png|*.jpg|*.ico" 'Windows #MAGE_FILES="*.png|*.jpg|*.icns" 'OS X and name the icon app_icon.ico or app_icon.icns. One thing to note the code handles the default project templates that come with monkey, so if they have been altered in VS or Xcode before the icons are added; It could mess things up but the name change should be safe. I really need a better way to parse these files especially for xcode. |