Skip to content

Support activeBuildProfile parameter #737

@ryo0ka

Description

@ryo0ka

Context

Enhancing #674 to cover more use cases.

Unity 6000+'s new feature "build profile" comes with multiple benefits:

  1. Allows to override project/build configurations per profile
  2. Allows to compile the project with profile-specific preprocessors before the build function is invoked

Current implementation by @MichaelBuhler (5eccc32) covers 1, but not 2.

Calling BuildProfile.SetActiveBuildProfile() during build script will not apply preprocessors, as documented here:

[...] when the Editor runs in batch mode, it runs “headless”, so there is no editor loop which would cause it to recompile with the new scripting symbols. Because of this, you should not use Editor scripts to set scripting symbols within a batch mode CI server because the scripts will not be recompiled, so they will not be applied.

It'll affect projects that manage code stripping like this:

#if PROFILE_A_LOADED
using ProfileA.Specific.Module;
ProfileA.Specific.Module.DoSomething();
#endif

We can cover this by passing buildProfile to -activeBuildProfile. In previous discussion, we went over compatibility mitigation:

  1. We continue to use targetPlatform to identify which Docker image to pull.
  2. If buildProfile is given by user, we pass it to -activeBuildProfile; otherwise we pass targetPlatform to -buildTarget.
  3. In case users made a mistake to specify a mismatching pair of targetPlatform and buildProfile, build may fail (undefined behavior).

Regarding 3, previous discussion went over the possibility of reading the profile (yaml). I personally feel like not doing it because the file content format is not documented and it's a fairly new feature.

There was another compatibility issue surrounding the default build function but @MichaelBuhler has gracefully implemented a branching logic.

Suggested solution

Current implementation passes buildProfile to -customBuildProfile. Maybe we can simply reroute it to -activeBuildProfile but maybe I'm not seeing other compatibility issues?

Considered alternatives

Running two passes of unity-build action: (1) run the action with a function that sets active build profile and (2) run the action again with another function that actually runs the build.

Additional details

The -activeBuildProfile's behavior (that it invokes script compilation before -executeMethod function call) is actually not officially documented as far as I searched over their API documentation, but I believe that they just forgot to mention it. I've submitted a ticket to their documentation page assuming they ever read those.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions