erebrus 0.1.1 → 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: 519cdef5b67694f284b00f6114a6f9ac439fe608f31452ac157c48b8859c184a
4
- data.tar.gz: fdbe5002c3136d3835f87f203033ce1d5e06c3ccec0c451ff12fb2ab0864e954
3
+ metadata.gz: 2b58c1ca924ac2f95499d284111464068d82a0e6820285bbde05c58799caac73
4
+ data.tar.gz: 8a4deb8f063ea47317cac4ff9fc2910943756da449ce0f2c33018534f9939ac3
5
5
  SHA512:
6
- metadata.gz: caaeec63caf2ae10b477a5b83b59399b9bdc8f45a4614a3901703bef84f58ba8d00cafae1f7e90e6e1152e91a4563c3d4182272d9459dd7b719075f5b779e0dd
7
- data.tar.gz: 76d06dfbaf4bda854cda916944e8ba0a448276dee4b9a837e3402a508c6619686c1ae639f3223e926d77ad6eb035df6a380c68b967805ad13f908208b7af69a5
6
+ metadata.gz: 3a2c8188a7fc58ea49bee72c54a517d1a1ed4c774b1ab01203b7b41af4f09f5a0afef33c854052d253ffe0adfffa6920f6c02f3f194da27cf9d49f75dcad3ebc
7
+ data.tar.gz: 4f67840ed5820865d5b005e313a1b14ed52a182a3982994af699d0c8983226522bc227bbe45828a16079cf21687ecd5bf21da75e7170055fdbb959e7f24f03f8
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Erebrus
2
2
 
3
- Modern C/C++ build system like msbuild, with ruby instead of xml
3
+ Modern Ruby based build system like make.
4
4
 
5
5
  ## Usage
6
6
 
data/bin/erebrus CHANGED
@@ -39,7 +39,7 @@ class ErebrusCommand < Thor
39
39
  load_buildfile_with_error_handling
40
40
 
41
41
  begin
42
- puts "" # spacing for readability
42
+ puts ""
43
43
  if namespace
44
44
  say_title("Targets in namespace '#{namespace}'")
45
45
  else
@@ -216,7 +216,6 @@ class ErebrusCommand < Thor
216
216
  context
217
217
  end
218
218
 
219
- # --- Styling helpers -----------------------------------------------------
220
219
  def color_enabled?
221
220
  options[:color] && $stdout.respond_to?(:isatty) && $stdout.isatty && ENV["NO_COLOR"].nil?
222
221
  rescue StandardError
data/examples/Buildfile CHANGED
@@ -143,6 +143,13 @@ end
143
143
 
144
144
  target :show_info, description: "Show host and environment info" do
145
145
  echo "Host OS: ${HOST_OS}"
146
+ echo "Host Architecture: ${HOST_ARCH}"
147
+ echo "CPU Count: ${CPU_COUNT}"
148
+ echo "User: ${USER}"
149
+ echo "Home Directory: ${HOME}"
150
+ echo "Temp Directory: ${TEMP_DIR}"
151
+ echo "Build Time: ${BUILD_TIME}"
152
+ echo "Build Timestamp: ${BUILD_TIMESTAMP}"
146
153
  echo "Ruby: ${RUBY_VERSION}"
147
154
  echo "PWD: ${PWD}"
148
155
  end
@@ -155,8 +162,11 @@ end
155
162
  # Demonstrate write/append utilities
156
163
  target :write_demo, description: "Write and append notes" do
157
164
  depends_on :setup
158
- write "dist/notes.txt", "Notes for ${HOST_OS}\n"
159
- append "dist/notes.txt", "Built at: #{Time.now}\n"
165
+ write "dist/notes.txt", "Build Notes\n"
166
+ append "dist/notes.txt", "Host: ${HOST_OS} ${HOST_ARCH}\n"
167
+ append "dist/notes.txt", "User: ${USER}\n"
168
+ append "dist/notes.txt", "Built at: ${BUILD_TIME}\n"
169
+ append "dist/notes.txt", "CPU Count: ${CPU_COUNT}\n"
160
170
  end
161
171
 
162
172
  # Demonstrate environment handling
@@ -182,12 +192,32 @@ target :parallel_compile, description: "Compile sources and tests in parallel" d
182
192
  parallel :compile_sources, :compile_tests
183
193
  end
184
194
 
195
+ # Demonstrate conditional logic with system variables
196
+ target :system_specific, description: "Show system-specific behavior" do
197
+ echo "Detected system: ${HOST_OS} on ${HOST_ARCH}"
198
+
199
+ conditional(get_variable("HOST_OS") == "windows") do
200
+ echo "Running Windows-specific commands"
201
+ echo "User profile: ${HOME}"
202
+ echo "Temp directory: ${TEMP_DIR}"
203
+ end
204
+
205
+ conditional(get_variable("HOST_ARCH") == "x64") do
206
+ echo "64-bit architecture detected"
207
+ echo "Using optimized 64-bit settings"
208
+ end
209
+
210
+ # Show CPU-based logic
211
+ echo "System has ${CPU_COUNT} CPU cores available"
212
+ end
213
+
185
214
  # Aggregate demo target
186
215
  target :demo, description: "Run all demonstration features" do
187
216
  depends_on :show_info
188
217
  depends_on :gen_config
189
218
  depends_on :write_demo
190
219
  depends_on :env_demo
220
+ depends_on :system_specific
191
221
  depends_on :build
192
222
  depends_on :symlink_demo
193
223
  end
@@ -19,8 +19,14 @@ module Erebrus
19
19
  @progress_count = 0
20
20
  @progress_enabled = false
21
21
  @progress_line_open = false
22
- # Predefine HOST_OS for use in Buildfiles and contexts
23
22
  @variables["HOST_OS"] = detect_host_os
23
+ @variables["HOST_ARCH"] = detect_host_arch
24
+ @variables["CPU_COUNT"] = detect_cpu_count
25
+ @variables["USER"] = detect_user
26
+ @variables["HOME"] = detect_home_dir
27
+ @variables["TEMP_DIR"] = detect_temp_dir
28
+ @variables["BUILD_TIME"] = Time.now.strftime("%Y-%m-%d %H:%M:%S")
29
+ @variables["BUILD_TIMESTAMP"] = Time.now.to_i.to_s
24
30
  end
25
31
 
26
32
  def target(name, description: nil, namespace: nil, &block)
@@ -133,7 +139,6 @@ module Erebrus
133
139
 
134
140
  merged_context = @variables.merge(context)
135
141
 
136
- # Setup build-level progress bar across targets to execute
137
142
  target_obj = @targets[target_name]
138
143
  to_run = collect_targets_to_run(target_obj)
139
144
  @progress_total = to_run.size
@@ -248,7 +253,6 @@ module Erebrus
248
253
  execute_target(dep_target, context, visited.dup)
249
254
  end
250
255
 
251
- # Ensure progress bar line is terminated before any action output
252
256
  finish_progress_bar if @progress_enabled
253
257
  target.execute(context)
254
258
  increment_progress!
@@ -260,13 +264,13 @@ module Erebrus
260
264
  @targets.each_value(&:reset!)
261
265
  end
262
266
 
263
- # Progress helpers -------------------------------------------------------
264
267
  def collect_targets_to_run(root)
265
268
  seen = Set.new
266
269
  stack = [root]
267
270
  until stack.empty?
268
271
  t = stack.pop
269
272
  next if seen.include?(t.name)
273
+
270
274
  seen.add(t.name)
271
275
  t.dependencies.each do |dep|
272
276
  dep_name = resolve_target_name(dep)
@@ -279,6 +283,7 @@ module Erebrus
279
283
 
280
284
  def increment_progress!
281
285
  return unless @progress_enabled
286
+
282
287
  @progress_count += 1
283
288
  print_progress_bar(@progress_count, @progress_total)
284
289
  end
@@ -286,21 +291,74 @@ module Erebrus
286
291
  def print_progress_bar(current, total)
287
292
  current = [current, total].min
288
293
  percent = total.zero? ? 100 : ((current.to_f / total) * 100).round
289
- bar_length = 30
290
- filled = (percent * bar_length / 100.0).round
291
- bar = "[" + "#" * filled + " " * (bar_length - filled) + "]"
292
- $stdout.print "\rProgress #{bar} #{percent}% (#{current}/#{total})"
294
+ bar_length = 25
295
+
296
+ filled_exact = (percent * bar_length / 100.0)
297
+ filled_full = filled_exact.floor
298
+ partial = filled_exact - filled_full
299
+
300
+ full_block = "█"
301
+ partial_blocks = ["", "▏", "▎", "▍", "▌", "▋", "▊", "▉"]
302
+ empty_block = "░"
303
+
304
+ bar = ""
305
+ bar += full_block * filled_full
306
+
307
+ if filled_full < bar_length && partial > 0
308
+ partial_index = (partial * (partial_blocks.length - 1)).round
309
+ bar += partial_blocks[partial_index]
310
+ filled_full += 1
311
+ end
312
+
313
+ bar += empty_block * (bar_length - filled_full)
314
+
315
+ if color_supported?
316
+ colored_bar = colorize_progress_bar(bar, filled_exact, bar_length)
317
+ $stdout.print "\r#{colored_bar} #{colorize(percent.to_s + "%",
318
+ :cyan)} #{colorize("(#{current}/#{total})", :dim)}"
319
+ else
320
+ $stdout.print "\r#{bar} #{percent}% (#{current}/#{total})"
321
+ end
322
+
293
323
  $stdout.flush
294
324
  @progress_line_open = true
295
325
  end
296
326
 
327
+ def color_supported?
328
+ $stdout.respond_to?(:isatty) && $stdout.isatty && ENV["NO_COLOR"].nil?
329
+ rescue StandardError
330
+ false
331
+ end
332
+
333
+ def colorize(text, color)
334
+ return text unless color_supported?
335
+
336
+ case color
337
+ when :green then "\e[32m#{text}\e[0m"
338
+ when :cyan then "\e[36m#{text}\e[0m"
339
+ when :dim then "\e[2m#{text}\e[0m"
340
+ else text
341
+ end
342
+ end
343
+
344
+ def colorize_progress_bar(bar, filled_exact, bar_length)
345
+ return bar unless color_supported?
346
+
347
+ filled_chars = filled_exact.ceil
348
+ filled_portion = bar[0, filled_chars]
349
+ empty_portion = bar[filled_chars..-1] || ""
350
+
351
+ "\e[32m#{filled_portion}\e[0m\e[2m#{empty_portion}\e[0m"
352
+ end
353
+
297
354
  def finish_progress_bar
298
355
  return unless @progress_enabled
299
356
  return unless @progress_line_open
357
+
300
358
  $stdout.puts
301
359
  @progress_line_open = false
302
360
  end
303
-
361
+
304
362
  private
305
363
 
306
364
  def detect_host_os
@@ -318,6 +376,41 @@ module Erebrus
318
376
  "unknown"
319
377
  end
320
378
  end
379
+
380
+ def detect_host_arch
381
+ arch = RbConfig::CONFIG["host_cpu"].downcase
382
+ case arch
383
+ when /x86_64|amd64/
384
+ "x64"
385
+ when /i[3-6]86/
386
+ "x86"
387
+ when /arm64|aarch64/
388
+ "arm64"
389
+ when /arm/
390
+ "arm"
391
+ else
392
+ arch
393
+ end
394
+ end
395
+
396
+ def detect_cpu_count
397
+ require "etc"
398
+ Etc.nprocessors.to_s
399
+ rescue StandardError
400
+ "1"
401
+ end
402
+
403
+ def detect_user
404
+ ENV["USER"] || ENV["USERNAME"] || "unknown"
405
+ end
406
+
407
+ def detect_home_dir
408
+ ENV["HOME"] || ENV["USERPROFILE"] || Dir.pwd
409
+ end
410
+
411
+ def detect_temp_dir
412
+ ENV["TMPDIR"] || ENV["TMP"] || ENV["TEMP"] || "/tmp"
413
+ end
321
414
  end
322
415
 
323
416
  class TargetContext
@@ -423,6 +516,7 @@ module Erebrus
423
516
  puts "Running (capture): #{expanded_command}"
424
517
  result = `#{expanded_command}`
425
518
  raise Error, "Command failed: #{expanded_command}" unless $?.success?
519
+
426
520
  @engine&.set_variable(name, result.chomp)
427
521
  end
428
522
  end
@@ -1,3 +1,3 @@
1
1
  module Erebrus
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erebrus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jel9
@@ -71,5 +71,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  requirements: []
72
72
  rubygems_version: 3.6.9
73
73
  specification_version: 4
74
- summary: Modern C/C++ build system like msbuild, with ruby instead of xml
74
+ summary: Modern Ruby based build system like make.
75
75
  test_files: []