main
sandyx 11 months ago
parent 100883624b
commit 6dceece0e4

@ -20,11 +20,6 @@ BUILDDIR="build"
INCLUDE=""
LIB="-lraylib"
def error(msg)
puts "error: #{msg}"
exit(1)
end
#handle argument parsing yourself
def parse(arg)
case arg
@ -60,12 +55,16 @@ end
#main build function
def main
if Dir.children(SRCDIR).count == 0
error("src directory empty")
end
threads = []
Dir.each_child(SRCDIR) {|x|
threads << Thread.new {
system("#{$CC} #{INCLUDE} #{CFLAGS} #{$EFLAGS} -c #{SRCDIR}/#{x} -o #{BUILDDIR}/#{File.basename(x, ".*") + ".o"}") if x.end_with?(".c")
print "compiled: #{x}\n" if x.end_with?(".c")
message "compiled: #{x}\n" if x.end_with?(".c")
}
}

@ -1,2 +0,0 @@
chmod +x rub
cp rub /usr/local/bin/rub

@ -0,0 +1,10 @@
#!/usr/bin/ruby
require 'fileutils'
RUBDIR = "#{Dir.home}/.rub"
File.mkdir RUBDIR unless File.exist? RUBDIR
FileUtils.cp("build.rb", RUBDIR)
FileUtils.chmod("+x", "rub")
FileUtils.cp("rub", "/usr/local/bin")

56
rub

@ -1,3 +1,57 @@
#!/usr/bin/ruby
require "#{Dir.pwd}/build.rb"
require 'fileutils'
ANSI_RED = "\e[31m"
ANSI_CLEAR = "\e[0m"
RUB = "#{ANSI_RED}RUB#{ANSI_CLEAR}"
RUBDIR = "#{Dir.home}/.rub/"
def error(msg)
puts "#{RUB}: error: #{msg}"
exit 1
end
def message(msg)
puts "#{RUB}: #{msg}"
end
def rub_init(name)
error("src directory already exists") if File.exist? "src"
error("build directory already exists") if File.exist? "build"
error(".git already exists") if File.exist? ".git"
File.mkdir "src"
File.mkdir "build"
FileUtils.cp(RUBDIR + "build.rb", Dir.pwd)
`git init`
`git branch -m main`
end
def parse_arg(arg)
case arg
when "init"
error("no project name provided")
when "meow"
puts "#{RUB}: meow :3"
end
end
def parse_args(argv)
case argv[0]
when "init"
rub_init(argv[1])
end
end
case ARGV.count
when 0
require "#{Dir.pwd}/build.rb"
when 1
parse_arg(ARGV[0])
when 2
parse_args(ARGV)
end

Loading…
Cancel
Save