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 # so put a $ in front of the name which makes
# them global and not CONSTANT # them global and not CONSTANT
$CC="gcc" $CC="gcc"
CFLAGS="-O1 -march=native -std=c11 -fmacro-prefix-map=src=" CFLAGS="-O1 -march=native -std=c11"
$EFLAGS = "" #extra flags $EFLAGS = "" #extra flags
APPNAME="chess" APPNAME="chess"
SRCDIR="src" SRCDIR="src"
BUILDDIR="build" BUILDDIR="build"
INCLUDE="" 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 #handle argument parsing yourself
def parse(arg) def parse(arg)
@ -58,16 +72,18 @@ end
#main build function #main build function
def main def main
if Dir.children(SRCDIR).count == 0 #if Dir.children(SRCDIR).count == 0
error("src directory empty") #error("src directory empty")
end #end
error("src directory empty") unless Dir.children(SRCDIR)
threads = [] threads = []
Dir.each_child(SRCDIR) {|x| Dir.each_child(SRCDIR) {|x|
threads << Thread.new { threads << Thread.new {
system("#{$CC} #{INCLUDE} #{CFLAGS} #{$EFLAGS} -c #{SRCDIR}/#{x} -o #{BUILDDIR}/#{File.basename(x, ".*") + ".o"}") 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?(".c") message "compiled: #{x}\n" if x.end_with?(EXT)
} }
} }

Loading…
Cancel
Save