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

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
src: move arch, platform and release into node_metadata.cc
Move definitions of more metadata into node_metadata{.h, .cc}
so the data can be reused and easily inspected in C++.
@joyeecheung

This comment has been minimized.

Copy link
Member Author

commented Dec 31, 2018

Release release;

std::string arch;
std::string platform;

This comment has been minimized.

Copy link
@addaleax

addaleax Jan 1, 2019

Member

Can the extern Metadata metadata; on L104 be const?

This comment has been minimized.

Copy link
@joyeecheung

joyeecheung Jan 4, 2019

Author Member

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.

@jasnell
jasnell approved these changes Jan 1, 2019
@bnoordhuis
Copy link
Member

left a comment

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

This comment has been minimized.

Copy link
Member Author

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/

@addaleax
Copy link
Member

left a comment

Just reaffirming my LGTM

@joyeecheung

This comment has been minimized.

Copy link
Member Author

commented Jan 6, 2019

Landed in 6c01621

@joyeecheung joyeecheung closed this Jan 6, 2019

joyeecheung added a commit that referenced this pull request Jan 6, 2019
src: move arch, platform and release into node_metadata.cc
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

This comment has been minimized.

Copy link
Member

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 added a commit to refack/node that referenced this pull request Jan 14, 2019
src: move arch, platform and release into node_metadata.cc
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

This comment has been minimized.

Copy link
Member

commented Jan 14, 2019

This applies cleanly now.

addaleax added a commit that referenced this pull request Jan 14, 2019
src: move arch, platform and release into node_metadata.cc
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 referenced this pull request Jan 16, 2019
BridgeAR added a commit to BridgeAR/node that referenced this pull request Jan 16, 2019
src: move arch, platform and release into node_metadata.cc
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 referenced this pull request Jan 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
5 participants
You can’t perform that action at this time.