Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Options to support improved automation #1

Merged
merged 13 commits into from Apr 24, 2022

Conversation

joodicator
Copy link
Contributor

As commissioned by Johnathan Fowler, I have added several features to the command-line tool to support usage of YYCBoost in a completely automatic fashion via GameMaker build hook scripts. I present the results of my work so far, so that you may incorporate it into the main project if you see fit to do so.

These changes are motivated by the fact that, as YYCBoost worked before these changes, it was occasionally necessary to manually clean and recompile the project and restart YYCBoost. I have not fixed the root cause of these errors, but instead implemented support for a workaround wherein, upon each build of a project:

  1. The project build cache is cleared,
  2. The project is built once without any YYCBoost extension, and
  3. The project is built a second time with YYCBoost running in the background to produce the final result.

We found step 2 to be necessary because, on some machines it was tested on, there was a race between the compiler and YYCBoost in modifying the project files that regularly resulted in build errors or the project being built without extensions.

The exact changes introduced in this pull request are:

  • Added new command-line arguments /help, /background, /close, /auto, -buildpath, -pidfile, -timeout, -logfile, and -threads, as described in the new /help output:
    Usage: yycboost.exe [/?] [/b] [/c] [/a] [-bp=PATH] [-pf[=PATH]] [-t=SECONDS] [-j=COUNT] [-l=PATH] [CPP_DIR]
    
    Options:
      /?, /help             Show information about command-line arguments.
      /b, /background       Create a background process that is detached from the current terminal (if any) and allows the
                            calling process to continue immediately instead of blocking until finished. Implies "/auto".
      /c, /close            Signal an existing instance of YYCBoost to exit, by deleting the file given by the "-pidfile"
                            option, or, if that option is absent, the default PID file location. Do not perform any code
                            injection and immediately exit after this.
      /a, /auto             Use default values rather than prompting the user for any input.
      -bp, -buildpath=PATH
                            The path of the "build.bff" file corresponding to the target. If not specified, the user is
                            prompted to enter a path on the terminal, unless "/auto" is set, in which case the default
                            value of "%LocalAppData%\GameMakerStudio2\GMS2TEMP\build.bff" is used.
      -pf, -pidfile[=PATH]
                            Creates a text file at "PATH" containing the main process ID of YYCBoost and watches it for
                            changes: if the file is deleted, moved, or its contents changed, this acts as a termination
                            signal and causes the present instance to exit; otherwise, YYCboost deletes the PID file when
                            exiting normally. If "PATH" exists, YYCBoost overwrites it. If "-pidfile" is given without a
                            "PATH" argument, then it defaults to "yycboost.pid" in the current user's home directory (on
                            Windows: %UserProfile%).
      -t, -timeout=SECONDS
                            Close after this many seconds, or stay open until explicitly closed if SECONDS is 0. If not
                            specified, defaults to 300 if "/background" is set, or otherwise to 0.
      -j, -threads=COUNT
                            The number of CPU cores to use. If not specified, defaults to the total number of cores on the
                            system.
      -l, -logfile=PATH
                            Print status messages to PATH rather than to stdout/err. This is useful for debugging while
                            the "/background" option is active.
    
    Positional arguments:
      CPP_DIR               Load cache directory from command line (no injection, only cleanup, handy for GMS1.4) [Note:
                            this option doesn't appear to do anything useful; it has been kept for backward compatibility,
                            but may be removed in the future. The "cache directory" referred to here is the project-
                            specific directory for .gml.cpp files, for example "%LocalAppData%\GameMakerStudio2\Cache\GMS2
                            CACHE\YYCBoost_2083F10D\YYCBoost\Default\Scripts\llvm-win"; if this argument is present, then
                            the "build.bff" file is not loaded and its path need not be given.]
    
  • Added build hook scripts pre_run_step.bat, post_run_step.bat, and pre_package_step.bat under the example Game Maker project that automatically run YYCBoost when the project is built, using the workflow described above.

All changes are backward compatible, so any previous usage of the command-line tool should continue to work as it did before. I have not updated the documentation under docs_src to reflect any of these changes, so, if these changes are accepted, that might be called for in the future.

While modifying the Python code for the YYCBoost utility, I found some parts of the code that didn't make sense to me and appeared to possibly be dead code, but I left them as they were so as to avoid making unnecessary changes, and only annotated them with # TODO: lines to suggest reviewing them in the future.

joodicator and others added 13 commits December 11, 2021 07:22
* yycboost now waits for certain required files before starting.
* A new option, `-timeout=SECONDS`, has been added.
* "-pidfile=PATH" creates a file at PATH containing the PID that,
  if deleted or modified, terminates the current instance.
* "/close" possibly terminates an existing instance of the program
  by deleting the PID file at the configured location.
* "-timeout" now sets an overall length of time after which the
  program will exit if not explicitly terminated sooner.
@kraifpatrik kraifpatrik merged commit 4c59f13 into kraifpatrik:main Apr 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants