mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +00:00
HackStudio: Put the Build directory inside the Serenity repository
Previously, the build directory for building serenity components was a temporary directory in /tmp which was generated whenever a different serenity component was built. Instead of doing that, Hack Studio now simply uses the Build/ directory inside the Serenity repository, similar to what is done in host builds. This makes it so we don't re-build when switching back and forth between different components. It also makes it easier to inspect the build products.
This commit is contained in:
parent
83688d0610
commit
506c13d143
2 changed files with 17 additions and 11 deletions
|
@ -64,7 +64,7 @@ ErrorOr<void> ProjectBuilder::run(StringView active_file)
|
||||||
ErrorOr<void> ProjectBuilder::run_serenity_component()
|
ErrorOr<void> ProjectBuilder::run_serenity_component()
|
||||||
{
|
{
|
||||||
auto relative_path_to_dir = LexicalPath::relative_path(LexicalPath::dirname(m_serenity_component_cmake_file), m_project_root);
|
auto relative_path_to_dir = LexicalPath::relative_path(LexicalPath::dirname(m_serenity_component_cmake_file), m_project_root);
|
||||||
m_terminal->run_command(LexicalPath::join(relative_path_to_dir, m_serenity_component_name).string(), LexicalPath::join(m_build_directory->path(), "Build").string());
|
m_terminal->run_command(LexicalPath::join(relative_path_to_dir, m_serenity_component_name).string(), build_directory());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,9 +80,6 @@ ErrorOr<void> ProjectBuilder::update_active_file(StringView active_file)
|
||||||
if (m_serenity_component_cmake_file == cmake_file.value())
|
if (m_serenity_component_cmake_file == cmake_file.value())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
if (!m_serenity_component_cmake_file.is_null())
|
|
||||||
m_build_directory.clear();
|
|
||||||
|
|
||||||
m_serenity_component_cmake_file = cmake_file.value();
|
m_serenity_component_cmake_file = cmake_file.value();
|
||||||
m_serenity_component_name = TRY(component_name(m_serenity_component_cmake_file));
|
m_serenity_component_name = TRY(component_name(m_serenity_component_cmake_file));
|
||||||
|
|
||||||
|
@ -92,7 +89,7 @@ ErrorOr<void> ProjectBuilder::update_active_file(StringView active_file)
|
||||||
|
|
||||||
ErrorOr<void> ProjectBuilder::build_serenity_component()
|
ErrorOr<void> ProjectBuilder::build_serenity_component()
|
||||||
{
|
{
|
||||||
m_terminal->run_command(String::formatted("make {}", m_serenity_component_name), LexicalPath::join(m_build_directory->path(), "Build"sv).string(), TerminalWrapper::WaitForExit::Yes);
|
m_terminal->run_command(String::formatted("make {}", m_serenity_component_name), build_directory(), TerminalWrapper::WaitForExit::Yes);
|
||||||
if (m_terminal->child_exit_status() == 0)
|
if (m_terminal->child_exit_status() == 0)
|
||||||
return {};
|
return {};
|
||||||
return Error::from_string_literal("Make failed"sv);
|
return Error::from_string_literal("Make failed"sv);
|
||||||
|
@ -112,19 +109,23 @@ ErrorOr<String> ProjectBuilder::component_name(StringView cmake_file_path)
|
||||||
|
|
||||||
ErrorOr<void> ProjectBuilder::initialize_build_directory()
|
ErrorOr<void> ProjectBuilder::initialize_build_directory()
|
||||||
{
|
{
|
||||||
m_build_directory = Core::TempFile::create(Core::TempFile::Type::Directory);
|
if (!Core::File::exists(build_directory())) {
|
||||||
if (mkdir(LexicalPath::join(m_build_directory->path(), "Build").string().characters(), 0700)) {
|
if (mkdir(LexicalPath::join(build_directory()).string().characters(), 0700)) {
|
||||||
return Error::from_errno(errno);
|
return Error::from_errno(errno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cmake_file_path = LexicalPath::join(m_build_directory->path(), "CMakeLists.txt").string();
|
auto cmake_file_path = LexicalPath::join(build_directory(), "CMakeLists.txt").string();
|
||||||
|
if (Core::File::exists(cmake_file_path))
|
||||||
|
MUST(Core::File::remove(cmake_file_path, Core::File::RecursionMode::Disallowed, false));
|
||||||
|
|
||||||
auto cmake_file = TRY(Core::File::open(cmake_file_path, Core::OpenMode::WriteOnly));
|
auto cmake_file = TRY(Core::File::open(cmake_file_path, Core::OpenMode::WriteOnly));
|
||||||
cmake_file->write(generate_cmake_file_content());
|
cmake_file->write(generate_cmake_file_content());
|
||||||
|
|
||||||
m_terminal->run_command(String::formatted("cmake -S {} -DHACKSTUDIO_BUILD=ON -DHACKSTUDIO_BUILD_CMAKE_FILE={}"
|
m_terminal->run_command(String::formatted("cmake -S {} -DHACKSTUDIO_BUILD=ON -DHACKSTUDIO_BUILD_CMAKE_FILE={}"
|
||||||
" -DENABLE_UNICODE_DATABASE_DOWNLOAD=OFF",
|
" -DENABLE_UNICODE_DATABASE_DOWNLOAD=OFF",
|
||||||
m_project_root, cmake_file_path),
|
m_project_root, cmake_file_path),
|
||||||
LexicalPath::join(m_build_directory->path(), "Build"sv).string(), TerminalWrapper::WaitForExit::Yes);
|
build_directory(), TerminalWrapper::WaitForExit::Yes);
|
||||||
|
|
||||||
if (m_terminal->child_exit_status() == 0)
|
if (m_terminal->child_exit_status() == 0)
|
||||||
return {};
|
return {};
|
||||||
|
@ -245,4 +246,9 @@ ErrorOr<void> ProjectBuilder::verify_cmake_is_installed()
|
||||||
return Error::from_string_literal("CMake port is not installed"sv);
|
return Error::from_string_literal("CMake port is not installed"sv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String ProjectBuilder::build_directory() const
|
||||||
|
{
|
||||||
|
return LexicalPath::join(m_project_root, "Build"sv).string();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ private:
|
||||||
Optional<String> find_cmake_file_for(StringView file_path) const;
|
Optional<String> find_cmake_file_for(StringView file_path) const;
|
||||||
String generate_cmake_file_content() const;
|
String generate_cmake_file_content() const;
|
||||||
ErrorOr<void> update_active_file(StringView active_file);
|
ErrorOr<void> update_active_file(StringView active_file);
|
||||||
|
String build_directory() const;
|
||||||
|
|
||||||
struct LibraryInfo {
|
struct LibraryInfo {
|
||||||
String path;
|
String path;
|
||||||
|
@ -50,7 +51,6 @@ private:
|
||||||
String m_project_root;
|
String m_project_root;
|
||||||
NonnullRefPtr<TerminalWrapper> m_terminal;
|
NonnullRefPtr<TerminalWrapper> m_terminal;
|
||||||
IsSerenityRepo m_is_serenity { IsSerenityRepo::No };
|
IsSerenityRepo m_is_serenity { IsSerenityRepo::No };
|
||||||
OwnPtr<Core::TempFile> m_build_directory;
|
|
||||||
String m_serenity_component_cmake_file;
|
String m_serenity_component_cmake_file;
|
||||||
String m_serenity_component_name;
|
String m_serenity_component_name;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue