mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:12:43 +00:00 
			
		
		
		
	 24d2c90a28
			
		
	
	
		24d2c90a28
		
	
	
	
	
		
			
			This commit teaches BindingsGenerator to generate depfiles, which can be used by CMake to ensure that bindings are properly regenerated when imported IDL files change. Two new options, `--depfile` and `--depfile-target` are added. - `--depfile` sets the path for the dependency file. - `--depfile-target` lets us set a target name different than the output file in the depfile. This option is needed because generated files are first written to a temporary file, but depfiles have to refer to the final location. These are analogous to GCC's `-MF` and `-MT` options respectively. The depfile's syntax matches the ones generated by GCC. Note: This changes the minimal required CMake version to 3.20 if the Make generator is used, and to 3.21 for the Xcode generator. Ninja is not affected.
		
			
				
	
	
		
			73 lines
		
	
	
	
		
			2.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			73 lines
		
	
	
	
		
			2.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
 | |
|  * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
 | |
|  * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
 | |
|  * Copyright (c) 2022, Ali Mohammad Pur <mpfard@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/CharacterTypes.h>
 | |
| #include <AK/GenericLexer.h>
 | |
| #include <LibIDL/Types.h>
 | |
| 
 | |
| namespace IDL {
 | |
| 
 | |
| class Parser {
 | |
| public:
 | |
|     Parser(DeprecatedString filename, StringView contents, DeprecatedString import_base_path);
 | |
|     Interface& parse();
 | |
| 
 | |
|     Vector<DeprecatedString> imported_files() const;
 | |
| 
 | |
| private:
 | |
|     // https://webidl.spec.whatwg.org/#dfn-special-operation
 | |
|     // A special operation is a getter, setter or deleter.
 | |
|     enum class IsSpecialOperation {
 | |
|         No,
 | |
|         Yes,
 | |
|     };
 | |
| 
 | |
|     Parser(Parser* parent, DeprecatedString filename, StringView contents, DeprecatedString import_base_path);
 | |
| 
 | |
|     void assert_specific(char ch);
 | |
|     void assert_string(StringView expected);
 | |
|     void consume_whitespace();
 | |
|     Optional<Interface&> resolve_import(auto path);
 | |
| 
 | |
|     HashMap<DeprecatedString, DeprecatedString> parse_extended_attributes();
 | |
|     void parse_attribute(HashMap<DeprecatedString, DeprecatedString>& extended_attributes, Interface&);
 | |
|     void parse_interface(Interface&);
 | |
|     void parse_non_interface_entities(bool allow_interface, Interface&);
 | |
|     void parse_enumeration(Interface&);
 | |
|     void parse_typedef(Interface&);
 | |
|     void parse_interface_mixin(Interface&);
 | |
|     void parse_dictionary(Interface&);
 | |
|     void parse_callback_function(HashMap<DeprecatedString, DeprecatedString>& extended_attributes, Interface&);
 | |
|     void parse_constructor(Interface&);
 | |
|     void parse_getter(HashMap<DeprecatedString, DeprecatedString>& extended_attributes, Interface&);
 | |
|     void parse_setter(HashMap<DeprecatedString, DeprecatedString>& extended_attributes, Interface&);
 | |
|     void parse_deleter(HashMap<DeprecatedString, DeprecatedString>& extended_attributes, Interface&);
 | |
|     void parse_stringifier(HashMap<DeprecatedString, DeprecatedString>& extended_attributes, Interface&);
 | |
|     void parse_iterable(Interface&);
 | |
|     Function parse_function(HashMap<DeprecatedString, DeprecatedString>& extended_attributes, Interface&, IsSpecialOperation is_special_operation = IsSpecialOperation::No);
 | |
|     Vector<Parameter> parse_parameters();
 | |
|     NonnullRefPtr<Type> parse_type();
 | |
|     void parse_constant(Interface&);
 | |
| 
 | |
|     DeprecatedString import_base_path;
 | |
|     DeprecatedString filename;
 | |
|     StringView input;
 | |
|     GenericLexer lexer;
 | |
| 
 | |
|     HashTable<NonnullOwnPtr<Interface>>& top_level_interfaces();
 | |
|     HashTable<NonnullOwnPtr<Interface>> interfaces;
 | |
|     HashMap<DeprecatedString, Interface*>& top_level_resolved_imports();
 | |
|     HashMap<DeprecatedString, Interface*> resolved_imports;
 | |
|     Parser* top_level_parser();
 | |
|     Parser* parent = nullptr;
 | |
| };
 | |
| 
 | |
| }
 |