Skip to content

Commit

Permalink
Add build support for Linux (Ubuntu) (#1181)
Browse files Browse the repository at this point in the history
* Add ant build target for linux

* Add CMake rule for linux

* update opensim.conf for Linux; add logo and .desktop file

* Fix file permissions in tar

* Add version to opensim.conf

* Add Ubuntu builds to GitHub Action CI

* Add INSTALL script; set jdkhome properly

* Fix INSTALL script

* Add Linux build instructions to README

* Run GitHub Actions CI on PRs

* Fix typo in opensim-core download

* Fix netbeans/harness location for cmake; try caching netbeans installer

* Try again...

* Change back to ~ for opensim-core

* Change netbeans install to verbose (will still fail, help with debug)

* Revert to silent netbeans install, ls home contents to verify install/location

* (Hopefully) Final GH actions CI update

- Cache the entire netbeans install directory

* Improve INSTALL script; tweak build instructions on README

* Revert GitHub CI to only run on push

* Update README, CHANGELOG, and CONTRIBUTING

* De-duplicate private properties file creation

* Use more reasonable OS conditionals

* Change INSTALL language to reflect beta status

* Update description in .desktop

* Remove extraneous line
  • Loading branch information
halleysfifthinc authored Apr 21, 2020
1 parent d344713 commit f123696
Show file tree
Hide file tree
Showing 10 changed files with 364 additions and 15 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,64 @@ jobs:
with:
name: OpenSim-${{ steps.build-gui.outputs.version }}-mac
path: OpenSim-${{ steps.build-gui.outputs.version }}.pkg

ubuntu:
name: Ubuntu

runs-on: ubuntu-18.04

steps:
- name: Install opensim-core
run: |
wget https://prdownloads.sourceforge.net/myosin/opensim-core/opensim-core-latest_linux_Release.zip
# -q: quiet
unzip -q opensim-core-latest_linux_Release.zip -d ~
- name: Checkout opensim-gui
uses: actions/checkout@v1

- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Cache Netbeans
id: cache-netbeans
uses: actions/cache@v1
with:
path: ~/netbeans-8.2
key: netbeans-8.2


- name: Download and Install Netbeans
if: steps.cache-netbeans.outputs.cache-hit != 'true'
run: |
wget -q https://download.netbeans.org/netbeans/8.2/final/bundles/netbeans-8.2-javase-linux.sh
chmod 755 netbeans-8.2-javase-linux.sh
./netbeans-8.2-javase-linux.sh --silent
ls $HOME/netbeans-8.2
- name: Update submodules
run: git submodule update --init --recursive -- opensim-models opensim-visualizer Gui/opensim/threejs

- name: Build GUI
id: build-gui
run: |
mkdir build
cd build
cmake ../ -DCMAKE_PREFIX_PATH=~/opensim-core -DANT_ARGS="-Dnbplatform.default.netbeans.dest.dir=$HOME/netbeans-8.2;-Dnbplatform.default.harness.dir=$HOME/netbeans-8.2/harness"
make CopyOpenSimCore
make PrepareInstaller
# Read the value of the cache variable storing the GUI build version.
VERSION=`cmake -L . | grep OPENSIMGUI_BUILD_VERSION | cut -d "=" -f2`
echo $VERSION
echo "::set-env name=VERSION::$VERSION"
echo "::set-output name=version::$VERSION"
cd $GITHUB_WORKSPACE
ls Gui/opensim/dist
mv Gui/opensim/dist/OpenSim-$VERSION.tar.gz $GITHUB_WORKSPACE
- name: Upload GUI installer
uses: actions/upload-artifact@v1.0.0
with:
name: OpenSim-${{ steps.build-gui.outputs.version }}-linux
path: OpenSim-${{ steps.build-gui.outputs.version }}.tar.gz
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ request related to the change, then we may provide the commit.

v4.2
====
- Merge PR [#1181](https://github.com/opensim-org/opensim-gui/pull/1181): Add build support for Linux (beta)
- Fix issue [#1182](https://github.com/opensim-org/opensim-gui/issues/1182): Scaling model with custom geometry meshes loses custom geomerty

v4.1
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ List of contributors
- Darryl Thelen
- Carmichael Ong
- Sebastian Skejo
- Allen Hill

19 changes: 17 additions & 2 deletions Gui/opensim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ add_custom_target(CopyModels ALL
add_dependencies(CopyModels opensim-models)
endif()


if (APPLE)
if (NOT WIN32)
if (OpenSim_FOUND)
set(PLATFORM_PRIVATE_PROPERTIES_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/nbproject/private/platform-private.properties")
Expand All @@ -132,6 +131,9 @@ if (APPLE)
"run.args.extra=-J-Djava.library.path=${OpenSim_LIB_DIR}")
endif()
endif()
endif()

if (APPLE)
add_custom_target(PrepareInstaller ALL
COMMAND ${Ant_EXECUTABLE} build-mac-installer
-Dapi.dir="${OpenSim_ROOT_DIR}"
Expand All @@ -143,3 +145,16 @@ if (APPLE)
COMMENT "Build OpenSim.app.")
add_dependencies(PrepareInstaller opensim-models)
endif()

if (UNIX AND NOT APPLE)
add_custom_target(PrepareInstaller ALL
COMMAND ${Ant_EXECUTABLE} build-linux
-Dapi.dir="${OpenSim_ROOT_DIR}"
-Dmodels.dir="${MODELS_INSTALL_DIR}"
-Dapp.version="${OPENSIMGUI_BUILD_VERSION}"
${ANT_ARGS}
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/build.xml"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Merge GUI build and opensim-core install into one folder.")
add_dependencies(PrepareInstaller opensim-models)
endif()
94 changes: 87 additions & 7 deletions Gui/opensim/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<project name="opensim" basedir=".">
<description>Builds the module suite opensim.</description>
<property name="api.dir" value="C:/Dev/gui/opensim-gui/OpenSimAPI-install"/>
<property name="apiJava.dir" value="C:/Dev/gui/opensim-gui/OpenSimAPI-install/sdk/Java/org"/>
<property name="apiJava.dir" value="${api.dir}/sdk/Java/org"/>
<property name="models.dir" value="C:/Dev/gui/opensim-models"/>
<property name="visualizer.dir" value="/Users/aymanhabib/dev/src/unused"/>
<property name="jre.dir" value="${java.home}"/>
Expand All @@ -32,8 +32,16 @@
<condition property="opensim.dist.dir" value="dist/OpenSim.app/Contents/Resources/OpenSim">
<os family="mac"/>
</condition>
<condition property="opensim.dist.dir" value="dist/installer/OpenSim">
<and>
<os family="unix"/>
<not>
<os family="mac"/>
</not>
</and>
</condition>
<condition property="opensim.threejs.dir" value="${opensim.dist.dir}/threejs">
<os family="mac"/>
<os family="unix"/>
</condition>
<condition property="opensim.threejs.dir" value="${opensim.dist.dir}/OpenSim/threejs">
<os family="windows"/>
Expand All @@ -50,7 +58,7 @@
</target>
<target name="unzip-distro" depends="build-zip"
description="unZIP distribution of the suite, launchers, and selected modules from the platform.">
<unzip src="dist/opensim.zip" dest="dist/installer" />
<unzip src="dist/OpenSim.zip" dest="dist/installer" />
</target>
<target name="copy-installer-files" depends="unzip-distro"
description="Copy prebuilt opensim-core installation into installer folder">
Expand Down Expand Up @@ -117,11 +125,11 @@
<replace file="${opensim.dist.dir}/../make_installer.nsi" value="${app.version}">
<replacefilter token="@VERSION@" />
</replace>
<replace file="${opensim.dist.dir}/etc/OpenSim.conf"
<replace file="${opensim.dist.dir}/etc/OpenSim.conf"
value="${app.version}">
<replacefilter token="@VERSION@" />
</replace>
<!-- http://wiki.netbeans.org/DevFaqExecutableIcon -->
<replacefilter token="@VERSION@" />
</replace>
<!-- http://wiki.netbeans.org/DevFaqExecutableIcon -->
<exec executable="installer_files/Windows/ReplaceVistaIcon.exe" resolveexecutable="true">
<arg line="${opensim.dist.dir}/bin/OpenSim64.exe installer_files/Windows/OpenSimLogoWindows.ico"/>
</exec>
Expand Down Expand Up @@ -308,4 +316,76 @@
</exec>

</target>
<target name="build-linux" depends="unzip-distro,copy-visualizer,copy-models">
<!-- <echoproperties/> -->

<copy todir="${opensim.dist.dir}/Resources/Code/GUI">
<fileset dir="Scripts" />
</copy>

<delete>
<fileset dir="${opensim.dist.dir}/OpenSim/modules/ext"
includes="**/jxbrowser-*mac*.jar"/>
<fileset dir="${opensim.dist.dir}/OpenSim/modules/ext"
includes="**/jxbrowser-*win*.jar"/>
<fileset file="${opensim.dist.dir}/bin/OpenSim.exe"/>
<fileset file="${opensim.dist.dir}/bin/OpenSim64.exe"/>
<fileset file="dist/OpenSim.zip"/>
</delete>

<!-- Copy the OpenSim API. -->
<copy todir="${opensim.dist.dir}">
<fileset dir="${api.dir}">
<!-- Don't need the java source code. -->
<exclude name="**/sdk/Java/org/**" />
<!-- Developers can build developer doxygen on their own. -->
<exclude name="**/html_developer/**" />
</fileset>
</copy>

<chmod file="${opensim.dist.dir}/bin/**" perm="755" />
<chmod file="${opensim.dist.dir}/sdk/Simbody/libexec/simbody/simbody-visualizer"
perm="755" />

<!-- Zip up Resources and delete the original Resources folder. -->
<zip basedir="${opensim.dist.dir}/Resources/" destfile="${opensim.dist.dir}/Resources.zip" />
<delete dir="${opensim.dist.dir}/Resources"/>

<replace file="${opensim.dist.dir}/etc/OpenSim.conf" value="${app.version}">
<replacefilter token="@VERSION@" />
</replace>

<copy tofile="${opensim.dist.dir}/LICENSE.txt"
file="installer_files/license_for_binary_distribution.txt"/>
<copy tofile="${opensim.dist.dir}/NOTICE.txt"
file="installer_files/notice_for_binary_distribution.txt"/>
<mkdir dir="${opensim.dist.dir}/third_party_license_texts"/>
<copy todir="${opensim.dist.dir}/third_party_license_texts/"
file="jfreechart/lgpl-3.0.txt"/>
<copy todir="${opensim.dist.dir}/third_party_license_texts/"
file="jfreechart/gpl-3.0.txt"/>
<copy todir="${opensim.dist.dir}/third_party_license_texts/"
file="visualViewer/src/org/opensim/topologyEditor/cddl.txt"/>

<copy todir="${opensim.dist.dir}/"
file="${installer-files.dir}/OpenSimLogoWhiteNoText.png" />
<copy todir="${opensim.dist.dir}/"
file="${installer-files.dir}/opensim.desktop" />
<copy todir="${opensim.dist.dir}/"
file="${installer-files.dir}/INSTALL" />

<tar destfile="${opensim.dist.dir}/../../OpenSim-${app.version}.tar.gz"
basedir="${opensim.dist.dir}/.."
excludes="OpenSim/bin/**,**/*.log,OpenSim/*.desktop,OpenSim/sdk/Simbody/libexec/simbody/simbody-visualizer,OpenSim/INSTALL"
defaultexcludes="yes"
longfile="posix"
compression="gzip">
<tarfileset dir="${opensim.dist.dir}" filemode="755" prefix="OpenSim">
<include name="bin/**" />
<include name="opensim.desktop" />
<include name="sdk/Simbody/libexec/simbody/simbody-visualizer" />
<include name="INSTALL" />
</tarfileset>
</tar>
</target>
</project>
140 changes: 140 additions & 0 deletions Gui/opensim/installer_files/Linux/INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#!/bin/bash

function err_unsupported_env {
printf "\r [\033[0;31mERROR:\033[0m] Your distro/release is not supported by this script\n"
printf " Ubuntu 18.04 LTS is currently the only Linux distribution that is tested \
against, however the OpenSim GUI will likely run on other distributions and/or \
releases. See the https://github.com/opensim-org/opensim-gui for more \
information.\n"
exit 1
}

function usage {
echo -n "INSTALL [OPTIONS]...

Install the OpenSim GUI. Ubuntu 18.04 LTS is the only tested Linux. Manual \
installation on other systems may be possible; see \
https://github.com/opensim-org/opensim-gui for more information.

Options:
-p, --prefix Install prefix; defaults to /opt/opensim-gui
-v, --verbose Be verbose
-h, --help Display this help and exit
"
}

# From https://stackoverflow.com/a/246128
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

## From https://stackoverflow.com/a/29754866
# saner programming env: these switches turn some bugs into errors
set -o errexit -o pipefail -o noclobber -o nounset

# -allow a command to fail with !’s side effect on errexit
# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
! getopt --test > /dev/null
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
echo 'I’m sorry, `getopt --test` failed in this environment.'
exit 1
fi

OPTIONS=hp:v
LONGOPTS=help,prefix:,verbose

# -regarding ! and PIPESTATUS see above
# -temporarily store output to be able to check for errors
# -activate quoting/enhanced mode (e.g. by writing out “--options”)
# -pass arguments only via -- "$@" to separate them correctly
! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@")
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
# e.g. return value is 1
# then getopt has complained about wrong arguments to stdout
exit 2
fi
# read getopt’s output this way to handle the quoting right:
eval set -- "$PARSED"

v=0 installPrefix=/opt/opensim-gui
# now enjoy the options in order and nicely split until we see --
while true; do
case "$1" in
-h|--help)
usage
exit 0
;;
-v|--verbose)
v=1
shift
;;
-p|--prefix)
installPrefix="$2"
shift 2
;;
--)
shift
break
;;
*)
echo "Bad argument: $1 is not a valid argument"
exit 3
;;
esac
done
## End from https://stackoverflow.com/a/29754866

if [[ -e /etc/os-release ]]; then
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
else
err_unsupported_env
fi

if [[ $OS == "Ubuntu" ]] && [[ $VER == "18.04" ]]; then

[[ $v == 1 ]] && echo "Installing Java..."
sudo apt install -qqqq -y openjdk-8-jre

[[ $v == 1 ]] && echo "Testing for system LAPACK/BLAS..."
if ! (ldconfig -p | grep -q "libblas|liblapack"); then
[[ $v == 1 ]] && echo " Installing liblapack3..."
sudo apt install -qqqq -y liblapack3
fi

[[ $v == 1 ]] && echo "Testing for libgconf..."
if ! (ldconfig -p | grep -q "libgconf"); then
[[ $v == 1 ]] && echo " Installing libgconf..."
sudo apt install -qqqq -y libgconf-2-4
fi

[[ $v == 1 ]] && echo "Installing OpenSim GUI to $installPrefix, owned by $USER..."
sudo mkdir -p $installPrefix
sudo chown -R $USER:$USER $installPrefix
cp -R $SCRIPTDIR/* $installPrefix

[[ $v == 1 ]] && echo "Adding OpenSim to list of desktop applications..."
echo "[Desktop Entry]
Version=1.0
Type=Application
Name=OpenSim
Comment=OpenSim is an open source software for neuromusculoskeletal modeling, simulation \
and analysis.
Path=$installPrefix
Exec=$installPrefix/bin/OpenSim
Icon=opensim
Terminal=false
Categories=Science;Education" | sudo tee /usr/share/applications/opensim.desktop > /dev/null
sudo cp OpenSimLogoWhiteNoText.png /usr/share/pixmaps/opensim.png

[[ $v == 1 ]] && echo "Installing opensim-core commands..."
cd $installPrefix/bin
if [[ $v == 1 ]]; then
./opensim-install-command-line.sh
else
./opensim-install-command-line.sh > /dev/null
fi
else
err_unsupported_env
fi


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f123696

Please sign in to comment.