Merge pull request #170 from openscad/mingw_installer2

Mingw installer2
felipesanches-svg
Marius Kintel 2012-08-13 12:57:16 -07:00
commit 7ef48a28ff
9 changed files with 490 additions and 77 deletions

View File

@ -164,9 +164,23 @@ After that, follow the Compilation instructions below.
### Building for Windows
OpenSCAD for Windows is usually cross-compiled from Linux. If you wish to
attempt an MSVC build, please see this site:
attempt an MSVC build on Windows, please see this site:
http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Building_on_Windows
To cross-build, first make sure that you have development tools
installed to get GCC. Then after you've cloned this git repository, run
the script that sets up the environment variables.
source ./scripts/setenv-mingw-xbuild.sh
Then run the script to download & compile all the prerequisite libraries above:
./scripts/mingw-x-build-dependencies.sh
Then skip the compilation instructions below. Instead, build an installer:
OSTYPE=mingw-cross-env ./scripts/release-common.sh
### Compilation
First, run 'qmake' from Qt4 to generate a Makefile. On some systems you need to

View File

@ -1,32 +1,44 @@
OpenSCAD Release Checklist
--------------------------
o Update version
scripts/release-linux.sh
o Update VERSION environment variable
export VERSION=2012.08
It will be used by the commands below, as well as these files:
scripts/release-common.sh
scripts/publish-macosx.sh
FIXME: Windows
scripts/publish-mingw-x.sh
o Update RELEASE_NOTES
o Tag release
git tag "openscad-2011.12"
git tag "openscad-$VERSION"
o build source package
scripts/git-archive-all.py --prefix=openscad-2011.12/ openscad-2011.12.src.tar.gz
scripts/git-archive-all.py --prefix=openscad-$VERSION/ openscad-$VERSION.src.tar.gz
o build binaries
tar xzf openscad-2011.12.src.tar.gz
cd openscad-2011.12
tar xzf openscad-$VERSION.src.tar.gz
cd openscad-$VERSION
Mac OS X
(For Qt-4.7.3: Remove /Developers/Applications/Qt/plugins/qmltooling)
./scripts/publish-macosx.sh -> OpenSCAD-2011.12.dmg
Linux: FIXME 32 vs. 64 bit
./scripts/release-linux.sh
Windows: FIXME 32 vs. 64 bit
./scripts/publish-macosx.sh -> OpenSCAD-$VERSION.dmg
Linux:
32-bit: run on a 32-bit machine or VM
64-bit: run on a 64-bit machine or VM
./scripts/release-common.sh -> openscad-$VERSION.x86-ARCH.tar.gz
(where ARCH will be detected and set to 32 or 64)
Windows mingw cross-build: FIXME 32 vs. 64 bit
./scripts/publish-mingw-x.sh -> mingw32/Openscad-$VERSION.zip
-> mingw32/Openscad-$VERSION-Installer.exe
o FIXME: Run some tests
o Set back version to being date-tagged: release-linux.sh, publish-macosx.sh, FIXME: Windows
o Remove VERSION environment variable
export VERSION=
o git push --tags

View File

@ -11,21 +11,6 @@ CONFIG(mingw-cross-env) {
LIBS += mingw-cross-env/lib/libgmp.a
LIBS += mingw-cross-env/lib/libCGAL.a
QMAKE_CXXFLAGS += -fpermissive
# Use different location for the cross-compiled binaries + .o files
# This allows compiling unix build + mingw build in same tree
DESTDIR=.
Release:DESTDIR = release_mingw32
Debug:DESTDIR = debug_mingw32
OBJECTS_DIR = $$DESTDIR/objects
MOC_DIR = $$DESTDIR/moc
RCC_DIR = $$DESTDIR/rcc
UI_DIR = $$DESTDIR/ui
}

View File

@ -1,4 +1,4 @@
!include "FileAssociation.nsh"
!include "mingw-file-association.nsh"
Name "OpenSCAD"
OutFile "openscad_setup.exe"
InstallDir $PROGRAMFILES\OpenSCAD
@ -6,8 +6,8 @@ DirText "This will install OpenSCAD on your computer. Choose a directory"
Section "install"
SetOutPath $INSTDIR
File openscad.exe
File /r examples
File /r libraries
File /r /x mingw-cross-env examples
File /r /x mingw-cross-env libraries
${registerExtension} "$INSTDIR\openscad.exe" ".scad" "OpenSCAD_File"
CreateShortCut $SMPROGRAMS\OpenSCAD.lnk $INSTDIR\openscad.exe
WriteUninstaller $INSTDIR\Uninstall.exe

View File

@ -0,0 +1,225 @@
/*
nsis.sourceforge.net COPYRIGHT
Copyright (C) 1995-2009 Contributors
Note the 'edit' page of the wiki at nsis.sourceforge.net specifically
states the following:
"All contributions sent to this wiki are generally considered to be in
the zlib/libpng license (see License for details)."
The NSIS 'license' link on the wiki states the following:
"All NSIS source code, plug-ins, documentation, examples, header files
and graphics, with the exception of the compression modules and where
otherwise noted, are licensed under the zlib/libpng license."
http://nsis.sourceforge.net/File_Assocation lists these authors:
Author: Vytautas (talk, contrib)
Author: intersol (talk, contrib)
Author: chefkoch (talk, contrib)
ZLIB/LIBPNG LICENSE
-------------------
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/*
_____________________________________________________________________________
File Association
_____________________________________________________________________________
Based on code taken from http://nsis.sourceforge.net/File_Association
Usage in script:
1. !include "FileAssociation.nsh"
2. [Section|Function]
${FileAssociationFunction} "Param1" "Param2" "..." $var
[SectionEnd|FunctionEnd]
FileAssociationFunction=[RegisterExtension|UnRegisterExtension]
_____________________________________________________________________________
${RegisterExtension} "[executable]" "[extension]" "[description]"
"[executable]" ; executable which opens the file format
;
"[extension]" ; extension, which represents the file format to open
;
"[description]" ; description for the extension. This will be display in Windows Explorer.
;
${UnRegisterExtension} "[extension]" "[description]"
"[extension]" ; extension, which represents the file format to open
;
"[description]" ; description for the extension. This will be display in Windows Explorer.
;
_____________________________________________________________________________
Macros
_____________________________________________________________________________
Change log window verbosity (default: 3=no script)
Example:
!include "FileAssociation.nsh"
!insertmacro RegisterExtension
${FileAssociation_VERBOSE} 4 # all verbosity
!insertmacro UnRegisterExtension
${FileAssociation_VERBOSE} 3 # no script
*/
!ifndef FileAssociation_INCLUDED
!define FileAssociation_INCLUDED
!include Util.nsh
!verbose push
!verbose 3
!ifndef _FileAssociation_VERBOSE
!define _FileAssociation_VERBOSE 3
!endif
!verbose ${_FileAssociation_VERBOSE}
!define FileAssociation_VERBOSE `!insertmacro FileAssociation_VERBOSE`
!verbose pop
!macro FileAssociation_VERBOSE _VERBOSE
!verbose push
!verbose 3
!undef _FileAssociation_VERBOSE
!define _FileAssociation_VERBOSE ${_VERBOSE}
!verbose pop
!macroend
!macro RegisterExtensionCall _EXECUTABLE _EXTENSION _DESCRIPTION
!verbose push
!verbose ${_FileAssociation_VERBOSE}
Push `${_DESCRIPTION}`
Push `${_EXTENSION}`
Push `${_EXECUTABLE}`
${CallArtificialFunction} RegisterExtension_
!verbose pop
!macroend
!macro UnRegisterExtensionCall _EXTENSION _DESCRIPTION
!verbose push
!verbose ${_FileAssociation_VERBOSE}
Push `${_EXTENSION}`
Push `${_DESCRIPTION}`
${CallArtificialFunction} UnRegisterExtension_
!verbose pop
!macroend
!define RegisterExtension `!insertmacro RegisterExtensionCall`
!define un.RegisterExtension `!insertmacro RegisterExtensionCall`
!macro RegisterExtension
!macroend
!macro un.RegisterExtension
!macroend
!macro RegisterExtension_
!verbose push
!verbose ${_FileAssociation_VERBOSE}
Exch $R2 ;exe
Exch
Exch $R1 ;ext
Exch
Exch 2
Exch $R0 ;desc
Exch 2
Push $0
Push $1
ReadRegStr $1 HKCR $R1 "" ; read current file association
StrCmp "$1" "" NoBackup ; is it empty
StrCmp "$1" "$R0" NoBackup ; is it our own
WriteRegStr HKCR $R1 "backup_val" "$1" ; backup current value
NoBackup:
WriteRegStr HKCR $R1 "" "$R0" ; set our file association
ReadRegStr $0 HKCR $R0 ""
StrCmp $0 "" 0 Skip
WriteRegStr HKCR "$R0" "" "$R0"
WriteRegStr HKCR "$R0\shell" "" "open"
WriteRegStr HKCR "$R0\DefaultIcon" "" "$R2,0"
Skip:
WriteRegStr HKCR "$R0\shell\open\command" "" '"$R2" "%1"'
WriteRegStr HKCR "$R0\shell\edit" "" "Edit $R0"
WriteRegStr HKCR "$R0\shell\edit\command" "" '"$R2" "%1"'
Pop $1
Pop $0
Pop $R2
Pop $R1
Pop $R0
!verbose pop
!macroend
!define UnRegisterExtension `!insertmacro UnRegisterExtensionCall`
!define un.UnRegisterExtension `!insertmacro UnRegisterExtensionCall`
!macro UnRegisterExtension
!macroend
!macro un.UnRegisterExtension
!macroend
!macro UnRegisterExtension_
!verbose push
!verbose ${_FileAssociation_VERBOSE}
Exch $R1 ;desc
Exch
Exch $R0 ;ext
Exch
Push $0
Push $1
ReadRegStr $1 HKCR $R0 ""
StrCmp $1 $R1 0 NoOwn ; only do this if we own it
ReadRegStr $1 HKCR $R0 "backup_val"
StrCmp $1 "" 0 Restore ; if backup="" then delete the whole key
DeleteRegKey HKCR $R0
Goto NoOwn
Restore:
WriteRegStr HKCR $R0 "" $1
DeleteRegValue HKCR $R0 "backup_val"
DeleteRegKey HKCR $R1 ;Delete key with association name settings
NoOwn:
Pop $1
Pop $0
Pop $R1
Pop $R0
!verbose pop
!macroend
!endif # !FileAssociation_INCLUDED

View File

@ -19,15 +19,8 @@ if [ ! -f $OPENSCADDIR/openscad.pro ]; then
echo "Must be run from the OpenSCAD source root directory"
exit 0
fi
BASEDIR=$HOME/openscad_deps
MXEDIR=$BASEDIR/mxe
PATH=$MXEDIR/usr/bin:$PATH
mkdir -p $BASEDIR
echo MXEDIR: $MXEDIR
echo BASEDIR: $BASEDIR
echo OPENSCADDIR: $OPENSCADDIR
echo PATH modified with $MXEDIR/usr/bin
if [ ! $NUMCPU ]; then
echo "note: you can 'export NUMCPU=x' for multi-core compiles (x=number)";
NUMCPU=1
@ -40,35 +33,27 @@ if [ ! $NUMJOBS ]; then
NUMJOBS=1
fi
fi
echo NUMCPU: $NUMCPU
echo NUMJOBS: $NUMJOBS
cd $BASEDIR
if [ ! -e mxe ]; then
. ./scripts/setenv-mingw-xbuild.sh
if [ ! -e $BASEDIR ]; then
mkdir -p $BASEDIR
fi
if [ ! -e $MXEDIR ]; then
echo "Downloading MXE into " $MXEDIR
cd $MXEDIR/..
git clone git://github.com/mxe/mxe.git
fi
echo "entering" $MXEDIR
cd $MXEDIR
echo "make mpfr eigen opencsg cgal qt -j $NUMCPU JOBS=$NUMJOBS"
make mpfr eigen opencsg cgal qt -j $NUMCPU JOBS=$NUMJOBS
#make mpfr -j$NUMCPU JOBS=$NUMJOBS # for testing
make mpfr eigen opencsg cgal qt nsis -j $NUMCPU JOBS=$NUMJOBS
#make mpfr -j $NUMCPU JOBS=$NUMJOBS # for testing
echo "leaving" $MXEDIR
echo "entering $OPENSCADDIR"
cd $OPENSCADDIR
if [ -e mingw-cross-env ]; then
rm ./mingw-cross-env
fi
echo "linking mingw-cross-env directory"
ln -s $MXEDIR/usr/i686-pc-mingw32/ ./mingw-cross-env
echo
echo "now copy/paste the following to cross-build openscad"
echo
echo "export PATH=$MXEDIR/usr/bin:\$PATH"
echo "i686-pc-mingw32-qmake CONFIG+=mingw-cross-env openscad.pro"
#echo "make -j$NUMCPU" # causes parser_yacc.hpp errors
echo "make"
echo

53
scripts/publish-mingw-x.sh Executable file
View File

@ -0,0 +1,53 @@
#!/bin/sh
# This is run as part of the checklist in docs/release-checklist.txt
#
# Set this if we're doing a release build. Comment it out for development builds
#VERSION=2011.12
if test -z "$VERSION"; then
VERSION=`date "+%Y.%m.%d"`
COMMIT=-c
fi
# Turn off ccache, just for safety
CCACHE_DISABLE=1
. ./scripts/setenv-mingw-xbuild.sh
if [ ! -e $MXEDIR ]; then
echo "MXEDIR: $MXEDIR"
echo "MXEDIR is a non-existent path. Mingw cross tools not found."
echo
echo " Please run ./scripts/mingw-x-build-dependencies.sh to install MXE"
echo " or modify MXEDIR to point to the root of your cross-tools setup"
echo " ( Please see http://mxe.cc for more info ) "
echo
exit 1
fi
if [ ! -f $OPENSCADDIR/openscad.pro ]; then
echo "Must be run from the OpenSCAD source root directory"
exit 1
fi
OSTYPE=mingw-cross-env ./scripts/release-common.sh -v $VERSION $COMMIT
if [ $? != 0 ]; then
echo "release-common.sh returned error code: $?. build stopped."
exit 1
fi
echo "Please upload these files to the appropriate location"
BINFILE=$DEPLOYDIR/OpenSCAD-$VERSION.zip
INSTALLFILE=$DEPLOYDIR/OpenSCAD-$VERSION-Installer.exe
echo $BINFILE
echo $INSTALLFILE
echo
echo "Then copy/paste these commands into your shell:"
echo
# Update snapshot filename on wab page
echo ./scripts/update-web.sh OpenSCAD-$VERSION.zip
echo ./scripts/update-web.sh OpenSCAD-$VERSION-Installer.exe

View File

@ -2,11 +2,11 @@
#
# This script creates a binary release of OpenSCAD.
# This should work under Mac OS X, Windows (msys), and Linux cross-compiling
# for windows using mingw-cross-env (use like: OS=LINXWIN release-common.sh).
# for windows using mingw-cross-env (use like: OSTYPE=mingw-cross-env release-common.sh).
# Linux support pending.
# The script will create a file called openscad-<versionstring>.zip
# in the current directory.
#
# in the current directory (or in the $DEPLOYDIR of a mingw cross build)
#
# Usage: release-common.sh [-v <versionstring>] [-c]
# -v Version string (e.g. -v 2010.01)
# -c Build with commit info
@ -24,6 +24,12 @@ printUsage()
echo " Example: $0 -v 2010.01
}
OPENSCADDIR=$PWD
if [ ! -f $OPENSCADDIR/openscad.pro ]; then
echo "Must be run from the OpenSCAD source root directory"
exit 1
fi
if [[ "$OSTYPE" =~ "darwin" ]]; then
OS=MACOSX
elif [[ $OSTYPE == "msys" ]]; then
@ -54,6 +60,37 @@ if test -z "$VERSION"; then
VERSION=`date "+%Y.%m.%d"`
fi
echo "Checking pre-requisites..."
case $OS in
LINXWIN)
MAKENSIS=
if [ "`command -v makensis`" ]; then
MAKENSIS=makensis
elif [ "`command -v i686-pc-mingw32-makensis`" ]; then
MAKENSIS=i686-pc-mingw32-makensis
else
echo "makensis not found. please install nsis"
exit 1
fi
echo NSIS makensis found: $MAKENSIS
;;
esac
if [ ! -e $OPENSCADDIR/libraries/MCAD/__init__.py ]; then
echo "Downloading MCAD"
git submodule init
git submodule update
else
echo "MCAD found:" $OPENSCADDIR/libraries/MCAD
fi
if [ -d .git ]; then
git submodule update
fi
echo "Building openscad-$VERSION $CONFIGURATION..."
case $OS in
@ -72,22 +109,34 @@ case $OS in
;;
LINXWIN)
unset CONFIG
. ./scripts/setenv-mingw-xbuild.sh
TARGET=release
ZIP="zip"
ZIPARGS="-r"
;;
esac
case $OS in
LINXWIN)
i686-pc-mingw32-qmake VERSION=$VERSION OPENSCAD_COMMIT=$OPENSCAD_COMMIT CONFIG+=$CONFIG CONFIG+=mingw-cross-env CONFIG-=debug openscad.pro
cd $DEPLOYDIR && i686-pc-mingw32-qmake VERSION=$VERSION OPENSCAD_COMMIT=$OPENSCAD_COMMIT CONFIG+=$CONFIG CONFIG+=mingw-cross-env CONFIG-=debug ../openscad.pro
cd $OPENSCADDIR
;;
*)
qmake VERSION=$VERSION OPENSCAD_COMMIT=$OPENSCAD_COMMIT CONFIG+=$CONFIG CONFIG-=debug openscad.pro
;;
esac
make -s clean
case $OS in
LINXWIN)
cd $DEPLOYDIR && make -s clean
cd $OPENSCADDIR
;;
*)
make -s clean
;;
esac
case $OS in
MACOSX)
rm -rf OpenSCAD.app
@ -98,7 +147,16 @@ case $OS in
;;
esac
make -j2 $TARGET
case $OS in
LINXWIN)
# make -jx sometimes has problems with parser_yacc
cd $DEPLOYDIR && make $TARGET
cd $OPENSCADDIR
;;
*)
make -j2 $TARGET
;;
esac
if [[ $? != 0 ]]; then
echo "Error building OpenSCAD. Aborting."
@ -112,6 +170,12 @@ case $OS in
EXAMPLESDIR=OpenSCAD.app/Contents/Resources/examples
LIBRARYDIR=OpenSCAD.app/Contents/Resources/libraries
;;
LINXWIN)
EXAMPLESDIR=$DEPLOYDIR/openscad-$VERSION/examples/
LIBRARYDIR=$DEPLOYDIR/openscad-$VERSION/libraries/
rm -rf $DEPLOYDIR/openscad-$VERSION
mkdir $DEPLOYDIR/openscad-$VERSION
;;
*)
EXAMPLESDIR=openscad-$VERSION/examples/
LIBRARYDIR=openscad-$VERSION/libraries/
@ -120,10 +184,6 @@ case $OS in
;;
esac
if [ -d .git ]; then
git submodule update
fi
if [ -n $EXAMPLESDIR ]; then
echo $EXAMPLESDIR
mkdir -p $EXAMPLESDIR
@ -133,9 +193,14 @@ fi
if [ -n $LIBRARYDIR ]; then
echo $LIBRARYDIR
mkdir -p $LIBRARYDIR
cp -R libraries/* $LIBRARYDIR
# exclude the .git stuff from MCAD which is a git submodule.
# tar is a relatively portable way to do exclusion, without the
# risks of rm
rm -f libraries.tar
tar cf libraries.tar --exclude=.git* libraries
cd $LIBRARYDIR/.. && tar xf $OPENSCADDIR/libraries.tar && cd $OPENSCADDIR
rm -f libraries.tar
chmod -R u=rwx,go=r,+X $LIBRARYDIR/*
rm -rf `find $LIBRARYDIR -name ".git"`
fi
echo "Creating archive.."
@ -158,15 +223,42 @@ case $OS in
;;
LINXWIN)
#package
echo "Creating binary package"
cd $DEPLOYDIR
cp $TARGET/openscad.exe openscad-$VERSION
rm -f OpenSCAD-$VERSION.zip
"$ZIP" $ZIPARGS OpenSCAD-$VERSION.zip openscad-$VERSION
cp scripts/installer.nsi openscad-$VERSION/
cd openscad-$VERSION && makensis installer.nsi && cd ..
cp openscad-$VERSION/openscad_setup.exe OpenSCAD-$VERSION-Installer.exe
rm -rf openscad-$VERSION
echo "Binary created: OpenSCAD-$VERSION.zip"
echo "Installer created: OpenSCAD-$VERSION-Installer.exe"
cd $OPENSCADDIR
echo "Binary package created"
echo "Creating installer"
echo "Copying NSIS files to $DEPLOYDIR/openscad-$VERSION"
cp ./scripts/installer.nsi $DEPLOYDIR/openscad-$VERSION
cp ./scripts/mingw-file-association.nsh $DEPLOYDIR/openscad-$VERSION
cd $DEPLOYDIR/openscad-$VERSION
NSISDEBUG=-V2
# NSISDEBUG= # leave blank for full log
echo $MAKENSIS $NSISDEBUG installer.nsi
$MAKENSIS $NSISDEBUG installer.nsi
cp $DEPLOYDIR/openscad-$VERSION/openscad_setup.exe $DEPLOYDIR/OpenSCAD-$VERSION-Installer.exe
cd $OPENSCADDIR
BINFILE=$DEPLOYDIR/OpenSCAD-$VERSION.zip
INSTFILE=$DEPLOYDIR/OpenSCAD-$VERSION-Installer.exe
if [ -e $BINFILE ]; then
if [ -e $INSTFILE ]; then
echo
echo "Binary created:" $BINFILE
echo "Installer created:" $INSTFILE
echo
else
echo "Build failed. Cannot find" $INSTFILE
exit 1
fi
else
echo "Build failed. Cannot find" $BINFILE
exit 1
fi
;;
LINUX)
# Do stuff from release-linux.sh
@ -186,6 +278,10 @@ case $OS in
strip openscad-$VERSION/lib/openscad/*
cp scripts/installer-linux.sh openscad-$VERSION/install.sh
chmod 755 -R openscad-$VERSION/
tar cz openscad-$VERSION > openscad-$VERSION.x86-$ARCH.tar.gz
PACKAGEFILE=openscad-$VERSION.x86-$ARCH.tar.gz
tar cz openscad-$VERSION > $PACKAGEFILE
echo
echo "Binary created:" $PACKAGEFILE
echo
;;
esac

View File

@ -0,0 +1,43 @@
#!/bin/sh -e
#
# set environment variables for mingw/mxe cross-build
#
# Usage: source ./scripts/setenv-mingw-xbuild.sh
#
# Prerequisites:
#
# Please see http://mxe.cc/#requirements
#
# Also see http://en.wikibooks.org/wiki/OpenSCAD_User_Manual/Cross-compiling_for_Windows_on_Linux_or_Mac_OS_X
#
export OPENSCADDIR=$PWD
if [ ! $BASEDIR ]; then
export BASEDIR=$HOME/openscad_deps
fi
if [ ! $DEPLOYDIR ]; then
export DEPLOYDIR=$OPENSCADDIR/mingw32
fi
if [ ! $MXEDIR ]; then
export MXEDIR=$BASEDIR/mxe
fi
export PATH=$MXEDIR/usr/bin:$PATH
echo BASEDIR: $BASEDIR
echo MXEDIR: $MXEDIR
echo DEPLOYDIR: $DEPLOYDIR
echo PATH modified with $MXEDIR/usr/bin
if [ ! -e $DEPLOYDIR ]; then
mkdir -p $DEPLOYDIR
fi
echo linking $MXEDIR/usr/i686-pc-mingw32/ to $DEPLOYDIR/mingw-cross-env
rm -f $DEPLOYDIR/mingw-cross-env
ln -s $MXEDIR/usr/i686-pc-mingw32/ $DEPLOYDIR/mingw-cross-env