mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 10:18:15 +09:00

ProjectBuilder takes care of building and running the current project from Hack Studio. The existing functionality of building javascript and Makefile projects remains, and in addition to it the ability to build standalone serenity components is added. If the Hack Studio project is the serenity repository itself, ProjectBuilder will attempt building the component that the currently active file belongs to. It does so by creating a new CMake file which adds the component as a build subdirectory. It also parses all CMake files in the serenity repository to gather all available libraries. It declares the libraries and their dependencies in this CMake file. It then uses the HACKSTUDIO_BUILD CMake option to direct the build system to use this CMake file instead of doing a full system build.
52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2022, Itamar S. <itamar8910@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "AK/Error.h"
|
|
#include "Project.h"
|
|
#include "TerminalWrapper.h"
|
|
#include <AK/Noncopyable.h>
|
|
#include <LibCore/TempFile.h>
|
|
|
|
namespace HackStudio {
|
|
class ProjectBuilder {
|
|
|
|
AK_MAKE_NONCOPYABLE(ProjectBuilder);
|
|
|
|
public:
|
|
ProjectBuilder(NonnullRefPtr<TerminalWrapper>, Project const&);
|
|
~ProjectBuilder() = default;
|
|
|
|
ErrorOr<void> build(StringView active_file);
|
|
ErrorOr<void> run(StringView active_file);
|
|
|
|
private:
|
|
enum class IsSerenityRepo {
|
|
No,
|
|
Yes
|
|
};
|
|
|
|
ErrorOr<void> build_serenity_component();
|
|
ErrorOr<void> run_serenity_component();
|
|
ErrorOr<void> initialize_build_directory();
|
|
Optional<String> find_cmake_file_for(StringView file_path) const;
|
|
String generate_cmake_file_content() const;
|
|
ErrorOr<void> update_active_file(StringView active_file);
|
|
|
|
static void generate_cmake_library_definitions(StringBuilder&);
|
|
static void generate_cmake_library_dependencies(StringBuilder&);
|
|
static ErrorOr<String> component_name(StringView cmake_file_path);
|
|
static ErrorOr<void> verify_cmake_is_installed();
|
|
|
|
String m_project_root;
|
|
NonnullRefPtr<TerminalWrapper> m_terminal;
|
|
IsSerenityRepo m_is_serenity { IsSerenityRepo::No };
|
|
OwnPtr<Core::TempFile> m_build_directory;
|
|
String m_serenity_component_cmake_file;
|
|
String m_serenity_component_name;
|
|
};
|
|
}
|