From 94fc5dc8a9ed5e0b1756de7b5f3653496ebb006c Mon Sep 17 00:00:00 2001 From: "Mike D. Lowis" Date: Thu, 28 May 2015 12:19:49 -0400 Subject: [PATCH] Switched from make to rscons for build system --- .gitignore | 6 ++++++ .gitmodules | 3 +++ Gemfile | 4 ++++ Gemfile.lock | 29 +++++++++++++++++++++++++++++ Makefile | 40 ---------------------------------------- build.rb | 33 +++++++++++++++++++++++++++++++++ modules/build-system | 1 + source/main.c | 5 +++-- 8 files changed, 79 insertions(+), 42 deletions(-) create mode 100644 Gemfile create mode 100644 Gemfile.lock delete mode 100644 Makefile create mode 100755 build.rb create mode 160000 modules/build-system diff --git a/.gitignore b/.gitignore index bbf313b..6086a3e 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,9 @@ # Debug files *.dSYM/ +project.vim +tags +tags .rsconscache +source/lex.yy.c +.rsconscache +parser diff --git a/.gitmodules b/.gitmodules index 09ec159..5235c74 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "modules/libcds"] path = modules/libcds url = https://github.com/mikedlowis/data-structures.git +[submodule "modules/build-system"] + path = modules/build-system + url = https://github.com/mikedlowis/build-system.git diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..894906d --- /dev/null +++ b/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' +gem 'rake', '>= 0' +gem 'rscons', '>= 0' +gem 'rspec', '>= 0' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..88f9e23 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,29 @@ +GEM + remote: https://rubygems.org/ + specs: + diff-lcs (1.2.5) + json (1.8.2) + rake (10.4.2) + rscons (1.9.0) + json (~> 1.0) + rspec (3.2.0) + rspec-core (~> 3.2.0) + rspec-expectations (~> 3.2.0) + rspec-mocks (~> 3.2.0) + rspec-core (3.2.2) + rspec-support (~> 3.2.0) + rspec-expectations (3.2.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.2.0) + rspec-mocks (3.2.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.2.0) + rspec-support (3.2.2) + +PLATFORMS + ruby + +DEPENDENCIES + rake + rscons + rspec diff --git a/Makefile b/Makefile deleted file mode 100644 index 4bef298..0000000 --- a/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -INCLUDES = \ - source/ \ - modules/libcds/source/ \ - modules/libcds/source/buffer/ \ - modules/libcds/source/cmp/ \ - modules/libcds/source/exn/ \ - modules/libcds/source/list/ \ - modules/libcds/source/map/ \ - modules/libcds/source/mem/ \ - modules/libcds/source/murmur3/ \ - modules/libcds/source/rbt/ \ - modules/libcds/source/set/ \ - modules/libcds/source/string/ \ - modules/libcds/source/vector/ - -SOURCES = $(wildcard source/*.c) \ - $(wildcard modules/libcds/source/*/*.c) - -LD = $(CC) -MAKEDEPEND = $(CPP) -M $(CPPFLAGS) -o $< -CCDEPGEN = -MMD -MF $*.d -CFLAGS = -Wall -Wextra -O3 --std=c99 --pedantic $(addprefix -I,$(INCLUDES)) - --include $(SOURCES:.c=.d) - -parser: source/lex.yy.o $(SOURCES:.c=.o) - $(LD) $(LDFLAGS) -o $@ $^ - -%.o : %.c - $(CC) $(CCDEPGEN) $(CFLAGS) -c $< -o $@ - -source/lex.yy.c: source/lexer.l - $(LEX) $(LFLAGS) -o $@ $^ - -clean: - rm -f $(SOURCES:.c=.o) - rm -f $(SOURCES:.c=.d) - rm -f source/lex.yy.c - rm -f parser parser.exe - diff --git a/build.rb b/build.rb new file mode 100755 index 0000000..6071448 --- /dev/null +++ b/build.rb @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby +require './modules/build-system/setup' + +#------------------------------------------------------------------------------ +# Environment Definitions +#------------------------------------------------------------------------------ +# Define the default compiler environment +main_env = BuildEnv.new do |env| + env["CFLAGS"] += ['-Wall', '-Wextra', '--std=c99', '--pedantic'] + env["CPPPATH"] += Dir['modules/libcds/source/**/'] + [ ] +end + +#------------------------------------------------------------------------------ +# Release Build Targets +#------------------------------------------------------------------------------ +# Build third party libraries +main_env.Library('build/lib/libcds.a', FileList['modules/libcds/source/**/*.c']) +runtime_libs = ['build/lib/libcds.a'] + +# Build the parser +main_env.CFile('source/lex.yy.c', 'source/lexer.l') +main_env.Program('parser', FileList['source/*.c'] + ['source/lex.yy.c'] + runtime_libs) + +#------------------------------------------------------------------------------ +# Test Build Targets +#------------------------------------------------------------------------------ +if Opts[:profile].include? "test" +# compiler_libs = ['build/lib/libparse-test.a'] + runtime_libs +# test_env.Library('build/lib/libparse-test.a', FileList['source/libparse/*.c']) +# test_env.Program('build/bin/sclpl-test', FileList['source/sclpl/*.c'] + compiler_libs) +# test_env.Command('RSpec', [], 'CMD' => [ +# 'rspec', '--pattern', 'spec/**{,/*/**}/*_spec.rb', '--format', 'documentation']) +end diff --git a/modules/build-system b/modules/build-system new file mode 160000 index 0000000..f1a522b --- /dev/null +++ b/modules/build-system @@ -0,0 +1 @@ +Subproject commit f1a522b4aed7c58ce3c8467ff8a00f00c3e27e64 diff --git a/source/main.c b/source/main.c index 3cb0448..1aab45e 100644 --- a/source/main.c +++ b/source/main.c @@ -88,7 +88,7 @@ void reduce(int count) { AST* tree = Tree(type, count); intptr_t* stack = Token_Stack - (count-1); for (int i = 0; i < count; i++) { - tree->children[i] = stack[i]; + tree->children[i] = (void*)stack[i]; } Token_Stack -= count ; *(++Token_Stack) = (intptr_t)tree; @@ -111,7 +111,6 @@ static void keyword_send(void); static void binary_send(void); static void unary_send(void); static void operand(void); -static void messages(void); static void literal(void); static void array(void); static void object(void); @@ -253,6 +252,8 @@ int main(int argc, char** argv) { PrintTree((AST*)*Token_Stack, 0); Token_Stack = Token_Buffer-1; } + (void)argc; + (void)argv; return 0; } -- 2.55.0