Improve build script

This commit is contained in:
John Bintz 2024-05-02 17:04:43 -04:00
parent f93a33ee0d
commit 79e77287bb
1 changed files with 42 additions and 23 deletions

View File

@ -6,14 +6,14 @@ require 'erb'
source = File.read('src/BSDSocket.s')
aminet_template = ERB.new(File.read("aminet.readme.erb"))
aminet_template = ERB.new(File.read('aminet.readme.erb'))
capture_version = false
version = nil
source.lines.each do |line|
if capture_version
version = line[/dc\.b "([^"]+)"/,1]
version = line[/dc\.b "([^"]+)"/, 1]
break
end
@ -34,37 +34,56 @@ FileUtils.rm_rf build_dir
FileUtils.mkdir_p build_dir
FileUtils.mkdir_p 'aminet'
FileUtils.cp 'src/AMOSPro_BSDSocket.Lib', 'AMOSPro_BSDSocket.lib'
hackerbun_target = File.expand_path("dist/AMOSPro_BSDSocket_#{version}.lha")
[
"AMOSPro_BSDSocket.Lib",
"README.md",
"API.md",
"LICENSE",
'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
[
"src",
"examples"
%w[
src
examples
].each do |dir|
FileUtils.cp_r dir, "#{build_dir}/#{dir}"
end
Dir["icons/**/*.info"].each do |info|
target = info.gsub("icons/", build_base + "/")
Dir['icons/**/*.info'].each do |info|
target = info.gsub('icons/', build_base + '/')
FileUtils.mkdir_p File.dirname(target)
FileUtils.cp info, target
end
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
Dir[File.join(build_base, 'src', '*.Lib')].each do |file|
pp file
FileUtils.rm file
end
Dir[File.join(build_base, 'src', 'bsdsocket_l*')].each do |file|
FileUtils.rm file
end
Dir.chdir build_base do
Open3.popen2e(
"jlha", "c", hackerbun_target,
*(Dir["*"])) do |stdin, stdout_and_stderr, wait_thr|
'jlha', 'c', hackerbun_target,
*(Dir['*'])
) do |stdin, stdout_and_stderr, wait_thr|
Thread.new do
stdout_and_stderr.each { |l| puts l }
end
@ -75,7 +94,7 @@ Dir.chdir build_base do
end
end
FileUtils.cp hackerbun_target, "aminet/BSDSocket-Extension.lha"
File.open("aminet/BSDSocket-Extension.readme", "w") do |fh|
FileUtils.cp hackerbun_target, 'aminet/BSDSocket-Extension.lha'
File.open('aminet/BSDSocket-Extension.readme', 'w') do |fh|
fh.puts aminet_template.result(binding)
end