Build and release scripts, reorganize code, prep for releases
This commit is contained in:
parent
bcfa274836
commit
1447390f3f
|
@ -1,2 +1,5 @@
|
|||
*.uaem
|
||||
*.Bak
|
||||
dist/
|
||||
build/
|
||||
aminet/
|
||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT No Attribution
|
||||
|
||||
Copyright <YEAR> <COPYRIGHT HOLDER>
|
||||
Copyright 2023 John Bintz
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
software and associated documentation files (the "Software"), to deal in the Software
|
||||
|
|
23
README.md
23
README.md
|
@ -1,6 +1,6 @@
|
|||
# amos-pro-bsdsocket-extension
|
||||
|
||||
Want to get online with your AMOS program? Now you can in (some) style!
|
||||
Want to get online with your AMOS program? Now you can in style!
|
||||
|
||||
This extension provides a wrapper around the BSD Socket library
|
||||
provided by your Internet stack. There's some attempt to roll up some
|
||||
|
@ -151,16 +151,33 @@ This project uses semantic versioning.
|
|||
Copyright 2023 John Bintz. Licensed under the MIT License.
|
||||
|
||||
If you use this in your project, and you really want to,
|
||||
throw a link to theindustriousrabbit.com somewhere.
|
||||
throw a link to theindustriousrabbit.com somewhere! You can
|
||||
also find a donate link on
|
||||
[the About section on The Industrious Rabbit](https://theindustriousrabbit.com/about).
|
||||
|
||||
## Feedback? Bug reports?
|
||||
|
||||
Go to the [About section on The Industrious Rabbit](https://theindustriousrabbit.com/about)
|
||||
to contact me.
|
||||
|
||||
## Changelog
|
||||
|
||||
### 0.7.0 (2023-02-20)
|
||||
|
||||
* Current development release
|
||||
|
||||
## Development
|
||||
|
||||
### Environment
|
||||
|
||||
* Clone the [AMOS Professional source code](https://github.com/AOZ-Studio/AMOS-Professional-Official)
|
||||
* Copy the contents of
|
||||
* Copy the contents of `src` into the `extensions` folder
|
||||
* Run `absdsocket`
|
||||
|
||||
### Releasing
|
||||
|
||||
#### Ubuntu/Debian
|
||||
|
||||
* Install `jlha-utils` and a modern enough Java to run it
|
||||
* Install Ruby
|
||||
* Run `bin/release`
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
Short: Use bsdsocket.library in AMOS Pro
|
||||
Uploader: aminet@theindustriousrabbit.com (John Bintz)
|
||||
Author: John Bintz
|
||||
Type: dev/amos
|
||||
Version: <%= version %>
|
||||
Architecture: m68k-amigaos
|
||||
|
||||
Want to get online with your AMOS program? Now you can in style!
|
||||
|
||||
This extension provides a wrapper around the BSD Socket library
|
||||
provided by your Internet stack. There's some attempt to roll up some
|
||||
of the low-level functionality into something more usable by AMOS.
|
||||
|
||||
More details provided in README.md in the archive file, and in the
|
||||
source code repository at:
|
||||
https://code.hackerbun.dev/TheIndustriousRabbit/amos-pro-bsdsocket-extension
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
for i in examples/*.amos; do
|
||||
echo "$i"
|
||||
~/Projects/amostools/listamos -e AMOSPro_BSDSocket.Lib "${i}" > "${i%.amos}.basic" 2>/dev/null
|
||||
done
|
|
@ -0,0 +1,81 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'fileutils'
|
||||
require 'open3'
|
||||
require 'erb'
|
||||
|
||||
source = File.read('src/BSDSocket.s')
|
||||
|
||||
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]
|
||||
|
||||
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'
|
||||
|
||||
hackerbun_target = File.expand_path("dist/AMOSPro_BSDSocket_#{version}.lha")
|
||||
|
||||
[
|
||||
"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"
|
||||
].each do |dir|
|
||||
FileUtils.cp_r dir, "#{build_dir}/#{dir}"
|
||||
end
|
||||
|
||||
Dir["icons/**/*.info"].each do |info|
|
||||
target = info.gsub("icons/", build_base + "/")
|
||||
FileUtils.mkdir_p File.dirname(target)
|
||||
FileUtils.cp info, target
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
stdin.close
|
||||
|
||||
wait_thr.value
|
||||
end
|
||||
end
|
||||
|
||||
FileUtils.cp hackerbun_target, "aminet/BSDSocket-Extension.lha"
|
||||
File.open("aminet/BSDSocket-Extension.readme", "w") do |fh|
|
||||
fh.puts aminet_template.result(binding)
|
||||
end
|
|
@ -0,0 +1,93 @@
|
|||
' This code shows how to make a non-blocking request with
|
||||
' timeout to a remote HTTP server to retrieve a webpage
|
||||
' and print it on the screen.
|
||||
'
|
||||
' This requires the BSD Socket Extension installed in Extension
|
||||
' Slot 18.
|
||||
'
|
||||
' Copyright 2023 John Bintz
|
||||
' Visit theindustriousrabbit.com for more info
|
||||
' Licensed under the MIT License
|
||||
|
||||
LIB=Socket Library Open
|
||||
|
||||
If LIB<=0
|
||||
Print "Unable to open bsdsocket.library!"
|
||||
End
|
||||
End If
|
||||
|
||||
SOCKET=Socket Create Inet Socket
|
||||
|
||||
' A lot of functions return debugging info. Assign that to
|
||||
' some useless variable, unless you're trying to figure out
|
||||
' an issue with the extension.
|
||||
_=Socket Set Nonblocking(SOCKET,True)
|
||||
|
||||
HOST$="aminet.net"
|
||||
Print "Trying to connect to "+HOST$
|
||||
IP$=Dns Get Address By Name$(HOST$)
|
||||
|
||||
' When nonblocking sockets start to connect, they may or
|
||||
' may not finish their connection before the function
|
||||
' returns. If the socket doesn't connect, we have to wait
|
||||
' for it to do so.
|
||||
ALREADY_CONNECTED=Socket Connect(SOCKET To IP$,80)
|
||||
|
||||
Reserve As Work 30,1024
|
||||
|
||||
' Due to how AMOS takes over Ctrl-C handing, there's no way
|
||||
' for the bsdsocket code to use Exec's Ctrl-C handling.
|
||||
' This means we need to poll for network activity.
|
||||
' However, the async functions will immediately return
|
||||
' if they get appropriate data before the timeout ends.
|
||||
' This is somewhat more CPU efficient.
|
||||
For I=1 To 100
|
||||
If ALREADY_CONNECTED=-1
|
||||
' We can check a socket for writing if it's currently
|
||||
' attempting to connect. Once it connects, we can stop
|
||||
' checking for that status -- we're ready to communicate
|
||||
' with the remote server.
|
||||
RESULT=Socket Wait Async Writing(SOCKET,100)
|
||||
|
||||
If RESULT>0
|
||||
ALREADY_CONNECTED=0
|
||||
End If
|
||||
End If
|
||||
|
||||
If ALREADY_CONNECTED=0
|
||||
Print "Connected to "+HOST$
|
||||
|
||||
HTTPGET$="GET / HTTP/1.0"+Chr$(10)+"Host: amiga"+Chr$(10)+Chr$(10)
|
||||
Print "Making HTTP request to "+HOST$
|
||||
_=Socket Send(SOCKET,Varptr(HTTPGET$),Len(HTTPGET$))
|
||||
|
||||
For J=1 To 100
|
||||
RESULT=Socket Wait Async Reading(SOCKET,50)
|
||||
|
||||
If RESULT>0
|
||||
Print "Receiving data"
|
||||
' You can receive either to a block of memory...
|
||||
'
|
||||
'OUT=Socket Recv(SOCKET To Start(30),1024)
|
||||
'For K=0 To OUT-1
|
||||
' _DATA$=_DATA$+Chr$(Peek(Start(30)+K))
|
||||
'Next K
|
||||
'
|
||||
' ...or to a string...
|
||||
_DATA$=Socket Recv$(SOCKET,1024)
|
||||
|
||||
Print _DATA$
|
||||
' If the amount read is less than the length of data,
|
||||
' assume we're done. This is fine for HTTP.
|
||||
If Len(_DATA$)<1024
|
||||
Exit 2
|
||||
End If
|
||||
End If
|
||||
Next J
|
||||
Exit
|
||||
End If
|
||||
Next I
|
||||
|
||||
Socket Library Close
|
||||
|
||||
|
Binary file not shown.
|
@ -0,0 +1,56 @@
|
|||
' This is example code for opening a port on your machine,
|
||||
' waiting for a client to connect, then printing out the
|
||||
' first 1024 bytes the server receives from the client.
|
||||
'
|
||||
' Copyright 2023 John Bintz
|
||||
' Licensed under the MIT License
|
||||
' Visit theindustriousrabbit.com for more information
|
||||
|
||||
If Socket Library Open<=0
|
||||
End
|
||||
End If
|
||||
|
||||
SOCKET=Socket Create Inet Socket
|
||||
|
||||
' Ensure our socket does not block, and that we can reuse
|
||||
' the address we bind to right away if our server is closed.
|
||||
_=Socket Set Nonblocking(SOCKET,True)
|
||||
_=Socket Reuse Addr(SOCKET)
|
||||
|
||||
' You can bind your socket to any interface on the machine.
|
||||
' You'd have to get that list of interfaces yourself.
|
||||
' Using "INADDR_ANY" is the equivalent of binding to 0.0.0.0.
|
||||
RESULT=Socket Bind(SOCKET To "INADDR_ANY",8000)
|
||||
|
||||
_=Socket Listen(SOCKET)
|
||||
Print "Listening on port 8000"
|
||||
|
||||
For I=1 To 100
|
||||
' Here. we're testing our non-blocking async socket for
|
||||
' reading. If the socket has been connected to, this request
|
||||
' will return a value greater than 0. Otherwise, it will
|
||||
' wait for a half second, then return 0.
|
||||
RESULT=Socket Wait Async Reading(SOCKET,500)
|
||||
|
||||
If RESULT>0
|
||||
' Accept the connection so we can receive data from it.
|
||||
_REMOTE_SOCKET=Socket Accept(SOCKET)
|
||||
|
||||
' Print out the remote IP address and port.
|
||||
Print Socket Inet Ntoa$(Socket Get Host(_REMOTE_SOCKET))
|
||||
Print Socket Get Port(_REMOTE_SOCKET)
|
||||
|
||||
' Receive the first 1024 or fewer bytes of data from the
|
||||
' client and print them out.
|
||||
Print Socket Recv$(_REMOTE_SOCKET,1024)
|
||||
|
||||
' If we exit now, the connection will stay open. Closing the
|
||||
' library or restarting the program will close all open
|
||||
' connections.
|
||||
Exit
|
||||
End If
|
||||
Wait Vbl
|
||||
Next I
|
||||
|
||||
Socket Library Close
|
||||
|
BIN
http get v3.amos
BIN
http get v3.amos
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
the minimum.amos
BIN
the minimum.amos
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue