Fix source location and add support for GIR2SWIFT_PATH and BUILD_DIR

This commit is contained in:
Rene Hexel 2020-06-14 15:07:40 +10:00
parent ce16fe1760
commit 9cef67ebd5
6 changed files with 24 additions and 14 deletions

View File

@ -5,4 +5,4 @@
#
. ./config.sh
[ -e Sources/${Mod}/${Module}.swift ] || ./generate-wrapper.sh
exec swift build $CCFLAGS $LINKFLAGS "$@"
exec swift build --build-path "$BUILD_DIR" $CCFLAGS $LINKFLAGS "$@"

View File

@ -10,8 +10,14 @@ Mod=Gdk
Module=${Mod}-$VER
module=`echo "${Module}" | tr '[:upper:]' '[:lower:]'`
mod=`echo "${Mod}" | tr '[:upper:]' '[:lower:]'`
BUILD_DIR=`pwd`/.build
export PATH="${BUILD_DIR}/gir2swift/.build/release:${BUILD_DIR}/gir2swift/.build/debug:${PATH}:/usr/local/opt/ruby/bin:`echo /usr/local/lib/ruby/gems/*/bin | tr ' ' '\n' | tail -n1`:${PATH}:`echo /var/lib/gems/*/gems/jazzy-*/bin/ | tr ' ' '\n' | tail -n1`:/usr/local/bin"
if [ -z "$BUILD_DIR" ]; then
if `pwd -P | grep -q Dropbox` ; then
export BUILD_DIR="/tmp/.build-$Module"
else
export BUILD_DIR=`pwd`/.build
fi
fi
export PATH="${GIR2SWIFT_PATH}:${BUILD_DIR}/gir2swift/.build/release:${BUILD_DIR}/gir2swift/.build/debug:${PATH}:/usr/local/opt/ruby/bin:`echo /usr/local/lib/ruby/gems/*/bin | tr ' ' '\n' | tail -n1`:${PATH}:`echo /var/lib/gems/*/gems/jazzy-*/bin/ | tr ' ' '\n' | tail -n1`:/usr/local/bin"
export PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig:${PKG_CONFIG_PATH}
LINKFLAGS=`pkg-config --libs $module pangocairo pangoft2 pango gobject-$GLIB_VER gio-unix-$GLIB_VER glib-$GLIB_VER | tr ' ' '\n' | sed -e 's/^/-Xlinker /' -e 's/-Wl,//' | tr '\n' ' ' | sed -e 's/^/-Xlinker /' -e 's/-Wl,//g' -e 's/ -pthread/ -lpthread/g' -e 's/-Xcc[ ]*-Xlinker/-Xlinker/g' -e 's/-Xlinker[ ]*-Xcc/-Xcc/g' -e 's/-Xlinker[ ]*--export-dynamic//g' -e 's/-Xlinker[ ]*-Xlinker/-Xlinker/g' -e 's/-Xcc *$//' -e 's/-Xlinker *$//'`
CCFLAGS=`pkg-config --cflags $module pangocairo pangoft2 pango gobject-$GLIB_VER gio-unix-$GLIB_VER glib-$GLIB_VER | tr ' ' '\n' | sed 's/^/-Xcc /' | tr '\n' ' ' | sed -e 's/^/-Xlinker /' -e 's/-Wl,//g' -e 's/ -pthread/ -lpthread/g' -e 's/-Xcc[ ]*-Xlinker/-Xlinker/g' -e 's/-Xlinker[ ]*-Xcc/-Xcc/g' -e 's/-Xlinker[ ]*--export-dynamic//g' -e 's/-Xlinker[ ]*-Xlinker/-Xlinker/g' -e 's/-Xcc *$//' -e 's/-Xlinker *$//'`

View File

@ -8,9 +8,12 @@
if [ -z "$@" ]; then
JAZZY_ARGS="--theme fullwidth --author René Hexel --author_url https://www.ict.griffith.edu.au/~rhexel/ --github_url https://github.com/rhx/Swift$Mod --github-file-prefix https://github.com/rhx/Swift$Mod/tree/generated --root-url http://rhx.github.io/Swift$Mod/ --output docs"
fi
[ -e .build/build.db ] || ./build.sh
[ -e "$BUILD_DIR/build.db" ] || ./build.sh
rm -rf .docs.old
mv docs .docs.old 2>/dev/null
sourcekitten doc --spm-module $Mod -- $CCFLAGS $LINKFLAGS > .build/$Mod-doc.json
jazzy --sourcekitten-sourcefile .build/$Mod-doc.json --clean \
[ -e .build ] || ln -s "$BUILD_DIR" .build
sourcekitten doc --spm-module $Mod -- --build-path "$BUILD_DIR" \
$CCFLAGS $LINKFLAGS > "$BUILD_DIR/$Mod-doc.json"
jazzy --sourcekitten-sourcefile "$BUILD_DIR/$Mod-doc.json" --clean \
--module-version $JAZZY_VER --module $Mod $JAZZY_ARGS "$@"
rm -f .build 2>/dev/null

View File

@ -5,15 +5,16 @@
#
. ./config.sh
./package.sh update
if ! pushd .build/gir2swift >/dev/null 2>&1 ; then
mkdir -p .build
pushd .build >/dev/null
if [ ! -x "${GIR2SWIFT_PATH}/gir2swift" ] &&
! pushd "$BUILD_DIR/gir2swift" >/dev/null 2>&1 ; then
mkdir -p "$BUILD_DIR"
pushd "$BUILD_DIR" >/dev/null
git clone https://github.com/rhx/gir2swift.git
cd gir2swift && ./build.sh
fi
export PATH=`pwd`/.build/debug:${PATH}
popd >/dev/null
export PACKAGES=.build/checkouts
popd >/dev/null 2>&1
export PACKAGES="${BUILD_DIR}/checkouts"
[ -e $PACKAGES ] || export PACKAGES=Packages
if which parallel >/dev/null ; then
for gen in $PACKAGES/*/gir-to-swift.sh ; do \

View File

@ -4,4 +4,4 @@
# to pass compiler and linker flags.
#
. ./config.sh
exec swift package $CCFLAGS $LINKFLAGS "$@"
exec swift package --build-path "$BUILD_DIR" $CCFLAGS $LINKFLAGS "$@"

View File

@ -4,5 +4,5 @@
# that the swift wrapper code exists
#
. ./config.sh
[ -e Sources/${Module}.swift ] || ./generate-wrapper.sh
exec swift test $CCFLAGS $LINKFLAGS "$@"
[ -e Sources/${Mod}/${Module}.swift ] || ./generate-wrapper.sh
exec swift test --build-path "$BUILD_DIR" $CCFLAGS $LINKFLAGS "$@"