mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
ConfigureComponents: Reduce duplicated code
This commit is contained in:
parent
9f6eabd73a
commit
686efb6737
Notes:
sideshowbarker
2024-07-18 01:37:16 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/686efb6737d Pull-request: https://github.com/SerenityOS/serenity/pull/10749 Reviewed-by: https://github.com/EWouters ✅
1 changed files with 3 additions and 15 deletions
|
@ -45,18 +45,6 @@ enum class WhiptailMode {
|
|||
Checklist
|
||||
};
|
||||
|
||||
static Optional<String> get_current_working_directory()
|
||||
{
|
||||
char* cwd = getcwd(nullptr, 0);
|
||||
if (!cwd) {
|
||||
perror("getcwd");
|
||||
return {};
|
||||
}
|
||||
String data { cwd };
|
||||
free(cwd);
|
||||
return data;
|
||||
}
|
||||
|
||||
static Vector<ComponentData> read_component_data(Core::ConfigFile const& config_file)
|
||||
{
|
||||
VERIFY(!config_file.read_entry("Global", "build_everything", {}).is_empty());
|
||||
|
@ -236,10 +224,10 @@ int main()
|
|||
return 1;
|
||||
}
|
||||
|
||||
auto current_working_directory = get_current_working_directory();
|
||||
if (!current_working_directory.has_value())
|
||||
auto current_working_directory = Core::File::current_working_directory();
|
||||
if (current_working_directory.is_null())
|
||||
return 1;
|
||||
auto lexical_cwd = LexicalPath(*current_working_directory);
|
||||
auto lexical_cwd = LexicalPath(current_working_directory);
|
||||
auto& parts = lexical_cwd.parts_view();
|
||||
if (parts.size() < 2 || parts[parts.size() - 2] != "Build") {
|
||||
warnln("\e[31mError:\e[0m This program needs to be executed from inside 'Build/*'.");
|
||||
|
|
Loading…
Reference in a new issue