standalone mode

main
sandyx 11 months ago
parent 8740e081f0
commit 9f7e3f15f7

@ -12,13 +12,27 @@
# so put a $ in front of the name which makes
# them global and not CONSTANT
$CC="gcc"
CFLAGS="-O1 -march=native -std=c11 -fmacro-prefix-map=src="
CFLAGS="-O1 -march=native -std=c11"
$EFLAGS = "" #extra flags
APPNAME="chess"
SRCDIR="src"
BUILDDIR="build"
INCLUDE=""
LIB="-lraylib"
LIB=""
EXT=".c" #extension of source file
#should maybe use environment variables for these
#standalone funcs
unless __FILE__ == $0
def error(msg)
puts "#{RUB}: error: #{msg}"
exit 1
end
def message(msg)
puts "#{RUB}: #{msg}"
end
end
#handle argument parsing yourself
def parse(arg)
@ -58,16 +72,18 @@ end
#main build function
def main
if Dir.children(SRCDIR).count == 0
error("src directory empty")
end
#if Dir.children(SRCDIR).count == 0
#error("src directory empty")
#end
error("src directory empty") unless Dir.children(SRCDIR)
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")
message "compiled: #{x}\n" if x.end_with?(".c")
system("#{$CC} #{INCLUDE} #{CFLAGS} #{$EFLAGS} -c #{SRCDIR}/#{x} -o #{BUILDDIR}/#{File.basename(x, ".*") + ".o"}") if x.end_with?(EXT)
message "compiled: #{x}\n" if x.end_with?(EXT)
}
}

Loading…
Cancel
Save