mt-lang 0.2.2 → 0.2.4

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: 4cffe1ff676e4ac5144fe70cf4e7be194072adc1291c59fa38678e1f4082e00f
4
- data.tar.gz: 0bc2bf96c010bab477df55452c835bd82ff6e18ce96d2b3f18ce6fa648ae2f59
3
+ metadata.gz: e084e93ef653242052b06a0357bc6b67a9ec1f29f966dd4cff918218d950812e
4
+ data.tar.gz: a0a20b5e101aaef6f21e28487b24beaf116c60fa8b36f5cc1bf81ea716102124
5
5
  SHA512:
6
- metadata.gz: 24e0c9b23bdde1e472073a5fcbf39ac5742bce6df1ccc7b1688a7fffed9ad71aa8f681056e582e3d310a338790045a23f292daf91872b511eaa92576fa320adf
7
- data.tar.gz: 3e33af1f89a1c8571182fd11bbec65e10088c51f0f2105af131f50dccc77e93aa06cd05dd3aa4b666038d080f2dc52f4da9935686df8ec97d88b915d5663d91c
6
+ metadata.gz: '00458f0f8f2250b76f257643bafbd9868adc31c609ff73b35ae913aadacaefa14b782da12114f1f7bdad95534430e21f841baea279cbf90f1ea8a763b1c9d14b'
7
+ data.tar.gz: 243c6c9c8b9fd48c3ddc8fc4c6dad82a95666418e0d6f52df34733458bd7318deab8b9ba16b2a04e2418a4c259c80ac856121c44a4c23e9ef3bd50a351f061cb
data/lib/milk_tea/base.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require "pathname"
4
4
 
5
5
  module MilkTea
6
- VERSION = "0.2.2"
6
+ VERSION = "0.2.4"
7
7
 
8
8
  def self.root
9
9
  @root ||= Pathname.new(File.expand_path("../..", __dir__))
@@ -9,9 +9,10 @@ module MilkTea
9
9
  end
10
10
 
11
11
  def self.build_all!(root: MilkTea.root)
12
+ data = MilkTea.writable_root_for(root)
12
13
  results = all(root:).map do |tool|
13
14
  binary = tool.build!
14
- install = tool.install_path(root:)
15
+ install = tool.install_path(root: data)
15
16
  FileUtils.mkdir_p(File.dirname(install))
16
17
  FileUtils.cp(binary, install)
17
18
  FileUtils.chmod(0o755, install)
@@ -5,8 +5,9 @@ require_relative "vendored_tool"
5
5
  module MilkTea
6
6
  module VendoredTracy
7
7
  def self.library(root: MilkTea.root)
8
- source = MilkTea.writable_root_for(root).join("third_party/tracy-upstream/public/TracyClient.cpp")
9
- build = MilkTea.writable_root_for(root).join("tmp/tracy-lib")
8
+ data = MilkTea.writable_root_for(root)
9
+ source = data.join("third_party/tracy-upstream/public/TracyClient.cpp")
10
+ build = data.join("tmp/tracy-lib")
10
11
  MilkTea::VendoredCLibrary::Archive.new(
11
12
  name: "tracy",
12
13
  source_root: source.dirname,
@@ -20,11 +21,12 @@ module MilkTea
20
21
  end
21
22
 
22
23
  def self.profiler_tool(root: MilkTea.root)
23
- upstream_root = root.join("third_party/tracy-upstream")
24
+ data = MilkTea.writable_root_for(root)
25
+ source_dir = data.join("third_party/tracy-upstream/profiler")
24
26
  MilkTea::VendoredTool.new(
25
27
  name: "tracy-profiler",
26
- source_dir: upstream_root.join("profiler").to_s,
27
- build_dir: MilkTea.writable_root_for(root).join("tmp/tracy-profiler-build").to_s,
28
+ source_dir: source_dir.to_s,
29
+ build_dir: data.join("tmp/tracy-profiler-build").to_s,
28
30
  output_binary_name: "tracy-profiler",
29
31
  cmake_args: ["-DLEGACY=ON"],
30
32
  )
@@ -11,9 +11,12 @@ module MilkTea
11
11
  @out = out
12
12
  @err = err
13
13
  @help_printer = help_printer
14
+ @quiet = false
14
15
  end
15
16
 
16
17
  def start
18
+ extract_options!
19
+
17
20
  subcommand = @argv.shift
18
21
  unless subcommand
19
22
  @err.puts("missing toolchain subcommand")
@@ -37,6 +40,29 @@ module MilkTea
37
40
 
38
41
  private
39
42
 
43
+ def extract_options!
44
+ remaining = []
45
+ until @argv.empty?
46
+ arg = @argv.first
47
+ case arg
48
+ when "-q", "--quiet"
49
+ @quiet = true
50
+ @argv.shift
51
+ when "--"
52
+ @argv.shift
53
+ remaining.concat(@argv)
54
+ @argv.clear
55
+ else
56
+ remaining << @argv.shift
57
+ end
58
+ end
59
+ @argv.replace(remaining)
60
+ end
61
+
62
+ def info(message)
63
+ @out.puts(message) unless @quiet
64
+ end
65
+
40
66
  def print_help
41
67
  @help_printer.call(@err)
42
68
  end
@@ -50,12 +76,39 @@ module MilkTea
50
76
 
51
77
  require_relative "../bindings"
52
78
 
53
- results = UpstreamSources.bootstrap_all!
54
- results.each do |result|
55
- verb = result.status == :present ? "kept" : "bootstrapped"
56
- @out.puts("#{verb} #{result.source.name} -> #{result.path}")
79
+ sources = UpstreamSources.default_sources(root: MilkTea.root)
80
+ info "Bootstrapping #{sources.length} vendored libraries..."
81
+ info ""
82
+
83
+ ok = 0
84
+ skipped = 0
85
+ failed = 0
86
+
87
+ sources.each do |source|
88
+ if source.complete?
89
+ info " #{source.name} (already present)"
90
+ skipped += 1
91
+ next
92
+ end
93
+
94
+ info " #{source.name} \e[2mcloning...\e[0m"
95
+ @out.flush
96
+ begin
97
+ result = source.bootstrap!
98
+ verb = result.status == :present ? "kept" : "bootstrapped"
99
+ info "\r #{source.name} \e[32m#{verb}\e[0m"
100
+ ok += 1
101
+ rescue UpstreamSources::Error => e
102
+ info "\r #{source.name} \e[31mfailed\e[0m"
103
+ @err.puts(" #{e.message}")
104
+ failed += 1
105
+ end
57
106
  end
58
- 0
107
+
108
+ info ""
109
+ total = ok + skipped + failed
110
+ info "#{total} source(s): #{ok} bootstrapped, #{skipped} skipped, #{failed} failed"
111
+ failed.zero? ? 0 : 1
59
112
  end
60
113
 
61
114
  def doctor_command
@@ -71,6 +124,7 @@ module MilkTea
71
124
  ar = ENV.fetch("AR", "ar")
72
125
  checks = []
73
126
 
127
+ info "Checking system tools..."
74
128
  checks << ["ruby", true, RUBY_DESCRIPTION]
75
129
  checks << ["cc", executable_available?(cc), cc]
76
130
  checks << ["ar", executable_available?(ar), ar]
@@ -80,6 +134,7 @@ module MilkTea
80
134
  checks << ["cmake", executable_available?(ENV.fetch("CMAKE", "cmake")), ENV.fetch("CMAKE", "cmake")]
81
135
  checks << ["ninja", executable_available?("ninja"), "ninja"]
82
136
 
137
+ info "Checking vendored libraries..."
83
138
  UpstreamSources.default_sources(root: MilkTea.root).each do |source|
84
139
  missing = source.sentinel_paths.reject do |relative_path|
85
140
  File.exist?(source.checkout_root.join(relative_path))
@@ -91,6 +146,7 @@ module MilkTea
91
146
  end
92
147
  end
93
148
 
149
+ info "Checking bindings..."
94
150
  RawBindings.default_registry(root: MilkTea.root)
95
151
  .select { |binding| binding.module_name.start_with?("std.c.") }
96
152
  .sort_by(&:name)
@@ -119,8 +175,9 @@ module MilkTea
119
175
  end
120
176
  end
121
177
 
178
+ info ""
122
179
  checks.each do |name, ok, detail|
123
- @out.puts("#{ok ? 'ok' : 'fail'} #{name}: #{detail}")
180
+ @out.puts("#{ok ? "ok" : "fail"} #{name}: #{detail}")
124
181
  end
125
182
 
126
183
  checks.all? { |_, ok, _| ok } ? 0 : 1
@@ -135,9 +192,13 @@ module MilkTea
135
192
 
136
193
  require_relative "../bindings"
137
194
 
195
+ tools = VendoredTools.all(root: MilkTea.root)
196
+ info "Building #{tools.length} vendored tool(s)..."
197
+ info ""
198
+
138
199
  results = VendoredTools.build_all!(root: MilkTea.root)
139
200
  results.each do |result|
140
- @out.puts("built #{result[:tool].name} -> #{result[:binary]}")
201
+ info " #{result[:tool].name} \e[32mbuilt\e[0m -> #{result[:binary]}"
141
202
  end
142
203
  0
143
204
  rescue VendoredTool::Error => e
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mt-lang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Long (Teefan) Tran
@@ -583,7 +583,7 @@ metadata:
583
583
  homepage_uri: https://teefan.github.io/mt-lang/
584
584
  source_code_uri: https://github.com/teefan/mt-lang
585
585
  post_install_message: |
586
- Milk Tea 0.2.2 installed!
586
+ Milk Tea 0.2.4 installed!
587
587
 
588
588
  System requirements:
589
589
  - A C compiler (gcc or clang) must be available on PATH