moon_rabbit 1.0.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 +7 -0
- data/.gitignore +21 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +105 -0
- data/Rakefile +1 -0
- data/lib/moon_rabbit/version.rb +3 -0
- data/lib/moon_rabbit.rb +224 -0
- data/moon_rabbit.gemspec +23 -0
- data/sample/Makefile.process +39 -0
- data/sample/Makefiles.rb +23 -0
- data/sample/Rakefile +42 -0
- data/sample/inc/sub.h +6 -0
- data/sample/process.c +35 -0
- data/sample/src/main.c +9 -0
- data/sample/src/sub.c +5 -0
- data/sample/watch.rb +10 -0
- metadata +88 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 64abddbaac9c3544c9f402ddc4adee31f8389d5d
         | 
| 4 | 
            +
              data.tar.gz: 507e22fd773afffc0c8eeb8cab5090aab1e525f8
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 8e7da3b0712eceab27b68258c3d85583c54248c3a365d49426434a9c2bc44bfb9b2b61ec63e6c9c963826d370d241b2f24c463a42fe543c22786ec5eaee2302c
         | 
| 7 | 
            +
              data.tar.gz: 400985e8b6cd1c40368dfdb89e58e77997b754e77a2e55042696456d59c6b4a1ccd6b3523d1a37f6be67190ebc2e0674ab9379ef0276bb0dfc6102175732e422
         | 
    
        data/.gitignore
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            *.gem
         | 
| 2 | 
            +
            *.rbc
         | 
| 3 | 
            +
            .bundle
         | 
| 4 | 
            +
            .config
         | 
| 5 | 
            +
            .yardoc
         | 
| 6 | 
            +
            Gemfile.lock
         | 
| 7 | 
            +
            InstalledFiles
         | 
| 8 | 
            +
            _yardoc
         | 
| 9 | 
            +
            coverage
         | 
| 10 | 
            +
            doc/
         | 
| 11 | 
            +
            lib/bundler/man
         | 
| 12 | 
            +
            pkg
         | 
| 13 | 
            +
            rdoc
         | 
| 14 | 
            +
            spec/reports
         | 
| 15 | 
            +
            test/tmp
         | 
| 16 | 
            +
            test/version_tmp
         | 
| 17 | 
            +
            tmp
         | 
| 18 | 
            +
            sample/Makefile
         | 
| 19 | 
            +
            sample/main
         | 
| 20 | 
            +
            sample/obj
         | 
| 21 | 
            +
            sample/process
         | 
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            Copyright (c) 2015 liveralmask
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            MIT License
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 6 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 7 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 8 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 9 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 10 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 11 | 
            +
            the following conditions:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 14 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 18 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 20 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 21 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 22 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,105 @@ | |
| 1 | 
            +
            # MoonRabbit
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Briefly build & process monitoring scripts.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Installation
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Add this line to your application's Gemfile:
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                gem 'moon_rabbit'
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            And then execute:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                $ bundle
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            Or install it yourself as:
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                $ gem install moon_rabbit
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            ## Usage
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            [Makefiles.rb]  
         | 
| 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"
         | 
| 45 | 
            +
                }
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            [Rakefile]  
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                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 ]
         | 
| 59 | 
            +
                
         | 
| 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
         | 
| 91 | 
            +
             | 
| 92 | 
            +
            [bash]  
         | 
| 93 | 
            +
             | 
| 94 | 
            +
                rake output all
         | 
| 95 | 
            +
                ./main
         | 
| 96 | 
            +
                
         | 
| 97 | 
            +
                ruby watch.rb &
         | 
| 98 | 
            +
             | 
| 99 | 
            +
            ## Contributing
         | 
| 100 | 
            +
             | 
| 101 | 
            +
            1. Fork it ( http://github.com/<my-github-username>/moon_rabbit/fork )
         | 
| 102 | 
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         | 
| 103 | 
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         | 
| 104 | 
            +
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 105 | 
            +
            5. Create new Pull Request
         | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            require "bundler/gem_tasks"
         | 
    
        data/lib/moon_rabbit.rb
    ADDED
    
    | @@ -0,0 +1,224 @@ | |
| 1 | 
            +
            require "moon_rabbit/version"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module MoonRabbit
         | 
| 4 | 
            +
              class Makefile
         | 
| 5 | 
            +
                attr_accessor   :file_path, :compile, :link
         | 
| 6 | 
            +
                
         | 
| 7 | 
            +
                def initialize( file_path = nil, &block )
         | 
| 8 | 
            +
                  @file_path = file_path
         | 
| 9 | 
            +
                  
         | 
| 10 | 
            +
                  @compile = {
         | 
| 11 | 
            +
                    :compiler     => "",
         | 
| 12 | 
            +
                    :main_target  => "",
         | 
| 13 | 
            +
                    :srcs         => [],
         | 
| 14 | 
            +
                    :obj_dir      => ".",
         | 
| 15 | 
            +
                    :options      => [],
         | 
| 16 | 
            +
                  }
         | 
| 17 | 
            +
                  
         | 
| 18 | 
            +
                  @link = {
         | 
| 19 | 
            +
                    :static_libs  => [],
         | 
| 20 | 
            +
                    :options      => [],
         | 
| 21 | 
            +
                  }
         | 
| 22 | 
            +
                  
         | 
| 23 | 
            +
                  instance_eval( &block )
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
                
         | 
| 26 | 
            +
                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
         | 
| 32 | 
            +
                    end
         | 
| 33 | 
            +
                  }
         | 
| 34 | 
            +
                  
         | 
| 35 | 
            +
                  makefile.link.each{|key, value|
         | 
| 36 | 
            +
                    @link[ key ].concat value
         | 
| 37 | 
            +
                  }
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
                
         | 
| 40 | 
            +
                def compiler( compiler )
         | 
| 41 | 
            +
                  @compile[ :compiler ] = compiler
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
                
         | 
| 44 | 
            +
                def main_target( main_target )
         | 
| 45 | 
            +
                  @compile[ :main_target ] = main_target
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
                
         | 
| 48 | 
            +
                def src( src )
         | 
| 49 | 
            +
                  @compile[ :srcs ].push src
         | 
| 50 | 
            +
                end
         | 
| 51 | 
            +
                
         | 
| 52 | 
            +
                def srcs( srcs )
         | 
| 53 | 
            +
                  srcs.each{|src|
         | 
| 54 | 
            +
                    self.src src
         | 
| 55 | 
            +
                  }
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
                
         | 
| 58 | 
            +
                def obj_dir( obj_dir )
         | 
| 59 | 
            +
                  @compile[ :obj_dir ] = obj_dir
         | 
| 60 | 
            +
                end
         | 
| 61 | 
            +
                
         | 
| 62 | 
            +
                def compile_option( compile_option )
         | 
| 63 | 
            +
                  @compile[ :options ].push compile_option
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
                
         | 
| 66 | 
            +
                def compile_options( compile_options )
         | 
| 67 | 
            +
                  compile_options.each{|compile_option|
         | 
| 68 | 
            +
                    self.compile_option compile_option
         | 
| 69 | 
            +
                  }
         | 
| 70 | 
            +
                end
         | 
| 71 | 
            +
                
         | 
| 72 | 
            +
                def static_lib( static_lib )
         | 
| 73 | 
            +
                  @link[ :static_libs ].push static_lib
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
                
         | 
| 76 | 
            +
                def static_libs( static_libs )
         | 
| 77 | 
            +
                  static_libs.each{|static_lib|
         | 
| 78 | 
            +
                    self.static_lib static_lib
         | 
| 79 | 
            +
                  }
         | 
| 80 | 
            +
                end
         | 
| 81 | 
            +
                
         | 
| 82 | 
            +
                def link_option( link_option )
         | 
| 83 | 
            +
                  @link[ :options ].push link_option
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
                
         | 
| 86 | 
            +
                def link_options( link_options )
         | 
| 87 | 
            +
                  link_options.each{|link_option|
         | 
| 88 | 
            +
                    self.link_option link_option
         | 
| 89 | 
            +
                  }
         | 
| 90 | 
            +
                end
         | 
| 91 | 
            +
                
         | 
| 92 | 
            +
                def output
         | 
| 93 | 
            +
                  return if @file_path.nil?
         | 
| 94 | 
            +
                  
         | 
| 95 | 
            +
                  objs = []
         | 
| 96 | 
            +
                  deps = []
         | 
| 97 | 
            +
                  @compile[ :srcs ].each{|src|
         | 
| 98 | 
            +
                    obj = "#{@compile[ :obj_dir ]}/#{sub_ext( src, '.o' )}"
         | 
| 99 | 
            +
                    objs.push obj
         | 
| 100 | 
            +
                    deps.push sub_ext( obj, ".d" )
         | 
| 101 | 
            +
                  }
         | 
| 102 | 
            +
                  src_ext = @compile[ :srcs ].empty? ? nil : File.extname( @compile[ :srcs ].first )
         | 
| 103 | 
            +
                  main_target_ext = File.extname( @compile[ :main_target ] )
         | 
| 104 | 
            +
                  
         | 
| 105 | 
            +
                  open( @file_path, "wb" ){|f|
         | 
| 106 | 
            +
                    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( " " )}
         | 
| 111 | 
            +
            RM                        = rm -f
         | 
| 112 | 
            +
            MKDIR                     = mkdir -p
         | 
| 113 | 
            +
            MAIN_TARGET               = #{@compile[ :main_target ]}
         | 
| 114 | 
            +
            SRCS                      = #{@compile[ :srcs ].join( " " )}
         | 
| 115 | 
            +
            OBJ_DIR                   = #{@compile[ :obj_dir ]}
         | 
| 116 | 
            +
            OBJS                      = #{objs.join( " " )}
         | 
| 117 | 
            +
            DEPS                      = #{deps.join( " " )}
         | 
| 118 | 
            +
             | 
| 119 | 
            +
            .PHONY: all obj clean
         | 
| 120 | 
            +
             | 
| 121 | 
            +
            all: $(MAIN_TARGET)
         | 
| 122 | 
            +
             | 
| 123 | 
            +
            obj: $(OBJS)
         | 
| 124 | 
            +
             | 
| 125 | 
            +
            clean:
         | 
| 126 | 
            +
            	$(RM) $(MAIN_TARGET)
         | 
| 127 | 
            +
            	$(RM) $(OBJS)
         | 
| 128 | 
            +
            	$(RM) $(DEPS)
         | 
| 129 | 
            +
             | 
| 130 | 
            +
            EOS
         | 
| 131 | 
            +
                    
         | 
| 132 | 
            +
                    if ! src_ext.nil?
         | 
| 133 | 
            +
                      f.puts <<EOS
         | 
| 134 | 
            +
            $(OBJ_DIR)/%.o: %#{src_ext}
         | 
| 135 | 
            +
            	@[ -e $(dir $@) ] || $(MKDIR) $(dir $@)
         | 
| 136 | 
            +
            	
         | 
| 137 | 
            +
            	$(COMPILER) $(COMPILE_OPTIONS) -c $< -o $@
         | 
| 138 | 
            +
            	
         | 
| 139 | 
            +
            	@$(COMPILER) $(COMPILE_OPTIONS) -MM -MG -MP $< \\
         | 
| 140 | 
            +
            		| sed "s/.*\\.o/$(subst /,\\/,$@) $(subst /,\\/,$(patsubst %.o,%.d,$@))/g" > $(patsubst %.o,%.d,$@); \\
         | 
| 141 | 
            +
            		[ -s $(patsubst %.o,%.d,$@) ] || $(RM) $(patsubst %.o,%.d,$@)
         | 
| 142 | 
            +
             | 
| 143 | 
            +
            -include $(DEPS)
         | 
| 144 | 
            +
             | 
| 145 | 
            +
            EOS
         | 
| 146 | 
            +
                    end
         | 
| 147 | 
            +
                    
         | 
| 148 | 
            +
                    case main_target_ext
         | 
| 149 | 
            +
                    when ".a"
         | 
| 150 | 
            +
                      f.puts <<EOS
         | 
| 151 | 
            +
            AR = ar r
         | 
| 152 | 
            +
             | 
| 153 | 
            +
            $(MAIN_TARGET): $(OBJS)
         | 
| 154 | 
            +
            	@[ -e $(dir $@) ] || $(MKDIR) $(dir $@)
         | 
| 155 | 
            +
            	
         | 
| 156 | 
            +
            	$(AR) $@ $^
         | 
| 157 | 
            +
             | 
| 158 | 
            +
            EOS
         | 
| 159 | 
            +
                    else
         | 
| 160 | 
            +
                      f.puts <<EOS
         | 
| 161 | 
            +
            $(MAIN_TARGET): $(OBJS) $(STATIC_LIBS)
         | 
| 162 | 
            +
            	@[ -e $(dir $@) ] || $(MKDIR) $(dir $@)
         | 
| 163 | 
            +
            	
         | 
| 164 | 
            +
            	$(COMPILER) $(LINK_OPTIONS) -o $@ $^
         | 
| 165 | 
            +
             | 
| 166 | 
            +
            EOS
         | 
| 167 | 
            +
                    end
         | 
| 168 | 
            +
                  }
         | 
| 169 | 
            +
                end
         | 
| 170 | 
            +
                
         | 
| 171 | 
            +
              protected
         | 
| 172 | 
            +
                def sub_ext( file_path, ext )
         | 
| 173 | 
            +
                  "#{File.dirname( file_path )}/#{File.basename( file_path, '.*' )}#{ext}"
         | 
| 174 | 
            +
                end
         | 
| 175 | 
            +
              end
         | 
| 176 | 
            +
              
         | 
| 177 | 
            +
              class Makefiles
         | 
| 178 | 
            +
                @@makefiles = []
         | 
| 179 | 
            +
                
         | 
| 180 | 
            +
                def self.add( makefile )
         | 
| 181 | 
            +
                  @@makefiles.push makefile
         | 
| 182 | 
            +
                end
         | 
| 183 | 
            +
                
         | 
| 184 | 
            +
                def self.makefiles
         | 
| 185 | 
            +
                  @@makefiles
         | 
| 186 | 
            +
                end
         | 
| 187 | 
            +
                
         | 
| 188 | 
            +
                def self.each
         | 
| 189 | 
            +
                  @@makefiles.each{|makefile|
         | 
| 190 | 
            +
                    yield( makefile )
         | 
| 191 | 
            +
                  }
         | 
| 192 | 
            +
                end
         | 
| 193 | 
            +
                
         | 
| 194 | 
            +
                def self.file_paths
         | 
| 195 | 
            +
                  @@makefiles.collect{|makefile| makefile.file_path}
         | 
| 196 | 
            +
                end
         | 
| 197 | 
            +
                
         | 
| 198 | 
            +
                def self.clear
         | 
| 199 | 
            +
                  @@makefiles = []
         | 
| 200 | 
            +
                end
         | 
| 201 | 
            +
              end
         | 
| 202 | 
            +
              
         | 
| 203 | 
            +
              class Options
         | 
| 204 | 
            +
                @@options = {}
         | 
| 205 | 
            +
                
         | 
| 206 | 
            +
                def self.merge!( options )
         | 
| 207 | 
            +
                  @@options.merge!( options ){|key, value1, value2| "#{value1} #{value2}"}
         | 
| 208 | 
            +
                end
         | 
| 209 | 
            +
                
         | 
| 210 | 
            +
                def self.to_s
         | 
| 211 | 
            +
                  @@options.collect{|key, value| "#{key}='#{value}'"}.join( " " )
         | 
| 212 | 
            +
                end
         | 
| 213 | 
            +
              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 | 
            +
            end
         | 
    
        data/moon_rabbit.gemspec
    ADDED
    
    | @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'moon_rabbit/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = "moon_rabbit"
         | 
| 8 | 
            +
              spec.version       = MoonRabbit::VERSION
         | 
| 9 | 
            +
              spec.authors       = ["liveralmask"]
         | 
| 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      = ""
         | 
| 14 | 
            +
              spec.license       = "MIT"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              spec.files         = `git ls-files -z`.split("\x0")
         | 
| 17 | 
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         | 
| 18 | 
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 19 | 
            +
              spec.require_paths = ["lib"]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              spec.add_development_dependency "bundler", "~> 1.5"
         | 
| 22 | 
            +
              spec.add_development_dependency "rake", "~> 0"
         | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,39 @@ | |
| 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/Makefiles.rb
    ADDED
    
    | @@ -0,0 +1,23 @@ | |
| 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"
         | 
| 13 | 
            +
            }
         | 
| 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
    ADDED
    
    | @@ -0,0 +1,42 @@ | |
| 1 | 
            +
            require "moon_rabbit"
         | 
| 2 | 
            +
            include MoonRabbit
         | 
| 3 | 
            +
             | 
| 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
         | 
    
        data/sample/inc/sub.h
    ADDED
    
    
    
        data/sample/process.c
    ADDED
    
    | @@ -0,0 +1,35 @@ | |
| 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/src/main.c
    ADDED
    
    
    
        data/sample/src/sub.c
    ADDED
    
    
    
        data/sample/watch.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | @@ -0,0 +1,88 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: moon_rabbit
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 1.0.3
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - liveralmask
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2015-05-13 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.5'
         | 
| 20 | 
            +
              type: :development
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '1.5'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rake
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            description: Briefly build & process monitoring scripts.
         | 
| 42 | 
            +
            email:
         | 
| 43 | 
            +
            - liveralmask.lisk@gmail.com
         | 
| 44 | 
            +
            executables: []
         | 
| 45 | 
            +
            extensions: []
         | 
| 46 | 
            +
            extra_rdoc_files: []
         | 
| 47 | 
            +
            files:
         | 
| 48 | 
            +
            - ".gitignore"
         | 
| 49 | 
            +
            - Gemfile
         | 
| 50 | 
            +
            - LICENSE.txt
         | 
| 51 | 
            +
            - README.md
         | 
| 52 | 
            +
            - Rakefile
         | 
| 53 | 
            +
            - lib/moon_rabbit.rb
         | 
| 54 | 
            +
            - lib/moon_rabbit/version.rb
         | 
| 55 | 
            +
            - moon_rabbit.gemspec
         | 
| 56 | 
            +
            - sample/Makefile.process
         | 
| 57 | 
            +
            - sample/Makefiles.rb
         | 
| 58 | 
            +
            - sample/Rakefile
         | 
| 59 | 
            +
            - sample/inc/sub.h
         | 
| 60 | 
            +
            - sample/process.c
         | 
| 61 | 
            +
            - sample/src/main.c
         | 
| 62 | 
            +
            - sample/src/sub.c
         | 
| 63 | 
            +
            - sample/watch.rb
         | 
| 64 | 
            +
            homepage: ''
         | 
| 65 | 
            +
            licenses:
         | 
| 66 | 
            +
            - MIT
         | 
| 67 | 
            +
            metadata: {}
         | 
| 68 | 
            +
            post_install_message: 
         | 
| 69 | 
            +
            rdoc_options: []
         | 
| 70 | 
            +
            require_paths:
         | 
| 71 | 
            +
            - lib
         | 
| 72 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
              requirements:
         | 
| 74 | 
            +
              - - ">="
         | 
| 75 | 
            +
                - !ruby/object:Gem::Version
         | 
| 76 | 
            +
                  version: '0'
         | 
| 77 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 78 | 
            +
              requirements:
         | 
| 79 | 
            +
              - - ">="
         | 
| 80 | 
            +
                - !ruby/object:Gem::Version
         | 
| 81 | 
            +
                  version: '0'
         | 
| 82 | 
            +
            requirements: []
         | 
| 83 | 
            +
            rubyforge_project: 
         | 
| 84 | 
            +
            rubygems_version: 2.2.2
         | 
| 85 | 
            +
            signing_key: 
         | 
| 86 | 
            +
            specification_version: 4
         | 
| 87 | 
            +
            summary: Briefly build & process monitoring scripts.
         | 
| 88 | 
            +
            test_files: []
         |