Write symbolik links or batch files in INSTALL_DIR

Since `bin/mruby-config` now points to a directory relative to itself, it is no longer possible to reach `include/` or `lib/`.
Therefore, avoid placing entities in them.
This commit is contained in:
dearblue
2023-02-12 21:02:33 +09:00
parent 11513bae43
commit 7c7ed3c27a
+24 -3
View File
@@ -375,14 +375,35 @@ EOS
end
end
def define_installer(src)
dst = "#{self.class.install_dir}/#{File.basename(src)}"
def define_installer_outline(src, dst)
file dst => src do
install_D src, dst
_pp "GEN", src.relative_path, dst.relative_path
mkdir_p(File.dirname(dst))
yield dst
end
dst
end
if ENV['OS'] == 'Windows_NT'
def define_installer(src)
dst = "#{self.class.install_dir}/#{File.basename(src)}".pathmap("%X.bat")
define_installer_outline(src, dst) do
File.write dst, <<~BATCHFILE
@echo off
call "#{src}" %*
BATCHFILE
end
end
else
def define_installer(src)
dst = "#{self.class.install_dir}/#{File.basename(src)}"
define_installer_outline(src, dst) do
File.unlink(dst) if File.exist?(dst)
File.symlink(src, dst)
end
end
end
def define_installer_if_needed(bin)
exe = exefile("#{build_dir}/bin/#{bin}")
host? ? define_installer(exe) : exe