Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for optional deps in otp24 #885

Closed
wants to merge 1 commit into from

Conversation

evanmcc
Copy link
Contributor

@evanmcc evanmcc commented Sep 24, 2021

rebar3 currently throws an error when building releases with optional applications, which were added in OTP 24. see:
erlang/rebar3#2473 for more context. it turns out that relx assumes that all deps it knows about are required, so this PR threads the optional application information through rebar3 and into relx, then does the right thing with it.

Copy link
Collaborator

@ferd ferd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense, but we probably want to maintain backwards compat on the calls to relx_app_info:new()

There's also a relx export to annotate properly for CI to go through.

@@ -71,17 +72,18 @@
-export_type([t/0,
app_type/0]).

-spec new(atom(), string(), file:name(), [atom()], [atom()]) -> t().
new(Name, Vsn, Dir, Applications, IncludedApplications) ->
new(Name, Vsn, Dir, Applications, IncludedApplications, dep).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is technically a backwards-incompatible change since this is the one bit of the public API users of relx must call. I don't know if we want to provide the sort of "match on the app_type() and know which signature this is" backwards-compatible behavior instead.

Like:

new(Name, Vsn, Dir, Applications, IncludedApplications) ->
    new(Name, Vsn, Dir, Applications, IncludedApplications, [], dep).

new(Name, Vsn, Dir, Applications, IncludedApplications, OptionalApplications) when is_list(OptionalApplications) ->
    new(Name, Vsn, Dir, Applications, IncludedApplications, OptionalApplications, dep);
new(Name, Vsn, Dir, Applications, IncludedApplications, AppType) when is_atom(AppType) ->
    new(Name, Vsn, Dir, Applications, IncludedApplications, OptionalApplications, [], AppType).

...

These tend to make the type specs real messy though it'd be fine keeping the new ones only.

subset(Rest ++ Applications ++ IncludedApplications,
{Rest1, Acc1} =
case find_app(Name, Vsn, World, LibDirs, CheckCodeLibDirs) of
not_found when Optional == true ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
not_found when Optional == true ->
not_found when Optional ->

Note that this omits the little weird case where an included_application can't logically be an optional_application but this validation allows an included app to miss if optional. I don't think we should really bother fixing that aspect yet.

@tsloughter
Copy link
Member

Is there a need for backwards compat? Only rebar3 uses this library and it is built with a specific locked version.

@ferd
Copy link
Collaborator

ferd commented Sep 26, 2021

The need isn't super hard, but I guess it technically requires a bump to 5.0.0 then.

@tsloughter
Copy link
Member

I don't think relx has been following semver. Except for that 4.0 bump I guess.

But yea, if keeping backwards compat isn't much trouble we may as well.

@tsloughter
Copy link
Member

Replaced by #898

@tsloughter tsloughter closed this Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants