c_project 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +18 -0
- data/bin/c_project +77 -0
- data/c_project.gemspec +25 -0
- data/lib/c_project/version.rb +3 -0
- data/lib/c_project.rb +5 -0
- data/templates/LICENCE.tt +23 -0
- data/templates/Makefile.tt +74 -0
- data/templates/README.md.tt +15 -0
- data/templates/src/CExceptionConfig.h.tt +8 -0
- data/templates/src/c_project.c.tt +16 -0
- data/templates/src/c_project.h.tt +8 -0
- data/templates/src/main.c.tt +15 -0
- data/templates/test/support/test_helper.c.tt +2 -0
- data/templates/test/support/test_helper.h.tt +13 -0
- data/templates/test/test_c_project.c.tt +41 -0
- data/templates/vendor/cexception/docs/license.txt +30 -0
- data/templates/vendor/cexception/docs/readme.txt +242 -0
- data/templates/vendor/cexception/lib/CException.c +43 -0
- data/templates/vendor/cexception/lib/CException.h +86 -0
- data/templates/vendor/cexception/release/build.info +2 -0
- data/templates/vendor/cexception/release/version.info +2 -0
- data/templates/vendor/commander.c/History.md +27 -0
- data/templates/vendor/commander.c/Makefile +8 -0
- data/templates/vendor/commander.c/Readme.md +103 -0
- data/templates/vendor/commander.c/package.json +9 -0
- data/templates/vendor/commander.c/src/commander.c +250 -0
- data/templates/vendor/commander.c/src/commander.h +88 -0
- data/templates/vendor/commander.c/test.c +34 -0
- data/templates/vendor/unity/.gitignore +1 -0
- data/templates/vendor/unity/auto/colour_prompt.rb +94 -0
- data/templates/vendor/unity/auto/colour_reporter.rb +39 -0
- data/templates/vendor/unity/auto/generate_config.yml +36 -0
- data/templates/vendor/unity/auto/generate_module.rb +202 -0
- data/templates/vendor/unity/auto/generate_test_runner.rb +316 -0
- data/templates/vendor/unity/auto/test_file_filter.rb +23 -0
- data/templates/vendor/unity/auto/unity_test_summary.rb +139 -0
- data/templates/vendor/unity/docs/Unity Summary.txt +216 -0
- data/templates/vendor/unity/docs/license.txt +31 -0
- data/templates/vendor/unity/release/build.info +2 -0
- data/templates/vendor/unity/release/version.info +2 -0
- data/templates/vendor/unity/src/unity.c +1146 -0
- data/templates/vendor/unity/src/unity.h +245 -0
- data/templates/vendor/unity/src/unity_internals.h +546 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 549cd23c32d308b17666fa8ee6ec6fe8fcb42ef9
|
4
|
+
data.tar.gz: 98eb91295947c019418a6877a638719f5cfbfea5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 405c0e7c9f291c79eeae4a22b3648668ec7447831bc90ecfedbdb3245c6a13d10199e7773fea61ce4d9100bb7096843fd77d0344b6cf25e48904b516514c5c3d
|
7
|
+
data.tar.gz: 81d5a0e89256c082fa56c2531e8ef435bab56928cde86ffa0e8f11c2339cad85fbeed018a31e35a1084af064f53d7988f07231d56c677a5b492d300b08bca502
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Dustin Morrill
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# CProject
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'c_project'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install c_project
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
require 'rake/clean'
|
5
|
+
require 'rake/testtask'
|
6
|
+
|
7
|
+
include Rake::DSL
|
8
|
+
|
9
|
+
Bundler::GemHelper.install_tasks
|
10
|
+
|
11
|
+
Rake::TestTask.new do |t|
|
12
|
+
t.libs << "lib" << 'spec/support'
|
13
|
+
t.test_files = FileList['spec/**/*_spec.rb']
|
14
|
+
t.verbose = false
|
15
|
+
t.warning = false # pry-rescue has a lot of warnings
|
16
|
+
end
|
17
|
+
|
18
|
+
task :default => [:test]
|
data/bin/c_project
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "rubygems"
|
3
|
+
require 'thor'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
module CProject
|
7
|
+
class New < Thor::Group
|
8
|
+
include Thor::Actions
|
9
|
+
|
10
|
+
argument :name, :desc => 'Name of the new project.'
|
11
|
+
|
12
|
+
def self.source_root
|
13
|
+
File.expand_path('../../', __FILE__)
|
14
|
+
end
|
15
|
+
|
16
|
+
def gen_root
|
17
|
+
empty_directory name
|
18
|
+
end
|
19
|
+
|
20
|
+
def fill_root
|
21
|
+
create_file_from_template "LICENCE"
|
22
|
+
create_file_from_template "README.md"
|
23
|
+
create_file_from_template "Makefile"
|
24
|
+
end
|
25
|
+
|
26
|
+
def src
|
27
|
+
create_file_from_template 'src/CExceptionConfig.h'
|
28
|
+
template 'templates/src/c_project.c.tt', file_path("src/#{name}.c")
|
29
|
+
template 'templates/src/c_project.h.tt', file_path("src/#{name}.h")
|
30
|
+
create_file_from_template 'src/main.c'
|
31
|
+
end
|
32
|
+
|
33
|
+
def test
|
34
|
+
template 'templates/test/test_c_project.c.tt', file_path("test/test_#{name}.c")
|
35
|
+
end
|
36
|
+
|
37
|
+
def support
|
38
|
+
create_file_from_template 'test/support/test_helper.c'
|
39
|
+
create_file_from_template 'test/support/test_helper.h'
|
40
|
+
end
|
41
|
+
|
42
|
+
def vendor
|
43
|
+
directory 'templates/vendor', file_path("vendor")
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def header_guard
|
49
|
+
"__#{name.upcase}_H__"
|
50
|
+
end
|
51
|
+
|
52
|
+
def file_path(file_name)
|
53
|
+
File.join name, file_name
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_file_from_template(file_name)
|
57
|
+
template(
|
58
|
+
"templates/#{file_name}.tt",
|
59
|
+
file_path(file_name)
|
60
|
+
)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class CProject < Thor
|
65
|
+
map 'n' => :new
|
66
|
+
|
67
|
+
register(
|
68
|
+
New,
|
69
|
+
'new',
|
70
|
+
'new NAME',
|
71
|
+
"Creates a new C project the name NAME"
|
72
|
+
)
|
73
|
+
tasks["new"].options = New.class_options
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
CProject::CProject.start(ARGV)
|
data/c_project.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'c_project/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "c_project"
|
8
|
+
spec.version = CProject::VERSION
|
9
|
+
spec.authors = ["Dustin Morrill"]
|
10
|
+
spec.email = ["morrill@ualberta.ca"]
|
11
|
+
spec.description = %q{Simple C project generator}
|
12
|
+
spec.summary = %q{Simple C project generator}
|
13
|
+
spec.homepage = "https://github.com/dmorrill10/c_project"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'thor', '~> 0.18.1'
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
data/lib/c_project.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (C) 2013
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
8
|
+
so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
Except as contained in this notice, the name(s) of the above copyright holders
|
14
|
+
shall not be used in advertising or otherwise to promote the sale, use or other
|
15
|
+
dealings in this Software without prior written authorization.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
SOFTWARE.
|
@@ -0,0 +1,74 @@
|
|
1
|
+
THIS_DIR := $(CURDIR)/$(dir $(lastword $(MAKEFILE_LIST)))
|
2
|
+
|
3
|
+
CC = gcc -std=gnu99
|
4
|
+
CFLAGS = -O3 -g -Wall
|
5
|
+
LIBS = -lm
|
6
|
+
TARGET_SYMBOLS = -DCEXCEPTION_USE_CONFIG_FILE
|
7
|
+
|
8
|
+
VENDOR_DIR := $(THIS_DIR)/vendor/
|
9
|
+
COMMANDER_DIR := $(VENDOR_DIR)/commander.c
|
10
|
+
TARGET_INCLUDES = -I$(THIS_DIR)/src -I$(CEXCEPTION_LIB) -I$(COMMANDER_DIR)/src
|
11
|
+
|
12
|
+
CEXCEPTION_DIR := $(VENDOR_DIR)/cexception/
|
13
|
+
CEXCEPTION_LIB := $(CEXCEPTION_DIR)/lib
|
14
|
+
CEXCEPTION_SRC := $(CEXCEPTION_LIB)/CException.c
|
15
|
+
|
16
|
+
TARGET_BASE = <%= name %>
|
17
|
+
TARGET_SRC_DIR := $(THIS_DIR)/src
|
18
|
+
TARGET_SRC := $(TARGET_SRC_DIR)/$(TARGET_BASE).c $(CEXCEPTION_SRC)
|
19
|
+
|
20
|
+
BUILD_PREFIX := $(CC) $(CFLAGS) $(TARGET_SYMBOLS)
|
21
|
+
|
22
|
+
TARGET := $(THIS_DIR)/$(TARGET_BASE)
|
23
|
+
|
24
|
+
default: $(TARGET)
|
25
|
+
|
26
|
+
# Build target
|
27
|
+
#==============
|
28
|
+
$(TARGET): $(TARGET_SRC)
|
29
|
+
$(BUILD_PREFIX) $(TARGET_INCLUDES) $(TARGET_SRC) $(TARGET_SRC_DIR)/main.c $(COMMANDER_DIR)/src/commander.c $(PROJECT_SRC) $(LIBS) -o $@
|
30
|
+
chmod 755 $@
|
31
|
+
|
32
|
+
# Testing
|
33
|
+
#===========
|
34
|
+
UNITY_DIR := $(VENDOR_DIR)/unity
|
35
|
+
TEST_DIR := $(THIS_DIR)/test
|
36
|
+
TEST_SUPPORT_DIR := $(TEST_DIR)/support
|
37
|
+
INC_DIRS := -I$(UNITY_DIR)/src -I$(TEST_SUPPORT_DIR) -I$(THIS_DIR)/src $(TARGET_INCLUDES)
|
38
|
+
SYMBOLS = -DTEST -DUNITY_FLOAT_TYPE=double -DUNITY_FLOAT_VERBOSE
|
39
|
+
TEST_BASE := $(TEST_DIR)/test_$(TARGET_BASE)
|
40
|
+
ifeq ($(OS),Windows_NT)
|
41
|
+
TEST_EXTENSION=.exe
|
42
|
+
else
|
43
|
+
TEST_EXTENSION=.out
|
44
|
+
endif
|
45
|
+
|
46
|
+
# Test 1
|
47
|
+
#-------------
|
48
|
+
TEST1_BASE := $(TEST_BASE)
|
49
|
+
TEST1_SRC := $(TEST1_BASE).c
|
50
|
+
TEST1 := $(TEST1_BASE)$(TEST_EXTENSION)
|
51
|
+
TEST1_RUNNER := $(TEST1_BASE)_Runner.c
|
52
|
+
|
53
|
+
$(TEST1_RUNNER): $(TEST1_SRC)
|
54
|
+
ruby $(UNITY_DIR)/auto/generate_test_runner.rb $(TEST1_SRC) $(TEST1_RUNNER)
|
55
|
+
|
56
|
+
$(TEST1): $(TARGET) $(TEST1_RUNNER)
|
57
|
+
$(BUILD_PREFIX) $(SYMBOLS) $(INC_DIRS) $(TARGET_SRC) $(PROJECT_SRC) $(TEST_SUPPORT_DIR)/test_helper.c $(UNITY_DIR)/src/unity.c $(TEST1_SRC) $(TEST1_RUNNER) $(LIBS) -o $@
|
58
|
+
chmod 755 $@
|
59
|
+
|
60
|
+
# Automatic tests (require Ruby)
|
61
|
+
#--------------------------------
|
62
|
+
test: clean $(TEST1)
|
63
|
+
$(TEST1)
|
64
|
+
|
65
|
+
# Clean
|
66
|
+
#============
|
67
|
+
clean:
|
68
|
+
rm -f $(TARGET) *.o *.il *.out $(TEST1) $(TEST1_RUNNER) $(THIS_DIR)/test/*.out
|
69
|
+
|
70
|
+
# Makefile debugging
|
71
|
+
#===================
|
72
|
+
print-%:
|
73
|
+
@echo $* = $($*)
|
74
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= name %>
|
2
|
+
==================
|
3
|
+
|
4
|
+
@todo Write description
|
5
|
+
|
6
|
+
License
|
7
|
+
-------
|
8
|
+
MIT license (see `LICENCE`).
|
9
|
+
|
10
|
+
Acknowledgements
|
11
|
+
----------------
|
12
|
+
This project includes software developed for
|
13
|
+
the CException Project, by Mark VanderVoord and other
|
14
|
+
contributors, as well as the Unity Project, by Mike Karlesky,
|
15
|
+
Mark VanderVoord, and Greg Williams and other contributors.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <stdlib.h>
|
3
|
+
#include <string.h>
|
4
|
+
#include <stdbool.h>
|
5
|
+
#include <math.h>
|
6
|
+
#include <assert.h>
|
7
|
+
|
8
|
+
#include "CException.h"
|
9
|
+
void print_and_throw_error(const char const *message)
|
10
|
+
{
|
11
|
+
fprintf(stderr, "ERROR: %s", message);
|
12
|
+
Throw(1);
|
13
|
+
}
|
14
|
+
|
15
|
+
#include "<%= name %>.h"
|
16
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#include <stdlib.h>
|
2
|
+
#include <assert.h>
|
3
|
+
#include "commander.h"
|
4
|
+
|
5
|
+
#include "<%= name %>.h"
|
6
|
+
|
7
|
+
int main(int argc, char **argv)
|
8
|
+
{
|
9
|
+
command_t cmd;
|
10
|
+
command_init(&cmd, argv[0], "0.0.1");
|
11
|
+
|
12
|
+
command_parse(&cmd, argc, argv);
|
13
|
+
command_free(&cmd);
|
14
|
+
}
|
15
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <string.h>
|
3
|
+
#include <unistd.h>
|
4
|
+
|
5
|
+
#include "test_helper.h"
|
6
|
+
|
7
|
+
#include "<%= name %>.h"
|
8
|
+
|
9
|
+
static int stderr_copy;
|
10
|
+
static FILE* dev_null = NULL;
|
11
|
+
void setUp()
|
12
|
+
{
|
13
|
+
// Silence error output
|
14
|
+
stderr_copy = dup(fileno(stderr));
|
15
|
+
dev_null = freopen("/dev/null", "w", stderr);
|
16
|
+
}
|
17
|
+
|
18
|
+
void tearDown()
|
19
|
+
{
|
20
|
+
if (dev_null) {
|
21
|
+
// Restore error output
|
22
|
+
fflush(stderr);
|
23
|
+
dup2(stderr_copy, fileno(stderr));
|
24
|
+
close(stderr_copy);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
void test_things_work() {
|
29
|
+
CEXCEPTION_T e = 0;
|
30
|
+
|
31
|
+
Try
|
32
|
+
{
|
33
|
+
Throw(1);
|
34
|
+
TEST_FAIL_MESSAGE("Should Have Thrown An Error");
|
35
|
+
}
|
36
|
+
Catch(e)
|
37
|
+
{
|
38
|
+
TEST_ASSERT_EQUAL(1, e);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Copyright (c) 2007 Mark VanderVoord
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
The end-user documentation included with the redistribution, if
|
16
|
+
any, must include the following acknowledgment: "This product
|
17
|
+
includes software developed for the CEXCeption Project, by Mark
|
18
|
+
VanderVoord and other contributors", in the same place and form
|
19
|
+
as other third-party acknowledgments. Alternately, this
|
20
|
+
acknowledgment may appear in the software itself, in the same
|
21
|
+
form and location as other such third-party acknowledgments.
|
22
|
+
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
24
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
25
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
26
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
27
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
28
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
29
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
30
|
+
OTHER DEALINGS IN THE SOFTWARE.
|