1

我正在阅读有关遥控器的 Origen 文档并有一个问题。何时相对于Origen 回调检索远程文件?我问的原因是我们要检索的文件将用于构建我们的 DUT 模型,并且存在一些顺序依赖性。

我已经尝试了所有现有的回调,试图配置遥控器,但没有成功。

def pre_initialize
  Origen.app.config.remotes = [
    {
      dir: 'product',
      vault: 'ssh://git@stash.com/myproduct/origen.git',
      version: '0.1.0'
    }
  ]
end

如果我将遥控器配置添加到应用程序文件中,它可以工作:

config.remotes = [
    {
      dir: 'product',
      vault: 'ssh://git@stash.com/myproduct/origen.git',
      version: '0.1.0'
    }
  ]

使用 config/application.rb 文件的问题是我们无法将产品特定信息保存在应用程序空间的任何位置。我们使用符号链接映射到存储在测试程序存储库中的源文件。我想我们可能需要一个新的回调,请告知。

谢谢

** 编辑 **

所以我在另一个文件中定义了遥控器,并在 boot.rb 文件中调用该方法来实际执行它。然后我将远程管理器 require 方法放在 on_create 回调中,但没有获取任何遥控器。

    284: def on_create
    285:   binding.pry
 => 286:   Origen.remote_manager.require!
    287: end

[1] pry(#<PPEKit::Product>)> Origen.config.remotes
=> [{:dir=>"remote_checkout", :rc_url=>"ssh://git@stash.us.com:7999/osdk/us-calendar.git", :version=>"v0.1.0"}]
[2] pry(#<PPEKit::Product>)>
origen(main):001:0>

好像是 Origen.remote_manager.require!不管用。所以我检查了远程管理器文件,没有看到需要!方法可以使用回调,因为它似乎正在检查遥控器是否脏,这对于在 application.rb 文件加载后设置的远程定义永远不会发生。所以我创建了一个resolve_remotes!似乎有效的方法:

def resolve_remotes!
  resolve_remotes
  remotes.each do |_name, remote|
    dir = workspace_of(remote)
    rc_url = remote[:rc_url] || remote[:vault]
    tag = Origen::VersionString.new(remote[:version])
    version_file = dir.to_s + '/.current_version'
    begin
      if File.exist?("#{dir}/.initial_populate_successful")
        FileUtils.rm_f(version_file) if File.exist?(version_file)
        rc = RevisionControl.new remote: rc_url, local: dir
        rc.checkout version: prefix_tag(tag), force: true
        File.open(version_file, 'w') do |f|
          f.write tag
        end
      else
        rc = RevisionControl.new remote: rc_url, local: dir
        rc.checkout version: prefix_tag(tag), force: true
        FileUtils.touch "#{dir}/.initial_populate_successful"
        File.open(version_file, 'w') do |f|
          f.write tag
        end
      end
    rescue Origen::GitError, Origen::DesignSyncError => e
      # If Git failed in the remote, its usually easy to see what the problem is, but now *where* it is.
      # This will prepend the failing remote along with the error from the revision control system,
      # then rethrow the error
      e.message.prepend "When updating remotes for #{remote[:importer].name}: "
      raise e
    end
  end
end

解决遥控器!方法只是强制获取所有已知的遥控器。这个解决方案会接受 PR 吗?

谢谢

4

1 回答 1

1

目前在应用程序加载时需要远程,这意味着它发生在任何应用程序回调点之前。

的内容config.remotes仍然可以通过在块中分配来动态化:

config.remotes do
  r = [{
    dir: 'product',
    vault: 'ssh://git@stash.com/myproduct/origen.git',
    version: '0.1.0'
  }]

  if some_condition
    r << { dir: ... }
  end

  r      
end

但是,将在加载目标之前评估该config.remotes属性,因此您将无法引用dut例如,尽管这可能已经足够好了。

或者,您可以很容易地在您的应用程序中实现远程目标的发布目标。

如果 dut 尚不可用,则使遥控器返回一个空数组,这将使其在应用程序加载期间被 Origen 调用时正常工作:

config.remotes do
  if dut
    # As above example
  else
    []
  end
end

然后在您选择的回调处理程序中:

Origen.remote_manager.require!

这应该会导致它重新评估config.remotes并获取任何丢失的遥控器。

于 2018-02-21T07:57:04.617 回答