1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-01 07:54:27 +00:00

Update some Wii U development metadata (#13013)

== DETAILS
- add a `WiiU` IntelliSense configuration for vscode
- rewrite the `net_listen.sh` script in python because the
  shell script approach just isn't portable enough and doesn't handle
  things like multiple network adapters gracefully at all.
This commit is contained in:
gblues 2021-09-18 16:22:59 -07:00 committed by GitHub
parent b3d724b7a3
commit ae617c0ee6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 71 deletions

View File

@ -150,6 +150,23 @@
"cStandard": "c11",
"cppStandard": "c++11",
"intelliSenseMode": "gcc-x64"
},
{
"name": "WiiU",
"includePath": [
"/opt/devkitpro/devkitPPC/powerpc-eabi/include",
"/opt/devkitpro/devkitPPC/lib/gcc/powerpc-eabi/6.3.0/include",
"/opt/devkitpro/portlibs/ppc/include",
"${workspaceFolder}/**"
],
"defines": [
"WIIU"
],
"windowsSdkVersion": "10.0.17763.0",
"compilerPath": "/opt/devkitpro/devkitPPC/bin/powerpc-eabi-gcc",
"cStandard": "c11",
"cppStandard": "c++11",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4

View File

@ -1,82 +1,49 @@
#!/bin/bash
#!/usr/bin/env python
# Adapted from the Python UDP broadcast client example by ninedraft: https://github.com/ninedraft/python-udp/
#
# This script listens for the WiiU network logger and prints the messages to
# the terminal.
#
# If you would like a logfile, pipe this script's output to tee.
from __future__ import print_function
NETCAT=
import datetime
import os
import signal
import sys
find_netcat()
{
NETCAT=$(which netcat 2>/dev/null |grep '/')
if [ -z "$NETCAT" ]; then
NETCAT=$(which nc 2>/dev/null |grep '/')
if [ -z "$NETCAT" ]; then
echo "Failed to find either 'netcat' or 'nc'. Please install it."
exit 1
fi
fi
}
from socket import (
socket,
AF_INET,
SOCK_DGRAM,
IPPROTO_UDP,
SOL_SOCKET,
SO_REUSEPORT,
SO_BROADCAST
)
do_readlink()
{
local exe=$1
echo "$(cd $(dirname $exe) && pwd)"
}
def get_bind_port():
default = 4405
candidate = os.getenv('PC_DEVELOPMENT_TCP_PORT', str(default))
try:
port = int(candidate)
except ValueError:
port = default
find_netcat
script_dir=$(do_readlink $0)
return port
IP=$(which ip 2>/dev/null | grep '^/')
IFCONFIG=$(which ifconfig 2>/dev/null | grep '^/')
TS=$(which ts 2>/dev/null | grep '^/')
def exit_gracefully(signum, frame):
sys.exit(0)
# Using wiiu-devel.properties ensure your make file and this listen script
# stay in sync with each other.
#
# See wiiu-devel.properties.template for instructions.
if [ -e "$script_dir/../wiiu-devel.properties" ]; then
. $script_dir/../wiiu-devel.properties
fi
def main():
signal.signal(signal.SIGINT, exit_gracefully)
signal.signal(signal.SIGTERM, exit_gracefully)
if [ -z "$PC_DEVELOPMENT_TCP_PORT" ]; then
PC_DEVELOPMENT_TCP_PORT=4405
fi
client = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)
client.setsockopt(SOL_SOCKET, SO_REUSEPORT, 1)
client.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
client.bind(("", get_bind_port()) )
while True:
data, addr = client.recvfrom(1024)
print(datetime.datetime.now().isoformat(), data.decode('utf-8').rstrip('\r\n'))
exit_listen_loop=0
getBroadcastIp()
{
if [ ! -z "$IP" ]; then
$IP addr show | grep 'inet' |grep 'brd' | awk '{print $4}'
elif [ ! -z "$IFCONFIG" ]; then
$IFCONFIG | grep 'broadcast' | awk '{print $6}'
else
echo "255.255.255.255"
fi
}
#
# This prevents a tug-of-war between bash and netcat as to who gets the
# CTRL+C code.
#
trap 'exit_listen_loop=1' SIGINT
if [ -z "$TS" ]; then
echo "[WARN] 'ts' not found. Install the moreutils package to get timestamps."
fi
broadcast=$(getBroadcastIp)
echo "Listening for UDP packets on broadcast IP: $broadcast"
while [ $exit_listen_loop -eq 0 ]; do
echo ========= `date` =========
if [ -z "$TS" ]; then
$NETCAT -kluw 0 $broadcast $PC_DEVELOPMENT_TCP_PORT
else
$NETCAT -kluw 0 $broadcast $PC_DEVELOPMENT_TCP_PORT |ts '[%Y-%m-%d %H:%M:%.S]'
fi
done
if __name__ == '__main__':
main()