/* * Copyright (c) 2022, Itamar S. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include "AK/Error.h" #include "Project.h" #include "TerminalWrapper.h" #include #include namespace HackStudio { class ProjectBuilder { AK_MAKE_NONCOPYABLE(ProjectBuilder); public: ProjectBuilder(NonnullRefPtr, Project const&); ~ProjectBuilder() = default; ErrorOr build(StringView active_file); ErrorOr run(StringView active_file); private: enum class IsSerenityRepo { No, Yes }; ErrorOr build_serenity_component(); ErrorOr run_serenity_component(); ErrorOr initialize_build_directory(); Optional find_cmake_file_for(StringView file_path) const; DeprecatedString generate_cmake_file_content() const; ErrorOr update_active_file(StringView active_file); DeprecatedString build_directory() const; struct LibraryInfo { DeprecatedString path; Vector dependencies {}; }; static HashMap> get_defined_libraries(); static void for_each_library_definition(Function); static void for_each_library_dependencies(Function)>); static ErrorOr component_name(StringView cmake_file_path); static ErrorOr verify_cmake_is_installed(); static ErrorOr verify_make_is_installed(); DeprecatedString m_project_root; Project const& m_project; NonnullRefPtr m_terminal; IsSerenityRepo m_is_serenity { IsSerenityRepo::No }; DeprecatedString m_serenity_component_cmake_file; DeprecatedString m_serenity_component_name; }; }