ruby_make_script 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +86 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/ruby_make_script.rb +180 -0
- data/lib/ruby_make_script/target.rb +106 -0
- data/lib/ruby_make_script/utils.rb +80 -0
- data/lib/ruby_make_script/version.rb +3 -0
- data/ruby_make_script.gemspec +43 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3406be1df614999fd1ca1ea31185363c98ae75e77beae44547c3ea4a6225c2a4
|
4
|
+
data.tar.gz: c01a6f7f1975958eee6c8db653bf8001789575c12f3880651809cdd990ef7a75
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 97cfd2352791c73010bf3c06239a02af829530e023d7092b10297b8fa80a090bfde40ff082b33fe7de8cd31851c48ade3cf0b3964d9e80237befac9f273a2de6
|
7
|
+
data.tar.gz: 387906e219c62fa99ed6d573b013b1037512623a02af0114e0b35d6585bfca532af5a856de7b7e83d4ab935429bdda65f49d348f8653c1c678adbd52fbf70c29
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at dnailzb@outlook.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 dnailz
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# RubyMakeScript
|
2
|
+
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
|
7
|
+
Or install it yourself as:
|
8
|
+
|
9
|
+
```
|
10
|
+
$ gem install ruby_make_script
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
Write ruby_make_script like this:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
require "ruby_make_script"
|
19
|
+
|
20
|
+
make do
|
21
|
+
:run .from "a.out" do
|
22
|
+
r "./a.out"
|
23
|
+
end
|
24
|
+
"a.out" .from "test.c" do
|
25
|
+
r "gcc test.c"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
then run:
|
31
|
+
|
32
|
+
```
|
33
|
+
$ ruby make.rb
|
34
|
+
$ ruby make.rb run
|
35
|
+
```
|
36
|
+
|
37
|
+
It works very similar to GNU Make.
|
38
|
+
|
39
|
+
Here is a little complex one:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
require "ruby_make_script"
|
43
|
+
|
44
|
+
def CC(*str)
|
45
|
+
r "gcc", "-I.", *str
|
46
|
+
end
|
47
|
+
|
48
|
+
mkdir? ".build" # `?` take error as warning, and also return a bool to indicate success/failure.
|
49
|
+
sources = Dir.glob("**/*.c") # Dir.glob will be very useful
|
50
|
+
objects = sources.map{
|
51
|
+
|f| ".build/" + f.gsub('.c', '.o')
|
52
|
+
}
|
53
|
+
headers = Dir.glob("**/*.h")
|
54
|
+
|
55
|
+
make do
|
56
|
+
:app .from "prog" do
|
57
|
+
runfile $d[0] # $d: dependencies array
|
58
|
+
end
|
59
|
+
"prog" .from(*objects) do
|
60
|
+
CC "-o", $t[0], *$d # $t: targets array
|
61
|
+
end
|
62
|
+
sources.zip(objects).each do |s, o|
|
63
|
+
o .from(s, *headers) do
|
64
|
+
CC "-c", "-o", $t[0], $d[0]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
## Development
|
71
|
+
|
72
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
73
|
+
|
74
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruby_make_script. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
79
|
+
|
80
|
+
## License
|
81
|
+
|
82
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
83
|
+
|
84
|
+
## Code of Conduct
|
85
|
+
|
86
|
+
Everyone interacting in the RubyMakeScript project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ruby_make_script/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ruby_make_script"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
#
|
2
|
+
# Usage:
|
3
|
+
# ```
|
4
|
+
# require "ruby_make_script"
|
5
|
+
# make do
|
6
|
+
# :run .from "a.out" do
|
7
|
+
# ~ "./a.out"
|
8
|
+
# end
|
9
|
+
# "a.out" .from "test.c" do
|
10
|
+
# ~ "gcc test.c"
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
# ````
|
14
|
+
#
|
15
|
+
#
|
16
|
+
#
|
17
|
+
|
18
|
+
require 'pastel'
|
19
|
+
require 'yaml'
|
20
|
+
|
21
|
+
# all targets list
|
22
|
+
$targetlist = []
|
23
|
+
|
24
|
+
# file -> target
|
25
|
+
$file_target_dict = Hash[]
|
26
|
+
|
27
|
+
# file -> mtime (last make)
|
28
|
+
$file_time_dict = Hash[]
|
29
|
+
|
30
|
+
# file -> mtime
|
31
|
+
$cur_file_time_dict = Hash[]
|
32
|
+
|
33
|
+
require 'ruby_make_script/utils'
|
34
|
+
require 'ruby_make_script/target'
|
35
|
+
|
36
|
+
# check a file (recursively) and run the commands of the target.
|
37
|
+
def resolve(file, force_exec=false)
|
38
|
+
if file_modified?(file) || force_exec
|
39
|
+
t = $file_target_dict[file]
|
40
|
+
# when t == nil, its a file not used for target
|
41
|
+
if t != nil
|
42
|
+
t.depend_each { |f|
|
43
|
+
resolve(f)
|
44
|
+
}
|
45
|
+
t.run()
|
46
|
+
# if File.exist?(file)
|
47
|
+
# puts "#{file} modified #{$file_time_dict[file]} != #{File.mtime(file)}"
|
48
|
+
# else
|
49
|
+
# puts "#{file} modified not exist?"
|
50
|
+
# end
|
51
|
+
file_modified!(file)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# check if a file is modified or its dependency is modified
|
57
|
+
def file_modified?(file)
|
58
|
+
if $file_target_dict[file].class == FileTarget
|
59
|
+
# 文件真正被修改:文件之前不存在,或文件现在已经不存在,或时间戳修改
|
60
|
+
real_modified = $file_time_dict[file] == nil || !File.exist?(file) || ($file_time_dict[file] != File.mtime(file))
|
61
|
+
# 文件依赖被修改
|
62
|
+
return real_modified || $file_target_dict[file].depend_modified?
|
63
|
+
elsif $file_target_dict[file].class == PhonyTarget
|
64
|
+
# 假目标被修改:依赖被修改或之前不存在
|
65
|
+
return $file_time_dict[file] == nil || $file_target_dict[file].depend_modified?
|
66
|
+
elsif $file_target_dict[file] == nil
|
67
|
+
# 对无目标的文件,判断其存在,存在则直接使用即可
|
68
|
+
if !File.exist?(file)
|
69
|
+
raise "file not found #{file}"
|
70
|
+
else
|
71
|
+
$cur_file_time_dict[file] = File.mtime(file)
|
72
|
+
return $file_time_dict[file] == nil || ($file_time_dict[file] != File.mtime(file))
|
73
|
+
end
|
74
|
+
else
|
75
|
+
raise "file type error #{$file_target_dict[file].class}"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# mark a file is modified
|
80
|
+
def file_modified!(file)
|
81
|
+
if $file_target_dict[file].class == FileTarget
|
82
|
+
$cur_file_time_dict[file] = File.mtime(file)
|
83
|
+
elsif $file_target_dict[file].class == PhonyTarget
|
84
|
+
$cur_file_time_dict[file] = true
|
85
|
+
else
|
86
|
+
raise "file type error #{file.class}"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
class Symbol
|
92
|
+
# Usage:
|
93
|
+
#
|
94
|
+
# ```
|
95
|
+
# :app .from "file1" do
|
96
|
+
# <your command here>
|
97
|
+
# end
|
98
|
+
# ```
|
99
|
+
def from(*dependlist)
|
100
|
+
PhonyTarget.new(String(self)).from(*dependlist) { yield }
|
101
|
+
end
|
102
|
+
|
103
|
+
# Usage:
|
104
|
+
#
|
105
|
+
# ```
|
106
|
+
# :app .then do
|
107
|
+
# <your command here>
|
108
|
+
# end
|
109
|
+
# ```
|
110
|
+
def then
|
111
|
+
from()
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
class String
|
116
|
+
# Usage:
|
117
|
+
#
|
118
|
+
# ```
|
119
|
+
# "file1" .from "file2" do
|
120
|
+
# <your command here>
|
121
|
+
# end
|
122
|
+
# ```
|
123
|
+
def from(*dependlist)
|
124
|
+
[self].from(*dependlist) { yield }
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class Array
|
129
|
+
# Usage:
|
130
|
+
#
|
131
|
+
# ```
|
132
|
+
# ["file1", "file2"] .from "file3", "file4" do
|
133
|
+
# <your command here>
|
134
|
+
# end
|
135
|
+
# ```
|
136
|
+
def from(*dependlist)
|
137
|
+
tar = FileTarget.new(self)
|
138
|
+
tar.from(*dependlist) { yield }
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
# Usage:
|
144
|
+
#
|
145
|
+
# ```
|
146
|
+
# make do
|
147
|
+
# <define target here>
|
148
|
+
# end
|
149
|
+
# ```
|
150
|
+
def make
|
151
|
+
$targetlist = []
|
152
|
+
|
153
|
+
yield
|
154
|
+
|
155
|
+
raise "at least a target" if $targetlist.length < 1
|
156
|
+
|
157
|
+
if File.exist?('./.make_script.yaml')
|
158
|
+
$file_time_dict = YAML.load(File.read('./.make_script.yaml'))
|
159
|
+
$cur_file_time_dict = $file_time_dict.clone()
|
160
|
+
end
|
161
|
+
puts Pastel.new.green.bold("ruby_make_script> ") + "start"
|
162
|
+
begin
|
163
|
+
if ARGV.length <= 1
|
164
|
+
$targetlist[0].resolve_all
|
165
|
+
else
|
166
|
+
resolve(ARGV[1], force_exec=true)
|
167
|
+
end
|
168
|
+
|
169
|
+
rescue StandardError => e
|
170
|
+
puts Pastel.new.red.bold("ruby_make_script failed> ") + e.message
|
171
|
+
if e.message != "make command failed"
|
172
|
+
puts e.backtrace
|
173
|
+
end
|
174
|
+
else
|
175
|
+
puts Pastel.new.green.bold("ruby_make_script> ") + "completed"
|
176
|
+
end
|
177
|
+
|
178
|
+
File.open('./.make_script.yaml', 'w') { |f| f.write(YAML.dump($cur_file_time_dict)) }
|
179
|
+
|
180
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
$t = []
|
2
|
+
$d = []
|
3
|
+
|
4
|
+
module Target
|
5
|
+
|
6
|
+
def depend_each
|
7
|
+
depend.each { |f|
|
8
|
+
yield f
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
def depend_modified?
|
13
|
+
return depend.map{ |f| file_modified?(f) }.reduce(false, :|)
|
14
|
+
end
|
15
|
+
|
16
|
+
def resolve_all
|
17
|
+
raise nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
raise nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def from(*dependlist)
|
25
|
+
raise nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def add
|
29
|
+
raise nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class FileTarget
|
34
|
+
include Target
|
35
|
+
attr_accessor :depend
|
36
|
+
|
37
|
+
def resolve_all
|
38
|
+
@target.each{ |f|
|
39
|
+
resolve(f)
|
40
|
+
}
|
41
|
+
end
|
42
|
+
def run
|
43
|
+
if ! @completed
|
44
|
+
@update_proc.call
|
45
|
+
@completed = true
|
46
|
+
@target.each{ |f|
|
47
|
+
file_modified!(f)
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
def initialize(targetlist)
|
52
|
+
@target = targetlist
|
53
|
+
@depend = []
|
54
|
+
@completed = false
|
55
|
+
end
|
56
|
+
def from(*dependlist)
|
57
|
+
@depend = dependlist
|
58
|
+
@update_proc = Proc.new {
|
59
|
+
$t = @target
|
60
|
+
$d = @depend
|
61
|
+
yield
|
62
|
+
}
|
63
|
+
add()
|
64
|
+
end
|
65
|
+
def add
|
66
|
+
$targetlist += [self]
|
67
|
+
@target.each { |t|
|
68
|
+
$file_target_dict[t] = self
|
69
|
+
}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class PhonyTarget
|
74
|
+
include Target
|
75
|
+
attr_accessor :depend
|
76
|
+
def resolve_all
|
77
|
+
resolve(@target)
|
78
|
+
end
|
79
|
+
|
80
|
+
def run
|
81
|
+
if ! @completed
|
82
|
+
@update_proc.call
|
83
|
+
@completed = true
|
84
|
+
file_modified!(@target)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
def initialize(str)
|
88
|
+
@target = str
|
89
|
+
@depend = []
|
90
|
+
@completed = false
|
91
|
+
end
|
92
|
+
|
93
|
+
def from(*dependlist)
|
94
|
+
@depend = dependlist
|
95
|
+
@update_proc = Proc.new {
|
96
|
+
$t = @target
|
97
|
+
$d = @depend
|
98
|
+
yield
|
99
|
+
}
|
100
|
+
add()
|
101
|
+
end
|
102
|
+
def add
|
103
|
+
$targetlist += [self]
|
104
|
+
$file_target_dict[@target] = self
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# since ~ "cd <path>" invalid, add a function here
|
4
|
+
def cd(str)
|
5
|
+
if block_given?
|
6
|
+
orig = Dir.pwd
|
7
|
+
Dir.chdir(str)
|
8
|
+
yield
|
9
|
+
Dir.chdir(orig)
|
10
|
+
else
|
11
|
+
Dir.chdir(str)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# these were like cd function
|
16
|
+
def rm(*str)
|
17
|
+
r"rm #{str.join(' ')}"
|
18
|
+
end
|
19
|
+
|
20
|
+
# these were like cd function
|
21
|
+
def mkdir(*str)
|
22
|
+
r"mkdir #{str.join(' ')}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def r(*str)
|
26
|
+
str = str.join(" ")
|
27
|
+
puts Pastel.new.green("running> ") + str
|
28
|
+
if !system(str)
|
29
|
+
puts Pastel.new.red.bold("error> ") + "command error: " + str
|
30
|
+
raise "make command failed"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# since ~ "cd <path>" invalid, add a function here
|
35
|
+
def cd?(str)
|
36
|
+
begin
|
37
|
+
if block_given?
|
38
|
+
orig = Dir.pwd
|
39
|
+
Dir.chdir(str)
|
40
|
+
yield
|
41
|
+
Dir.chdir(orig)
|
42
|
+
else
|
43
|
+
Dir.chdir(str)
|
44
|
+
end
|
45
|
+
rescue => exception
|
46
|
+
puts Pastel.new.yellow("warning> ") + "command error: cd " + str + " (suppressed)"
|
47
|
+
return false
|
48
|
+
end
|
49
|
+
return true
|
50
|
+
end
|
51
|
+
|
52
|
+
# these were like cd function
|
53
|
+
def rm?(*str)
|
54
|
+
r?"rm #{str.join(' ')}"
|
55
|
+
end
|
56
|
+
|
57
|
+
# these were like cd function
|
58
|
+
def mkdir?(*str)
|
59
|
+
r?"mkdir #{str.join(' ')}"
|
60
|
+
end
|
61
|
+
|
62
|
+
# no error
|
63
|
+
def r?(*str)
|
64
|
+
str = str.join(" ")
|
65
|
+
puts Pastel.new.green("running> ") + str
|
66
|
+
flag = system(str)
|
67
|
+
if !flag
|
68
|
+
puts Pastel.new.yellow("warning> ") + "command error: " + str + " (suppressed)"
|
69
|
+
end
|
70
|
+
flag
|
71
|
+
end
|
72
|
+
|
73
|
+
def runfile(file, *args)
|
74
|
+
path = File.expand_path(file)
|
75
|
+
r path, *args
|
76
|
+
end
|
77
|
+
def runfile?(file, *args)
|
78
|
+
path = File.expand_path(file)
|
79
|
+
r? path, *args
|
80
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "ruby_make_script/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruby_make_script"
|
8
|
+
spec.version = RubyMakeScript::VERSION
|
9
|
+
spec.authors = ["dnailz"]
|
10
|
+
spec.email = ["dnailzb@outlook.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{make script}
|
13
|
+
spec.description = %q{A ruby make DSL for ruby like GNU make. (very simple)}
|
14
|
+
spec.homepage = "https://github.com/DnailZ/ruby_make_script"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/DnailZ/ruby_make_script"
|
24
|
+
spec.metadata["changelog_uri"] = "https://github.com/DnailZ/ruby_make_script"
|
25
|
+
else
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
"public gem pushes."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
p spec.files
|
36
|
+
spec.bindir = "exe"
|
37
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
38
|
+
spec.require_paths = ["lib"]
|
39
|
+
|
40
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
41
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
42
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby_make_script
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- dnailz
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description: A ruby make DSL for ruby like GNU make. (very simple)
|
56
|
+
email:
|
57
|
+
- dnailzb@outlook.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- CODE_OF_CONDUCT.md
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- lib/ruby_make_script.rb
|
72
|
+
- lib/ruby_make_script/target.rb
|
73
|
+
- lib/ruby_make_script/utils.rb
|
74
|
+
- lib/ruby_make_script/version.rb
|
75
|
+
- ruby_make_script.gemspec
|
76
|
+
homepage: https://github.com/DnailZ/ruby_make_script
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata:
|
80
|
+
allowed_push_host: https://rubygems.org
|
81
|
+
homepage_uri: https://github.com/DnailZ/ruby_make_script
|
82
|
+
source_code_uri: https://github.com/DnailZ/ruby_make_script
|
83
|
+
changelog_uri: https://github.com/DnailZ/ruby_make_script
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubygems_version: 3.0.3
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: make script
|
103
|
+
test_files: []
|