Skip to content

Fix TypeError in XcodeVersion()#1939

Merged
gengjiawen merged 3 commits into
nodejs:masterfrom
cclauss:fix-TypeError-from-XcodeVersion
Oct 27, 2019
Merged

Fix TypeError in XcodeVersion()#1939
gengjiawen merged 3 commits into
nodejs:masterfrom
cclauss:fix-TypeError-from-XcodeVersion

Conversation

@cclauss

@cclauss cclauss commented Oct 24, 2019

Copy link
Copy Markdown
Contributor

Fixes: #1917

Recent changes have resulted in improper encoding of versions in the XcodeVersion() function.
This PR is meant to streamline the logic and properly encode versions that have single digit as well as double digit major versions.

Checklist
  • npm install && npm test passes
  • tests are included
  • documentation is changed or added
  • commit message follows commit guidelines
Description of change

@richardlau richardlau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not really a macOS person but the changes look to be an improvement over what is already there. I'd question the returned format (does it mean the minor and micro bits of the version string cannot be more than a single digit?) but it looks like it's used to populate Info.plist:

cache['DTXcode'] = xcode
cache['DTXcodeBuild'] = xcode_build

I haven't been able to find an authoritive reference for those keys with a quick web search.

@LavaToaster

LavaToaster commented Oct 25, 2019

Copy link
Copy Markdown

I'm not sure that this is a solution to the issue I posted:

If XcodeVersion returns a tuple, and gets used in a comparison function, like these:

Then surely it will error, like it did for me.

By comparison, if you look at the others uses of it, where I believe its used properly. They properly deconstruct the tuple for use in comparisons.

  • xcode_version, _ = XcodeVersion()
    if xcode_version < '0500':
    XCODE_ARCHS_DEFAULT_CACHE = XcodeArchsDefault(
    '$(ARCHS_STANDARD)',
    XcodeArchsVariableMapping(['i386']),
    XcodeArchsVariableMapping(['i386']),
    XcodeArchsVariableMapping(['armv7']))
    elif xcode_version < '0510':
    XCODE_ARCHS_DEFAULT_CACHE = XcodeArchsDefault(
    '$(ARCHS_STANDARD_INCLUDING_64_BIT)',
    XcodeArchsVariableMapping(['x86_64'], ['x86_64']),
    XcodeArchsVariableMapping(['i386'], ['i386', 'x86_64']),
    XcodeArchsVariableMapping(
    ['armv7', 'armv7s'],
    ['armv7', 'armv7s', 'arm64']))
    else:
    XCODE_ARCHS_DEFAULT_CACHE = XcodeArchsDefault(
    '$(ARCHS_STANDARD)',
    XcodeArchsVariableMapping(['x86_64'], ['x86_64']),
    XcodeArchsVariableMapping(['i386', 'x86_64'], ['i386', 'x86_64']),
    XcodeArchsVariableMapping(
    ['armv7', 'armv7s', 'arm64'],
    ['armv7', 'armv7s', 'arm64']))
    return XCODE_ARCHS_DEFAULT_CACHE
  • xcode, xcode_build = XcodeVersion()
    cache['DTXcode'] = xcode
    cache['DTXcodeBuild'] = xcode_build
    sdk_root = self._SdkRoot(configname)
    if not sdk_root:
    sdk_root = self._DefaultSdkRoot()
    cache['DTSDKName'] = sdk_root
    if xcode >= '0430':
    cache['DTSDKBuild'] = self._GetSdkVersionInfoItem(
    sdk_root, 'ProductBuildVersion')
    else:
    cache['DTSDKBuild'] = cache['BuildMachineOSBuild']
  • xcode_version, xcode_build = XcodeVersion()
    if xcode_version < '0500':
    return ''

These previews are rendered from your commit.

@cclauss

cclauss commented Oct 25, 2019

Copy link
Copy Markdown
Contributor Author

@Lavoaster You are correct. Thanks for this very precise review. I have made appropriate changes.

@sam-github sam-github left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks reasonable to me.

@cclauss

cclauss commented Oct 26, 2019

Copy link
Copy Markdown
Contributor Author

@bdon

@cclauss cclauss requested review from Trott and gengjiawen October 27, 2019 06:27
@gengjiawen gengjiawen merged commit ec4d403 into nodejs:master Oct 27, 2019
@cclauss cclauss deleted the fix-TypeError-from-XcodeVersion branch October 27, 2019 09:40
@rvagg

rvagg commented Oct 27, 2019

Copy link
Copy Markdown
Member

@gengjiawen these commits needed metadata before merging, PR-URL and Reviewed-By at a minimum, and the middle one is missing the subsystem prefix. Please don't merge using the GitHub UI so this can be avoided.
I'll address it and force-push.

@rvagg

rvagg commented Oct 27, 2019

Copy link
Copy Markdown
Member

sorry, there's two commits at fault here, one is from #1937 and this one got squashed (thanks), but they're both missing subsystem, in this case gyp: from the commit messages plus the metadata. We do this mainly for nice changelogs.

rvagg pushed a commit that referenced this pull request Oct 27, 2019
PR-URL: #1939
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
@rvagg

rvagg commented Oct 27, 2019

Copy link
Copy Markdown
Member

see 9c0f340 and bb2eb72 for the modified forms, force pushed to master

@gengjiawen

Copy link
Copy Markdown
Member

@gengjiawen these commits needed metadata before merging, PR-URL and Reviewed-By at a minimum, and the middle one is missing the subsystem prefix. Please don't merge using the GitHub UI so this can be avoided.
I'll address it and force-push.

Sorry for this trouble. Is https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md#git-node-metadata can generate the meta info ?

@rvagg

rvagg commented Oct 28, 2019

Copy link
Copy Markdown
Member

that's the metadata we need but I don't know if it'll work on this repo, I just do it manually, but keeping to nodejs/node conventions is the aim (also no merge commits)

@gengjiawen

Copy link
Copy Markdown
Member

Hate merge commits too :)

chrmoritz added a commit to chrmoritz/node that referenced this pull request Nov 5, 2019
original commit: nodejs/node-gyp@ec4d403
Refs: nodejs/node-gyp#1939
Co-Authored-By: Christian Clauss <cclauss@me.com>
rvagg pushed a commit that referenced this pull request Nov 18, 2019
PR-URL: #1939
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: '>=' not supported between instances of 'tuple' and 'str'

6 participants