beaver-build 2.0.0 → 2.2.0
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 +4 -4
- data/lib/beaver.rb +30 -1
- data/lib/command.rb +25 -1
- data/lib/file.rb +3 -0
- data/lib/file_dep.rb +1 -1
- data/lib/sh.rb +20 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c14453e56d234a62a48d99e3151389a8987ad31413fb822e3c239309b3a933b
|
4
|
+
data.tar.gz: ad7487c17109c457e5d7d9fbda58a7479599f947f8c74be00623d10c6170627d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa4a243e27a05613f9e042bd2e2a17419d461b17cef85865bef00ce57f6141e9fe383891ac229c5f9481a256e5785d4f88edd60796e3769255cb6ae8b9ab21c2
|
7
|
+
data.tar.gz: 50a9fbb0f1103e13b00025dd84707c8c175b70f906e7a8e49b5806c91185822af4751096b5ac5c278dd7f01f7704d7ef5d3b31eaecd322b7bc02c89b885fde97
|
data/lib/beaver.rb
CHANGED
@@ -60,26 +60,51 @@ class Beaver
|
|
60
60
|
def call(cmd)
|
61
61
|
_cmd = @commands[cmd.to_sym]
|
62
62
|
if _cmd.nil?
|
63
|
-
puts "No command called #{cmd} found"
|
63
|
+
STDERR.puts "No command called #{cmd} found"
|
64
64
|
exit 1
|
65
65
|
end
|
66
66
|
|
67
67
|
_cmd.call
|
68
68
|
end
|
69
69
|
|
70
|
+
# Run this command when it is called, no matter if its dependencies did not change
|
71
|
+
def must_run cmd
|
72
|
+
_cmd = @commands[cmd.to_sym]
|
73
|
+
if _cmd.nil?
|
74
|
+
STDERR.puts "\001b[31mNON-FATAL ERROR\001b[0m: Command #{cmd} does not exist, so `must_run` has not effect"
|
75
|
+
exit 1
|
76
|
+
end
|
77
|
+
_cmd.overwrite_should_run = true
|
78
|
+
|
79
|
+
_cmd.call
|
80
|
+
end
|
81
|
+
|
82
|
+
def set_main(cmd)
|
83
|
+
@mainCommand = cmd.to_sym
|
84
|
+
end
|
85
|
+
|
70
86
|
# Put this at the end of a file
|
71
87
|
def end
|
72
88
|
$cache = CacheManager.new # load cache file
|
73
89
|
|
74
90
|
command = ARGV[0] || @mainCommand
|
91
|
+
if command == "--" # passing arguments to be processed by the builld file -> pass "--" as the command to specify the default
|
92
|
+
command = @mainCommand
|
93
|
+
end
|
75
94
|
self.call command
|
76
95
|
|
77
96
|
$cache.save # save cache file
|
78
97
|
end
|
79
98
|
|
99
|
+
# Returns all available commands as an array
|
100
|
+
def list_commands
|
101
|
+
return @commands.map { |k, v| k }
|
102
|
+
end
|
103
|
+
|
80
104
|
# Clean cache
|
81
105
|
def clean
|
82
106
|
FileUtils.rm_r @cache_loc
|
107
|
+
reset_cache
|
83
108
|
end
|
84
109
|
end
|
85
110
|
|
@@ -95,3 +120,7 @@ require 'sh'
|
|
95
120
|
def call(cmd)
|
96
121
|
$beaver.call cmd
|
97
122
|
end
|
123
|
+
|
124
|
+
def must_run(cmd)
|
125
|
+
$beaver.musts_run cmd
|
126
|
+
end
|
data/lib/command.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
require 'file.rb'
|
2
2
|
|
3
|
+
$__BEAVER_SHOULD_RUN_SCOPE = false
|
4
|
+
|
3
5
|
class Command
|
4
6
|
attr_accessor :name
|
5
7
|
attr_accessor :fn
|
8
|
+
attr_accessor :overwrite_should_run
|
6
9
|
|
7
10
|
def initialize(name, file_deps, fn)
|
8
11
|
@name = name
|
@@ -10,19 +13,38 @@ class Command
|
|
10
13
|
# Type: FileDep, or nil
|
11
14
|
@file_deps = file_deps
|
12
15
|
@fn = fn
|
16
|
+
@overwrite_should_run = false
|
13
17
|
end
|
14
18
|
|
15
19
|
# Execute the command if needed (dependency files changed)
|
16
20
|
def call
|
21
|
+
global_alread_defined = $__BEAVER_SHOULD_RUN_SCOPE
|
22
|
+
if self.overwrite_should_run
|
23
|
+
$__BEAVER_SHOULD_RUN_SCOPE = true
|
24
|
+
end
|
25
|
+
if $__BEAVER_SHOULD_RUN_SCOPE
|
26
|
+
self.overwrite_should_run = true
|
27
|
+
end
|
28
|
+
|
17
29
|
if self.should_run?
|
18
30
|
self.call_now()
|
19
31
|
end
|
32
|
+
|
33
|
+
if !global_alread_defined && $__BEAVER_SHOULD_RUN_SCOPE
|
34
|
+
$__BEAVER_SHOULD_RUN_SCOPE = false
|
35
|
+
end
|
20
36
|
end
|
21
37
|
|
22
38
|
# Force call the command, even if none of the files changed
|
23
39
|
def call_now
|
24
40
|
$file = nil
|
25
41
|
$files = nil
|
42
|
+
|
43
|
+
if @file_deps.nil?
|
44
|
+
@fn.call()
|
45
|
+
return
|
46
|
+
end
|
47
|
+
|
26
48
|
if @file_deps.type == :each
|
27
49
|
@file_deps.files.each do |file_obj|
|
28
50
|
$file = file_obj
|
@@ -37,6 +59,8 @@ class Command
|
|
37
59
|
# Returns wheter the command should run, meaning if any of the depency
|
38
60
|
# files changed
|
39
61
|
def should_run?
|
62
|
+
return true if @overwrite_should_run
|
63
|
+
|
40
64
|
if changed? "__BEAVER__CONFIG__", $PROGRAM_NAME
|
41
65
|
# Ruby script itself changed
|
42
66
|
# TODO: does not account for dependencies of the script (probably uncommon though)
|
@@ -71,6 +95,6 @@ class Command
|
|
71
95
|
end
|
72
96
|
|
73
97
|
def cmd(name, deps = nil, &fn)
|
74
|
-
cmd = Command.new name, deps, fn
|
98
|
+
cmd = Command.new name.to_sym, deps, fn
|
75
99
|
$beaver.__appendCommand cmd
|
76
100
|
end
|
data/lib/file.rb
CHANGED
data/lib/file_dep.rb
CHANGED
data/lib/sh.rb
CHANGED
@@ -10,14 +10,21 @@ def sh(strcmd)
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
if strcmd.is_a?
|
13
|
+
if strcmd.is_a?(SilentAll) || strcmd.is_a?(SilentOutput)
|
14
14
|
`#{strcmd}`
|
15
15
|
else
|
16
|
-
|
16
|
+
system "#{strcmd}"
|
17
17
|
end
|
18
18
|
|
19
19
|
if $beaver.has(:e)
|
20
|
-
|
20
|
+
if $?.to_i != 0
|
21
|
+
if $?.exitstatus.nil?
|
22
|
+
puts $?
|
23
|
+
end
|
24
|
+
exit($?.exitstatus || -1)
|
25
|
+
end
|
26
|
+
elsif $?.to_i != 0 && $?.exitstatus.nil?
|
27
|
+
puts $?
|
21
28
|
end
|
22
29
|
end
|
23
30
|
|
@@ -31,6 +38,11 @@ SilentAll = Struct.new(:strcmd) do
|
|
31
38
|
strcmd
|
32
39
|
end
|
33
40
|
end
|
41
|
+
SilentOutput = Struct.new(:strcmd) do
|
42
|
+
def to_s
|
43
|
+
strcmd
|
44
|
+
end
|
45
|
+
end
|
34
46
|
|
35
47
|
# Do not print the command
|
36
48
|
def silent(strcmd)
|
@@ -41,3 +53,8 @@ end
|
|
41
53
|
def full_silent(strcmd)
|
42
54
|
return SilentAll.new(strcmd)
|
43
55
|
end
|
56
|
+
|
57
|
+
# Do not print out the output of the command
|
58
|
+
def output_silent(strcmd)
|
59
|
+
return SilentOutput.new(strcmd)
|
60
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaver-build
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Everaert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
version: 1.6.0
|
27
27
|
description: |-
|
28
28
|
Beaver is an easy to understand build tool with a lot of capabilities.
|
29
|
-
Documentation and examples on [github](https://github.com/jomy10/beaver)
|
29
|
+
Documentation and examples on [github](https://github.com/jomy10/beaver).
|
30
30
|
email:
|
31
31
|
executables:
|
32
32
|
- beaver
|