2023-03-31 17:47:58 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
require 'fileutils'
|
|
|
|
require 'open3'
|
|
|
|
require 'erb'
|
|
|
|
|
|
|
|
source = File.read('src/BSDSocket.s')
|
|
|
|
|
2023-04-05 13:43:33 +00:00
|
|
|
aminet_template = ERB.new(File.read('aminet.readme.erb'))
|
2023-03-31 17:47:58 +00:00
|
|
|
|
|
|
|
capture_version = false
|
|
|
|
version = nil
|
|
|
|
|
|
|
|
source.lines.each do |line|
|
|
|
|
if capture_version
|
2023-04-05 13:43:33 +00:00
|
|
|
version = line[/dc\.b "([^"]+)"/, 1]
|
2023-03-31 17:47:58 +00:00
|
|
|
|
|
|
|
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
|
2023-04-05 13:43:33 +00:00
|
|
|
FileUtils.rm_rf 'aminet'
|
2023-03-31 17:47:58 +00:00
|
|
|
FileUtils.mkdir_p build_dir
|
|
|
|
FileUtils.mkdir_p 'aminet'
|
|
|
|
|
2024-03-17 17:42:22 +00:00
|
|
|
FileUtils.mv 'src/AMOSPro_BSDSocket.Lib', 'AMOSPro_BSDSocket.Lib' if File.exist?('src/AMOSPro_BSDSocket.Lib')
|
|
|
|
|
2023-03-31 17:47:58 +00:00
|
|
|
hackerbun_target = File.expand_path("dist/AMOSPro_BSDSocket_#{version}.lha")
|
|
|
|
|
|
|
|
[
|
2023-04-05 13:43:33 +00:00
|
|
|
'AMOSPro_BSDSocket.Lib',
|
|
|
|
'README.md',
|
|
|
|
'API.md',
|
|
|
|
'LICENSE'
|
2023-03-31 17:47:58 +00:00
|
|
|
].each do |file|
|
|
|
|
target = "#{build_dir}/#{file}"
|
|
|
|
FileUtils.mkdir_p File.dirname(target)
|
|
|
|
FileUtils.cp file, target
|
|
|
|
end
|
|
|
|
|
2023-04-05 13:43:33 +00:00
|
|
|
gitignores = File.readlines('.gitignore').map(&:strip)
|
|
|
|
|
|
|
|
%w[
|
|
|
|
src
|
|
|
|
examples
|
2023-03-31 17:47:58 +00:00
|
|
|
].each do |dir|
|
|
|
|
FileUtils.cp_r dir, "#{build_dir}/#{dir}"
|
2023-04-05 13:43:33 +00:00
|
|
|
|
|
|
|
Dir["#{build_dir}/#{dir}/**/*"].each do |file|
|
|
|
|
FileUtils.rm file if gitignores.any? { |gi| File.fnmatch(gi, file) }
|
2024-03-17 17:42:22 +00:00
|
|
|
FileUtils.rm file if [/\.fd$/, /\.i$/].any? { |p| file[p] }
|
2023-04-05 13:43:33 +00:00
|
|
|
end
|
2023-03-31 17:47:58 +00:00
|
|
|
end
|
|
|
|
|
2023-04-05 13:43:33 +00:00
|
|
|
Dir['icons/**/*.info'].each do |info|
|
|
|
|
target = info.gsub('icons/', build_base + '/')
|
2023-03-31 17:47:58 +00:00
|
|
|
FileUtils.mkdir_p File.dirname(target)
|
|
|
|
FileUtils.cp info, target
|
|
|
|
end
|
|
|
|
|
|
|
|
Dir.chdir build_base do
|
|
|
|
Open3.popen2e(
|
2023-04-05 13:43:33 +00:00
|
|
|
'jlha', 'c', hackerbun_target,
|
|
|
|
*(Dir['*'])
|
|
|
|
) do |stdin, stdout_and_stderr, wait_thr|
|
|
|
|
Thread.new do
|
|
|
|
stdout_and_stderr.each { |l| puts l }
|
|
|
|
end
|
2023-03-31 17:47:58 +00:00
|
|
|
|
2023-04-05 13:43:33 +00:00
|
|
|
stdin.close
|
2023-03-31 17:47:58 +00:00
|
|
|
|
2023-04-05 13:43:33 +00:00
|
|
|
wait_thr.value
|
|
|
|
end
|
2023-03-31 17:47:58 +00:00
|
|
|
end
|
|
|
|
|
2023-04-05 13:43:33 +00:00
|
|
|
FileUtils.cp hackerbun_target, 'aminet/BSDSocket-Extension.lha'
|
|
|
|
File.open('aminet/BSDSocket-Extension.readme', 'w') do |fh|
|
2023-03-31 17:47:58 +00:00
|
|
|
fh.puts aminet_template.result(binding)
|
|
|
|
end
|