udb 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 030b2114165b983357479c5b9f5c278ddcb859f6b89a529b2c632eb7227749dc
4
- data.tar.gz: e2be4d1bec8e2fc90c32b96f457b8ebb2cef0390d9a0b9f431ed34803d87f55f
3
+ metadata.gz: d153646bfddc91ed1ea91a1682e7a38185601ecdb3a930d20c997c9609cddcfa
4
+ data.tar.gz: 557547a04c8a9fba8c9d1af6aee8d2707c5ce4fa899371e171482fb2037cfc51
5
5
  SHA512:
6
- metadata.gz: cadc118ddaa3396e17d89c5d3b89e754bed287c50285f7b6711ad63f5ecc305e00de02de3e5abf7b58e39b38989f2b24f94c022209c7f2b4185e9599fcde33e9
7
- data.tar.gz: b1026028c8bd8a0c51fe497653b580fdc0af7c7e30878920a85aec71b6cc41c83e3b99bc84abbe63c6e7e8bb04371fe6cda49112245ce83de09ccca8a696f427
6
+ metadata.gz: 27848eabc18fca2cb68d75a062cab95157c4b2c8464910059ac45bf81eba0079aee491556d0e4c93d356bb2cebb506b64eb6435acbf6ea9ba10eb7138d3b96d2
7
+ data.tar.gz: 4603d6032e3762b1e16e805b63a328d52fb7766b6e4903dd351dfb5a69ca4db09614089e8a30a00cef69a0fa097f61706236f9d5b60fececd4d79fd8827cc70f
data/lib/udb/paths.rb ADDED
@@ -0,0 +1,91 @@
1
+ # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2
+ # SPDX-License-Identifier: BSD-3-Clause-Clear
3
+
4
+ # typed: true
5
+ # frozen_string_literal: true
6
+
7
+ require "pathname"
8
+ require "sorbet-runtime"
9
+
10
+ require_relative "version"
11
+
12
+ module Udb
13
+ extend T::Sig
14
+
15
+ sig { returns(Pathname) }
16
+ def self.gem_path
17
+ @gem_path ||= Pathname.new(Gem::Specification.find_by_name("udb").full_gem_path)
18
+ end
19
+
20
+ sig { params(from_dir: Pathname).returns(T.nilable(Pathname)) }
21
+ def self.find_udb_root(from_dir)
22
+ if from_dir.root?
23
+ nil
24
+ elsif (from_dir / "do").executable? && (from_dir / "spec").directory?
25
+ from_dir
26
+ else
27
+ find_udb_root(from_dir.dirname)
28
+ end
29
+ end
30
+ private_class_method :find_udb_root
31
+
32
+ sig { returns(T.nilable(Pathname)) }
33
+ def self.repo_root
34
+ @root ||=
35
+ if ENV.key?("UDB_ROOT")
36
+ Pathname.new(ENV["UDB_ROOT"])
37
+ else
38
+ find_udb_root(Pathname.new(__dir__))
39
+ end
40
+ end
41
+
42
+ sig { returns(Pathname) }
43
+ def self.default_std_isa_path
44
+ if repo_root.nil?
45
+ # not in the udb repo. try for a copy of the database stored with the gem
46
+ gem_path / ".data" / "spec" / "std" / "isa"
47
+ else
48
+ T.must(repo_root) / "spec" / "std" / "isa"
49
+ end
50
+ end
51
+
52
+ sig { returns(Pathname) }
53
+ def self.default_custom_isa_path
54
+ if repo_root.nil?
55
+ # not in the udb repo. try for a copy of the database stored with the gem
56
+ gem_path / ".data" / "spec" / "custom" / "isa"
57
+ else
58
+ T.must(repo_root) / "spec" / "custom" / "isa"
59
+ end
60
+ end
61
+
62
+ sig { returns(Pathname) }
63
+ def self.default_schemas_path
64
+ if repo_root.nil?
65
+ # not in the udb repo. try for a copy of the database stored with the gem
66
+ gem_path / ".data" / "spec" / "schemas"
67
+ else
68
+ T.must(repo_root) / "spec" / "schemas"
69
+ end
70
+ end
71
+
72
+ sig { returns(Pathname) }
73
+ def self.default_gen_path
74
+ if repo_root.nil?
75
+ # not in the udb repo. use XDG path
76
+ data_home = Pathname.new(ENV.fetch("XDG_DATA_HOME", "#{ENV["HOME"]}/.local/share"))
77
+ data_home / "udb" / Udb.version / "gen"
78
+ else
79
+ T.must(repo_root) / "gen"
80
+ end
81
+ end
82
+
83
+ sig { returns(Pathname) }
84
+ def self.default_cfgs_path
85
+ if repo_root.nil?
86
+ gem_path / ".data" / "cfgs"
87
+ else
88
+ T.must(repo_root) / "cfgs"
89
+ end
90
+ end
91
+ end
data/lib/udb/resolver.rb CHANGED
@@ -9,88 +9,10 @@ require "concurrent/hash"
9
9
  require "sorbet-runtime"
10
10
 
11
11
  require_relative "cfg_arch"
12
+ require_relative "paths"
12
13
  require_relative "yaml/yaml_resolver"
13
14
 
14
15
  module Udb
15
- extend T::Sig
16
-
17
- sig { returns(Pathname) }
18
- def self.gem_path
19
- @gem_path ||= Pathname.new(Gem::Specification.find_by_name("udb").full_gem_path)
20
- end
21
-
22
- sig { params(from_dir: Pathname).returns(T.nilable(Pathname)) }
23
- def self.find_udb_root(from_dir)
24
- if from_dir.root?
25
- nil
26
- elsif (from_dir / "do").executable? && (from_dir / "spec").directory?
27
- from_dir
28
- else
29
- find_udb_root(from_dir.dirname)
30
- end
31
- end
32
- private_class_method :find_udb_root
33
-
34
- sig { returns(T.nilable(Pathname)) }
35
- def self.repo_root
36
- @root ||=
37
- if ENV.key?("UDB_ROOT")
38
- Pathname.new(ENV["UDB_ROOT"])
39
- else
40
- find_udb_root(Pathname.new(__dir__))
41
- end
42
- end
43
-
44
- sig { returns(Pathname) }
45
- def self.default_std_isa_path
46
- if repo_root.nil?
47
- # not in the udb repo. try for a copy of the database stored with the gem
48
- gem_path / ".data" / "spec" / "std" / "isa"
49
- else
50
- T.must(repo_root) / "spec" / "std" / "isa"
51
- end
52
- end
53
-
54
- sig { returns(Pathname) }
55
- def self.default_custom_isa_path
56
- if repo_root.nil?
57
- # not in the udb repo. try for a copy of the database stored with the gem
58
- gem_path / ".data" / "spec" / "custom" / "isa"
59
- else
60
- T.must(repo_root) / "spec" / "custom" / "isa"
61
- end
62
- end
63
-
64
- sig { returns(Pathname) }
65
- def self.default_schemas_path
66
- if repo_root.nil?
67
- # not in the udb repo. try for a copy of the database stored with the gem
68
- gem_path / ".data" / "spec" / "schemas"
69
- else
70
- T.must(repo_root) / "spec" / "schemas"
71
- end
72
- end
73
-
74
- sig { returns(Pathname) }
75
- def self.default_gen_path
76
- if repo_root.nil?
77
- # not in the udb repo. use XDG path
78
- data_home = Pathname.new(ENV.fetch("XDG_DATA_HOME", "#{ENV["HOME"]}/.local/share"))
79
- data_home / "udb" / Udb.version / "gen"
80
- else
81
- T.must(repo_root) / "gen"
82
- end
83
- end
84
-
85
- sig { returns(Pathname) }
86
- def self.default_cfgs_path
87
- if repo_root.nil?
88
- gem_path / ".data" / "cfgs"
89
- else
90
- T.must(repo_root) / "cfgs"
91
- end
92
- end
93
-
94
16
  # resolves the specification in the context of a config, and writes to a generation folder
95
17
  #
96
18
  # The primary interface for users will be #cfg_arch_for
data/lib/udb/version.rb CHANGED
@@ -5,5 +5,5 @@
5
5
  # frozen_string_literal: true
6
6
 
7
7
  module Udb
8
- def self.version = "0.1.2"
8
+ def self.version = "0.1.3"
9
9
  end
@@ -16,6 +16,7 @@ require "idlc"
16
16
  require_relative "comment_parser"
17
17
  require_relative "preserving_emitter"
18
18
  require_relative "../log"
19
+ require_relative "../paths"
19
20
 
20
21
  module Udb
21
22
  module Yaml
@@ -44,11 +45,11 @@ module Udb
44
45
  end
45
46
 
46
47
  # Returns the path to JSON schema files.
47
- # Defaults to <repo_root>/spec/schemas but can be overridden via the constructor.
48
+ # Defaults to Udb.default_schemas_path but can be overridden via the constructor.
48
49
  sig { returns(Pathname) }
49
50
  def schemas_path
50
51
  if @schemas_path.nil?
51
- @schemas_path = Pathname.new(__dir__).parent.parent.parent.parent.parent.parent / "spec" / "schemas"
52
+ @schemas_path = Udb.default_schemas_path
52
53
  end
53
54
  T.must(@schemas_path)
54
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: udb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Hower
@@ -3058,6 +3058,7 @@ files:
3058
3058
  - lib/udb/obj/prm.rb
3059
3059
  - lib/udb/obj/profile.rb
3060
3060
  - lib/udb/obj/register_file.rb
3061
+ - lib/udb/paths.rb
3061
3062
  - lib/udb/portfolio_design.rb
3062
3063
  - lib/udb/presence.rb
3063
3064
  - lib/udb/prm_generator.rb