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

src: move arch, platform and release into node_metadata.cc #25293

Closed
wants to merge 2 commits into from

Conversation

joyeecheung
Copy link
Member

@joyeecheung joyeecheung commented Dec 31, 2018

Move definitions of more metadata into node_metadata{.h, .cc}
so the data can be reused and easily inspected in C++.

In a peudo-release build:

(lldb) p node::per_process::metadata
(node::Metadata) $0 = {
  versions = {
    node = "12.0.0-nightly2018-12-31819a868a49a2b7dbb7b3adab2b79cc8b783f7279"
    v8 = "7.1.302.33-node.8"
    uv = "1.24.1"
    zlib = "1.2.11"
    ares = "1.15.0"
    modules = "68"
    nghttp2 = "1.34.0"
    napi = "3"
    llhttp = "1.0.1"
    http_parser = "2.8.0"
    openssl = "1.1.0j"
    cldr = "34.0"
    icu = "63.1"
    tz = "2018e"
    unicode = "11.0"
  }
  release = (name = "node", sourceUrl = "https://nodejs.org/download/release/v12.0.0-nightly2018-12-31819a868a49a2b7dbb7b3adab2b79cc8b783f7279/node-v12.0.0-nightly2018-12-31819a868a49a2b7dbb7b3adab2b79cc8b783f7279.tar.gz", headersUrl = "https://nodejs.org/download/release/v12.0.0-nightly2018-12-31819a868a49a2b7dbb7b3adab2b79cc8b783f7279/node-v12.0.0-nightly2018-12-31819a868a49a2b7dbb7b3adab2b79cc8b783f7279-headers.tar.gz")
  arch = "x64"
  platform = "darwin"
}
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

Move definitions of more metadata into node_metadata{.h, .cc}
so the data can be reused and easily inspected in C++.
@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Dec 31, 2018
@joyeecheung
Copy link
Member Author

Release release;

std::string arch;
std::string platform;
Copy link
Member

Choose a reason for hiding this comment

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

Can the extern Metadata metadata; on L104 be const?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think Metadata itself can be const - the ICU data versions have to be loaded after they are initialized. Other members should be able to be made const though.

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

Turning string literals into mutable std::strings is kind of inelegant. It'd be better to have some kind of struct that lives in rodata:

extern "C" static const struct {
  char arch[sizeof(NODE_ARCH)];
  char platform[sizeof(NODE_PLATFORM)];
  // etc.
} node_metadata = {
  NODE_ARCH,
  NODE_PLATFORM,
  // etc.
};

src/node_metadata.h Outdated Show resolved Hide resolved
@joyeecheung
Copy link
Member Author

joyeecheung commented Jan 4, 2019

I've marked per_process:metadata.release, per_process:metadata.arch and per_process:metadata.platform added in this PR const. It should be possible to move the non-intl version strings const too, but I'd prefer leave that to another PR (also it's probably better if we make sure Metadata is a singleton and all its members are static)

CI: https://ci.nodejs.org/job/node-test-pull-request/19932/

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Just reaffirming my LGTM

@joyeecheung joyeecheung added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 4, 2019
@joyeecheung
Copy link
Member Author

Landed in 6c01621

@joyeecheung joyeecheung closed this Jan 6, 2019
joyeecheung added a commit that referenced this pull request Jan 6, 2019
Move definitions of more metadata into node_metadata{.h, .cc}
so the data can be reused and easily inspected in C++.

PR-URL: #25293
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
@addaleax
Copy link
Member

addaleax commented Jan 9, 2019

This needs to be backported to v11.x.

@BridgeAR BridgeAR added this to Backport requested in v11.x Jan 10, 2019
refack pushed a commit to refack/node that referenced this pull request Jan 14, 2019
Move definitions of more metadata into node_metadata{.h, .cc}
so the data can be reused and easily inspected in C++.

PR-URL: nodejs#25293
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
@addaleax
Copy link
Member

This applies cleanly now.

addaleax pushed a commit that referenced this pull request Jan 14, 2019
Move definitions of more metadata into node_metadata{.h, .cc}
so the data can be reused and easily inspected in C++.

PR-URL: #25293
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
@BridgeAR BridgeAR moved this from Backport requested to Backported in v11.x Jan 14, 2019
@BridgeAR BridgeAR mentioned this pull request Jan 16, 2019
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request Jan 16, 2019
Move definitions of more metadata into node_metadata{.h, .cc}
so the data can be reused and easily inspected in C++.

PR-URL: nodejs#25293
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Jan 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
No open projects
v11.x
  
Backported
Development

Successfully merging this pull request may close these issues.

None yet

5 participants