Class: FFI::Clang::Args
- Inherits:
-
Object
- Object
- FFI::Clang::Args
- Defined in:
- lib/ffi/clang/args/args.rb
Overview
Platform-specific clang configuration: finding libclang, locating the resource directory, and injecting extra command-line arguments into parse_translation_unit.
All discovery is lazy — nothing runs until a method is called.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#libclang_loaded_path ⇒ Object
writeonly
Set the loaded libclang path after ffi_lib succeeds, so resource dir probing can use it.
Class Method Summary collapse
-
.create ⇒ Object
Factory: returns the platform-appropriate subclass instance.
Instance Method Summary collapse
-
#command_line_args(command_line_args = []) ⇒ Object
Extra args to inject into parse_translation_unit.
-
#libclang_paths ⇒ Object
Ordered list of library paths for ffi_lib.
-
#post_load(library) ⇒ Object
Called after ffi_lib successfully loads libclang.
-
#resource_dir ⇒ Object
The resolved resource directory path.
Instance Attribute Details
#libclang_loaded_path=(value) ⇒ Object (writeonly)
Set the loaded libclang path after ffi_lib succeeds, so resource dir probing can use it.
19 20 21 |
# File 'lib/ffi/clang/args/args.rb', line 19 def libclang_loaded_path=(value) @libclang_loaded_path = value end |
Class Method Details
.create ⇒ Object
Factory: returns the platform-appropriate subclass instance.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ffi/clang/args/args.rb', line 23 def self.create case FFI::Clang.platform when :darwin DarwinArgs.new when :mingw MingwArgs.new when :mswin MswinArgs.new else LinuxArgs.new end end |
Instance Method Details
#command_line_args(command_line_args = []) ⇒ Object
Extra args to inject into parse_translation_unit. Includes -resource-dir (unless already present) plus any platform-specific flags.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/ffi/clang/args/args.rb', line 51 def command_line_args(command_line_args = []) args = [] if !command_line_args.include?("-resource-dir") && resource_dir args.push("-resource-dir", resource_dir) end args.concat(extra_args(command_line_args)) args end |
#libclang_paths ⇒ Object
Ordered list of library paths for ffi_lib.
38 39 40 41 42 43 44 |
# File 'lib/ffi/clang/args/args.rb', line 38 def libclang_paths @libclang_paths ||= if ENV["LIBCLANG"] [ENV["LIBCLANG"]] else find_libclang_paths end end |
#post_load(library) ⇒ Object
Called after ffi_lib successfully loads libclang. Subclasses may override to perform post-load setup.
76 77 |
# File 'lib/ffi/clang/args/args.rb', line 76 def post_load(library) end |
#resource_dir ⇒ Object
The resolved resource directory path.
64 65 66 67 68 69 70 |
# File 'lib/ffi/clang/args/args.rb', line 64 def resource_dir if defined?(@resource_dir) @resource_dir else @resource_dir = find_resource_dir end end |