summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-bin-config
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2019-07-17 10:35:41 +0900
committerGitHub <[email protected]>2019-07-17 10:35:41 +0900
commitd605b72c1d6fa4564a0a5e88535504b6850463b5 (patch)
tree774fc0de56002abb3bb2b1c3387ff08f91876d17 /mrbgems/mruby-bin-config
parent2af92d0ebcbeca6d3d85a27c8193273080a63090 (diff)
parent9af3b7c6258de327218dd04e69d76ae68caf17b1 (diff)
downloadmruby-d605b72c1d6fa4564a0a5e88535504b6850463b5.tar.gz
mruby-d605b72c1d6fa4564a0a5e88535504b6850463b5.zip
Merge branch 'master' into i110/inspect-recursion
Diffstat (limited to 'mrbgems/mruby-bin-config')
-rw-r--r--mrbgems/mruby-bin-config/mrbgem.rake23
-rw-r--r--mrbgems/mruby-bin-config/mruby-config20
-rw-r--r--mrbgems/mruby-bin-config/mruby-config.bat42
3 files changed, 85 insertions, 0 deletions
diff --git a/mrbgems/mruby-bin-config/mrbgem.rake b/mrbgems/mruby-bin-config/mrbgem.rake
new file mode 100644
index 000000000..3a0a1b897
--- /dev/null
+++ b/mrbgems/mruby-bin-config/mrbgem.rake
@@ -0,0 +1,23 @@
+unless MRuby::Build.current.kind_of?(MRuby::CrossBuild)
+ MRuby::Gem::Specification.new('mruby-bin-config') do |spec|
+ name = 'mruby-config'
+ spec.license = 'MIT'
+ spec.author = 'mruby developers'
+ spec.summary = "#{name} command"
+
+ mruby_config = name + (ENV['OS'] == 'Windows_NT' ? '.bat' : '')
+ mruby_config_path = "#{build.build_dir}/bin/#{mruby_config}"
+ make_cfg = "#{build.build_dir}/lib/libmruby.flags.mak"
+ tmplt_path = "#{__dir__}/#{mruby_config}"
+ build.bins << mruby_config
+
+ file mruby_config_path => [make_cfg, tmplt_path] do |t|
+ config = Hash[File.readlines(make_cfg).map!(&:chomp).map! {|l|
+ l.gsub('\\"', '"').split(' = ', 2).map! {|s| s.sub(/^(?=.)/, 'echo ')}
+ }]
+ tmplt = File.read(tmplt_path)
+ File.write(t.name, tmplt.gsub(/(#{Regexp.union(*config.keys)})\b/, config))
+ FileUtils.chmod(0755, t.name)
+ end
+ end
+end
diff --git a/mrbgems/mruby-bin-config/mruby-config b/mrbgems/mruby-bin-config/mruby-config
new file mode 100644
index 000000000..57346c03f
--- /dev/null
+++ b/mrbgems/mruby-bin-config/mruby-config
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ --cflags) echo MRUBY_CFLAGS;;
+ --ldflags) echo MRUBY_LDFLAGS;;
+ --ldflags-before-libs) echo MRUBY_LDFLAGS_BEFORE_LIBS;;
+ --libs) echo MRUBY_LIBS;;
+ --libmruby-path) echo MRUBY_LIBMRUBY_PATH;;
+ --help) echo "Usage: mruby-config [switches]"
+ echo " switches:"
+ echo " --cflags print flags passed to compiler"
+ echo " --ldflags print flags passed to linker"
+ echo " --ldflags-before-libs print flags passed to linker before linked libraries"
+ echo " --libs print linked libraries"
+ echo " --libmruby-path print libmruby path"
+ exit 0;;
+ esac
+ shift
+done
diff --git a/mrbgems/mruby-bin-config/mruby-config.bat b/mrbgems/mruby-bin-config/mruby-config.bat
new file mode 100644
index 000000000..a1f7bfdd1
--- /dev/null
+++ b/mrbgems/mruby-bin-config/mruby-config.bat
@@ -0,0 +1,42 @@
+@echo off
+
+:top
+shift
+if "%0" equ "" goto :eof
+if "%0" equ "--cflags" goto cflags
+if "%0" equ "--ldflags" goto ldflags
+if "%0" equ "--ldflags-before-libs" goto ldflagsbeforelibs
+if "%0" equ "--libs" goto libs
+if "%0" equ "--libmruby-path" goto libmrubypath
+if "%0" equ "--help" goto showhelp
+echo Invalid Option
+goto :eof
+
+:cflags
+echo MRUBY_CFLAGS
+goto top
+
+:libs
+echo MRUBY_LIBS
+goto top
+
+:ldflags
+echo MRUBY_LDFLAGS
+goto top
+
+:ldflagsbeforelibs
+echo MRUBY_LDFLAGS_BEFORE_LIBS
+goto top
+
+:libmrubypath
+echo MRUBY_LIBMRUBY_PATH
+goto top
+
+:showhelp
+echo Usage: mruby-config [switches]
+echo switches:
+echo --cflags print flags passed to compiler
+echo --ldflags print flags passed to linker
+echo --ldflags-before-libs print flags passed to linker before linked libraries
+echo --libs print linked libraries
+echo --libmruby-path print libmruby path