File: presym.rake

package info (click to toggle)
mruby 3.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,584 kB
  • sloc: ansic: 51,933; ruby: 29,510; yacc: 7,077; cpp: 517; makefile: 51; sh: 42
file content (48 lines) | stat: -rw-r--r-- 1,603 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
all_prerequisites = ->(task_name, prereqs) do
  Rake::Task[task_name].prerequisites.each do |prereq_name|
    next if prereqs[prereq_name]
    prereqs[prereq_name] = true
    all_prerequisites.(Rake::Task[prereq_name].name, prereqs)
  end
end

MRuby.each_target do |build|
  gensym_task = task(:gensym)
  next unless build.presym_enabled?

  presym = build.presym

  include_dir = "#{build.build_dir}/include"
  build.compilers.each{|c| c.include_paths << include_dir}
  build.gems.each{|gem| gem.compilers.each{|c| c.include_paths << include_dir}}

  prereqs = {}
  ppps = []
  build_dir = "#{build.build_dir}/"
  mrbc_build_dir = "#{build.mrbc_build.build_dir}/" if build.mrbc_build
  build.products.each{|product| all_prerequisites.(product, prereqs)}
  prereqs.each_key do |prereq|
    next unless File.extname(prereq) == build.exts.object
    next unless prereq.start_with?(build_dir)
    next if mrbc_build_dir && prereq.start_with?(mrbc_build_dir)
    ppp = prereq.ext(build.exts.presym_preprocessed)
    if Rake.application.lookup(ppp) ||
       Rake.application.enhance_with_matching_rule(ppp)
      ppps << ppp
    end
  end

  file presym.list_path => ppps do
    presyms = presym.scan(ppps)
    current_presyms = presym.read_list if File.exist?(presym.list_path)
    update = presyms != current_presyms
    presym.write_list(presyms) if update
    mkdir_p presym.header_dir
    %w[id table].each do |type|
      next if !update && File.exist?(presym.send("#{type}_header_path"))
      presym.send("write_#{type}_header", presyms)
    end
  end

  gensym_task.enhance([presym.list_path])
end