Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README and Installer from CMake build #49

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BuildWindowsRelease.sh
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ make -f Makefile.omdev.mingw omsimulator
# build the installer
cd /c/dev/${OM_ENCRYPT}OM${PLATFORM}/OMSetup
rm -rf OMLibraries.nsh
if ! makensis //MSYSRUNTIME="${MSYSRUNTIME}" //DPLATFORMVERSION="${PLATFORM::-3}" //DOMVERSION="${REVISION_SHORT}" //DPRODUCTVERSION=${PRODUCT_VERSION} OpenModelicaSetup.nsi > trace.txt 2>&1 ; then
if ! makensis //DMSYSRUNTIME="${MSYSRUNTIME}" //DPLATFORMVERSION="${PLATFORM::-3}" //DOMVERSION="${REVISION_SHORT}" //DPRODUCTVERSION=${PRODUCT_VERSION} //DOPENMODELICASOURCEDIR=/c/dev/${OM_ENCRYPT}OM${PLATFORM} //DOPENMODELICAHOME="${OPENMODELICAHOME}" OpenModelicaSetup.nsi > trace.txt 2>&1 ; then
cat trace.txt
exit 1
fi
Expand Down
58 changes: 35 additions & 23 deletions OpenModelicaSetup.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Unicode true

!ifndef MSYSRUNTIME
!error "Argument MSYSRUNTIME is not set. Call with argument /MSYSRUNTIME=mingw32|mingw64|ucrt64"
!error "Argument MSYSRUNTIME is not set. Call with argument /MSYSRUNTIME=mingw|ucrt"
!endif

!ifndef PLATFORMVERSION
Expand All @@ -19,6 +19,14 @@ Unicode true
!error "Argument PRODUCTVERSION is not set. Call with argument /DPRODUCTVERSION=OpenModelica version"
!endif

!ifndef OPENMODELICASOURCEDIR
!error "Argument OPENMODELICASOURCEDIR is not set. Call with argument /DOPENMODELICASOURCEDIR=c:\path\to\OpenModelica"
!endif

!ifndef OPENMODELICAHOME
!error "Argument OPENMODELICAHOME is not set. Call with argument /DOPENMODELICAHOME=c:\path\to\OpenModelica\build_cmake\install_cmake"
!endif

Name OpenModelica${OMVERSION}-${PLATFORMVERSION}bit

# General Symbol Definitions
Expand Down Expand Up @@ -118,10 +126,10 @@ Section "OpenModelica Core" Section1
SetOverwrite on
# Create bin directory and copy files in it
SetOutPath "\\?\$INSTDIR\bin"
File "..\build\bin\*"
File "..\OSMC-License.txt"
File "${OPENMODELICAHOME}\bin\*"
File "${OPENMODELICASOURCEDIR}\OSMC-License.txt"
# Copy the openssl binaries
!if ${PLATFORMVERSION} == "32"
!if PLATFORMVERSION == "32"
File "bin\32bit\libeay32.dll"
File "bin\32bit\libssl32.dll"
File "bin\32bit\ssleay32.dll"
Expand All @@ -137,33 +145,37 @@ Section "OpenModelica Core" Section1
File /r /x "*.svn" "$%OMDEV%\tools\msys\${MSYSRUNTIME}${PLATFORMVERSION}\bin\osgPlugins-3.6.5\*"
# Create bin\ffi directory and copy files in it
SetOutPath "\\?\$INSTDIR\bin\ffi"
File "..\build\bin\ffi\*"
!if /FILEEXISTS "..\build\bin\omc-semla\*.*"
File "${OPENMODELICAHOME}\bin\ffi\*"
!if /FILEEXISTS "${OPENMODELICAHOME}\bin\omc-semla\*.*"
# Create bin\omc-semla directory and copy files in it
SetOutPath "\\?\$INSTDIR\bin\omc-semla"
File /r "..\build\bin\omc-semla\*"
File /r "${OPENMODELICAHOME}\bin\omc-semla\*"
!endif
# Create icons directory and copy files in it
SetOutPath "\\?\$INSTDIR\icons"
File /r /x "*.svn" "icons\*"
File "..\OMEdit\OMEditLIB\Resources\icons\omedit.ico"
File "..\OMOptim\OMOptim\GUI\Resources\omoptim.ico"
File "..\OMPlot\OMPlot\OMPlotGUI\Resources\icons\omplot.ico"
File "..\OMShell\OMShell\OMShellGUI\Resources\omshell.ico"
File "..\OMNotebook\OMNotebook\OMNotebookGUI\Resources\OMNotebook_icon.ico"
File "${OPENMODELICASOURCEDIR}\OMEdit\OMEditLIB\Resources\icons\omedit.ico"
File "${OPENMODELICASOURCEDIR}\OMOptim\OMOptim\GUI\Resources\omoptim.ico"
File "${OPENMODELICASOURCEDIR}\OMPlot\OMPlot\OMPlotGUI\Resources\icons\omplot.ico"
File "${OPENMODELICASOURCEDIR}\OMShell\OMShell\OMShellGUI\Resources\omshell.ico"
File "${OPENMODELICASOURCEDIR}\OMNotebook\OMNotebook\OMNotebookGUI\Resources\OMNotebook_icon.ico"
# Create include\omc directory and copy files in it
SetOutPath "\\?\$INSTDIR\include\omc"
File /r /x "*.svn" "..\build\include\omc\*"
File /r /x "*.svn" "${OPENMODELICAHOME}\include\omc\*"
# Create lib\omc directory and copy files in it
SetOutPath "\\?\$INSTDIR\lib\omc"
File /r /x "*.svn" /x "*.git" "..\build\lib\omc\*"
File /r /x "*.svn" /x "*.git" "${OPENMODELICAHOME}\lib\omc\*"
!if /FILEEXISTS "${OPENMODELICAHOME}\lib\python\*"
# Create lib\python directory and copy files in it
SetOutPath "\\?\$INSTDIR\lib\python"
File /r /x "*.svn" /x "*.git" "..\build\lib\python\*"
File /r /x "*.svn" /x "*.git" "${OPENMODELICAHOME}\lib\python\*"
!endif
# Create tools directory and copy files in it
SetOutPath "\\?\$INSTDIR\tools"
# copy the setup file / readme
!if /FILEEXISTS "$%OMDEV%\tools\MSYS_SETUP.bat"
File "$%OMDEV%\tools\MSYS_SETUP*"
!endif
# Create msys directory and copy files in it
SetOutPath "\\?\$INSTDIR\tools\msys"
!if ${PLATFORMVERSION} == "32"
Expand All @@ -185,8 +197,8 @@ Section "OpenModelica Core" Section1
/x "osgVolume" /x "osgWidget" /x "clang-cl.exe" /x "clang-check.exe" /x "llvm-lto2.exe" /x "doc" \
"$%OMDEV%\tools\msys\*"
!else #64 bit
!if ${MSYSTEM} == "ucrt"
File /r /x "mingw32" /x "mingw64" /x "clang64" /x "clang32" /x "group" /x "passwd" /x "pacman.log" /x "tmp\*.*" /x "*.pyc" /x "libQt5*.*" \
!if ${MSYSRUNTIME} == "ucrt"
File /r /x "mingw32" /x "mingw64" /x "mingw*.*" /x "clang64" /x "clang32" /x "clang*.*" /x "group" /x "passwd" /x "pacman.log" /x "tmp" /x "home" /x "*.pyc" /x "libQt5*.*" \
/x "moc.exe" /x "qt*.qch" /x "Qt5*.dll" /x "libwx*.*" /x "libgtk*.*" /x "qtcreator" /x "rcc.exe" \
/x "testcon.exe" /x "libsicu*.*" /x "libicu*.*" /x "wx*.dll" /x "libosg*.*" /x "Adwaita" /x "OpenSceneGraph" /x "gtk-doc" \
/x "poppler" /x "man" /x "libdbus.*" /x "tcl*.*" /x "avcodec*.*" /x "windeployqt.exe" /x "python3.5" /x "mingw_osg*.*" \
Expand All @@ -204,7 +216,7 @@ Section "OpenModelica Core" Section1
/x "osgVolume" /x "osgWidget" /x "clang-cl.exe" /x "clang-check.exe" /x "llvm-lto2.exe" /x "doc" \
"$%OMDEV%\tools\msys\*"
!else # mingw64
File /r /x "mingw32" /x "ucrt64" /x "clang64" /x "clang32" /x "group" /x "passwd" /x "pacman.log" /x "tmp\*.*" /x "*.pyc" /x "libQt5*.*" \
File /r /x "mingw32" /x "mingw32.*" /x "ucrt64" /x "ucrt64.*" /x "clang64" /x "clang32" /x "clang*.*" /x "group" /x "passwd" /x "pacman.log" /x "tmp" /x "home" /x "*.pyc" /x "libQt5*.*" \
/x "moc.exe" /x "qt*.qch" /x "Qt5*.dll" /x "libwx*.*" /x "libgtk*.*" /x "qtcreator" /x "rcc.exe" \
/x "testcon.exe" /x "libsicu*.*" /x "libicu*.*" /x "wx*.dll" /x "libosg*.*" /x "Adwaita" /x "OpenSceneGraph" /x "gtk-doc" \
/x "poppler" /x "man" /x "libdbus.*" /x "tcl*.*" /x "avcodec*.*" /x "windeployqt.exe" /x "python3.5" /x "mingw_osg*.*" \
Expand All @@ -225,14 +237,14 @@ Section "OpenModelica Core" Section1
!endif
# Create share directory and copy files in it
SetOutPath "\\?\$INSTDIR\share"
File /r /x "*.svn" /x "*.git" "..\build\share\*"
File /r /x "*.svn" /x "*.git" "${OPENMODELICAHOME}\share\*"
# Copy the OpenModelica web page & users guide url shortcut
SetOutPath "\\?\$INSTDIR\share\doc\omc"
File "..\doc\OpenModelica Project Online.url"
File "..\doc\OpenModelicaUsersGuide.url"
File "${OPENMODELICASOURCEDIR}\doc\OpenModelica Project Online.url"
File "${OPENMODELICASOURCEDIR}\doc\OpenModelicaUsersGuide.url"
# Copy OMSens directory
SetOutPath "\\?\$INSTDIR\share\OMSens"
File /r /x ".git*" "..\build\share\OMSens\*"
File /r /x ".git*" "${OPENMODELICAHOME}\share\OMSens\*"
SectionEnd

Section -Main SEC0000
Expand Down Expand Up @@ -282,7 +294,7 @@ Section -post SEC0001
Rename "$INSTDIR\tools\msys\mingw32\bin\libeay32.dll" "$INSTDIR\tools\msys\mingw32\bin\libeay32-O.dll"
Rename "$INSTDIR\tools\msys\mingw32\bin\ssleay32.dll" "$INSTDIR\tools\msys\mingw32\bin\ssleay32-O.dll"
!else # mingw64 or ucrt64
!if ${MSYSTEM} == "mingw"
!if ${MSYSRUNTIME} == "mingw"
Rename "$INSTDIR\tools\msys\mingw64\bin\libeay32.dll" "$INSTDIR\tools\msys\mingw64\bin\libeay32-O.dll"
Rename "$INSTDIR\tools\msys\mingw64\bin\ssleay32.dll" "$INSTDIR\tools\msys\mingw64\bin\ssleay32-O.dll"
!endif
Expand Down
84 changes: 83 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,89 @@ OpenModelica Windows installer based on [NSIS](https://nsis.sourceforge.io/Main_

## Dependencies

- [NSIS](https://nsis.sourceforge.io/Main_Page)
- [NSIS 3.0.4](https://nsis.sourceforge.io/Main_Page)
- Copy `AccessControlW.dll` into your NSIS plugin directory, e.g. into
`C:\Program Files (x86)\NSIS\Plugins\x86-unicode`.
- [git](https://git-scm.com/)
- [OMDev](https://gitlab.liu.se/OpenModelica/OMDevUCRT)
- (optional) [SignTool](https://learn.microsoft.com/en-us/windows/win32/seccrypto/signtool),
part of
[Microsoft Windows Software Development Kit](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/).

## Build Windows installer

### Environment variables

You'll need to export all tools to `PATH` environment variable in your MSYS2 UCRT64 shell
`%OMDEV%\tools\msys\ucrt64.exe`:

```bash
export PATH=$PATH:/c/Program\ Files/Git/bin
export PATH=$PATH:/c/Program\ Files\ \(x86\)/NSIS/Bin
```

Also make sure to set environment variables

- `OMDEV`, e.g. `c:\\OMDev`
- `OPENMODELICAHOME`, e.g. `d:\\path\\to\\OpenModelica\\build_cmake\\install_cmake`
- `OPENMODELICALIBRARY`, e.g. `d:\\path\\to\\OpenModelica\\build_cmake\\install_cmake\\lib\\omlibrary`

with Windows style paths using `\`.

Build:

- OpenModelica
- OpenModelica libraries
- OMPython
- OMSimulator
- OMSens

Download the the HTML and PDF versions of OpenModelica User's Guide:

```bash
cd ${OPENMODELICAHOME}/share/doc/omc
wget --no-check-certificate https://openmodelica.org/doc/openmodelica-doc-latest.tar.xz
tar -xJf openmodelica-doc-latest.tar.xz --strip-components=2
rm openmodelica-doc-latest.tar.xz
wget --no-check-certificate https://openmodelica.org/doc/OpenModelicaUsersGuide/OpenModelicaUsersGuide-latest.pdf
```

## Run NSIS

Start `%OMDEV%\tools\msys\ucrt64.exe` or `%OMDEV%\tools\msys\mingw64.exe` and run:

```bash
export PLATFORM="64" # 64 or 32 bit
export MSYSRUNTIME="ucrt" # ucrt or mingw
export OPENMODELICA_SOURCE_DIR="d:\\path\\to\\OpenModelica"
export REVISION_SHORT=`cd $OPENMODELICA_SOURCE_DIR; git describe --match "v*.*" --always --abbrev=0`
export PRODUCT_VERSION="${REVISION_SHORT:1}"
# make a valid VIProductVersion by stripping everything after "-"
BEGIN=${PRODUCT_VERSION/-*/}
PRODUCT_VERSION=${PRODUCT_VERSION::${#BEGIN}}
PRODUCT_VERSION=${PRODUCT_VERSION}.0

makensis //DMSYSRUNTIME="${MSYSRUNTIME}" \
//DPLATFORMVERSION="${PLATFORM}" \
//DOMVERSION="${REVISION_SHORT}" \
//DPRODUCTVERSION="${PRODUCT_VERSION}" \
//DOPENMODELICASOURCEDIR="${OPENMODELICA_SOURCE_DIR}" \
//DOPENMODELICAHOME="${OPENMODELICAHOME}" \
OpenModelicaSetup.nsi
```

> [!NOTE]
> `PRODUCT_VERSION` needs to be in `X.X.X.X` format.

## Optional: Sign the installer

To sign the installer you'll need a code-signing certificate (SPC).
See the [doc for more information](https://learn.microsoft.com/en-us/dotnet/framework/tools/signtool-exe).

```bash
export SIGNTOOL=`find /c/Program\ Files\ \(x86\)/Windows\ Kits/10/ -wholename "*${XPREFIX}/signtool.exe" | tail -1`
"${SIGNTOOL}" sign /n "Me" /f MySPC.pfx /tr "http://timestamp.globalsign.com/tsa/r6advanced1" /a /td SHA256 /v OpenModelica.exe
```

## Bug Reports

Expand Down