Skip to content

Commit

Permalink
Add node_enable_deprecated_declarations_warnings GN flag (nodejs#181)
Browse files Browse the repository at this point in the history
* Add node_enable_deprecated_declarations_warnings GN flag

Warnings about using deprecated declarations were disabled by default
which made it hard to ensure that Node doesn't use V8's deprecated
Apis.

The flag allows enabling deprecated warnings and suppresses (hopefully)
known issues with using deprecated functionality in c-api.

The flag is off by default which preserves the existing behavior.

Drive-by: fix deps/openssl/unofficial.gni by exposing the required
OpenSSL compatibility level (OPENSSL_API_COMPAT) via public_configs.
  • Loading branch information
isheludko authored and victorgomes committed Aug 13, 2024
1 parent bae2412 commit 95fa564
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion deps/openssl/unofficial.gni
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ template("openssl_gn_build") {
"openssl/crypto/include",
"openssl/include",
]
defines = [ "OPENSSL_API_COMPAT=0x10100001L" ]
}

config("openssl_internal_config") {
Expand All @@ -26,7 +27,6 @@ template("openssl_gn_build") {

defines = [
"MODULESDIR=\"deps/openssl/lib/openssl-modules\"",
"OPENSSL_API_COMPAT=0x10100001L",
"STATIC_LEGACY",
] + gypi_values.openssl_default_defines_all
if (is_win) {
Expand Down
18 changes: 16 additions & 2 deletions unofficial.gni
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import("node.gni")
import("$node_v8_path/gni/snapshot_toolchain.gni")
import("$node_v8_path/gni/v8.gni")

declare_args() {
# Enable warnings about usages of deprecated declarations and suppress
# known issues with c-ares.
node_enable_deprecated_declarations_warnings = false
}

# The actual configurations are put inside a template in unofficial.gni to
# prevent accidental edits from contributors.
template("node_gn_build") {
Expand Down Expand Up @@ -33,7 +39,7 @@ template("node_gn_build") {
defines += [ "HAVE_INSPECTOR=0" ]
}
if (node_use_node_code_cache) {
defines += [ "NODE_USE_NODE_CODE_CACHE=1"]
defines += [ "NODE_USE_NODE_CODE_CACHE=1" ]
}
if (v8_enable_i18n_support) {
defines += [ "NODE_HAVE_I18N_SUPPORT=1" ]
Expand Down Expand Up @@ -64,7 +70,6 @@ template("node_gn_build") {
libs = []
cflags = [ "-Wno-microsoft-include" ]
cflags_cc = [
"-Wno-deprecated-declarations",
"-Wno-extra-semi",
"-Wno-implicit-fallthrough",
"-Wno-macro-redefined",
Expand All @@ -82,6 +87,10 @@ template("node_gn_build") {
"-Wno-unused-function",
]

if (!node_enable_deprecated_declarations_warnings) {
cflags_cc += [ "-Wno-deprecated-declarations" ]
}

if (current_cpu == "x86") {
node_arch = "ia32"
} else {
Expand All @@ -100,6 +109,11 @@ template("node_gn_build") {
"NODE_REPORT"
]

if (node_enable_deprecated_declarations_warnings) {
# Refs: https://github.com/nodejs/node/issues/52464
defines += [ "CARES_NO_DEPRECATED=1" ]
}

if (is_win) {
defines += [
"NOMINMAX",
Expand Down

0 comments on commit 95fa564

Please sign in to comment.