mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
06d236d535
`build.bins` is for compiled binaries with bare names; entries are fed through `exefile()` in `tasks/bin.rake`, which appends `exts.executable` (e.g. `.exe`) when no extension is present. When `ENV['OS']` is not `Windows_NT` but the toolchain has `exts.executable=".exe"` (e.g. cross builds, or environments where `OS` is unset under visualcpp), `mruby-bin-config` ended up with a file task at `.../mruby-config` while rake asked for `.../mruby-config.exe`, aborting with "Don't know how to build task". Skip the `bins` path and call `build.define_installer` directly with `mruby_config_path`, mirroring the existing `iscross` branch. The file task path now always matches the script content's extension (`.bat` on Windows, no extension elsewhere). close #6807, reported by UENO, M. (@eunos-1128). Co-authored-by: Claude <noreply@anthropic.com>
50 lines
1.4 KiB
Ruby
50 lines
1.4 KiB
Ruby
iscross = 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"
|
|
|
|
if iscross
|
|
mruby_config_dir = "#{build.build_dir}/host-bin"
|
|
else
|
|
mruby_config_dir = "#{build.build_dir}/bin"
|
|
end
|
|
|
|
if ENV['OS'] == 'Windows_NT'
|
|
suffix = '.bat'
|
|
refvar = '%\\1%'
|
|
else
|
|
suffix = ''
|
|
refvar = '${\\1}'
|
|
end
|
|
|
|
mruby_config = name + suffix
|
|
mruby_config_path = "#{mruby_config_dir}/#{mruby_config}"
|
|
make_cfg = "#{build.build_dir}/#{build.libdir_name}/libmruby.flags.mak"
|
|
tmplt_path = "#{__dir__}/#{mruby_config}"
|
|
|
|
if iscross
|
|
build.products << mruby_config_path
|
|
else
|
|
build.products << build.define_installer(mruby_config_path)
|
|
end
|
|
|
|
directory mruby_config_dir
|
|
|
|
file mruby_config_path => [__FILE__, mruby_config_dir, make_cfg, tmplt_path] do |t|
|
|
config = Hash[File.readlines(make_cfg).map!(&:chomp).map! {|l|
|
|
l.gsub!(/\$\((\w+)\)/, refvar)
|
|
l.gsub('\\"', '"').split(' = ', 2).map! {|s| s.sub(/^(?=.)/, 'echo ')}
|
|
}]
|
|
tmplt = File.read(tmplt_path)
|
|
tmplt.sub!(%r((?<=\A#!/bin/sh\n\n)), <<~SETDIR)
|
|
MRUBY_PACKAGE_DIR=$(dirname "$(dirname "$(readlink -f "$0")")")
|
|
|
|
SETDIR
|
|
File.write(t.name, tmplt.gsub(/(#{Regexp.union(*config.keys)})\b/, config))
|
|
chmod(0755, t.name)
|
|
end
|
|
end
|