c0_setup 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/c0_setup +17 -0
- data/cc0 +0 -0
- data/coin +0 -0
- data/lib/c0_setup.rb +105 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 002018b1b3177d7f303ad7eb0c35db70f8a23c4d
|
4
|
+
data.tar.gz: c2204473ddde76fbfdcb805b49ebee003bfcf74a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 153e8f3e9e18b225f28ae3f51c5813a0acf7877e64d3a7c4639e1056888b694a05e2aaa30cc1a096c7b390e7f2a18b543f06a76d401fb16ebad93709bbde0b7a
|
7
|
+
data.tar.gz: 5ca62af343d469037e340d03eadc2c3d4322cd50ea76d39a7a536c4d6103aba4c02c1670d499c5d38f1a56d38aca2b6f4422e4b1f43c726963cf8a70e8f87d71
|
data/bin/c0_setup
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# an unofficial setup utility for C0, a subset of C used to teach 15-122 @ CMU
|
4
|
+
# should work on unix/bsd (linux/mac)
|
5
|
+
|
6
|
+
require 'c0_setup'
|
7
|
+
|
8
|
+
unless ARGV[0].nil? or ARGV[0] != "install"
|
9
|
+
puts "Trying to setup C0 utilities..."
|
10
|
+
result = C0Setup.new.setup
|
11
|
+
puts result
|
12
|
+
puts "make sure you restart your terminal session for any changes to take effect" if !result.empty?
|
13
|
+
else
|
14
|
+
puts "to install c0 utils (cc0 and coin), try again 'cc0-setup install"
|
15
|
+
end
|
16
|
+
|
17
|
+
|
data/cc0
ADDED
Binary file
|
data/coin
ADDED
Binary file
|
data/lib/c0_setup.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
# an unofficial setup utility for C0, a subset of C used to teach 15-122 @ CMU
|
2
|
+
# should work on unix/bsd (linux/mac)
|
3
|
+
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
class C0Setup
|
7
|
+
|
8
|
+
# do the setup yo
|
9
|
+
def setup
|
10
|
+
to_do = check_precedence()
|
11
|
+
result = []
|
12
|
+
if to_do.include? "runpath"
|
13
|
+
if create_runpath
|
14
|
+
result.push "successfully created runpath"
|
15
|
+
else
|
16
|
+
result.push "failed to create runpath"
|
17
|
+
return result
|
18
|
+
end
|
19
|
+
else
|
20
|
+
result.push ".c0 folder already exists, remove it and retry if broken"
|
21
|
+
return result
|
22
|
+
end
|
23
|
+
if to_do.include? "cc0"
|
24
|
+
if install_cc0
|
25
|
+
result.push "successfully installed cc0"
|
26
|
+
else
|
27
|
+
result.push "failed to install cc0"
|
28
|
+
end
|
29
|
+
else
|
30
|
+
result.push "cc0 is already installed somewhere, remove it and retry if broken"
|
31
|
+
end
|
32
|
+
if to_do.include? "coin"
|
33
|
+
if install_coin
|
34
|
+
result.push "successfully installed coin"
|
35
|
+
else
|
36
|
+
result.push "failed to install coin"
|
37
|
+
end
|
38
|
+
else
|
39
|
+
result.push "cc0 is already installed somewhere, remove it and retry if broken"
|
40
|
+
end
|
41
|
+
return result
|
42
|
+
end
|
43
|
+
|
44
|
+
# check for things that don't exist yet
|
45
|
+
def check_precedence
|
46
|
+
Dir.chdir(File.expand_path("~")) do
|
47
|
+
not_yet = []
|
48
|
+
if which("cc0").nil?
|
49
|
+
not_yet.push("cc0")
|
50
|
+
end
|
51
|
+
if which("coin").nil?
|
52
|
+
not_yet.push("coin")
|
53
|
+
end
|
54
|
+
if !Dir.exist?(".c0")
|
55
|
+
not_yet.push("runpath")
|
56
|
+
end
|
57
|
+
return not_yet
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# create folder for binaries and set executable path
|
62
|
+
def create_runpath
|
63
|
+
Dir.chdir(File.expand_path("~")) do
|
64
|
+
Dir.mkdir ".c0"
|
65
|
+
File.new ".bashrc" unless File.exist? ".bashrc"
|
66
|
+
File.open(".bashrc", "a") do |file|
|
67
|
+
file.puts "export PATH=$PATH:~/.c0"
|
68
|
+
end
|
69
|
+
in_path = File.open(".bashrc", "r").read.include? "export PATH=$PATH:~/.c0"
|
70
|
+
return (in_path and Dir.exist? ".c0")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def install_cc0
|
75
|
+
# copy the cc0 binary to "~/.c0"
|
76
|
+
user = File.expand_path("~")
|
77
|
+
Dir.chdir(File.dirname __dir__) do
|
78
|
+
FileUtils.cp("./cc0", "#{user}/.c0")
|
79
|
+
end
|
80
|
+
return File.exist?("#{user}/.c0/cc0")
|
81
|
+
end
|
82
|
+
|
83
|
+
def install_coin
|
84
|
+
# copy the coin binary to "~/.c0"
|
85
|
+
user = File.expand_path("~")
|
86
|
+
Dir.chdir(File.dirname __dir__) do
|
87
|
+
FileUtils.cp("./coin", "#{user}/.c0")
|
88
|
+
end
|
89
|
+
return File.exist?("#{user}/.c0/coin")
|
90
|
+
end
|
91
|
+
|
92
|
+
def which(cmd)
|
93
|
+
# check for the presence of a binary in $PATH
|
94
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
95
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
96
|
+
exts.each do |ext|
|
97
|
+
exe = File.join(path, "#{cmd}#{ext}")
|
98
|
+
return exe if File.executable?(exe) && !File.directory?(exe)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
return nil
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: c0_setup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Brigden
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-16 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Setup C0 compiler and interpreter (cc0 and coin)
|
14
|
+
email: rbrigden@cmu.edu
|
15
|
+
executables:
|
16
|
+
- c0_setup
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/c0_setup
|
21
|
+
- cc0
|
22
|
+
- coin
|
23
|
+
- lib/c0_setup.rb
|
24
|
+
homepage: https://github.com/rbrigden
|
25
|
+
licenses: []
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.4.8
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: An unofficial setup utility for C0, a subset of C used to teach 15-122 @
|
47
|
+
CMU
|
48
|
+
test_files: []
|
49
|
+
has_rdoc:
|