mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 02:03:06 -05:00
LibWeb: Use the LibWeb source directory as the IDL #import base path
This allows us to include IDL files from other base LibWeb directories wihout using relative `../foo.idl` references.
This commit is contained in:
parent
bd648d082c
commit
7f551d7f6a
Notes:
sideshowbarker
2024-07-18 03:14:33 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/7f551d7f6a7 Pull-request: https://github.com/SerenityOS/serenity/pull/10299
3 changed files with 13 additions and 7 deletions
|
@ -185,7 +185,7 @@ struct Interface {
|
|||
bool is_legacy_platform_object() const { return !extended_attributes.contains("Global") && (supports_indexed_properties() || supports_named_properties()); }
|
||||
};
|
||||
|
||||
static NonnullOwnPtr<Interface> parse_interface(StringView filename, StringView input)
|
||||
static NonnullOwnPtr<Interface> parse_interface(StringView filename, StringView input, StringView import_base_path)
|
||||
{
|
||||
auto interface = make<Interface>();
|
||||
|
||||
|
@ -233,7 +233,7 @@ static NonnullOwnPtr<Interface> parse_interface(StringView filename, StringView
|
|||
};
|
||||
|
||||
auto resolve_import = [&](auto path) {
|
||||
auto include_path = LexicalPath::join(LexicalPath::dirname(filename), path).string();
|
||||
auto include_path = LexicalPath::join(import_base_path, path).string();
|
||||
if (!Core::File::exists(include_path))
|
||||
report_parsing_error(String::formatted("{}: No such file or directory", include_path), filename, input, lexer.tell());
|
||||
|
||||
|
@ -242,7 +242,7 @@ static NonnullOwnPtr<Interface> parse_interface(StringView filename, StringView
|
|||
report_parsing_error(String::formatted("Failed to open {}: {}", include_path, file_or_error.error()), filename, input, lexer.tell());
|
||||
|
||||
auto data = file_or_error.value()->read_all();
|
||||
return IDL::parse_interface(include_path, data);
|
||||
return IDL::parse_interface(include_path, data, import_base_path);
|
||||
};
|
||||
|
||||
NonnullOwnPtrVector<Interface> imports;
|
||||
|
@ -690,7 +690,8 @@ static void generate_iterator_implementation(IDL::Interface const&);
|
|||
int main(int argc, char** argv)
|
||||
{
|
||||
Core::ArgsParser args_parser;
|
||||
char const* path = nullptr;
|
||||
StringView path = nullptr;
|
||||
StringView import_base_path = nullptr;
|
||||
bool header_mode = false;
|
||||
bool implementation_mode = false;
|
||||
bool constructor_header_mode = false;
|
||||
|
@ -712,6 +713,7 @@ int main(int argc, char** argv)
|
|||
args_parser.add_option(iterator_prototype_header_mode, "Generate the iterator prototype .h file", "iterator-prototype-header", 0);
|
||||
args_parser.add_option(iterator_prototype_implementation_mode, "Generate the iterator prototype .cpp file", "iterator-prototype-implementation", 0);
|
||||
args_parser.add_positional_argument(path, "IDL file", "idl-file");
|
||||
args_parser.add_positional_argument(import_base_path, "Import base path", "import-base-path", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
auto file_or_error = Core::File::open(path, Core::OpenMode::ReadOnly);
|
||||
|
@ -724,7 +726,11 @@ int main(int argc, char** argv)
|
|||
auto& namespace_ = lexical_path.parts_view().at(lexical_path.parts_view().size() - 2);
|
||||
|
||||
auto data = file_or_error.value()->read_all();
|
||||
auto interface = IDL::parse_interface(path, data);
|
||||
|
||||
if (import_base_path.is_null())
|
||||
import_base_path = lexical_path.dirname();
|
||||
|
||||
auto interface = IDL::parse_interface(path, data, import_base_path);
|
||||
|
||||
if (namespace_.is_one_of("Crypto", "CSS", "DOM", "HTML", "UIEvents", "Geometry", "HighResolutionTime", "NavigationTiming", "RequestIdleCallback", "SVG", "XHR", "URL")) {
|
||||
StringBuilder builder;
|
||||
|
|
|
@ -323,7 +323,7 @@ function(libweb_js_wrapper class)
|
|||
list(GET BINDINGS_TYPES ${iter} bindings_type)
|
||||
add_custom_command(
|
||||
OUTPUT "${bindings_src}"
|
||||
COMMAND "$<TARGET_FILE:Lagom::WrapperGenerator>" "--${bindings_type}" "${CMAKE_CURRENT_SOURCE_DIR}/${class}.idl" > "${bindings_src}.tmp"
|
||||
COMMAND "$<TARGET_FILE:Lagom::WrapperGenerator>" "--${bindings_type}" "${CMAKE_CURRENT_SOURCE_DIR}/${class}.idl" "${CMAKE_CURRENT_SOURCE_DIR}/" > "${bindings_src}.tmp"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${bindings_src}.tmp" "${bindings_src}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove "${bindings_src}.tmp"
|
||||
VERBATIM
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#import <Event.idl>
|
||||
#import <DOM/Event.idl>
|
||||
|
||||
[Exposed=(Window,Worker), CustomVisit]
|
||||
interface CustomEvent : Event {
|
||||
|
|
Loading…
Add table
Reference in a new issue