How do I debug loading dragonfly grammars in NatLink? - naturallyspeaking

I've been trying to get dragonfly to work on my Windows 10 machine, but I can only get as far as making NatLink activate.
I've configured the user directory in the NatLink GUI, as well as activated the two debugging options.
In my user directory, I have one file called grammar.py:
from dragonfly import Grammar, CompoundRule
# Voice command rule combining spoken form and recognition processing.
class ExampleRule(CompoundRule):
spec = "do something computer" # Spoken form of command.
def _process_recognition(self, node, extras): # Callback when command is spoken.
print("Voice command spoken.")
# Create a grammar which contains and loads the command rule.
grammar = Grammar("example grammar") # Create a grammar to contain the command rule.
grammar.add_rule(ExampleRule()) # Add the command rule to the grammar.
grammar.load()
The expected outcome is that when I say "do something computer", NatLink should print "voice command activated" to its console. However, this doesn't happen.
When I start Dragon, the NatLink console prints the following:
UserDirectory: C:\Users\bp\Documents\dragonfly-grammar
do extra output at (re)loading time: 1
do extra output at callback time: 1
-- natlinkmain starting...
NatLink pyd dir C:\Natlink\Natlink\MacroSystem\core
NatLink base dirC:\Natlink\Natlink\MacroSystem
userDirectory: C:\Users\bp\Documents\dragonfly-grammar
Unimacro not enabled
changeCallback, Type: user, args: ('bp', 'C:\\ProgramData\\Nuance\\NaturallySpeaking15\\Users\\bp\\current', 'US English', 'General - Large')
callback user, args: ('bp', 'C:\\ProgramData\\Nuance\\NaturallySpeaking15\\Users\\bp\\current', 'US English', 'General - Large')
---------changeCallback, User changed to bp
setting shiftkey to: {shift} (language: enx)
usercallback, language: enx
--- natlinkstartup starting...
vocolaEnabled: True
Loading _vocola_main
Vocola not active
Vocola is disabled...
filesToLoad: ['_vocola_main']
beginCallback, cbd: 0
check for changed files (all files)...
vocolaEnabled: 0
filesToLoad: []
vocolaEnabled: 0
filesToLoad: []
language: enx (<type 'str'>)
userLanguage: US English (<type 'str'>)
DNSuserDirectory: C:\ProgramData\Nuance\NaturallySpeaking15\Users\bp\current (<type 'str'>)
=== debugCallback info ===
natlinkmain changeCallback, global variable: coreDirectory: C:\Natlink\Natlink\MacroSystem\core
natlinkmain changeCallback, global variable: baseDirectory: C:\Natlink\Natlink\MacroSystem
natlinkmain changeCallback, global variable: DNSuserDirectory: C:\ProgramData\Nuance\NaturallySpeaking15\Users\bp\current
natlinkmain changeCallback, global variable: userName: bp
natlinkmain changeCallback, global variable: unimacroDirectory: C:\Natlink\Unimacro
natlinkmain changeCallback, global variable: userDirectory: C:\Users\bp\Documents\dragonfly-grammar
natlinkmain changeCallback, global variable: WindowsVersion: 10
natlinkmain changeCallback, global variable: BaseModel: US English | BestMatch IV
natlinkmain changeCallback, global variable: BaseTopic: US English | Large | General
natlinkmain changeCallback, global variable: language: enx
natlinkmain changeCallback, global variable: userLanguage: US English
natlinkmain changeCallback, global variable: userTopic: General - Large
vocolaEnabled: 0
filesToLoad: ['_vocola_main']
natlinkmain started from C:\Natlink\Natlink\MacroSystem\core:
NatLink version: 4.2
DNS version: 15
Python version: 27
Windows Version: 10
userDirectory: C:\Users\bp\Documents\dragonfly-grammar
baseDirectory: C:\Natlink\Natlink\MacroSystem
unimacroDirectory: C:\Natlink\Unimacro
natlinkmain imported-----------------------------------
Then, when I activate the microphone, the NatLink console prints the following:
changeCallback, Type: mic, args: on
findAndLoadFiles...
vocolaEnabled: 0
filesToLoad: ['_vocola_main']
beginCallback, cbd: 1
check for changed files (all files)...
vocolaEnabled: 0
filesToLoad: []
vocolaEnabled: 0
filesToLoad: []
=== debugCallback info ===
natlinkmain changeCallback, global variable: coreDirectory: C:\Natlink\Natlink\MacroSystem\core
natlinkmain changeCallback, global variable: baseDirectory: C:\Natlink\Natlink\MacroSystem
natlinkmain changeCallback, global variable: DNSuserDirectory: C:\ProgramData\Nuance\NaturallySpeaking15\Users\bp\current
natlinkmain changeCallback, global variable: userName: bp
natlinkmain changeCallback, global variable: unimacroDirectory: C:\Natlink\Unimacro
natlinkmain changeCallback, global variable: userDirectory: C:\Users\bp\Documents\dragonfly-grammar
natlinkmain changeCallback, global variable: WindowsVersion: 10
natlinkmain changeCallback, global variable: BaseModel: US English | BestMatch IV
natlinkmain changeCallback, global variable: BaseTopic: US English | Large | General
natlinkmain changeCallback, global variable: language: enx
natlinkmain changeCallback, global variable: userLanguage: US English
natlinkmain changeCallback, global variable: userTopic: General - Large
beginCallback, cbd: 1
check for changed files (only specific)
beginCallback, cbd: 1
check for changed files (only specific)
vocolaEnabled: 0
filesToLoad: []
changeCallback, Type: mic, args: off
Win10 64 bit, Python 2.7 32 bit

Turns out grammar files must (apparently) begin with _, so renaming file to _grammar.py did the trick

Related

How to exit a REPL from the command line

I'm currently learning Lua and also learning how to work with CMD.
I know how to change a directory path and run my codes and files from that path
but what I don't know and I'm here to ask for is how to get out of a programming language REPL when you start it in CMD
For example to jump into the Lua REPL you should type:
lua53 (--like python3 for the Python language)
then you changed the CMD environment to a Lua compiler and can't access CMD commands such as
dir, cd, cls etc. and everytime when I need to access these commands I have to close the CMD window and open a new one.
Now can you guys tell me am I able to access CMD commands while in the Lua REPL? Or do I have to exit Lua first, and is there any command to exit a REPL?
I'd recommend EOF (Ctrl + D on Unix) rather than SIGKILL (Ctrl + C) because some REPLs (node and python) choose to ignore the latter (perhaps because it's often used for copying text?); python will just print KeyboardInterrupt whereas node will only exit if you press Ctrl + C twice (it will send a message telling you this the first time).
EOF (Ctrl + D) on the other hand immediately exists all REPLs I have used so far.
The Lua REPL stops immediately when it receives either EOF or SIGKILL, so you can use both here.
Edit: As Sowban points out, EOF apparently is entered as Ctrl + Z then Enter in powershell.
You could type ctrl c to exit the process that's running generally.
I suggest to write a REPL by yourself.
But be warned :-)
The main loop with a prompt and the interpreting and executing function/method is mostly the easiest part.
99.99999% is the errorhandling thing.
One of my earliest interpreter language is (A)REXX.
A REPL without any errorhandling is done with...
/* REXX have to start with a comment */
do forever
parse pull input
interpret input
end
Now Lua sandboxed to an _ENV with io and os library and a little bit of errorhandling...
#!/usr/bin/env -S readline-editor /usr/local/bin/lua
-- ^--SHEBANG for Linux --------------------------------------------------------------------------------------
-- interpreter.lua
-- Sandboxed to io and os
-- Lua 5.4 >>-because-> goto label <const> load()
--------------------------------------------------------------------------------------------------------------
local Lua = function(...)
-- Info about OS
io.write(("%s\n"):format(io.popen('uname -a'):read())):flush()
-- Global Setting
debug.setmetatable((1), {__index = math}) -- Add math library to number as methods (like string for strings)
os.setlocale('de_DE.UTF8')
os.setlocale('en_US.UTF8', 'time')
io.write(os.date("[%c]\n" .. ("%s\n"):format(os.setlocale():gsub("%;", "\n")))):flush()
-- io.write(("%s\n"):format(_VERSION)):flush()
-- Label for goto
::lua::
-- Local Setting
local args <const> = args or {...}
local Lua = Lua or true
local cmd = cmd or ""
--------------------------------------------------------------------------------------------------------------
local env <const> = env or setmetatable({os = os, io = io}, -- The _ENV for load()
{__call = function(self, ...)
local self, t = ({...})[1] or self, "" -- First argument becomes self if one
if ({...})[1] == "help" then self = getmetatable(({...})[2]).__index end -- Showing metamethod __index (table)
for k, v in pairs(self) do
t = t .. ("%s => %s\n"):format(k, v)
end
return t
end,
__index = {cg = collectgarbage,
gt = getmetatable,
pairs = pairs,
tn = tonumber,
ts = tostring,
_V = ("%s \27[1;" .. (31):random(36) .. "m(sandboxed)\27[0m"):format(_VERSION)},
__tostring = function(self) return self._V end}) -- end env
--------------------------------------------------------------------------------------------------------------
local prompt = prompt or setmetatable({}, {__tostring = function() return getmetatable(env).__index._V .. "> " end})
local name <const> = name or _VERSION
local result = result or true
--------------------------------------------------------------------------------------------------------------
while Lua do
io.write(tostring(prompt))
cmd = io.read() or 'quit'
if cmd == "quit" then Lua, result = true, true break end
Lua, result = pcall(load("return " .. cmd or false, name, "t", env))
if Lua and result then
io.write(("%s"):format(tostring(result)))
else
goto exception
end
end
--------------------------------------------------------------------------------------------------------------
-- Errorhandler
::exception::
io.write(("%s\n"):format("Exception"))
if not Lua or not result then
io.output(io.stderr)
io.write(("[%s][%s][%s]\n\27[1;31m>>-Exception->\27[0m %s\n"):format(os.date(), _VERSION, cmd, result)):flush()
io.output(io.stdout)
collectgarbage()
goto lua
end
goto lua
end
--------------------------------------------------------------------------------------------------------------
-- EXAMPLE ---------------------------------------------------------------------------------------------------
-- Lua = require("interpreter")
Lua() -- UNCOMMENT-> For direct execution like: /bin/lua interpreter.lua
return Lua -- UNCOMMENT-> For: Lua = require("interpreter")
Ctrl&C quits hardly
Ctrl&D is only an exception
...and os.exit(0) do an clean exit with returncode 0.
Impression

Why Does Podman Report "Not enough IDs available in namespace" with different UIDs?

Facts:
Rootless podman works perfectly for uid 1480
Rootless podman fails for uid 2088
CentOS 7
Kernel 3.10.0-1062.1.2.el7.x86_64
podman version 1.4.4
Almost the entire environment has been removed between the two
The filesystem for /tmp is xfs
The capsh output of the two users is identical but for uid / username
Both UIDs have identical entries in /etc/sub{u,g}id files
The $HOME/.config/containers/storage.conf is the default and is identical between the two with the exception of the uids. The storage.conf is below for reference.
I wrote the following shell script to demonstrate just how similar an environment the two are operating in:
#!/bin/sh
for i in 1480 2088; do
sudo chroot --userspec "$i":10 / env -i /bin/sh <<EOF
echo -------------- $i ----------------
/usr/sbin/capsh --print
grep "$i" /etc/subuid /etc/subgid
mkdir /tmp/"$i"
HOME=/tmp/"$i"
export HOME
podman --root=/tmp/"$i" info > /tmp/podman."$i"
podman run --rm --root=/tmp/"$i" docker.io/library/busybox printf "\tCOMPLETE\n"
echo -----------END $i END-------------
EOF
sudo rm -rf /tmp/"$i"
done
Here's the output of the script:
$ sh /tmp/podman-fail.sh
[sudo] password for functional:
-------------- 1480 ----------------
Current: =
Bounding set =cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,cap_sys_nice,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,35,36
Securebits: 00/0x0/1'b0
secure-noroot: no (unlocked)
secure-no-suid-fixup: no (unlocked)
secure-keep-caps: no (unlocked)
uid=1480(functional)
gid=10(wheel)
groups=0(root)
/etc/subuid:1480:100000:65536
/etc/subgid:1480:100000:65536
Trying to pull docker.io/library/busybox...Getting image source signatures
Copying blob 7c9d20b9b6cd done
Copying config 19485c79a9 done
Writing manifest to image destination
Storing signatures
ERRO[0003] could not find slirp4netns, the network namespace won't be configured: exec: "slirp4netns": executable file not found in $PATH
COMPLETE
-----------END 1480 END-------------
-------------- 2088 ----------------
Current: =
Bounding set =cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_linux_immutable,cap_net_bind_service,cap_net_broadcast,cap_net_admin,cap_net_raw,cap_ipc_lock,cap_ipc_owner,cap_sys_module,cap_sys_rawio,cap_sys_chroot,cap_sys_ptrace,cap_sys_pacct,cap_sys_admin,cap_sys_boot,cap_sys_nice,cap_sys_resource,cap_sys_time,cap_sys_tty_config,cap_mknod,cap_lease,cap_audit_write,cap_audit_control,cap_setfcap,cap_mac_override,cap_mac_admin,cap_syslog,35,36
Securebits: 00/0x0/1'b0
secure-noroot: no (unlocked)
secure-no-suid-fixup: no (unlocked)
secure-keep-caps: no (unlocked)
uid=2088(broken)
gid=10(wheel)
groups=0(root)
/etc/subuid:2088:100000:65536
/etc/subgid:2088:100000:65536
Trying to pull docker.io/library/busybox...Getting image source signatures
Copying blob 7c9d20b9b6cd done
Copying config 19485c79a9 done
Writing manifest to image destination
Storing signatures
ERRO[0003] Error while applying layer: ApplyLayer exit status 1 stdout: stderr: there might not be enough IDs available in the namespace (requested 65534:65534 for /home): lchown /home: invalid argument
ERRO[0003] Error pulling image ref //busybox:latest: Error committing the finished image: error adding layer with blob "sha256:7c9d20b9b6cda1c58bc4f9d6c401386786f584437abbe87e58910f8a9a15386b": ApplyLayer exit status 1 stdout: stderr: there might not be enough IDs available in the namespace (requested 65534:65534 for /home): lchown /home: invalid argument
Failed
Error: unable to pull docker.io/library/busybox: unable to pull image: Error committing the finished image: error adding layer with blob "sha256:7c9d20b9b6cda1c58bc4f9d6c401386786f584437abbe87e58910f8a9a15386b": ApplyLayer exit status 1 stdout: stderr: there might not be enough IDs available in the namespace (requested 65534:65534 for /home): lchown /home: invalid argument
Here's the storage.conf for the 1480 uid. It's identical except s/1480/2088/:
[storage]
driver = "vfs"
runroot = "/run/user/1480"
graphroot = "/tmp/1480/.local/share/containers/storage"
[storage.options]
size = ""
remap-uids = ""
remap-gids = ""
remap-user = ""
remap-group = ""
ostree_repo = ""
skip_mount_home = ""
mount_program = ""
mountopt = ""
[storage.options.thinpool]
autoextend_percent = ""
autoextend_threshold = ""
basesize = ""
blocksize = ""
directlvm_device = ""
directlvm_device_force = ""
fs = ""
log_level = ""
min_free_space = ""
mkfsarg = ""
mountopt = ""
use_deferred_deletion = ""
use_deferred_removal = ""
xfs_nospace_max_retries = ""
You can see there's basically no difference between the two podman info outputs for the users:
$ diff -u /tmp/podman.1480 /tmp/podman.2088
--- /tmp/podman.1480 2019-10-17 22:41:21.991573733 -0400
+++ /tmp/podman.2088 2019-10-17 22:41:26.182584536 -0400
## -7,7 +7,7 ##
Distribution:
distribution: '"centos"'
version: "7"
- MemFree: 45654056960
+ MemFree: 45652697088
MemTotal: 67306323968
OCIRuntime:
package: containerd.io-1.2.6-3.3.el7.x86_64
## -24,7 +24,7 ##
kernel: 3.10.0-1062.1.2.el7.x86_64
os: linux
rootless: true
- uptime: 30h 17m 50.23s (Approximately 1.25 days)
+ uptime: 30h 17m 54.42s (Approximately 1.25 days)
registries:
blocked: null
insecure: null
## -35,14 +35,14 ##
- quay.io
- registry.centos.org
store:
- ConfigFile: /tmp/1480/.config/containers/storage.conf
+ ConfigFile: /tmp/2088/.config/containers/storage.conf
ContainerStore:
number: 0
GraphDriverName: vfs
GraphOptions: null
- GraphRoot: /tmp/1480
+ GraphRoot: /tmp/2088
GraphStatus: {}
ImageStore:
number: 0
- RunRoot: /run/user/1480
- VolumePath: /tmp/1480/volumes
+ RunRoot: /run/user/2088
+ VolumePath: /tmp/2088/volumes
I refuse to believe there's an if (2088 == uid) { abort(); } or similar nonsense somewhere in podman's source code. What am I missing?
Does podman system migrate fix there might not be enough IDs available in the namespace for you?
It did for me and others:
https://github.com/containers/libpod/issues/3421
AFAICT, sub-UID and GID ranges should not overlap between users. For reference, here is what the useradd manpage has to say about the matter:
SUB_GID_MIN (number), SUB_GID_MAX (number), SUB_GID_COUNT
(number)
If /etc/subuid exists, the commands useradd and newusers
(unless the user already have subordinate group IDs)
allocate SUB_GID_COUNT unused group IDs from the range
SUB_GID_MIN to SUB_GID_MAX for each new user.
The default values for SUB_GID_MIN, SUB_GID_MAX,
SUB_GID_COUNT are respectively 100000, 600100000 and 65536.
SUB_UID_MIN (number), SUB_UID_MAX (number), SUB_UID_COUNT
(number)
If /etc/subuid exists, the commands useradd and newusers
(unless the user already have subordinate user IDs) allocate
SUB_UID_COUNT unused user IDs from the range SUB_UID_MIN to
SUB_UID_MAX for each new user.
The default values for SUB_UID_MIN, SUB_UID_MAX,
SUB_UID_COUNT are respectively 100000, 600100000 and 65536.
The key word is unused.
CentOS 7.6 does not suport rootless buildah by default - see https://github.com/containers/buildah/pull/1166 and https://www.redhat.com/en/blog/preview-running-containers-without-root-rhel-76

WinDbg: How do I include a thread id and time value in a breakpoint .printf _without_ using pseudo registers?

I have some breakpoint "pairs," and I'd like to measure the time in between when they are hit.
The simplest thing that would allow me to do this is to include some sort of timestamp (even if it's just clock ticks or something) in the .printf I use when the breakpoint is hit.
I could use the pseudo registers $tid and $dbgtime in the breakpoint code. When I do, the performance really suffers.
bp1000 ucrtbase!malloc ".printf \"[0x%08x] [ucrtbase] [0x%04x] [0x%08x] malloc(%d): \", $dbgtime, $tid, dwo(#esp), dwo(#esp+4); gc "
When the same code is used (without using meaningful values for timestamp and thread id), things work much better.
bp1000 ucrtbase!malloc ".printf \"[0x%08x] [ucrtbase] [0x%04x] [0x%08x] malloc(%d): \", 0, 0, dwo(#esp), dwo(#esp+4); gc "
Is there some other (high-performance) way to get this information? The current time is more valuable than the thread ID. I can always make the breakpoint only apply to a specific thread so that emitting the ID is only sugar.
try this
0:000> bp ucrtbase!malloc "~# ; .echotime ; dd #$csp l2 ; gc ;"
0:000> bl
0 e 00007ff8`ab61c9e0 0001 (0001) 0:**** ucrtbase!malloc "~# ; .echotime ; dd #$csp l2 ; gc ;"
0:000> g
. 0 Id: 1a84.1f14 Suspend: 1 Teb: 00000018`f49d1000 Unfrozen
Start: cdb!wmainCRTStartup (00007ff6`efd2bbf0)
Priority: 0 Priority class: 32 Affinity: f
Debugger (not debuggee) time: Wed Aug 7 22:17:44.992 2019
00000018`f47eeb58 ab622762 00007ff8
. 0 Id: 1a84.1f14 Suspend: 1 Teb: 00000018`f49d1000 Unfrozen
Start: cdb!wmainCRTStartup (00007ff6`efd2bbf0)
Priority: 0 Priority class: 32 Affinity: f
Debugger (not debuggee) time: Wed Aug 7 22:17:44.992 2019 (UTC + 5:30)
00000018`f47eeb08 ab622762 00007ff8

CMD start .exe with just one of multiple parameters

I would like my batch script to randomly choose one parameter on its own (from around 70 parameters eg. param1 - param70), without my input.
In addition to the random param, the exe has more parameters which always stay the same.
I dont know how to put this in code.
Here's an example of my thought:
param1=--abc
param2=--mno
param3=--xyz
./example.exe --hello --world --(param1 OR param2 OR param3)
which equals to:
./example.exe --hello --world --abc
or
./example.exe --hello --world --mno
or
./example.exe --hello --world --xyz
This can work in batch.You need to set each param though.
set /a numb=%random% %% 3
goto :param%numb%
:param0
Set "var=abc"
Goto :execute
:param1
Set "var=mno"
Goto :execute
:param2
Set "var=xyz"
Goto :execute
:execute
.\example.exe --hello --%var%
For 70 params you need to change %% 3 to %% 70
In powershell:
$params = "abc","mno","xyz"
& example.exe --hello --world --$(Get-Random -InputObject $params -Count 1)
Handling 70 parameters Gerhards way will get tedious. I'd build a parameter array and get a random one.
:: Q:\Test\2018\04\27\SO_50059458.cmd
#Echo off&SetLocal EnableExtensions EnableDelayedExpansion
Rem Build param[] array and count params
Set Cnt=-1&Set "param= abc bcd cde def efg fgh ghi hij ijk jkl klm lmn mno"
Set "param=%param: ="&Set /a Cnt+=1&Set "param[!Cnt!]=%"
:: show array
Set param
:: get random # in Cnt
Set /a Rnd=%Random% %% Cnt
echo Random %Rnd% out of %Cnt%
Echo .\example.exe --hello --!param[%Rnd%]!
Sample output:
> Q:\Test\2018\04\27\SO_50059458.cmd
param[0]=abc
param[10]=klm
param[11]=lmn
param[12]=mno
param[1]=bcd
param[2]=cde
param[3]=def
param[4]=efg
param[5]=fgh
param[6]=ghi
param[7]=hij
param[8]=ijk
param[9]=jkl
Random 10 out of 12
.\example.exe --hello --klm

swiftc: Possible values for "-target" command line option

There is Swift compiler option -target:
$ swiftc -h
...
-target <value> Generate code for the given target
...
Where from can I get all possible values for compiler option -target (i.e: x86_64-apple-ios11.0, x86_64-apple-macosx10.12, ...) ?
Thanks!
Look at https://github.com/apple/swift/blob/master/utils/build-script-impl
Search the build script for terms like SWIFT_HOST_VARIANT, SWIFT_HOST_VARIANT_SDK, SWIFT_HOST_VARIANT_ARCH and SWIFT_HOST_TRIPLE
#!/usr/bin/env bash
#===--- build-script-impl - Implementation details of build-script ---------===#
#
## This source file is part of the Swift.org open source project
# Each variable name is re-exported into this script in uppercase, where dashes
# are substituted by underscores. For example, `swift-install-components` is
# referred to as `SWIFT_INSTALL_COMPONENTS` in the remainder of this script.
KNOWN_SETTINGS=(
# name default description
# ... snip ...
darwin-deployment-version-osx "10.9" "minimum deployment target version for OS X"
darwin-deployment-version-ios "7.0" "minimum deployment target version for iOS"
# ... snip ...
function set_build_options_for_host() {
llvm_cmake_options=()
swift_cmake_options=()
cmark_cmake_options=()
lldb_cmake_options=()
swiftpm_bootstrap_options=()
SWIFT_HOST_VARIANT=
SWIFT_HOST_VARIANT_SDK=
SWIFT_HOST_VARIANT_ARCH=
SWIFT_HOST_TRIPLE=
local host="$1"
# Hosts which can be cross-compiled must specify:
# SWIFT_HOST_TRIPLE and llvm_target_arch (as well as usual HOST_VARIANT flags)
case ${host} in
freebsd-x86_64)
SWIFT_HOST_VARIANT="freebsd"
SWIFT_HOST_VARIANT_SDK="FREEBSD"
SWIFT_HOST_VARIANT_ARCH="x86_64"
;;
cygwin-x86_64)
SWIFT_HOST_VARIANT="cygwin"
SWIFT_HOST_VARIANT_SDK="CYGWIN"
SWIFT_HOST_VARIANT_ARCH="x86_64"
;;
# ... snip ...
linux-*)
SWIFT_HOST_VARIANT="linux"
SWIFT_HOST_VARIANT_SDK="LINUX"
case ${host} in
linux-x86_64)
SWIFT_HOST_VARIANT_ARCH="x86_64"
;;
# ... snip ...
linux-aarch64)
SWIFT_HOST_VARIANT_ARCH="aarch64"
;;
# ... snip ...
;;
macosx-* | iphoneos-* | iphonesimulator-* | \
appletvos-* | appletvsimulator-* | \
watchos-* | watchsimulator-*)
case ${host} in
macosx-x86_64)
xcrun_sdk_name="macosx"
llvm_target_arch=""
SWIFT_HOST_TRIPLE="x86_64-apple-macosx${DARWIN_DEPLOYMENT_VERSION_OSX}"
SWIFT_HOST_VARIANT="macosx"
SWIFT_HOST_VARIANT_SDK="OSX"
SWIFT_HOST_VARIANT_ARCH="x86_64"