2017-08-06 22:19:31 +02:00
|
|
|
#!/bin/sh -e
|
|
|
|
|
|
2017-08-06 22:56:38 +02:00
|
|
|
# Specify the Python interpreter to use.
|
|
|
|
|
# This is the command executed for the Python interpreter that is going
|
|
|
|
|
# to be included in KLayout.
|
|
|
|
|
|
2019-11-09 19:39:20 +01:00
|
|
|
python="python3"
|
2017-08-06 22:56:38 +02:00
|
|
|
|
|
|
|
|
# Specify the Ruby interpreter to use.
|
|
|
|
|
# This is the command executed for the Ruby interpreter that is going
|
|
|
|
|
# to be included in KLayout.
|
|
|
|
|
|
|
|
|
|
ruby="ruby"
|
|
|
|
|
|
|
|
|
|
# Specify the path to the NSIS compiler
|
|
|
|
|
|
|
|
|
|
makensis=/c/Program\ Files\ \(x86\)/NSIS/makensis.exe
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------
|
|
|
|
|
# General initialization
|
|
|
|
|
|
|
|
|
|
if ! [ -e ./build.sh ]; then
|
|
|
|
|
echo "ERROR: build script not found (not in the main directory?)"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
pwd=$(pwd)
|
|
|
|
|
|
2017-10-19 23:09:30 +02:00
|
|
|
enable32bit=1
|
|
|
|
|
enable64bit=1
|
2019-11-12 21:51:49 +01:00
|
|
|
args=""
|
|
|
|
|
suffix=""
|
2024-04-07 21:13:06 +02:00
|
|
|
qt="qt5"
|
2017-10-19 23:09:30 +02:00
|
|
|
|
2019-11-12 21:51:49 +01:00
|
|
|
while [ "$1" != "" ]; do
|
|
|
|
|
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
|
|
|
|
echo "Runs the Windows build include installer generation."
|
|
|
|
|
echo ""
|
|
|
|
|
echo "Run this script from the root directory."
|
|
|
|
|
echo ""
|
|
|
|
|
echo "Usage:"
|
|
|
|
|
echo " scripts/deploy-win-mingw.sh <options>"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "Options:"
|
|
|
|
|
echo " -32 Run 32 bit build only"
|
|
|
|
|
echo " -64 Run 64 bit build only"
|
2024-04-07 21:13:06 +02:00
|
|
|
echo " -qt5 Builds on qt5 (default)"
|
|
|
|
|
echo " -qt6 Builds on qt6"
|
2019-11-12 21:51:49 +01:00
|
|
|
echo " -s <suffix> Binary suffix"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "By default, both 32 and 64 bit builds are performed"
|
|
|
|
|
exit 0
|
|
|
|
|
elif [ "$1" = "-32" ]; then
|
|
|
|
|
enable64bit=0
|
|
|
|
|
enable32bit=1
|
|
|
|
|
elif [ "$1" = "-64" ]; then
|
|
|
|
|
enable64bit=1
|
|
|
|
|
enable32bit=0
|
2024-04-07 21:13:06 +02:00
|
|
|
elif [ "$1" = "-qt5" ]; then
|
|
|
|
|
qt="qt5"
|
|
|
|
|
elif [ "$1" = "-qt6" ]; then
|
|
|
|
|
qt="qt6"
|
|
|
|
|
args="$qrgs -qmake qmake-qt6"
|
2019-11-12 21:51:49 +01:00
|
|
|
elif [ "$1" = "-s" ]; then
|
|
|
|
|
shift
|
|
|
|
|
suffix="-$1"
|
|
|
|
|
else
|
|
|
|
|
args="$args $1"
|
|
|
|
|
fi
|
|
|
|
|
shift
|
|
|
|
|
done
|
2017-10-19 23:09:30 +02:00
|
|
|
|
2017-08-06 22:56:38 +02:00
|
|
|
# ---------------------------------------------------
|
|
|
|
|
# Bootstrap script
|
|
|
|
|
# This branch will fork to the actual builds for win32 and win64
|
|
|
|
|
|
|
|
|
|
if [ "$KLAYOUT_BUILD_IN_PROGRESS" == "" ]; then
|
|
|
|
|
|
|
|
|
|
self=$(which $0)
|
|
|
|
|
|
|
|
|
|
export KLAYOUT_BUILD_IN_PROGRESS=1
|
2019-11-12 21:51:49 +01:00
|
|
|
export KLAYOUT_BUILD_ARGS="$args"
|
|
|
|
|
export KLAYOUT_BUILD_SUFFIX="$suffix"
|
2017-08-06 22:56:38 +02:00
|
|
|
|
|
|
|
|
# Run ourself in MINGW32 system for the win32 build
|
2017-10-19 23:09:30 +02:00
|
|
|
if [ "$enable32bit" != "0" ]; then
|
|
|
|
|
MSYSTEM=MINGW32 bash --login -c "cd $pwd ; $self"
|
|
|
|
|
fi
|
2017-08-06 22:56:38 +02:00
|
|
|
|
|
|
|
|
# Run ourself in MINGW64 system for the win64 build
|
2017-10-19 23:09:30 +02:00
|
|
|
if [ "$enable64bit" != "0" ]; then
|
|
|
|
|
MSYSTEM=MINGW64 bash --login -c "cd $pwd ; $self"
|
|
|
|
|
fi
|
2017-08-06 22:56:38 +02:00
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------
|
|
|
|
|
# Actual build branch
|
|
|
|
|
|
2017-08-06 22:19:31 +02:00
|
|
|
if [ "$MSYSTEM" == "MINGW32" ]; then
|
|
|
|
|
arch=win32
|
|
|
|
|
mingw_inst=/mingw32
|
|
|
|
|
elif [ "$MSYSTEM" == "MINGW64" ]; then
|
|
|
|
|
arch=win64
|
|
|
|
|
mingw_inst=/mingw64
|
|
|
|
|
else
|
|
|
|
|
echo "ERROR: not in mingw32 or mingw64 system."
|
|
|
|
|
fi
|
|
|
|
|
|
2024-01-04 21:32:27 +01:00
|
|
|
target=$pwd/bin-release-$arch$KLAYOUT_BUILD_SUFFIX
|
|
|
|
|
build=$pwd/build-release-$arch$KLAYOUT_BUILD_SUFFIX
|
2017-08-06 22:19:31 +02:00
|
|
|
src=$pwd/src
|
|
|
|
|
scripts=$pwd/scripts
|
2017-08-10 23:31:32 +02:00
|
|
|
# Update in NSIS script too:
|
2019-12-15 16:26:33 +01:00
|
|
|
plugins="audio generic iconengines imageformats platforms printsupport sqldrivers styles"
|
2017-08-06 22:19:31 +02:00
|
|
|
|
2017-08-27 21:49:49 +02:00
|
|
|
# read the current version
|
|
|
|
|
. ./version.sh
|
|
|
|
|
|
2017-08-06 22:56:38 +02:00
|
|
|
echo "------------------------------------------------------------------"
|
|
|
|
|
echo "Running build for architecture $arch .."
|
|
|
|
|
echo ""
|
2019-11-12 21:51:49 +01:00
|
|
|
echo " target = $target"
|
|
|
|
|
echo " build = $build"
|
|
|
|
|
echo " version = $KLAYOUT_VERSION"
|
|
|
|
|
echo " build args = $KLAYOUT_BUILD_ARGS"
|
|
|
|
|
echo " suffix = $KLAYOUT_BUILD_SUFFIX"
|
2017-08-06 22:56:38 +02:00
|
|
|
echo ""
|
2017-08-06 22:19:31 +02:00
|
|
|
|
|
|
|
|
rm -rf $target
|
2019-11-12 21:51:49 +01:00
|
|
|
./build.sh -python $python -ruby $ruby -bin $target -build $build -j2$KLAYOUT_BUILD_ARGS
|
2017-08-06 22:19:31 +02:00
|
|
|
|
|
|
|
|
if ! [ -e $target ]; then
|
|
|
|
|
echo "ERROR: Target directory $target not found"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if ! [ -e $target/klayout.exe ]; then
|
|
|
|
|
echo "ERROR: Target directory $target does not contain klayout.exe"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2023-12-07 19:57:14 +01:00
|
|
|
# ----------------------------------------------------------
|
|
|
|
|
# cert.pem
|
|
|
|
|
|
|
|
|
|
echo "Installing cert.pem .."
|
|
|
|
|
|
|
|
|
|
cp $mingw_inst/etc/ssl/cert.pem $target
|
|
|
|
|
|
2017-08-06 22:19:31 +02:00
|
|
|
# ----------------------------------------------------------
|
2017-08-10 23:31:32 +02:00
|
|
|
# Plugins
|
2017-08-06 22:19:31 +02:00
|
|
|
|
2017-08-10 23:45:54 +02:00
|
|
|
echo "Installing plugins .."
|
2017-08-10 23:31:32 +02:00
|
|
|
for p in $plugins; do
|
2024-04-07 21:13:06 +02:00
|
|
|
cp -R $mingw_inst/share/${qt}/plugins/$p $target
|
2017-08-10 23:31:32 +02:00
|
|
|
# remove the debug versions - otherwise they pull in the debug Qt libs
|
2021-07-06 23:46:04 +02:00
|
|
|
shopt -s nullglob
|
|
|
|
|
rm -f $target/$p/*d.dll $target/$p/*.dll.debug
|
|
|
|
|
shopt -u nullglob
|
2017-08-10 23:31:32 +02:00
|
|
|
done
|
2017-08-06 22:19:31 +02:00
|
|
|
|
|
|
|
|
# ----------------------------------------------------------
|
|
|
|
|
# Ruby dependencies
|
|
|
|
|
|
2019-12-01 23:55:53 +01:00
|
|
|
rubys=$($ruby -e 'puts $:' | sort)
|
|
|
|
|
|
2017-08-06 22:19:31 +02:00
|
|
|
rm -rf $target/.ruby-paths.txt
|
2017-08-28 22:27:30 +02:00
|
|
|
echo '# Builds the Ruby paths.' >$target/.ruby-paths.txt
|
|
|
|
|
echo '# KLayout will load the paths listed in this file into $0' >>$target/.ruby-paths.txt
|
2017-08-06 22:19:31 +02:00
|
|
|
echo '# Use KLayout EXPRESSIONS syntax to specify a list of file paths.' >>$target/.ruby-paths.txt
|
|
|
|
|
echo '[' >>$target/.ruby-paths.txt
|
|
|
|
|
|
|
|
|
|
first=1
|
|
|
|
|
for p in $rubys; do
|
|
|
|
|
p=$(cygpath $p)
|
|
|
|
|
if [[ $p == "$mingw_inst"* ]] && [ -e "$p" ]; then
|
|
|
|
|
rp=${p/"$mingw_inst/"}
|
2019-12-01 23:55:53 +01:00
|
|
|
# Apparently adding the paths to the interpreter isn't required -
|
|
|
|
|
# Ruby can figure out it's own paths
|
|
|
|
|
# if [ $first == "0" ]; then
|
|
|
|
|
# echo "," >>$target/.ruby-paths.txt
|
|
|
|
|
# fi
|
|
|
|
|
# first=0
|
|
|
|
|
# echo -n " combine(inst_path, '$rp')" >>$target/.ruby-paths.txt
|
2017-08-06 22:19:31 +02:00
|
|
|
echo "Copying Ruby installation partial $p -> $target/$rp .."
|
|
|
|
|
rm -rf $target/$rp
|
|
|
|
|
mkdir -p $target/$rp
|
|
|
|
|
rmdir $target/$rp
|
|
|
|
|
cp -vR $p $target/$rp | sed -u 's/.*/echo -n ./' | sh
|
|
|
|
|
echo ""
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo '' >>$target/.ruby-paths.txt
|
|
|
|
|
echo ']' >>$target/.ruby-paths.txt
|
|
|
|
|
|
2019-12-01 23:55:53 +01:00
|
|
|
# don't forget the gem directory (specifications and gems)
|
|
|
|
|
p=$(ruby -e 'puts Gem::dir')
|
|
|
|
|
p=$(cygpath $p)
|
|
|
|
|
if [[ $p == "$mingw_inst"* ]] && [ -e "$p" ]; then
|
|
|
|
|
rp=${p/"$mingw_inst/"}
|
|
|
|
|
echo "Copying Ruby gems $p -> $target/$rp .."
|
|
|
|
|
rm -rf $target/$rp
|
|
|
|
|
mkdir -p $target/$rp
|
|
|
|
|
rmdir $target/$rp
|
|
|
|
|
cp -vR $p $target/$rp | sed -u 's/.*/echo -n ./' | sh
|
|
|
|
|
echo ""
|
|
|
|
|
fi
|
|
|
|
|
|
2017-08-06 22:19:31 +02:00
|
|
|
# ----------------------------------------------------------
|
|
|
|
|
# Python dependencies
|
|
|
|
|
|
2019-12-01 23:55:53 +01:00
|
|
|
pythons=$($python -c "import sys; print('\n'.join(sys.path))" | sort)
|
|
|
|
|
|
2017-08-06 22:19:31 +02:00
|
|
|
rm -rf $target/.python-paths.txt
|
|
|
|
|
echo '# Builds the Python paths.' >$target/.python-paths.txt
|
|
|
|
|
echo '# KLayout will load the paths listed in this file into sys.path' >>$target/.python-paths.txt
|
|
|
|
|
echo '# unless $KLAYOUT_PYTHONHOME ist set.' >>$target/.python-paths.txt
|
|
|
|
|
echo '# Use KLayout EXPRESSIONS syntax to specify a list of file paths.' >>$target/.python-paths.txt
|
|
|
|
|
echo '[' >>$target/.python-paths.txt
|
|
|
|
|
|
|
|
|
|
first=1
|
|
|
|
|
for p in $pythons; do
|
|
|
|
|
p=$(cygpath $p)
|
2019-11-14 00:47:12 +01:00
|
|
|
rp=""
|
2017-08-06 22:19:31 +02:00
|
|
|
if [[ $p == "$mingw_inst"* ]] && [ -e "$p" ]; then
|
|
|
|
|
rp=${p/"$mingw_inst/"}
|
2019-11-14 00:47:12 +01:00
|
|
|
fi
|
|
|
|
|
# NOTE: "bin" is in the path sometimes and will pollute our installation, so we skip it
|
|
|
|
|
if [ "$rp" != "" ] && [ "$rp" != "bin" ]; then
|
2017-08-06 22:19:31 +02:00
|
|
|
if [ $first == "0" ]; then
|
|
|
|
|
echo "," >>$target/.python-paths.txt
|
|
|
|
|
fi
|
|
|
|
|
first=0
|
|
|
|
|
echo -n " combine(inst_path, '$rp')" >>$target/.python-paths.txt
|
|
|
|
|
echo "Copying Python installation partial $p -> $target/$rp .."
|
|
|
|
|
rm -rf $target/$rp
|
|
|
|
|
mkdir -p $target/$rp
|
|
|
|
|
rmdir $target/$rp
|
|
|
|
|
cp -vR $p $target/$rp | sed -u 's/.*/echo -n ./' | sh
|
|
|
|
|
echo ""
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo '' >>$target/.python-paths.txt
|
|
|
|
|
echo ']' >>$target/.python-paths.txt
|
|
|
|
|
|
2017-08-07 01:57:07 +02:00
|
|
|
# ----------------------------------------------------------
|
|
|
|
|
# Binary dependencies
|
|
|
|
|
|
2019-11-13 21:11:40 +01:00
|
|
|
pushd $target
|
|
|
|
|
|
2023-12-02 01:23:06 +01:00
|
|
|
new_libs=$(find . -name "*.dll" -or -name "*.pyd" -or -name "*.so")
|
2017-08-08 00:39:51 +02:00
|
|
|
|
|
|
|
|
while [ "$new_libs" != "" ]; do
|
|
|
|
|
|
|
|
|
|
echo "Analyzing dependencies of $new_libs .."
|
|
|
|
|
|
|
|
|
|
# Analyze the dependencies of our components and add the corresponding libraries from $mingw_inst/bin
|
|
|
|
|
libs=$(objdump -p $new_libs | grep "DLL Name:" | sort -u | sed 's/.*DLL Name: *//')
|
|
|
|
|
new_libs=""
|
|
|
|
|
|
|
|
|
|
for l in $libs; do
|
2019-11-13 21:11:40 +01:00
|
|
|
if [ -e $mingw_inst/bin/$l ] && ! [ -e $l ]; then
|
2019-11-13 23:23:44 +01:00
|
|
|
echo "Copying binary installation partial $mingw_inst/bin/$l -> $l .."
|
2019-11-13 21:11:40 +01:00
|
|
|
cp $mingw_inst/bin/$l $l
|
|
|
|
|
new_libs="$new_libs $l"
|
2017-08-08 00:39:51 +02:00
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
2017-08-07 01:57:07 +02:00
|
|
|
done
|
|
|
|
|
|
2019-11-13 21:11:40 +01:00
|
|
|
popd
|
|
|
|
|
|
2017-08-06 22:19:31 +02:00
|
|
|
# ----------------------------------------------------------
|
|
|
|
|
# Run NSIS
|
|
|
|
|
|
|
|
|
|
# TODO: NSIS now supports /nocd with which we would no
|
|
|
|
|
# longer require the copy
|
|
|
|
|
cp $scripts/klayout-inst.nsis $target
|
|
|
|
|
cd $target
|
2019-11-12 21:51:49 +01:00
|
|
|
NSIS_VERSION=$KLAYOUT_VERSION NSIS_ARCH=$arch$KLAYOUT_BUILD_SUFFIX "$makensis" klayout-inst.nsis
|
2017-08-06 22:19:31 +02:00
|
|
|
|
2017-08-06 23:10:38 +02:00
|
|
|
# ----------------------------------------------------------
|
|
|
|
|
# Produce the .zip file
|
|
|
|
|
|
2019-11-12 21:51:49 +01:00
|
|
|
zipname="klayout-$KLAYOUT_VERSION-$arch$KLAYOUT_BUILD_SUFFIX"
|
2017-08-06 23:10:38 +02:00
|
|
|
|
|
|
|
|
echo "Making .zip file $zipname.zip .."
|
|
|
|
|
|
|
|
|
|
rm -rf $zipname $zipname.zip
|
|
|
|
|
mkdir $zipname
|
2024-01-06 17:28:51 +01:00
|
|
|
cp -Rv strm*.exe *.dll cert.pem .*-paths.txt db_plugins lay_plugins pymod $plugins lib $zipname | sed -u 's/.*/echo -n ./' | sh
|
2017-08-06 23:10:38 +02:00
|
|
|
cp klayout.exe $zipname/klayout_app.exe
|
|
|
|
|
cp klayout.exe $zipname/klayout_vo_app.exe
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
zip -r $zipname.zip $zipname
|
|
|
|
|
rm -rf $zipname
|
|
|
|
|
|