amos-pro-bsdsocket-extension/bin/release

101 lines
1.9 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env ruby
require 'fileutils'
require 'open3'
require 'erb'
source = File.read('src/BSDSocket.s')
2024-05-02 21:04:43 +00:00
aminet_template = ERB.new(File.read('aminet.readme.erb'))
capture_version = false
version = nil
source.lines.each do |line|
if capture_version
2024-05-02 21:04:43 +00:00
version = line[/dc\.b "([^"]+)"/, 1]
break
end
if line[/^Version.*MACRO/]
# the version is on the next line
capture_version = true
end
end
FileUtils.mkdir_p 'dist'
build_base = 'build'
project_name = 'BSDSocket-Extension'
build_dir = File.join(build_base, project_name)
FileUtils.rm_rf build_dir
FileUtils.mkdir_p build_dir
FileUtils.mkdir_p 'aminet'
2024-05-02 21:08:44 +00:00
FileUtils.cp 'src/AMOSPro_BSDSocket.Lib', 'AMOSPro_BSDSocket.Lib'
2024-05-02 21:04:43 +00:00
hackerbun_target = File.expand_path("dist/AMOSPro_BSDSocket_#{version}.lha")
[
2024-05-02 21:04:43 +00:00
'AMOSPro_BSDSocket.Lib',
'README.md',
'API.md',
'LICENSE'
].each do |file|
target = "#{build_dir}/#{file}"
FileUtils.mkdir_p File.dirname(target)
FileUtils.cp file, target
end
2024-05-02 21:04:43 +00:00
%w[
src
examples
].each do |dir|
FileUtils.cp_r dir, "#{build_dir}/#{dir}"
end
2024-05-02 21:04:43 +00:00
Dir['icons/**/*.info'].each do |info|
target = info.gsub('icons/', build_base + '/')
FileUtils.mkdir_p File.dirname(target)
FileUtils.cp info, target
end
2024-05-02 21:04:43 +00:00
Dir[File.join(build_base, '**', '*.uaem')].each do |file|
FileUtils.rm file
end
Dir[File.join(build_base, '**', '*.bak')].each do |file|
FileUtils.rm file
end
2024-05-02 21:04:43 +00:00
Dir[File.join(build_base, 'src', '*.Lib')].each do |file|
pp file
FileUtils.rm file
end
2024-05-02 21:04:43 +00:00
Dir[File.join(build_base, 'src', 'bsdsocket_l*')].each do |file|
FileUtils.rm file
end
2024-05-02 21:04:43 +00:00
Dir.chdir build_base do
Open3.popen2e(
'jlha', 'c', hackerbun_target,
*(Dir['*'])
) do |stdin, stdout_and_stderr, wait_thr|
Thread.new do
stdout_and_stderr.each { |l| puts l }
end
2024-05-02 21:04:43 +00:00
stdin.close
wait_thr.value
end
end
2024-05-02 21:04:43 +00:00
FileUtils.cp hackerbun_target, 'aminet/BSDSocket-Extension.lha'
File.open('aminet/BSDSocket-Extension.readme', 'w') do |fh|
fh.puts aminet_template.result(binding)
end