`studio.project.build()` does not build banks if the script is run from the command line tool

Repro steps:

  1. Create a new project
  2. Add a “Scripts” directory to the project directory
  3. Add a “build.js” file with the following contents to the “Scripts” directory with the following contents:
function doBuild() {
    console.log("Build started");
    studio.project.build();
    console.log("Build finished");
}

var automation = {
    name: "Automation",
    execute: function(){ doBuild(); }
};

var automationMissing = true;
var menuItems = studio.menu.menuItems();
for (var i = 0; i < menuItems.length; ++i) {
    if (menuItems[i].name == automation.name) {
        automationMissing = false;
        break;
    }
}

if (automationMissing) {
    studio.menu.addMenuItem(automation);
}
else if (studio.system.question("Do you want to build?")) {
    doBuild();
}
  1. Select “Scripts” and then “Reload” from the menu bar
  2. Select “Scripts” and then “Automation” from the menu bar
  3. Observe that the “Build” directory has been created and populated with banks
  4. Delete the “Build” directory
  5. Open a terminal and run the following commands:
cd <PathToFmodInstallation>
./fmodstudio.exe -build <PathToTestProject><ProjectName>.fspro
  1. Observe that the “Build” directory has been created and populated with banks
  2. Delete the “Build” directory
  3. Open a terminal and run the following commands:
cd <PathToFmodInstallation>
./fmodstudio.exe -script <PathToTestProject>/Scripts/build.js <PathToTestProject><ProjectName>.fspro
  1. Select yes on the popup
  2. Observe that the “Build” directory was NOT created or populated with banks

Note that the “Build” directory is still not created if adding the following code to the beginning of “build.js”:

function getAbsolutePath(relativeFilePath) {
    var projectPath = studio.project.filePath.replace("\\", "/");
    var lastSlash = projectPath.lastIndexOf("/");
    var projectDir = studio.project.filePath.substring(0, lastSlash + 1);
    return projectDir + relativeFilePath;
}
studio.project.workspace.builtBanksOutputDirectory = getAbsolutePath("Build");
console.log(studio.project.workspace.builtBanksOutputDirectory);

Console output from the -build command:

Qt: Untested Windows version 10.0 detected!

Loading project "c:/dev/fmod/micro_test/command_line_script/command_line_script.fspro"...
[Scripting] C:/dev/fmod/micro_test/command_line_script/Build
Successfully opened project.
Building project "c:/dev/fmod/micro_test/command_line_script/command_line_script.fspro"...
Build Status: Preparing to build for Desktop...
Build Status: Loading "Master" objects...
Build Status: Building "Master" for Desktop...
Build completed successfully.

Console output from the -script command:

Qt: Untested Windows version 10.0 detected!

Loading project "c:/dev/fmod/micro_test/command_line_script/command_line_script.fspro"...
[Scripting] C:/dev/fmod/micro_test/command_line_script/Build
Successfully opened project.
Running script "c:/dev/fmod/micro_test/command_line_script/Scripts/build.js"...
[Scripting] C:/dev/fmod/micro_test/command_line_script/Build
[Scripting] Build started
[Scripting] Build finished

If your script causes any kind of dialog or GUI to appear, then it will stop the script then and there. Can you try the same script without the studio.system.question condition?

Actually, the script did not stop in it’s tracks. It prompted me as one would expect, and after I answered, it successfully executed per the output I posted. See the “Build started” and “Build finished” in the output?

Also, even running this command from the install directory:

./fmodstudio.exe -script c:/dev/fmod/micro_test/command_line_script/build.js c:/dev/fmod/micro_test/command_line_script/command_line_script.fspro

with this project directory:
image
and this script:

function getAbsolutePath(relativeFilePath) {
    var projectPath = studio.project.filePath.replace("\\", "/");
    var lastSlash = projectPath.lastIndexOf("/");
    var projectDir = studio.project.filePath.substring(0, lastSlash + 1);
    return projectDir + relativeFilePath;
}
studio.project.workspace.builtBanksOutputDirectory = getAbsolutePath("Build");
console.log(studio.project.workspace.builtBanksOutputDirectory);
console.log("Build started");
studio.project.build();
console.log("Build finished");

or even this script:

studio.project.build();

will still not generate the “Build” directory.

My apologies over the delay in getting back to you. This does indeed seem to be a bug, we’ve raised a report and will investigate fixing it for a future release.

1 Like

Hi everyone! It still doesn’t work.

This should have been fixed in a previously released version. Can you let me know which version you are experiencing this with?