mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:07:34 +00:00
HackStudio: Check for make command on startup
This commit is contained in:
parent
fa8cec6627
commit
f5412f10cf
1 changed files with 23 additions and 0 deletions
|
@ -34,6 +34,7 @@
|
||||||
#include <LibGUI/GWidget.h>
|
#include <LibGUI/GWidget.h>
|
||||||
#include <LibGUI/GWindow.h>
|
#include <LibGUI/GWindow.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
NonnullRefPtrVector<EditorWrapper> g_all_editor_wrappers;
|
NonnullRefPtrVector<EditorWrapper> g_all_editor_wrappers;
|
||||||
|
@ -91,6 +92,7 @@ Editor& current_editor()
|
||||||
static void build(TerminalWrapper&);
|
static void build(TerminalWrapper&);
|
||||||
static void run(TerminalWrapper&);
|
static void run(TerminalWrapper&);
|
||||||
void open_file(const String&);
|
void open_file(const String&);
|
||||||
|
bool make_is_available();
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
@ -109,6 +111,9 @@ int main(int argc, char** argv)
|
||||||
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||||
widget->layout()->set_spacing(0);
|
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) {
|
if (chdir("/home/anon/little") < 0) {
|
||||||
perror("chdir");
|
perror("chdir");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -578,3 +583,21 @@ void open_file(const String& filename)
|
||||||
|
|
||||||
current_editor().set_focus(true);
|
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…
Add table
Add a link
Reference in a new issue