mirror of
https://github.com/RGBCube/serenity
synced 2025-07-12 13:47:36 +00:00

Previously when generating the HackStudio CMake build file, we used all dependency libraries that are specified in target_link_libraries commands as the dependencies of a library. The recent addition of LibCryptSHA2 broke things because that library is not declared with serenity_lib like most other libraries (it uses special linking properties). This means that we don't declare it in the CMake file we generate. To fix this, we now filter the dependencies and only include libraries that we define in the build CMake file.
57 lines
1.6 KiB
C++
57 lines
1.6 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);
|
|
|
|
struct LibraryInfo {
|
|
String path;
|
|
Vector<String> dependencies {};
|
|
};
|
|
static HashMap<String, NonnullOwnPtr<LibraryInfo>> get_defined_libraries();
|
|
static void for_each_library_definition(Function<void(String, String)>);
|
|
static void for_each_library_dependencies(Function<void(String, Vector<StringView>)>);
|
|
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;
|
|
};
|
|
}
|