moon_rabbit 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64abddbaac9c3544c9f402ddc4adee31f8389d5d
4
- data.tar.gz: 507e22fd773afffc0c8eeb8cab5090aab1e525f8
3
+ metadata.gz: 59063aa3cca34929f0bfa18b0d327478d2499379
4
+ data.tar.gz: 88eca6098afe03eef4877e1a58b0cc736499b46d
5
5
  SHA512:
6
- metadata.gz: 8e7da3b0712eceab27b68258c3d85583c54248c3a365d49426434a9c2bc44bfb9b2b61ec63e6c9c963826d370d241b2f24c463a42fe543c22786ec5eaee2302c
7
- data.tar.gz: 400985e8b6cd1c40368dfdb89e58e77997b754e77a2e55042696456d59c6b4a1ccd6b3523d1a37f6be67190ebc2e0674ab9379ef0276bb0dfc6102175732e422
6
+ metadata.gz: 64d39f4dc19785b10b4e94e5192d4457fc3c48a7a57a65564b6f541043becbd4fe42ea651d65f316e24a06810b12b78a9c3124b4968015237b5636358b8bbb16
7
+ data.tar.gz: e93ebc33eaa3f0ff9f739343b75e11105e1798ae26452c2dcc1f253967575a1706a2c5f58aea3e305dabc7867fa3dddce6dfe93d02f2ddf89fbbc70136ab93f0
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MoonRabbit
2
2
 
3
- Briefly build & process monitoring scripts.
3
+ Briefly build scripts.
4
4
 
5
5
  ## Installation
6
6
 
@@ -20,85 +20,36 @@ Or install it yourself as:
20
20
 
21
21
  [Makefiles.rb]
22
22
 
23
- require "moon_rabbit"
24
- include MoonRabbit
25
-
26
- Makefiles.add Makefile.new( "Makefile" ){
27
- compiler "gcc"
28
- main_target "main"
29
- srcs [
30
- "src/main.c",
31
- "src/sub.c"
32
- ]
33
- obj_dir "obj"
34
- compile_option "-Iinc -g -Wall -O2"
35
- }
36
-
37
- Makefiles.add Makefile.new( "Makefile.process" ){
38
- compiler "gcc"
39
- main_target "process"
40
- srcs [
41
- "process.c"
42
- ]
43
- obj_dir "obj"
44
- compile_option "-g -Wall -O2"
23
+ MoonRabbit::Makefiles.add MoonRabbit::Makefile.new{
24
+ path "Makefile"
25
+ compiler "gcc"
26
+ main_target "main"
27
+ srcs [
28
+ "src/main.c",
29
+ "src/sub.c"
30
+ ]
31
+ obj_dir "obj"
32
+ compile_option "-Iinc -g -Wall -O2"
45
33
  }
46
34
 
47
35
  [Rakefile]
48
36
 
49
37
  require "moon_rabbit"
50
- include MoonRabbit
51
-
52
- def make( option )
53
- Makefiles.file_paths.each{|file_path|
54
- sh "make #{option} -f #{file_path}"
55
- }
56
- end
57
-
58
- task :default => [ :all ]
38
+ require "moon_rabbit/Rakefile"
39
+ require "./Makefiles"
59
40
 
60
- desc "All Build"
61
- task :all do |t, args|
62
- require "./Makefiles"
63
-
64
- make Options.to_s
65
- end
66
-
67
- desc "Clean Build"
68
- task :clean do |t, args|
69
- require "./Makefiles"
70
-
71
- make "clean"
72
- end
73
-
74
- desc "Remove Makefiles"
75
- task :rm do |t, args|
76
- require "./Makefiles"
77
-
78
- Makefiles.file_paths.each{|file_path|
79
- sh "rm -f #{file_path}"
80
- }
81
- end
82
-
83
- desc "Output Makefiles"
84
- task :output do |t, args|
85
- require "./Makefiles"
86
-
87
- Makefiles.each{|makefile|
88
- makefile.output
89
- }
90
- end
41
+ task :default => [ :build ]
91
42
 
92
43
  [bash]
93
44
 
94
- rake output all
95
- ./main
45
+ rake output # Output Makefile
46
+ rake build # Build Makefile
96
47
 
97
- ruby watch.rb &
48
+ ./main
98
49
 
99
50
  ## Contributing
100
51
 
101
- 1. Fork it ( http://github.com/<my-github-username>/moon_rabbit/fork )
52
+ 1. Fork it ( http://github.com/liveralmask/moon_rabbit/fork )
102
53
  2. Create your feature branch (`git checkout -b my-new-feature`)
103
54
  3. Commit your changes (`git commit -am 'Add some feature'`)
104
55
  4. Push to the branch (`git push origin my-new-feature`)
data/lib/moon_rabbit.rb CHANGED
@@ -2,12 +2,14 @@ require "moon_rabbit/version"
2
2
 
3
3
  module MoonRabbit
4
4
  class Makefile
5
- attr_accessor :file_path, :compile, :link
5
+ attr_accessor :files, :compiles, :links
6
6
 
7
- def initialize( file_path = nil, &block )
8
- @file_path = file_path
7
+ def initialize( &block )
8
+ @files = {
9
+ :path => "",
10
+ }
9
11
 
10
- @compile = {
12
+ @compiles = {
11
13
  :compiler => "",
12
14
  :main_target => "",
13
15
  :srcs => [],
@@ -15,7 +17,7 @@ module MoonRabbit
15
17
  :options => [],
16
18
  }
17
19
 
18
- @link = {
20
+ @links = {
19
21
  :static_libs => [],
20
22
  :options => [],
21
23
  }
@@ -24,29 +26,37 @@ module MoonRabbit
24
26
  end
25
27
 
26
28
  def add( makefile )
27
- makefile.compile.each{|key, value|
28
- if @compile[ key ].instance_of?( String )
29
- @compile[ key ] = value
30
- elsif @compile[ key ].instance_of?( Array )
31
- @compile[ key ].concat value
29
+ makefile.files.each{|key, value|
30
+ @files[ key ] = value
31
+ }
32
+
33
+ makefile.compiles.each{|key, value|
34
+ if @compiles[ key ].instance_of?( String )
35
+ @compiles[ key ] = value
36
+ elsif @compiles[ key ].instance_of?( Array )
37
+ @compiles[ key ].concat value
32
38
  end
33
39
  }
34
40
 
35
- makefile.link.each{|key, value|
36
- @link[ key ].concat value
41
+ makefile.links.each{|key, value|
42
+ @links[ key ].concat value
37
43
  }
38
44
  end
39
45
 
46
+ def path( path )
47
+ @files[ :path ] = path
48
+ end
49
+
40
50
  def compiler( compiler )
41
- @compile[ :compiler ] = compiler
51
+ @compiles[ :compiler ] = compiler
42
52
  end
43
53
 
44
54
  def main_target( main_target )
45
- @compile[ :main_target ] = main_target
55
+ @compiles[ :main_target ] = main_target
46
56
  end
47
57
 
48
58
  def src( src )
49
- @compile[ :srcs ].push src
59
+ @compiles[ :srcs ].push src
50
60
  end
51
61
 
52
62
  def srcs( srcs )
@@ -56,11 +66,11 @@ module MoonRabbit
56
66
  end
57
67
 
58
68
  def obj_dir( obj_dir )
59
- @compile[ :obj_dir ] = obj_dir
69
+ @compiles[ :obj_dir ] = obj_dir
60
70
  end
61
71
 
62
72
  def compile_option( compile_option )
63
- @compile[ :options ].push compile_option
73
+ @compiles[ :options ].push compile_option
64
74
  end
65
75
 
66
76
  def compile_options( compile_options )
@@ -70,7 +80,7 @@ module MoonRabbit
70
80
  end
71
81
 
72
82
  def static_lib( static_lib )
73
- @link[ :static_libs ].push static_lib
83
+ @links[ :static_libs ].push static_lib
74
84
  end
75
85
 
76
86
  def static_libs( static_libs )
@@ -80,7 +90,7 @@ module MoonRabbit
80
90
  end
81
91
 
82
92
  def link_option( link_option )
83
- @link[ :options ].push link_option
93
+ @links[ :options ].push link_option
84
94
  end
85
95
 
86
96
  def link_options( link_options )
@@ -90,38 +100,34 @@ module MoonRabbit
90
100
  end
91
101
 
92
102
  def output
93
- return if @file_path.nil?
94
-
95
103
  objs = []
96
104
  deps = []
97
- @compile[ :srcs ].each{|src|
98
- obj = "#{@compile[ :obj_dir ]}/#{sub_ext( src, '.o' )}"
105
+ @compiles[ :srcs ].each{|src|
106
+ obj = "#{@compiles[ :obj_dir ]}/#{change_ext( src, '.o' )}"
99
107
  objs.push obj
100
- deps.push sub_ext( obj, ".d" )
108
+ deps.push change_ext( obj, ".d" )
101
109
  }
102
- src_ext = @compile[ :srcs ].empty? ? nil : File.extname( @compile[ :srcs ].first )
103
- main_target_ext = File.extname( @compile[ :main_target ] )
110
+ src_ext = File.extname( @compiles[ :srcs ].first )
111
+ main_target_ext = File.extname( @compiles[ :main_target ] )
104
112
 
105
- open( @file_path, "wb" ){|f|
113
+ open( @files[ :path ], "wb" ){|f|
106
114
  f.puts <<EOS
107
- COMPILER = #{@compile[ :compiler ]}
108
- override COMPILE_OPTIONS += #{@compile[ :options ].join( " " )}
109
- override LINK_OPTIONS += #{@link[ :options ].join( " " )}
110
- override STATIC_LIBS += #{@link[ :static_libs ].join( " " )}
115
+ override COMPILER += #{@compiles[ :compiler ]}
116
+ override COMPILE_OPTIONS += #{@compiles[ :options ].join( " " )}
117
+ override LINK_OPTIONS += #{@links[ :options ].join( " " )}
118
+ override STATIC_LIBS += #{@links[ :static_libs ].join( " " )}
111
119
  RM = rm -f
112
120
  MKDIR = mkdir -p
113
- MAIN_TARGET = #{@compile[ :main_target ]}
114
- SRCS = #{@compile[ :srcs ].join( " " )}
115
- OBJ_DIR = #{@compile[ :obj_dir ]}
121
+ MAIN_TARGET = #{@compiles[ :main_target ]}
122
+ SRCS = #{@compiles[ :srcs ].join( " " )}
123
+ OBJ_DIR = #{@compiles[ :obj_dir ]}
116
124
  OBJS = #{objs.join( " " )}
117
125
  DEPS = #{deps.join( " " )}
118
126
 
119
- .PHONY: all obj clean
127
+ .PHONY: all clean
120
128
 
121
129
  all: $(MAIN_TARGET)
122
130
 
123
- obj: $(OBJS)
124
-
125
131
  clean:
126
132
  $(RM) $(MAIN_TARGET)
127
133
  $(RM) $(OBJS)
@@ -129,8 +135,7 @@ clean:
129
135
 
130
136
  EOS
131
137
 
132
- if ! src_ext.nil?
133
- f.puts <<EOS
138
+ f.puts <<EOS
134
139
  $(OBJ_DIR)/%.o: %#{src_ext}
135
140
  @[ -e $(dir $@) ] || $(MKDIR) $(dir $@)
136
141
 
@@ -143,7 +148,6 @@ $(OBJ_DIR)/%.o: %#{src_ext}
143
148
  -include $(DEPS)
144
149
 
145
150
  EOS
146
- end
147
151
 
148
152
  case main_target_ext
149
153
  when ".a"
@@ -168,8 +172,7 @@ EOS
168
172
  }
169
173
  end
170
174
 
171
- protected
172
- def sub_ext( file_path, ext )
175
+ def change_ext( file_path, ext )
173
176
  "#{File.dirname( file_path )}/#{File.basename( file_path, '.*' )}#{ext}"
174
177
  end
175
178
  end
@@ -192,7 +195,7 @@ EOS
192
195
  end
193
196
 
194
197
  def self.file_paths
195
- @@makefiles.collect{|makefile| makefile.file_path}
198
+ @@makefiles.collect{|makefile| makefile.files[ :path ]}
196
199
  end
197
200
 
198
201
  def self.clear
@@ -211,14 +214,4 @@ EOS
211
214
  @@options.collect{|key, value| "#{key}='#{value}'"}.join( " " )
212
215
  end
213
216
  end
214
-
215
- module PermanentProcess
216
- def self.watch( command, &block )
217
- begin
218
- pid = Process.spawn( command )
219
-
220
- Process.waitpid( pid )
221
- end while instance_exec( $?, &block )
222
- end
223
- end
224
217
  end
@@ -0,0 +1,37 @@
1
+ def file_paths
2
+ ENV.key?( "FILE_PATHS" ) ? ENV[ "FILE_PATHS" ].split( /\s+/ ) : MoonRabbit::Makefiles.file_paths
3
+ end
4
+
5
+ desc "Clean"
6
+ task :clean do |task, args|
7
+ file_paths.each{|file_path|
8
+ sh "make clean -f #{file_path}"
9
+ }
10
+ end
11
+
12
+ desc "Build"
13
+ task :build do |task, args|
14
+ file_paths.each{|file_path|
15
+ sh "make #{MoonRabbit::Options} -f #{file_path}"
16
+ }
17
+ end
18
+
19
+ desc "Remove Makefiles"
20
+ task :remove do |task, args|
21
+ file_paths.each{|file_path|
22
+ sh "rm -f #{file_path}"
23
+ }
24
+ end
25
+
26
+ desc "Output Makefiles"
27
+ task :output do |task, args|
28
+ MoonRabbit::Makefiles.each{|makefile|
29
+ makefile.output
30
+ }
31
+ end
32
+
33
+ desc "Show Variables"
34
+ task :show do |task, args|
35
+ puts "[file_paths] #{file_paths.join( ' ' )}"
36
+ puts "[options] #{MoonRabbit::Options}"
37
+ end
@@ -1,3 +1,3 @@
1
1
  module MoonRabbit
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
data/moon_rabbit.gemspec CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.version = MoonRabbit::VERSION
9
9
  spec.authors = ["liveralmask"]
10
10
  spec.email = ["liveralmask.lisk@gmail.com"]
11
- spec.summary = %q{Briefly build & process monitoring scripts.}
12
- spec.description = %q{Briefly build & process monitoring scripts.}
13
- spec.homepage = ""
11
+ spec.summary = %q{Briefly build scripts.}
12
+ spec.description = %q{Briefly build scripts.}
13
+ spec.homepage = "https://github.com/liveralmask/moon_rabbit"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
data/sample/Makefiles.rb CHANGED
@@ -1,23 +1,11 @@
1
- require "moon_rabbit"
2
- include MoonRabbit
3
-
4
- Makefiles.add Makefile.new( "Makefile" ){
5
- compiler "gcc"
6
- main_target "main"
7
- srcs [
8
- "src/main.c",
9
- "src/sub.c"
10
- ]
11
- obj_dir "obj"
12
- compile_option "-Iinc -g -Wall -O2"
1
+ MoonRabbit::Makefiles.add MoonRabbit::Makefile.new{
2
+ path "Makefile"
3
+ compiler "gcc"
4
+ main_target "main"
5
+ srcs [
6
+ "src/main.c",
7
+ "src/sub.c"
8
+ ]
9
+ obj_dir "obj"
10
+ compile_option "-Iinc -g -Wall -O2"
13
11
  }
14
-
15
- Makefiles.add Makefile.new( "Makefile.process" ){
16
- compiler "gcc"
17
- main_target "process"
18
- srcs [
19
- "process.c"
20
- ]
21
- obj_dir "obj"
22
- compile_option "-g -Wall -O2"
23
- }
data/sample/Rakefile CHANGED
@@ -1,42 +1,5 @@
1
1
  require "moon_rabbit"
2
- include MoonRabbit
2
+ require "moon_rabbit/Rakefile"
3
+ require "./Makefiles"
3
4
 
4
- def make( option )
5
- Makefiles.file_paths.each{|file_path|
6
- sh "make #{option} -f #{file_path}"
7
- }
8
- end
9
-
10
- task :default => [ :all ]
11
-
12
- desc "All Build"
13
- task :all do |t, args|
14
- require "./Makefiles"
15
-
16
- make Options.to_s
17
- end
18
-
19
- desc "Clean Build"
20
- task :clean do |t, args|
21
- require "./Makefiles"
22
-
23
- make "clean"
24
- end
25
-
26
- desc "Remove Makefiles"
27
- task :rm do |t, args|
28
- require "./Makefiles"
29
-
30
- Makefiles.file_paths.each{|file_path|
31
- sh "rm -f #{file_path}"
32
- }
33
- end
34
-
35
- desc "Output Makefiles"
36
- task :output do |t, args|
37
- require "./Makefiles"
38
-
39
- Makefiles.each{|makefile|
40
- makefile.output
41
- }
42
- end
5
+ task :default => [ :build ]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moon_rabbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - liveralmask
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-13 00:00:00.000000000 Z
11
+ date: 2015-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: Briefly build & process monitoring scripts.
41
+ description: Briefly build scripts.
42
42
  email:
43
43
  - liveralmask.lisk@gmail.com
44
44
  executables: []
@@ -51,17 +51,15 @@ files:
51
51
  - README.md
52
52
  - Rakefile
53
53
  - lib/moon_rabbit.rb
54
+ - lib/moon_rabbit/Rakefile.rb
54
55
  - lib/moon_rabbit/version.rb
55
56
  - moon_rabbit.gemspec
56
- - sample/Makefile.process
57
57
  - sample/Makefiles.rb
58
58
  - sample/Rakefile
59
59
  - sample/inc/sub.h
60
- - sample/process.c
61
60
  - sample/src/main.c
62
61
  - sample/src/sub.c
63
- - sample/watch.rb
64
- homepage: ''
62
+ homepage: https://github.com/liveralmask/moon_rabbit
65
63
  licenses:
66
64
  - MIT
67
65
  metadata: {}
@@ -84,5 +82,5 @@ rubyforge_project:
84
82
  rubygems_version: 2.2.2
85
83
  signing_key:
86
84
  specification_version: 4
87
- summary: Briefly build & process monitoring scripts.
85
+ summary: Briefly build scripts.
88
86
  test_files: []
@@ -1,39 +0,0 @@
1
- COMPILER = gcc
2
- override COMPILE_OPTIONS += -g -Wall -O2
3
- override LINK_OPTIONS +=
4
- override STATIC_LIBS +=
5
- RM = rm -f
6
- MKDIR = mkdir -p
7
- MAIN_TARGET = process
8
- SRCS = process.c
9
- OBJ_DIR = obj
10
- OBJS = obj/./process.o
11
- DEPS = obj/./process.d
12
-
13
- .PHONY: all obj clean
14
-
15
- all: $(MAIN_TARGET)
16
-
17
- obj: $(OBJS)
18
-
19
- clean:
20
- $(RM) $(MAIN_TARGET)
21
- $(RM) $(OBJS)
22
- $(RM) $(DEPS)
23
-
24
- $(OBJ_DIR)/%.o: %.c
25
- @[ -e $(dir $@) ] || $(MKDIR) $(dir $@)
26
-
27
- $(COMPILER) $(COMPILE_OPTIONS) -c $< -o $@
28
-
29
- @$(COMPILER) $(COMPILE_OPTIONS) -MM -MG -MP $< \
30
- | sed "s/.*\.o/$(subst /,\/,$@) $(subst /,\/,$(patsubst %.o,%.d,$@))/g" > $(patsubst %.o,%.d,$@); \
31
- [ -s $(patsubst %.o,%.d,$@) ] || $(RM) $(patsubst %.o,%.d,$@)
32
-
33
- -include $(DEPS)
34
-
35
- $(MAIN_TARGET): $(OBJS) $(STATIC_LIBS)
36
- @[ -e $(dir $@) ] || $(MKDIR) $(dir $@)
37
-
38
- $(COMPILER) $(LINK_OPTIONS) -o $@ $^
39
-
data/sample/process.c DELETED
@@ -1,35 +0,0 @@
1
- #include <stdio.h>
2
- #include <unistd.h>
3
- #include <signal.h>
4
- #include <string.h>
5
- #include <stdlib.h>
6
- #include <stdbool.h>
7
-
8
- static bool g_IsContinue = true;
9
-
10
- void signal_handler( int value, siginfo_t* info, void * context ){
11
- printf( "signal_handler: value=%d\n", value );
12
-
13
- if ( SIGTERM == value ){
14
- g_IsContinue = false;
15
- }
16
- }
17
-
18
- int main( int argc, char* argv[] ){
19
- int result = 0;
20
- if ( argc <= 1 ){
21
- struct sigaction new_action;
22
- memset( &new_action, 0, sizeof( new_action ) );
23
- new_action.sa_sigaction = signal_handler;
24
- new_action.sa_mask = 0;
25
- new_action.sa_flags = SA_SIGINFO | SA_NOCLDWAIT;
26
- sigaction( SIGINT, &new_action, NULL );
27
-
28
- do{
29
- sleep( 1 );
30
- }while ( g_IsContinue );
31
- }else{
32
- result = strtol( argv[ 1 ], NULL, 0 );
33
- }
34
- return result;
35
- }
data/sample/watch.rb DELETED
@@ -1,10 +0,0 @@
1
- require "moon_rabbit"
2
- include MoonRabbit
3
-
4
- count = 0
5
- PermanentProcess.watch( "./process" ){|status|
6
- p status
7
-
8
- count = count + 1
9
- ( count <= 3 )
10
- }