summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.editorconfig43
-rw-r--r--.github/dependabot.yml10
-rw-r--r--.github/workflows/build.yml2
-rw-r--r--.github/workflows/lint.yml4
-rw-r--r--.github/workflows/oss-fuzz.yml2
-rw-r--r--build_config/clang-asan.rb2
-rw-r--r--build_config/dreamcast_shelf.rb2
-rw-r--r--include/mruby/dump.h5
-rw-r--r--lib/mruby/build/command.rb7
-rw-r--r--lib/mruby/build/load_gems.rb2
-rw-r--r--lib/mruby/gem.rb5
-rw-r--r--mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c14
-rw-r--r--mrbgems/mruby-test/mrbgem.rake6
-rw-r--r--src/array.c7
-rw-r--r--src/dump.c24
-rw-r--r--tasks/mrblib.rake2
-rwxr-xr-xtest/check-for-trailing-whitespace.sh13
17 files changed, 103 insertions, 47 deletions
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..705b1f022
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,43 @@
+# About this file, see:
+# Website: https://editorconfig.org/
+# For Emacs users: https://github.com/editorconfig/editorconfig-emacs
+# For Vim users: https://github.com/editorconfig/editorconfig-vim
+
+root = true
+
+[*]
+indent_style = tab
+indent_size = 8
+tab_width = 8
+end_of_line = lf
+charset = utf-8
+insert_final_newline = true
+
+[{Makefile,Makefile.*,makefile,*.mk}]
+trim_trailing_whitespace = true
+#max_line_length = 80
+
+[*.{c,cc,C,cxx,cpp,h,hh,H,hxx,hpp,inc,y}]
+indent_style = space
+indent_size = 2
+trim_trailing_whitespace = true
+#max_line_length = 120
+
+[{*.rb,Rakefile,rakefile,*.rake,*.gemspec,*.gembox}]
+indent_style = space
+indent_size = 2
+trim_trailing_whitespace = true
+#max_line_length = 120
+
+[*.bat]
+end_of_line = crlf
+charset = latin1
+#max_line_length = 80
+
+[*.{yaml,yml}]
+indent_style = space
+indent_size = 2
+
+[*.md]
+indent_style = space
+indent_size = 2
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 000000000..dac4cac33
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,10 @@
+# Basic set up
+
+version: 2
+updates:
+
+ # Maintain dependencies for GitHub Actions
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "daily"
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 57c9c05be..435118e37 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -99,7 +99,7 @@ jobs:
cache-version: v1
steps:
- uses: actions/checkout@v2
- - uses: actions/cache@v2
+ - uses: actions/[email protected]
with:
path: ${{ env.package-dir }}
key: ${{ runner.os }}-cygwin-${{ env.cache-version }}
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index e8db09bfb..474890010 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -32,9 +32,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: 🧹 Check for trailing whitespace
- run: |
- cd test || exit
- sh ./check-for-trailing-whitespace.sh || exit 1
+ run: "! git grep -EIn $'[ \t]+$'"
yamllint:
name: 🍶 YAML
runs-on: ubuntu-latest
diff --git a/.github/workflows/oss-fuzz.yml b/.github/workflows/oss-fuzz.yml
index 60414e7dc..0fd505624 100644
--- a/.github/workflows/oss-fuzz.yml
+++ b/.github/workflows/oss-fuzz.yml
@@ -16,7 +16,7 @@ jobs:
fuzz-seconds: 600
dry-run: false
- name: Upload Crash
- uses: actions/upload-artifact@v1
+ uses: actions/[email protected]
if: failure()
with:
name: artifacts
diff --git a/build_config/clang-asan.rb b/build_config/clang-asan.rb
index 5ee0d9129..19cc53bf0 100644
--- a/build_config/clang-asan.rb
+++ b/build_config/clang-asan.rb
@@ -1,7 +1,7 @@
MRuby::Build.new do |conf|
conf.toolchain :clang
# include the GEM box
- conf.gembox 'default'
+ conf.gembox 'full-core'
# Turn on `enable_debug` for better debugging
conf.enable_sanitizer "address,undefined"
diff --git a/build_config/dreamcast_shelf.rb b/build_config/dreamcast_shelf.rb
index a92770070..7e7d6a52e 100644
--- a/build_config/dreamcast_shelf.rb
+++ b/build_config/dreamcast_shelf.rb
@@ -20,7 +20,7 @@ MRuby::CrossBuild.new("dreamcast") do |conf|
# C compiler
# Flags were extracted from KallistiOS environment files
conf.cc do |cc|
- cc.command = "#{BIN_PATH}/sh-elf-gcc"
+ cc.command = "#{BIN_PATH}/sh-elf-gcc"
cc.include_paths << ["#{KOS_PATH}/include", "#{KOS_PATH}/kernel/arch/dreamcast/include", "#{KOS_PATH}/addons/include", "#{KOS_PATH}/../kos-ports/include"]
cc.flags << ["-O2", "-fomit-frame-pointer", "-ml", "-m4-single-only", "-ffunction-sections", "-fdata-sections", "-Wall", "-g", "-fno-builtin", "-ml", "-m4-single-only", "-Wl,-Ttext=0x8c010000", "-Wl,--gc-sections", "-T#{KOS_PATH}/utils/ldscripts/shlelf.xc", "-nodefaultlibs"]
cc.compile_options = %Q[%{flags} -o "%{outfile}" -c "%{infile}"]
diff --git a/include/mruby/dump.h b/include/mruby/dump.h
index ed0c64b1a..3c48866d9 100644
--- a/include/mruby/dump.h
+++ b/include/mruby/dump.h
@@ -16,7 +16,10 @@
*/
MRB_BEGIN_DECL
-#define DUMP_DEBUG_INFO 1
+/* flags for mrb_dump_irep{,_binary,_cfunc,_cstruct} */
+#define MRB_DUMP_DEBUG_INFO 1
+#define MRB_DUMP_STATIC 2
+#define DUMP_DEBUG_INFO MRB_DUMP_DEBUG_INFO /* deprecated */
int mrb_dump_irep(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, uint8_t **bin, size_t *bin_size);
#ifndef MRB_NO_STDIO
diff --git a/lib/mruby/build/command.rb b/lib/mruby/build/command.rb
index 9d70ac086..dbe3763d9 100644
--- a/lib/mruby/build/command.rb
+++ b/lib/mruby/build/command.rb
@@ -328,13 +328,16 @@ module MRuby
@compile_options = "-B%{funcname} -o-"
end
- def run(out, infiles, funcname, cdump = true)
+ def run(out, infiles, funcname, cdump: true, static: false)
@command ||= @build.mrbcfile
infiles = [infiles].flatten
infiles.each_with_index do |f, i|
_pp i == 0 ? "MRBC" : "", f.relative_path, indent: 2
end
- cmd = %Q["#{filename @command}" #{cdump ? "-S" : ""} #{@compile_options % {:funcname => funcname}} #{filename(infiles).map{|f| %Q["#{f}"]}.join(' ')}]
+ opt = @compile_options % {funcname: funcname}
+ opt << " -S" if cdump
+ opt << " -s" if static
+ cmd = %["#{filename @command}" #{opt} #{filename(infiles).map{|f| %["#{f}"]}.join(' ')}]
puts cmd if Rake.verbose
IO.popen(cmd, 'r+') do |io|
out.puts io.read
diff --git a/lib/mruby/build/load_gems.rb b/lib/mruby/build/load_gems.rb
index 28811e8ec..6609a5c8e 100644
--- a/lib/mruby/build/load_gems.rb
+++ b/lib/mruby/build/load_gems.rb
@@ -100,7 +100,7 @@ module MRuby
options = [params[:options]] || []
options << "--recursive"
options << "--branch \"#{branch}\""
- options << "--depth 1" unless params[:checksum_hash]
+ options << "--depth 1" unless params[:checksum_hash] || lock
mkdir_p "#{gem_clone_dir}"
git.run_clone gemdir, url, options
diff --git a/lib/mruby/gem.rb b/lib/mruby/gem.rb
index 3a40fbbfc..716f21286 100644
--- a/lib/mruby/gem.rb
+++ b/lib/mruby/gem.rb
@@ -198,10 +198,11 @@ module MRuby
open(fname, 'w') do |f|
print_gem_init_header f
unless rbfiles.empty?
+ opts = {cdump: cdump?, static: true}
if cdump?
- build.mrbc.run f, rbfiles, "gem_mrblib_#{funcname}_proc"
+ build.mrbc.run f, rbfiles, "gem_mrblib_#{funcname}_proc", **opts
else
- build.mrbc.run f, rbfiles, "gem_mrblib_irep_#{funcname}", false
+ build.mrbc.run f, rbfiles, "gem_mrblib_irep_#{funcname}", **opts
end
end
f.puts %Q[void mrb_#{funcname}_gem_init(mrb_state *mrb);]
diff --git a/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c b/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c
index 31a4e6fa1..e17f32a2e 100644
--- a/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c
+++ b/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c
@@ -14,17 +14,17 @@
#define C_EXT ".c"
struct mrbc_args {
- int argc;
- char **argv;
- int idx;
const char *prog;
const char *outfile;
const char *initname;
+ char **argv;
+ int argc;
+ int idx;
mrb_bool dump_struct : 1;
mrb_bool check_syntax : 1;
mrb_bool verbose : 1;
mrb_bool remove_lv : 1;
- unsigned int flags : 4;
+ uint8_t flags : 4;
};
static void
@@ -38,6 +38,7 @@ usage(const char *name)
"-g produce debugging information",
"-B<symbol> binary <symbol> output in C language format",
"-S dump C struct (requires -B)",
+ "-s define <symbol> as static variable",
"--remove-lv remove local variables",
"--verbose run at verbose mode",
"--version print the version",
@@ -131,7 +132,10 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct mrbc_args *args)
args->verbose = TRUE;
break;
case 'g':
- args->flags |= DUMP_DEBUG_INFO;
+ args->flags |= MRB_DUMP_DEBUG_INFO;
+ break;
+ case 's':
+ args->flags |= MRB_DUMP_STATIC;
break;
case 'E':
case 'e':
diff --git a/mrbgems/mruby-test/mrbgem.rake b/mrbgems/mruby-test/mrbgem.rake
index 421108e0b..927447b4f 100644
--- a/mrbgems/mruby-test/mrbgem.rake
+++ b/mrbgems/mruby-test/mrbgem.rake
@@ -20,7 +20,7 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
_pp "GEN", t.name.relative_path
mkdir_p File.dirname(t.name)
open(t.name, 'w') do |f|
- mrbc.run f, assert_rb, 'mrbtest_assert_irep', false
+ mrbc.run f, assert_rb, 'mrbtest_assert_irep', cdump: false
end
end
@@ -52,10 +52,10 @@ MRuby::Gem::Specification.new('mruby-test') do |spec|
if test_preload.nil?
f.puts %Q[extern const uint8_t mrbtest_assert_irep[];]
else
- g.build.mrbc.run f, test_preload, "gem_test_irep_#{g.funcname}_preload", false
+ g.build.mrbc.run f, test_preload, "gem_test_irep_#{g.funcname}_preload", cdump: false
end
g.test_rbfiles.flatten.each_with_index do |rbfile, i|
- g.build.mrbc.run f, rbfile, "gem_test_irep_#{g.funcname}_#{i}", false
+ g.build.mrbc.run f, rbfile, "gem_test_irep_#{g.funcname}_#{i}", cdump: false, static: true
end
f.puts %Q[void mrb_#{g.funcname}_gem_test(mrb_state *mrb);] if g.custom_test_init?
dep_list.each do |d|
diff --git a/src/array.c b/src/array.c
index ab6adf52c..8ab30bd8e 100644
--- a/src/array.c
+++ b/src/array.c
@@ -56,9 +56,9 @@ mrb_ary_new(mrb_state *mrb)
}
/*
- * to copy array, use this instead of memcpy because of portability
+ * To copy array, use this instead of memcpy because of portability
* * gcc on ARM may fail optimization of memcpy
- * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3934.html
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56620
* * gcc on MIPS also fail
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39755
* * memcpy doesn't exist on freestanding environment
@@ -66,8 +66,7 @@ mrb_ary_new(mrb_state *mrb)
* If you optimize for binary size, use memcpy instead of this at your own risk
* of above portability issue.
*
- * see also http://togetter.com/li/462898
- *
+ * See also https://togetter.com/li/462898 (Japanese)
*/
static inline void
array_copy(mrb_value *dst, const mrb_value *src, mrb_int size)
diff --git a/src/dump.c b/src/dump.c
index 5173b88e5..e3f3320ea 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -806,7 +806,7 @@ dump_irep(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, uint8_t **bin, si
section_irep_size += get_irep_record_size(mrb, irep);
/* DEBUG section size */
- if (flags & DUMP_DEBUG_INFO) {
+ if (flags & MRB_DUMP_DEBUG_INFO) {
if (debug_info_defined) {
section_lineno_size += sizeof(struct rite_section_debug_header);
/* filename table */
@@ -842,7 +842,7 @@ dump_irep(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, uint8_t **bin, si
sizeof(struct rite_binary_footer);
/* write DEBUG section */
- if (flags & DUMP_DEBUG_INFO) {
+ if (flags & MRB_DUMP_DEBUG_INFO) {
if (debug_info_defined) {
result = write_section_debug(mrb, irep, cur, filenames, filenames_len);
if (result != MRB_DUMP_OK) {
@@ -920,11 +920,13 @@ mrb_dump_irep_cfunc(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE *f
return MRB_DUMP_WRITE_FAULT;
}
if (fprintf(fp,
- "#ifdef __cplusplus\n"
- "extern const uint8_t %s[];\n"
- "#endif\n"
+ "%s\n"
"const uint8_t %s[] = {",
- initname, initname) < 0) {
+ (flags & MRB_DUMP_STATIC) ? "static"
+ : "#ifdef __cplusplus\n"
+ "extern\n"
+ "#endif",
+ initname) < 0) {
mrb_free(mrb, bin);
return MRB_DUMP_WRITE_FAULT;
}
@@ -1232,8 +1234,14 @@ mrb_dump_irep_cstruct(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE
int max = 1;
int n = dump_irep_struct(mrb, irep, flags, fp, initname, 0, init_syms_code, &max);
if (n != MRB_DUMP_OK) return n;
- fprintf(fp, "#ifdef __cplusplus\nextern const struct RProc %s[];\n#endif\n", initname);
- fprintf(fp, "const struct RProc %s[] = {{\n", initname);
+ fprintf(fp,
+ "%s\n"
+ "const struct RProc %s[] = {{\n",
+ (flags & MRB_DUMP_STATIC) ? "static"
+ : "#ifdef __cplusplus\n"
+ "extern\n"
+ "#endif",
+ initname);
fprintf(fp, "NULL,NULL,MRB_TT_PROC,7,0,{&%s_irep_0},NULL,{NULL},\n}};\n", initname);
fputs("static void\n", fp);
fprintf(fp, "%s_init_syms(mrb_state *mrb)\n", initname);
diff --git a/tasks/mrblib.rake b/tasks/mrblib.rake
index 5567515d6..485375e55 100644
--- a/tasks/mrblib.rake
+++ b/tasks/mrblib.rake
@@ -28,7 +28,7 @@ MRuby.each_target do
f.puts %Q[#include <mruby.h>]
f.puts %Q[#include <mruby/irep.h>]
end
- mrbc.run f, rbfiles, "mrblib_#{suffix}", cdump
+ mrbc.run f, rbfiles, "mrblib_#{suffix}", cdump: cdump, static: true
f.puts %Q[void]
f.puts %Q[mrb_init_mrblib(mrb_state *mrb)]
f.puts %Q[{]
diff --git a/test/check-for-trailing-whitespace.sh b/test/check-for-trailing-whitespace.sh
deleted file mode 100755
index 00be038f3..000000000
--- a/test/check-for-trailing-whitespace.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env bash
-
-cd .. || exit
-# print first
-grep -EHInr '( +)$' ./*
-
-var=$(grep -EHInr '( +)$' ./*)
-# then exit with fail if found
-if test -z "$var"; then
- exit 0
-else
- exit 1
-fi