Skip to content

Commit def014d

Browse files
authored
tools: allow passing absolute path of config.gypi in js2c
PR-URL: #49162 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
1 parent c86e700 commit def014d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tools/js2c.cc

+7-4
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ bool StartsWith(const std::string& str, std::string_view prefix) {
8989
return str.compare(0, prefix_len, prefix) == 0;
9090
}
9191

92+
bool FilenameIsConfigGypi(const std::string& path) {
93+
return path == "config.gypi" || EndsWith(path, "/config.gypi");
94+
}
95+
9296
typedef std::vector<std::string> FileList;
9397
typedef std::map<std::string, FileList> FileMap;
9498

@@ -707,7 +711,7 @@ int JS2C(const FileList& js_files,
707711
}
708712
}
709713

710-
assert(config == "config.gypi");
714+
assert(FilenameIsConfigGypi(config));
711715
// "config.gypi" -> config_raw.
712716
int r = AddGypi("config", config, &definitions);
713717
if (r != 0) {
@@ -789,10 +793,9 @@ int Main(int argc, char* argv[]) {
789793
// Should have exactly 3 types: `.js`, `.mjs` and `.gypi`.
790794
assert(file_map.size() == 3);
791795
auto gypi_it = file_map.find(".gypi");
792-
std::string config = "config.gypi";
793796
// Currently config.gypi is the only `.gypi` file allowed
794797
if (gypi_it == file_map.end() || gypi_it->second.size() != 1 ||
795-
gypi_it->second[0] != config) {
798+
!FilenameIsConfigGypi(gypi_it->second[0])) {
796799
fprintf(
797800
stderr,
798801
"Arguments should contain one and only one .gypi file: config.gypi\n");
@@ -805,7 +808,7 @@ int Main(int argc, char* argv[]) {
805808
std::sort(js_it->second.begin(), js_it->second.end());
806809
std::sort(mjs_it->second.begin(), mjs_it->second.end());
807810

808-
return JS2C(js_it->second, mjs_it->second, config, output);
811+
return JS2C(js_it->second, mjs_it->second, gypi_it->second[0], output);
809812
}
810813
} // namespace js2c
811814
} // namespace node

0 commit comments

Comments
 (0)