1 --- a/src/generator/main.cr 2023-07-14 18:30:47.687581729 +0300
2 +++ b/src/generator/main.cr 2023-07-17 07:55:24.177630085 +0300
6 require "option_parser"
10 require "./binding_config"
16 - output_dir = Path.new(project_dir, "lib/gi-crystal/src/auto").normalize if output_dir.nil?
17 + output_dir = Path.new(Dir.current, "lib/gi-crystal/src/auto").normalize if output_dir.nil?
18 extra_bindings = argv.map { |path| Path.new(path).expand.to_s }
20 {output_dir: output_dir,
25 -private def find_bindings : Array(String)
26 - find_pattern = Path.new(project_dir, "**/binding.yml").normalize
27 +private def find_bindings_yml(path) : Array(String)
28 + find_pattern = File.join(path, "**/binding.yml")
32 +private def find_bindings : Array(String)
33 + current_directory = Dir.current
35 + bindings = find_bindings_yml(current_directory)
36 + Dir.glob(File.join(current_directory, "**/*")).each do |path|
37 + if File.symlink?(path)
38 + bindings += find_bindings_yml(path)
44 private def format_files(dir)
45 # We need to chdir into output dir since the formatter ignores everything under `lib` dir.
46 Dir.cd(dir) { `crystal tool format` }
48 Log.info { "Generating bindings at #{options[:output_dir]}" }
50 Generator::DocRepo.disable! unless options[:doc_gen]
53 + FileUtils.cp_r(project_dir, File.join(Dir.current, "lib/gi-crystal"))
55 binding_yamls = find_bindings.concat(options[:extra_bindings])
56 binding_yamls.each do |file|
57 Log.info { "Using binding config at #{file}" }