erebrus 0.1.1 → 0.1.2

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: c0a0cf035d47b272eefe1385dd63919f5b6c58c75765248dc165f3ba942057b6
4
+ data.tar.gz: 637e125435680c16aefe62e318bc78990b2b0e1910d3c669071757996442279c
5
5
  SHA512:
6
- metadata.gz: caaeec63caf2ae10b477a5b83b59399b9bdc8f45a4614a3901703bef84f58ba8d00cafae1f7e90e6e1152e91a4563c3d4182272d9459dd7b719075f5b779e0dd
7
- data.tar.gz: 76d06dfbaf4bda854cda916944e8ba0a448276dee4b9a837e3402a508c6619686c1ae639f3223e926d77ad6eb035df6a380c68b967805ad13f908208b7af69a5
6
+ metadata.gz: 935badb603ccfa49c812c702fd884f143a130fa051fda3f66fab25080a704549c11df48fc4fb3d731dd3789a1225488d2bd3229a700a5ef0dcab42cb6136bd9f
7
+ data.tar.gz: '008219953c4f5ca5f9e245240bc824c7db35cba780830dee4e2fa58680fe3a8259a87350e4146f42bb91ab838381a51c0b8b899a960338e6eb4bdcd69496861d'
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
@@ -209,6 +209,7 @@ class ErebrusCommand < Thor
209
209
 
210
210
  context.merge!(options[:var]) if options[:var]
211
211
 
212
+ # Legacy variables for backward compatibility
212
213
  context["PLATFORM"] = RUBY_PLATFORM
213
214
  context["RUBY_VERSION"] = RUBY_VERSION
214
215
  context["PWD"] = Dir.pwd
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,15 @@ 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
22
+ # Predefine useful system and build variables
23
23
  @variables["HOST_OS"] = detect_host_os
24
+ @variables["HOST_ARCH"] = detect_host_arch
25
+ @variables["CPU_COUNT"] = detect_cpu_count
26
+ @variables["USER"] = detect_user
27
+ @variables["HOME"] = detect_home_dir
28
+ @variables["TEMP_DIR"] = detect_temp_dir
29
+ @variables["BUILD_TIME"] = Time.now.strftime("%Y-%m-%d %H:%M:%S")
30
+ @variables["BUILD_TIMESTAMP"] = Time.now.to_i.to_s
24
31
  end
25
32
 
26
33
  def target(name, description: nil, namespace: nil, &block)
@@ -267,6 +274,7 @@ module Erebrus
267
274
  until stack.empty?
268
275
  t = stack.pop
269
276
  next if seen.include?(t.name)
277
+
270
278
  seen.add(t.name)
271
279
  t.dependencies.each do |dep|
272
280
  dep_name = resolve_target_name(dep)
@@ -279,6 +287,7 @@ module Erebrus
279
287
 
280
288
  def increment_progress!
281
289
  return unless @progress_enabled
290
+
282
291
  @progress_count += 1
283
292
  print_progress_bar(@progress_count, @progress_total)
284
293
  end
@@ -297,10 +306,11 @@ module Erebrus
297
306
  def finish_progress_bar
298
307
  return unless @progress_enabled
299
308
  return unless @progress_line_open
309
+
300
310
  $stdout.puts
301
311
  @progress_line_open = false
302
312
  end
303
-
313
+
304
314
  private
305
315
 
306
316
  def detect_host_os
@@ -318,6 +328,41 @@ module Erebrus
318
328
  "unknown"
319
329
  end
320
330
  end
331
+
332
+ def detect_host_arch
333
+ arch = RbConfig::CONFIG["host_cpu"].downcase
334
+ case arch
335
+ when /x86_64|amd64/
336
+ "x64"
337
+ when /i[3-6]86/
338
+ "x86"
339
+ when /arm64|aarch64/
340
+ "arm64"
341
+ when /arm/
342
+ "arm"
343
+ else
344
+ arch
345
+ end
346
+ end
347
+
348
+ def detect_cpu_count
349
+ require "etc"
350
+ Etc.nprocessors.to_s
351
+ rescue StandardError
352
+ "1"
353
+ end
354
+
355
+ def detect_user
356
+ ENV["USER"] || ENV["USERNAME"] || "unknown"
357
+ end
358
+
359
+ def detect_home_dir
360
+ ENV["HOME"] || ENV["USERPROFILE"] || Dir.pwd
361
+ end
362
+
363
+ def detect_temp_dir
364
+ ENV["TMPDIR"] || ENV["TMP"] || ENV["TEMP"] || "/tmp"
365
+ end
321
366
  end
322
367
 
323
368
  class TargetContext
@@ -423,6 +468,7 @@ module Erebrus
423
468
  puts "Running (capture): #{expanded_command}"
424
469
  result = `#{expanded_command}`
425
470
  raise Error, "Command failed: #{expanded_command}" unless $?.success?
471
+
426
472
  @engine&.set_variable(name, result.chomp)
427
473
  end
428
474
  end
@@ -1,3 +1,3 @@
1
1
  module Erebrus
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
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.2
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: []