Skip to content

Commit 65936a8

Browse files
richardlauaduh95
authored andcommitted
tools: add script to synch c-ares source lists
Add step to the updater script for c-ares to synchronize the list of sources in our gyp file with the lists in c-ares' Makefiles. PR-URL: #55445 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent a12dbf0 commit 65936a8

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

tools/dep_updaters/update-c-ares.mjs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Synchronize the sources for our c-ares gyp file from c-ares' Makefiles.
2+
import { readFileSync, writeFileSync } from 'node:fs';
3+
import { join } from 'node:path';
4+
5+
const srcroot = join(import.meta.dirname, '..', '..');
6+
const options = { encoding: 'utf8' };
7+
8+
// Extract list of sources from the gyp file.
9+
const gypFile = join(srcroot, 'deps', 'cares', 'cares.gyp');
10+
const contents = readFileSync(gypFile, options);
11+
const sourcesRE = /^\s+'cares_sources_common':\s+\[\s*\n(?<files>[\s\S]*?)\s+\],$/gm;
12+
const sourcesCommon = sourcesRE.exec(contents);
13+
14+
// Extract the list of sources from c-ares' Makefile.inc.
15+
const makefile = join(srcroot, 'deps', 'cares', 'src', 'lib', 'Makefile.inc');
16+
const libSources = readFileSync(makefile, options).split('\n')
17+
// Extract filenames (excludes comments and variable assignment).
18+
.map((line) => line.match(/^(?:.*= |\s*)?([^#\s]*)\s*\\?/)?.[1])
19+
// Filter out empty lines.
20+
.filter((line) => line !== '')
21+
// Prefix with directory and format as list entry.
22+
.map((line) => ` 'src/lib/${line}',`);
23+
24+
// Extract include files.
25+
const includeMakefile = join(srcroot, 'deps', 'cares', 'include', 'Makefile.am');
26+
const includeSources = readFileSync(includeMakefile, options)
27+
.match(/include_HEADERS\s*=\s*(.*)/)[1]
28+
.split(/\s/)
29+
.map((header) => ` 'include/${header}',`);
30+
31+
// Combine the lists. Alphabetically sort to minimize diffs.
32+
const fileList = includeSources.concat(libSources).sort();
33+
34+
// Replace the list of sources.
35+
const newContents = contents.replace(sourcesCommon.groups.files, fileList.join('\n'));
36+
if (newContents !== contents) {
37+
writeFileSync(gypFile, newContents, options);
38+
}

tools/dep_updaters/update-c-ares.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ cp "$DEPS_DIR/cares/"*.gn "$DEPS_DIR/cares/"*.gni "$WORKSPACE/cares"
7171
echo "Replacing existing c-ares"
7272
replace_dir "$DEPS_DIR/cares" "$WORKSPACE/cares"
7373

74+
echo "Updating cares.gyp"
75+
"$NODE" "$ROOT/tools/dep_updaters/update-c-ares.mjs"
76+
7477
# Update the version number on maintaining-dependencies.md
7578
# and print the new version as the last line of the script as we need
7679
# to add it to $GITHUB_ENV variable

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy