From 68e3b568feae6a54eb15f943dec509b3785e42aa Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 18 Aug 2014 20:53:21 -0400 Subject: [PATCH] Tweaked rakefile --- .gitignore | 1 + Rakefile | 22 ++++++++- SConstruct | 130 +++++++++++++++++++++-------------------------------- 3 files changed, 73 insertions(+), 80 deletions(-) diff --git a/.gitignore b/.gitignore index 4af146e..ccc2726 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ cscope.out Makefile .sconsign.dblite .DS_Store +.rsconscache diff --git a/Rakefile b/Rakefile index d81d9c4..14c6a51 100644 --- a/Rakefile +++ b/Rakefile @@ -64,7 +64,27 @@ BaseEnv = Environment.new(echo: :command) do |env| env["CFLAGS"] += ['-Wall', '-Wextra' ]#, '-Werror'] end -task(:build) { BaseEnv.Program('build/bin/sclpl', FileList['source/sclpl/*.c']) } +#------------------------------------------------------------------------------ +# Rscons Build Targets +#------------------------------------------------------------------------------ +task :default => [:build] + +desc "Build all targets" +task :build => [:sclpl] + +desc "Build the sclpl compiler and interpreter" +task :sclpl => ['source/sclpl/grammar.c'] do + BaseEnv.Program('build/bin/sclpl', FileList['source/sclpl/*.c']) +end + +file 'source/sclpl/grammar.c' => ['source/sclpl/grammar.y'] do + grammar = File.readlines('source/grammar.y').map{|l| l.chomp().inspect } + File.open('source/grammar.c','w') do |f| + f.write("const char Grammar[] = \n"); + grammar.each { |l| f.write("#{l}\n") } + f.write(";\n"); + end +end #------------------------------------------------------------------------------ # Cleanup Target diff --git a/SConstruct b/SConstruct index 1f144ab..b3ccc64 100644 --- a/SConstruct +++ b/SConstruct @@ -14,23 +14,6 @@ def find_files(path,pattern): matches.append(os.path.join(root, filename)) return matches -# Helper function to build scheme programs and test runners -def SchemeBuildAndTest(target,sources,tests): - # Figure out the target names - #test_runner = target + '_tests' - #test_output = target + '_results' - #test_sources = [e for e in sources if not e.endswith('main.scm')] + tests - # Create the targets - scheme.Program( target, sources ) - #scheme.Program( test_runner, test_sources ) - #RunTest( test_output, test_runner ) - -# Helper function to run a test suite and generate a log file -def RunTest( output, runner ): - runner_exe = runner + ('.exe' if (platform.system() == 'Windows') else '') - cmd = os.path.basename(runner_exe) - scheme.Command( output, runner_exe, cmd + ' > $TARGET') - #------------------------------------------------------------------------------ # Compiler Environments #------------------------------------------------------------------------------ @@ -61,17 +44,17 @@ nostdlib = c_cpp.Clone(LINKFLAGS = [ '-nostdlib' ], #--------------------------- # Scheme Source Compiler scheme_compiler = Builder( - action = 'csc $CCFLAGS -c -o $TARGET $SOURCE', - suffix = '.o', - src_suffix = '.scm', - single_source = True) + action = 'csc $CCFLAGS -c -o $TARGET $SOURCE', + suffix = '.o', + src_suffix = '.scm', + single_source = True) # Scheme Binary Linker scheme_linker = Builder( - action = 'csc $LDFLAGS -o $TARGET $SOURCES', - suffix = '$PROGSUFFIX', - src_suffix = '.o', - src_builder = [ scheme_compiler ]) + action = 'csc $LDFLAGS -o $TARGET $SOURCES', + suffix = '$PROGSUFFIX', + src_suffix = '.o', + src_builder = [ scheme_compiler ]) # Create the Environment for this project scheme = base.Clone(CCFLAGS = [ '-I', 'inc'], @@ -80,32 +63,32 @@ scheme = base.Clone(CCFLAGS = [ '-I', 'inc'], #------------------------------------------------------------------------------ # Vendor Targets #------------------------------------------------------------------------------ -import os - -llvm = base.Clone() -if platform.system() == 'Windows': - llvm.Append(CMAKE_GENERATOR='NMake Makefiles', - MAKECMD='cd build/llvm/ && nmake') -else: - llvm.Append(CMAKE_GENERATOR='Unix Makefiles', - MAKECMD='make -C build/llvm/') - -llvm.Command('build/llvm/Makefile', - 'source/vendor/llvm-3.4.2/', - 'cd ${TARGET.dir} && cmake -G"${CMAKE_GENERATOR}" ../../${SOURCE}') -llvm.Command('build/llvm/Release+Assert/bin/llc', - 'build/llvm/Makefile', - '${MAKECMD}') +#import os +# +#llvm = base.Clone() +#if platform.system() == 'Windows': +# llvm.Append(CMAKE_GENERATOR='NMake Makefiles', +# MAKECMD='cd build/llvm/ && nmake') +#else: +# llvm.Append(CMAKE_GENERATOR='Unix Makefiles', +# MAKECMD='make -C build/llvm/') +# +#llvm.Command('build/llvm/Makefile', +# 'source/vendor/llvm-3.4.2/', +# 'cd ${TARGET.dir} && cmake -G"${CMAKE_GENERATOR}" ../../${SOURCE}') +#llvm.Command('build/llvm/Release+Assert/bin/llc', +# 'build/llvm/Makefile', +# '${MAKECMD}') #------------------------------------------------------------------------------ # SCLPL Targets #------------------------------------------------------------------------------ # SOF Shared Library -#c_cpp.SharedLibrary('build/sof', find_files('source/libsof/','*.c')) +c_cpp.SharedLibrary('build/lib/sof', find_files('source/libsof/','*.c')) # SBC Shared Library -#c_cpp.SharedLibrary('build/sbc', find_files('source/libsbc/','*.c')) +#c_cpp.SharedLibrary('build/lib/sbc', find_files('source/libsbc/','*.c')) # readsof Command Line Utility #readsof = c_cpp.Clone(CPPPATH = [ 'source/libsof/' ], @@ -114,39 +97,28 @@ llvm.Command('build/llvm/Release+Assert/bin/llc', #readsof.Program('build/readsof', find_files('source/readsof/','*.c')) #readsof.Depends('readsof', 'sof') -# SCLPL Compiler -SchemeBuildAndTest( 'build/bin/slc', - find_files('source/slc/','*.scm'), - find_files('tests/slc/','*.scm') ) - -# SCLPL Package Manager -SchemeBuildAndTest( 'build/bin/slpkg', - find_files('source/slpkg/','*.scm'), - find_files('tests/slpkg/','*.scm') ) - -# SCLPL Assembler -SchemeBuildAndTest( 'build/bin/slas', - find_files('source/slas/','*.scm'), - find_files('tests/slas/','*.scm') ) - -# SCLPL Virtual Machine -#---------------------- -# Virtual Machine Kernel -nostdlib.StaticLibrary('build/lib/vmkernel', glob.glob('source/slvm/kernel/*.c')) - -# Standard Platform Library (C99) -c_cpp.StaticLibrary('build/lib/stdpf', - glob.glob('source/slvm/platforms/C99/*.c'), - CPPPATH = ['source/slvm/kernel']) - -# VM Executable Using Standard Platform -c_cpp.Program('build/bin/slvm', [], LIBS = ['vmkernel', 'stdpf']) - -# Build all VM Extensions -for ext in glob.glob('source/slvm/extensions/*/'): - name = os.path.basename(ext.strip('\\/')) - c_cpp.StaticLibrary('build/lib/'+name+'ext', - glob.glob(ext + '/*.c'), - CPPPATH = ['source/slvm/kernel'], - LIBS = ['stdpf']) - +## Register executable targets +#for name in ['slc', 'slpkg', 'slas']: +# scheme.Program('bin/'+name, find_files('source/'+name, '*.scm')) +# +## SCLPL Virtual Machine +##---------------------- +## Virtual Machine Kernel +#nostdlib.StaticLibrary('build/lib/vmkernel', glob.glob('source/slvm/kernel/*.c')) +# +## Standard Platform Library (C99) +#c_cpp.StaticLibrary('build/lib/stdpf', +# glob.glob('source/slvm/platforms/C99/*.c'), +# CPPPATH = ['source/slvm/kernel']) +# +## VM Executable Using Standard Platform +#c_cpp.Program('build/bin/slvm', [], LIBS = ['vmkernel', 'stdpf']) +# +## Build all VM Extensions +#for ext in glob.glob('source/slvm/extensions/*/'): +# name = os.path.basename(ext.strip('\\/')) +# c_cpp.StaticLibrary('build/lib/'+name+'ext', +# glob.glob(ext + '/*.c'), +# CPPPATH = ['source/slvm/kernel'], +# LIBS = ['stdpf']) +# -- 2.49.0