2023-04-03 22:36:01 +02:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require "bundler/setup"
|
|
|
|
require "comfpile"
|
|
|
|
|
|
|
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
|
|
# with your gem easier. You can also use a different console, if you like.
|
|
|
|
|
|
|
|
$core = Comfpile::Core.new()
|
|
|
|
|
2023-04-14 16:02:34 +02:00
|
|
|
$core.add_artefact_engine Comfpile::FilesourceEngine, root_path: File.join(File.dirname(__FILE__), '../test/faux_build_dir')
|
2023-04-17 16:55:54 +02:00
|
|
|
$core.add_artefact_engine Comfpile::ConfigLoaderEngine
|
2023-04-14 16:02:34 +02:00
|
|
|
|
|
|
|
$core.add_artefact_engine Comfpile::ParserEngine,
|
|
|
|
file_regex: /^(.+)\.(h|c|cpp)$/,
|
|
|
|
search_regexes: [
|
|
|
|
{
|
|
|
|
regex: /^#include\s*[<"](?<value>.+)[>"]/,
|
|
|
|
key: 'include'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
regex: /\/\/\s*comf\.(?<key>\w+)[=:]\s*(?<value>.+)/
|
|
|
|
}
|
|
|
|
]
|
2023-04-17 16:56:33 +02:00
|
|
|
$core.add_artefact_engine Comfpile::ParserEngine,
|
|
|
|
file_regex: /^(.+)\.vhd$/,
|
|
|
|
search_regexes: [
|
|
|
|
{
|
|
|
|
regex: /--+\s*comf\.(?<key>[^:]+)[=:]\s*(?<value>.+)/
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
$core.add_artefact_engine do |engine|
|
|
|
|
engine.add_recipe(:ghdl_analysed, /^(.+)\.vhd/) do |match, a|
|
|
|
|
a.parent_artefact :dependency_analysis_include, a.target
|
|
|
|
|
|
|
|
a.add_step do
|
|
|
|
@parent_artefact.dependencies.each do |dependency|
|
|
|
|
next if dependency.target == a.target
|
|
|
|
|
|
|
|
log "Adding dependency for ghdl analysis of #{dependency.target}..."
|
|
|
|
|
|
|
|
require_artefact :ghdl_analysed, dependency.target
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
a.add_step do
|
|
|
|
work_library = find_parsed_parameter('vhdl.work')
|
|
|
|
if work_library.nil?
|
|
|
|
work_library = ''
|
|
|
|
else
|
|
|
|
work_library = '--work=' + work_library
|
|
|
|
end
|
|
|
|
|
|
|
|
cmd = "ghdl -a -fsynopsys --std=08 #{work_library} #{self.file}"
|
|
|
|
log "Executing: #{cmd}"
|
|
|
|
|
|
|
|
`#{cmd}`
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
engine.add_recipe(:ghdl_elaborated, /^(.+)\.vhd/) do |match, a|
|
|
|
|
a.parent_artefact :dependency_analysis, a.target
|
|
|
|
|
|
|
|
a.add_step do
|
|
|
|
dependencies.each do |dep|
|
|
|
|
require_artefact :ghdl_analysed, dep.target
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
a.add_step do
|
|
|
|
work_library = find_parsed_parameter('vhdl.work')
|
|
|
|
if work_library.nil?
|
|
|
|
work_library = ''
|
|
|
|
else
|
|
|
|
work_library = '--work=' + work_library
|
|
|
|
end
|
|
|
|
|
|
|
|
elaborate_arch = find_parsed_parameter('vhdl.elaborate') || File.basename(@target).chomp(File.extname(@target))
|
|
|
|
|
|
|
|
cmd = "ghdl -e -fsynopsys --std=08 #{work_library} #{elaborate_arch}"
|
|
|
|
log "Executing: #{cmd}"
|
|
|
|
|
|
|
|
`#{cmd}`
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
engine.add_recipe :ghdl_run, /^(.+)\.vhd/ do |match, a|
|
|
|
|
a.parent_artefact :ghdl_elaborated, a.target
|
|
|
|
|
|
|
|
a.add_step do
|
|
|
|
work_library = find_parsed_parameter('vhdl.work')
|
|
|
|
if work_library.nil?
|
|
|
|
work_library = ''
|
|
|
|
else
|
|
|
|
work_library = '--work=' + work_library
|
|
|
|
end
|
|
|
|
|
|
|
|
elaborate_arch = find_parsed_parameter('vhdl.elaborate') || File.basename(@target).chomp(File.extname(@target))
|
|
|
|
|
|
|
|
@parameters[:ghdl_arch] = elaborate_arch
|
|
|
|
|
|
|
|
cmd = "ghdl -r -fsynopsys --std=08 #{work_library} #{elaborate_arch} --wave=#{elaborate_arch}.ghw"
|
|
|
|
log "Executing: #{cmd}"
|
|
|
|
|
|
|
|
`#{cmd}`
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
engine.add_recipe(:gtkwave_output, /^(.+)\.vhd/) do |match, a|
|
|
|
|
a.parent_artefact :ghdl_run, a.target
|
|
|
|
a.add_step do
|
|
|
|
`gtkwave #{@parent_artefact[:ghdl_arch]}.ghw`
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2023-04-03 22:36:01 +02:00
|
|
|
|
|
|
|
$core.add_artefact_engine do |engine|
|
|
|
|
|
|
|
|
engine.add_recipe(:dependency_list, /^(.+)\.(h|c|cpp)$/) do |match, a|
|
|
|
|
|
2023-04-14 16:02:34 +02:00
|
|
|
a.require_artefact :dependency_analysis, a.target
|
|
|
|
a.require_artefact :dependency_analysis_include, a.target
|
2023-04-03 22:36:01 +02:00
|
|
|
|
2023-04-14 16:02:34 +02:00
|
|
|
a.add_step do
|
|
|
|
deps_artefact = find_artefact(:dependency_analysis, @target)
|
|
|
|
@parameters[:dependency_list] = deps_artefact.dependencies
|
2023-04-03 22:36:01 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
engine.add_recipe(:x86_debug, /^run (.+)/) do |match, a|
|
|
|
|
|
|
|
|
a.require_artefact :parsed, "#{match[1]}.cpp"
|
|
|
|
end
|
|
|
|
|
|
|
|
engine.add_recipe(:x86_debug, /(.+)\.o$/) do |match, a|
|
|
|
|
a.require_artefact :sourcefile, "#{match[1]}.cpp"
|
|
|
|
|
|
|
|
a.add_step do
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
|
|
require "pry"
|
|
|
|
Pry.start
|
|
|
|
|