mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 11:18:30 +00:00
Redesign cosmocc
toolchain
The `cosmocc` compiler is now being distributed as a self-contained toolchain that's path-agnostic and it no longer requires you clone the Cosmop repo to use it. The bin/ folder has been deleted from the mono repo. The `fatcosmocc` command has been renamed to `cosmocc`. MacOS support now works very well.
This commit is contained in:
parent
3802428026
commit
291103ad8d
71 changed files with 2437 additions and 1398 deletions
100
tool/cosmocc/bin/cosmoinstall
Executable file
100
tool/cosmocc/bin/cosmoinstall
Executable file
|
@ -0,0 +1,100 @@
|
|||
#!/bin/sh
|
||||
|
||||
# the `install -s` strip flag provided by gnu coreutils surprisngly
|
||||
# enough understands the portable executable format however it will
|
||||
# silently corrupt any actually portable executable it touches, due
|
||||
# to how it overwrites the whole mz header and removes the dos stub
|
||||
FIRST=1
|
||||
for x; do
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
set --
|
||||
FIRST=0
|
||||
fi
|
||||
if [ x"$x" = x"-s" ]; then
|
||||
continue
|
||||
fi
|
||||
set -- "$@" "$x"
|
||||
done
|
||||
|
||||
# now magically copy multi-architecture build artifacts
|
||||
if [ $# -gt 1 ]; then
|
||||
|
||||
# parse `install [$flags]... $src $dst`
|
||||
i=0
|
||||
n=$(( $# - 2 ))
|
||||
dst=
|
||||
src=
|
||||
flags=
|
||||
for x; do
|
||||
if [ x"$x" != x"${x#* }" ]; then
|
||||
# give up if any arguments contain spaces
|
||||
exec install "$@"
|
||||
fi
|
||||
src=$dst
|
||||
dst=$x
|
||||
if [ $i -lt $n ]; then
|
||||
flags="$flags $x"
|
||||
fi
|
||||
i=$(( i + 1 ))
|
||||
done
|
||||
|
||||
arch=aarch64
|
||||
|
||||
# turn:
|
||||
# install -c -m 644 foo.a /usr/lib/foo.a
|
||||
# into:
|
||||
# install -c -m 644 foo.a /usr/lib/foo.a
|
||||
# install -c -m 644 .aarch/foo.a /usr/lib/.aarch/foo.a
|
||||
if [ x"${dst##*/}" = x"${src##*/}" ] && # basenames are equal
|
||||
[ x"$dst" != x"${dst%.a}" ]; then # specifies static archive
|
||||
srcdir=${src%/*}
|
||||
srcbas=${dst##*/}
|
||||
if [ x"$srcdir" = x"$src" ]; then
|
||||
srcdir=
|
||||
elif [ -n "$srcdir" ]; then
|
||||
srcdir="$srcdir/"
|
||||
fi
|
||||
if [ -f "$srcdir.$arch/$srcbas" ]; then
|
||||
dstdir=${dst%/*}
|
||||
dstbas=${dst##*/}
|
||||
if [ x"$dstdir" = x"$dst" ]; then
|
||||
dstdir=
|
||||
elif [ -n "$dstdir" ]; then
|
||||
dstdir="$dstdir/"
|
||||
fi
|
||||
if [ ! -d "$dstdir.$arch" ]; then
|
||||
mkdir -p "$dstdir.$arch" || exit
|
||||
fi
|
||||
install $flags $src $dst || exit
|
||||
exec install $flags \
|
||||
"$srcdir.$arch/$srcbas" \
|
||||
"$dstdir.$arch/$dstbas"
|
||||
fi
|
||||
fi
|
||||
|
||||
# turn:
|
||||
# install -c -m 644 foo.a /usr/lib
|
||||
# into:
|
||||
# install -c -m 644 foo.a /usr/lib
|
||||
# install -c -m 644 .aarch/foo.a /usr/lib/.aarch
|
||||
arch=aarch64
|
||||
if [ x"$src" != x"${src%.a}" ] && [ -d "$dst" ]; then
|
||||
srcdir=${src%/*}
|
||||
srcbas=${dst##*/}
|
||||
if [ x"$srcdir" = x"$src" ]; then
|
||||
srcdir=
|
||||
elif [ -n "$srcdir" ]; then
|
||||
srcdir="$srcdir/"
|
||||
fi
|
||||
if [ -f "$srcdir.$arch/$srcbas" ]; then
|
||||
if [ ! -d "$dst/.$arch" ]; then
|
||||
mkdir -p "$dst/.$arch" || exit
|
||||
fi
|
||||
install $flags $src $dst || exit
|
||||
exec install $flags "$srcdir.$arch/$srcbas" "$dst/.$arch"
|
||||
fi
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
exec install "$@"
|
Loading…
Add table
Add a link
Reference in a new issue