Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First working C Implementation #97

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ spec/nim/bin

# Rust compiled code, cargo and rls data
spec/rust/target/

src/bin
.vscode
spec/c/test_*
27 changes: 27 additions & 0 deletions builder/c_builder.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'fileutils'

require_relative 'cpp_builder'

class CBuilder < CppBuilder
attr_accessor :mode

def initialize(src_dir, cpp_spec_dir, cpp_test_out_dir)
super(src_dir, cpp_spec_dir, cpp_test_out_dir)
end

def list_disposable_files
list = Dir.glob("#{@cpp_spec_dir}/**/*.c") + Dir.glob("#{@src_dir}/*.c") + Dir.glob("#{@cpp_spec_dir}/**/*.cpp") + Dir.glob("#{@src_dir}/*.cpp")
list.map { |x|
r = File.absolute_path(x)

# On Windows, filesystem is case insensitive, but our Set
# implementation is not. So we proactively normalize everything we
# can to lower case.
if @mode == :msbuild_windows
r.downcase!
end

r
}
end
end
23 changes: 23 additions & 0 deletions ci-c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh -ef

. ./config

SRC_DIR="$(pwd)/compiled/c"
C_SPEC_DIR="$(pwd)/spec/c"
C_TEST_OUT_DIR="$TEST_OUT_DIR/c"

./run-c "$SRC_DIR" "$C_SPEC_DIR" "$C_TEST_OUT_DIR"

# Run C valgrind check, generates Valgrind XML report
echo 'Running Valgrind checks...'
if valgrind --version; then
./valgrind-c "$SRC_DIR" "$C_TEST_OUT_DIR" || :
else
echo 'Valgrind not found :-('

# Generate empty valgrind output - this is normal and it should not stop `ci.json` generation
echo '<?xml version="1.0"?><valgrindoutput></valgrindoutput>' >"$C_TEST_OUT_DIR/valgrind.xml"
fi

./kst-adoption-report $(basename "$SRC_DIR")
aggregate/convert_to_json cpp_stl "$C_TEST_OUT_DIR" "$C_TEST_OUT_DIR/ci.json"
5 changes: 5 additions & 0 deletions kst-adoption-report
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def glob_spec_files(lang)
Dir.glob('spec/construct/**/test_*.py')
when 'ruby'
Dir.glob('spec/ruby/**/*_spec.rb')
when 'c'
Dir.glob('spec/c/**/test_*.cpp')
else
raise "Unable to handle language #{@lang.inspect}"
end
Expand Down Expand Up @@ -74,6 +76,9 @@ def spec_file_to_test_name(lang, fn)
when 'ruby'
raise "Unable to extract test name from #{fn.inspect}" unless fn =~ /^(.*?)_spec\.rb$/
underscore_to_ucamelcase($1)
when 'c'
raise "Unable to extract test name from #{fn.inspect}" unless fn =~ /^test_(.*?)\.cpp$/
underscore_to_ucamelcase($1)
else
raise "Unable to handle language #{lang.inspect}"
end
Expand Down
4 changes: 4 additions & 0 deletions run-c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby

require_relative 'builder/c_builder'
CBuilder.new(ARGV[0], ARGV[1], ARGV[2]).command_line(ARGV[3..-1])
1 change: 1 addition & 0 deletions spec/c/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions spec/c/CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

143 changes: 143 additions & 0 deletions spec/c/cmake/FindIconv.cmake

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions spec/c/main.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions spec/c/prereq/custom.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions spec/c/prereq/custom_fx.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions spec/c/prereq/custom_fx_no_args.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions spec/c/prereq/my_custom_fx.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading