YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
24 stars 8 forks source link

"Building via command line" needs a thorough, deep review #7174

Open guillermoares opened 3 months ago

guillermoares commented 3 months ago

Description

Hi there!

I've been trying to set up a script to build my game for Windows (YYC) and HTML5 platforms. The documentation regarding how to do this seems very very off, so much that I can't recall all the issues I had so far. I would advise to have someone try to follow the doc to do what I'm trying to do and figure out all the things that don't work as described in the docs.

Please don't take this as a rant, I really appreciate the tool 😃. But this really needs some general attention 🙏. Also take into account this is me remembering stuff I saw in the last 24 hours, so I can't guarantee it is 100% accurate.

Some of the things I recall are:

  1. of and tf parameters are very confusing. Sometimes they need to be folders, sometimes they need to be filenames with no extension, sometimes they need to be filenames with extensions, sometimes they need to be full paths rather than just filenames... It feels really unstable and unpredictable. For example, the documentation says that of should have no extension so that Igor can decide that later and gives as an example that "game" could end up as "game.zip". But right after in the tf description it says that this should be the actual name of the zip or NSIS file... so which one is it? The doc also says that the behavior of of depends on the platform but it doesn't specify how or anything, which is misleading.
  2. What is really of supposed to be? From what I've seen, it seems to define an "output" folder that is rather used as a(nother) temp folder. For example, when building HTML5 folder, the HTML5 files are dropped in there but you also need to specify tf so that Igor doesn't crash. In this case tf just seems to be a copy of what was saved to of.
  3. Under some combination of tf and of when building HTML folder, Igor seems to get into an infinite folder-creating loop, which in my case resulted in something like [project-path]\builds\html5\files\files\files\files\...\files\.... Had to use bash to delete the thing because cmd just couldn't handle the resulting superlong paths. Would love to tell you exactly what combo of tf and of resulted in that, but I'd rather not do that to my file system again 😅 . It took a while for bash to handle it.
  4. Parameters seem to support relative paths, but they don't always do and Igor ends up failing in ways that don't make obvious what the issue is. In my case, I was using a relative path for the cache parameter and got into issues. If I recall correctly, using a relative cache path resulted in this line:
    C:\Windows\system32\cmd.exe /c ""C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" -host_arch=amd64 && C: && cd "C:\Users\The Guille\AppData\Roaming\GameMakerStudio2\Cache\GMS2CACHE\theplaneto_6885B2EE_6595FDC\theplanetologist\Default\Scripts\llvm-win\Win32solution" && set && msbuild /m:%NUMBER_OF_PROCESSORS% "theplanetologist.sln" /p:Configuration=Release /p:Platform=x64 /t:build /verbosity:normal"

    turning into this other line:

    C:\Windows\system32\cmd.exe /c ""C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" -host_arch=amd64 && ca && cd "C:\Users\The Guille\AppData\Roaming\GameMakerStudio2\Cache\GMS2CACHE\theplaneto_6885B2EE_6595FDC\theplanetologist\Default\Scripts\llvm-win\Win32solution" && set && msbuild /m:%NUMBER_OF_PROCESSORS% "theplanetologist.sln" /p:Configuration=Release /p:Platform=x64 /t:build /verbosity:normal"

    Notice that C: changed for ca, which I guess is some kind on unresolved alias or something, but it got me really puzzled for a while until it occured to me to build from the IDE and see what that line looked line there and then... guessing it might have something to do with relative paths. It wasn't smooth.

  5. The Windows executable file name is sometimes taken from the IDE Windows config and sometimes deduced(?) from of or tf. This is not documented or explained in the doc. Playing with those two parameters I could get one or the other, but I didn't investigate the pattern.
  6. The HTML5 Clean command seems to return a non-zero error code when actually nothing's wrong. I guess it didn't find something to clean (I might have ran "clean" twice in a row or something) so it returned some error, but this effectively prevents me from checking the error code unless I try to get into the rabbit hole of checking for specific error codes and what they mean myself, as this is also not documented.
  7. The Windows Clean command creates the output folder although it doesn't seem to be used.

And I'm sure there's more, I didn't even try other build targets.

I'm copying the bat file that finally worked for me in case it is useful in any way.

set GM_USER=guillermoares_4066461
set PROJECT_FOLDER=d:\repos\planetologist

set RUNTIME_PATH=C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-2024.6.1.208
set IGOR="%RUNTIME_PATH%\bin\igor\windows\x64\Igor.exe"

set USER_FOLDER=%AppData%\GameMakerStudio2\%GM_USER%
set PROJECT=%PROJECT_FOLDER%\theplanetologist.yyp
set CACHE=%PROJECT_FOLDER%\cache
set TEMP=c:\temp

set BUILDS=%PROJECT_FOLDER%\builds
set DEFAULT_OUTPUT_FOLDER=%PROJECT_FOLDER%\output
set WINDOWS_OUTPUT_FOLDER=%BUILDS%\theplanetologist-windows
set WINDOWS_OUTPUT=%WINDOWS_OUTPUT_FOLDER%\theplanetologist
set WINDOWS_ZIP=%BUILDS%\theplanetologist-windows.zip
set HTML_OUTPUT=%BUILDS%\html5
set HTML_ZIP=%BUILDS%\theplanetologist-web.zip

@echo Deleting old builds...
rmdir "%BUILDS%" /s /q
@echo Old builds deleted

@echo Deleting cache...
rmdir "%CACHE%" /s /q
@echo Cache deleted

@echo Deleting old output if any...
rmdir "%DEFAULT_OUTPUT_FOLDER%" /s /q
@echo Old output deleted

@echo Cleaning windows build...
%IGOR% /uf="%USER_FOLDER%" /rp="%RUNTIME_PATH%" /project="%PROJECT%" /cache="%CACHE%" /temp="%TEMP%" -- Windows Clean
if %errorlevel% neq 0 exit /b
@echo Windows build cleaned

@echo Building windows ZIP... 
%IGOR% /v /uf="%USER_FOLDER%" /rp="%RUNTIME_PATH%" /project="%PROJECT%" /cache="%CACHE%" /temp="%TEMP%" /of="%WINDOWS_OUTPUT%" /tf="%WINDOWS_ZIP%" /runtime=YYC -- Windows PackageZip
if %errorlevel% neq 0 exit /b
@echo Windows ZIP built!

@echo Deleting needless default output folder...
rmdir "%DEFAULT_OUTPUT_FOLDER%" /s /q
@echo Needless output folder deleted

@echo Deleting Windows YYC output...
rmdir "%WINDOWS_OUTPUT_FOLDER%" /s /q
@echo Windows YYC output deleted

@echo Cleaning HTML5 build...
%IGOR% /uf="%USER_FOLDER%" /rp="%RUNTIME_PATH%" /project="%PROJECT%" /cache="%CACHE%" /temp="%TEMP%" -- HTML5 Clean
@echo HTML5 build cleaned

@echo Building HTML5...
%IGOR% /uf="%USER_FOLDER%" /rp="%RUNTIME_PATH%" /project="%PROJECT%" /cache="%CACHE%" /temp="%TEMP%" /tf="%HTML_OUTPUT%" -- HTML5 folder
if %errorlevel% neq 0 exit /b
@echo HTML5 built!

@echo Deleting default output...
rmdir "%PROJECT_FOLDER%\output" /s /q
@echo Default output deleted

@echo Patching HTML JS to support full screen...
build-tools\fart "%HTML_OUTPUT%\html5game\theplanetologist.js" -- "top.chrome!=null&&top.chrome.app!=null&&top.chrome.app.window!=null" false
REM if %errorlevel% neq 0 exit /b
@echo HTML5 JS patched!

@echo Creating HTML5 ZIP
tar.exe acvf "%HTML_ZIP%" "%HTML_OUTPUT%"
if %errorlevel% neq 0 exit /b
@echo HTML5 ZIP created!

@echo Deleting HTML5 loose files...
rmdir "%HTML_OUTPUT%" /s /q
@echo HTML5 loose files deleted

Notice that I'm using this FART tool (yeah, funny name 😅 ) to patch an issue with HTML5 full screen (already filed a ticket). You can just remove those lines but if you want to download the tool, you can do so from sourceforge.

Keep up the good work and thanks in advance!

Manual Link

https://manual.gamemaker.io/monthly/en/index.htm#t=Settings%2FBuilding_via_Command_Line.htm

MagicShiba commented 2 months ago

/temp=[temp_dir_path] I would like to add that specifying the temp folder does not work. (Machine translation)