mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
HackStudio: Check for make command on startup
This commit is contained in:
parent
fa8cec6627
commit
f5412f10cf
Notes:
sideshowbarker
2024-07-19 10:34:27 +09:00
Author: https://github.com/deoxxa Commit: https://github.com/SerenityOS/serenity/commit/f5412f10cf1 Pull-request: https://github.com/SerenityOS/serenity/pull/950
1 changed files with 23 additions and 0 deletions
|
@ -34,6 +34,7 @@
|
|||
#include <LibGUI/GWidget.h>
|
||||
#include <LibGUI/GWindow.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
NonnullRefPtrVector<EditorWrapper> g_all_editor_wrappers;
|
||||
|
@ -91,6 +92,7 @@ Editor& current_editor()
|
|||
static void build(TerminalWrapper&);
|
||||
static void run(TerminalWrapper&);
|
||||
void open_file(const String&);
|
||||
bool make_is_available();
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
@ -109,6 +111,9 @@ int main(int argc, char** argv)
|
|||
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
widget->layout()->set_spacing(0);
|
||||
|
||||
if (!make_is_available())
|
||||
GMessageBox::show("The 'make' command is not available. You probably want to install the binutils, gcc, and make ports from the root of the Serenity repository.", "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, g_window);
|
||||
|
||||
if (chdir("/home/anon/little") < 0) {
|
||||
perror("chdir");
|
||||
return 1;
|
||||
|
@ -578,3 +583,21 @@ void open_file(const String& filename)
|
|||
|
||||
current_editor().set_focus(true);
|
||||
}
|
||||
|
||||
bool make_is_available()
|
||||
{
|
||||
auto pid = fork();
|
||||
if (pid < 0)
|
||||
return false;
|
||||
|
||||
if (!pid) {
|
||||
int rc = execlp("make", "make", "--version", nullptr);
|
||||
ASSERT(rc < 0);
|
||||
perror("execl");
|
||||
exit(127);
|
||||
}
|
||||
|
||||
int wstatus;
|
||||
waitpid(pid, &wstatus, 0);
|
||||
return WEXITSTATUS(wstatus) == 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue