ucc 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ucc.gemspec
4
+ gemspec
@@ -0,0 +1,15 @@
1
+ UCC
2
+ ===
3
+
4
+ This is a ruby gem that makes it easy to compile small apps using gcc or g++, you even don't need a makefile!
5
+
6
+ Installation
7
+ ------------
8
+
9
+ `gem install ucc`
10
+
11
+
12
+ Usage
13
+ -----
14
+
15
+ See `ucc -h`
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/u++ ADDED
@@ -0,0 +1,2 @@
1
+ require "ucc"
2
+ Ucc::Runner.new("g++")
data/bin/ucc ADDED
@@ -0,0 +1,2 @@
1
+ require "ucc"
2
+ Ucc::Runner.new("gcc")
@@ -0,0 +1,84 @@
1
+ require "ucc/version"
2
+ require "optparse"
3
+
4
+ module Ucc
5
+ WINDOWS = !!((`uname` rescue "") =~ /^$|windows/)
6
+ CURRENT_EXECUTABLE = File.basename($0)
7
+
8
+ class Runner
9
+ attr_reader :source_files
10
+
11
+ def initialize(compiler)
12
+ @compiler = compiler
13
+ raise "Compiler must be specified" unless @compiler
14
+ parse_options
15
+ work
16
+ end
17
+
18
+ # Variables
19
+ # =========
20
+
21
+ def optparse
22
+ @optparse ||= OptionParser.new do |opts|
23
+ opts.banner = "Usage: #{CURRENT_EXECUTABLE} [options] file..."
24
+
25
+ options[:runopts] = nil
26
+ opts.on( '-r', '--runopts "STRING"', 'Pass STRING as the command line arguments to the app' ) do |s|
27
+ options[:runopts] = s
28
+ end
29
+
30
+ options[:memcheck] = false
31
+ opts.on( '-V', '--valgrind', 'Run the app in valgrind' ) do
32
+ options[:memcheck] = true
33
+ end
34
+
35
+ opts.on( '-v', '--version', 'Show app version' ) do
36
+ puts "#{CURRENT_EXECUTABLE} #{VERSION}"
37
+ exit
38
+ end
39
+
40
+ opts.on( '-h', '--help', 'Display this screen' ) do
41
+ puts opts
42
+ exit
43
+ end
44
+ end
45
+ end
46
+
47
+ def options
48
+ @options ||= {}
49
+ end
50
+
51
+ def app_filename
52
+ return @app_filename if @app_filename
53
+ @app_filename = source_files[0].sub(/\.\w+$/, '')
54
+ @app_filename += ".exe" if WINDOWS
55
+ end
56
+
57
+ # Main logic
58
+ # ==========
59
+
60
+ def parse_options
61
+ optparse.parse!
62
+
63
+ # Here we have already parsed ARGV
64
+ @source_files = ARGV
65
+ if @source_files.empty?
66
+ #puts optparse
67
+ puts "#{CURRENT_EXECUTABLE}: no input files"
68
+ exit(1)
69
+ end
70
+ end
71
+
72
+ def work
73
+ exit unless system(%Q[#{@compiler} -Wall -o "#{app_filename}" #{source_files.map{ |f| '"'+f+'"' }.join(" ")}])
74
+
75
+ exec_params = app_filename
76
+ exec_params = "./#{exec_params}" unless WINDOWS
77
+ exec_params = "#{exec_params} #{options[:runopts]}" if options[:runopts]
78
+ exec_params = "valgrind #{exec_params}" if options[:memcheck]
79
+ puts "=== Compiled successfully, executing... === "
80
+ exec exec_params
81
+ end
82
+
83
+ end
84
+ end
@@ -0,0 +1,3 @@
1
+ module Ucc
2
+ VERSION = "2.0.0"
3
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "ucc/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ucc"
7
+ s.version = Ucc::VERSION
8
+ s.authors = ["MOZGIII"]
9
+ s.email = ["mike-n@narod.ru"]
10
+ s.homepage = ""
11
+ s.summary = %q{Use just "ucc file" instead of "gcc -Wall file -o file".}
12
+ s.description = %q{This gem makes it easy to compile small apps using gcc or g++, you even don't need a makefile!}
13
+
14
+ s.rubyforge_project = "ucc"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ucc
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - MOZGIII
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-18 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: This gem makes it easy to compile small apps using gcc or g++, you even
15
+ don't need a makefile!
16
+ email:
17
+ - mike-n@narod.ru
18
+ executables:
19
+ - u++
20
+ - ucc
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - .gitignore
25
+ - Gemfile
26
+ - README.md
27
+ - Rakefile
28
+ - bin/u++
29
+ - bin/ucc
30
+ - lib/ucc.rb
31
+ - lib/ucc/version.rb
32
+ - ucc.gemspec
33
+ homepage: ''
34
+ licenses: []
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubyforge_project: ucc
53
+ rubygems_version: 1.8.10
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: Use just "ucc file" instead of "gcc -Wall file -o file".
57
+ test_files: []