rumake 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/Readme.mdown +48 -0
  2. data/bin/rumake +98 -0
  3. metadata +71 -0
@@ -0,0 +1,48 @@
1
+ ## About
2
+
3
+ Rumake is a tiny build system similar to Make and Rake. Simply run the
4
+ "rumake.rb" script in a directory that contains a Rumake file ("rumakefile.rb")
5
+ and optionally specify a target (defualt is "all") to run.
6
+
7
+ ## Example
8
+
9
+ Here's an example (that is also included in the Rumake source) of a Rumake file
10
+ that compiles a simple C program:
11
+
12
+ # Some constant variables
13
+ BIN = 'hello'
14
+ SRC = 'hello.c'
15
+
16
+ # This is the default target
17
+ target :all do
18
+ sh "gcc -o #{BIN} #{SRC}"
19
+ end
20
+
21
+ # This is a target that will clean up after the default target
22
+ target :clean do
23
+ sh "rm #{BIN}"
24
+ end
25
+
26
+ The script works just like a regular Ruby script.
27
+
28
+ ## License
29
+
30
+ Copyright (c) 2010 Austin Gatchell
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining a copy
33
+ of this software and associated documentation files (the "Software"), to deal
34
+ in the Software without restriction, including without limitation the rights
35
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36
+ copies of the Software, and to permit persons to whom the Software is
37
+ furnished to do so, subject to the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be included in
40
+ all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
48
+ THE SOFTWARE.
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright (c) 2010 Austin Gatchell
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.
22
+
23
+ # Rumake version constant
24
+ RUMAKE_VERSION = 'v0.1.2'
25
+
26
+ # All the targets, which are Procs, are added to this global hash. Each key is
27
+ # a symbol of a target's name.
28
+ $targets = {}
29
+
30
+ # A simple target generator
31
+ def target(tar, &block)
32
+ $targets[tar] = block
33
+ end
34
+
35
+ # Display an error message and stop execution of the script. This should be used
36
+ # as the standard way to show error messages and end execution of the target.
37
+ def fail(error = nil)
38
+ puts "Error: #{error}" unless error.nil?
39
+ puts 'Target failed to execute properly.'
40
+ exit 1
41
+ end
42
+
43
+ # Run a shell command
44
+ def sh(command)
45
+ if system(command) == false
46
+ fail("Shell command \"#{command}\" exited with error.")
47
+ end
48
+ end
49
+
50
+ # Change the current working directory
51
+ def cd(dir)
52
+ Dir.chdir(dir)
53
+ end
54
+
55
+ # Get the current working directory
56
+ def getwd
57
+ Dir.getwd
58
+ end
59
+
60
+ # The following code is what actually loads and runs the Rumake file:
61
+
62
+ # Check the first argument
63
+ case ARGV[0]
64
+ when 'help'
65
+ puts 'Usage: rumake [target]'
66
+ puts "\nCommands:"
67
+ puts " help Print this help information."
68
+ puts " version Print the version information."
69
+ exit
70
+ when 'version'
71
+ puts "Rumake #{RUMAKE_VERSION}"
72
+ exit
73
+ when nil
74
+ tar = :all
75
+ else
76
+ tar = ARGV[0].to_sym
77
+ end
78
+
79
+ # Load any file called "rumakefile.rb"
80
+ begin
81
+ file = File::read('rumakefile.rb')
82
+ rescue
83
+ fail('Unable to open "rumakefile.rb"')
84
+ end
85
+
86
+ # Run the Rumake file
87
+ eval(file)
88
+
89
+ # Now, run all of the targets
90
+ if $targets[tar].nil?
91
+ puts "Target \"#{target}\" does not exist."
92
+ exit 1
93
+ else
94
+ $targets[tar].call
95
+
96
+ # The target should have executed successfully by now
97
+ puts 'Target executed successfully.'
98
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rumake
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 2
10
+ version: 0.1.2
11
+ platform: ruby
12
+ authors:
13
+ - Austin Gatchell
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-06-28 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: |-
23
+ Rumake is a tiny Make/Rake-like build utility. Rumake \
24
+ files are just regular Ruby scripts named "rumakefile.rb" that can be run by \
25
+ using "rumake" in the directory containing that file.
26
+ email: austin@ausgat.com
27
+ executables:
28
+ - rumake
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - Readme.mdown
35
+ - bin/rumake
36
+ has_rdoc: true
37
+ homepage: http://github.com/ausgat/Rumake
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options: []
42
+
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ hash: 3
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.3.7
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: A tiny Make/Rake-like build utility.
70
+ test_files: []
71
+