-
Notifications
You must be signed in to change notification settings - Fork 18
Pat Build Notes
These steps are only required when updating Pat dependencies. Most development can utilize prebuilt binaries post on Amazon S3, http://openstudio-resources.s3.amazonaws.com/pat-dependencies2/. Follow these steps to build new packages and upload to the S3 location.
These commands are expected to work equivalently on Mac and Windows provided they are performed from the git bash shell on Windows. Critically, git bash provides the tar utility used to archive binaries in these instructions.
I found that most Ruby installations are not relocatable. If you move the installation tree around, even on the same computer, things break. The reason for this seems to be two fold. One is that shebang lines get generated into the various ruby executables with hard paths to the installation. The second issue is that the ruby library path gets compiled in. This second thing is the real show stopper.
It turns out there is a configure option to fix the problem. Here is a procedure for a relocatable ruby build.
brew install ruby-build
export CONFIGURE_OPTS="--enable-load-relative"
ruby-build 2.0.0-p648 <path/to/ruby/install/ruby>
*** Update on Mac OS X ***
If ruby-build does not detect a recent version (>= 1.0.1) of the openssl library it will try to download and build it, then place it in the ruby install tree. The only problem is that ruby is linked to openssl in a way that does not allow the install tree to be relocated to a different location or a different machine. The solution is the following script that will apply use the install_name_tool to adjust the libraries so that they are located relative to the ruby executables. This scrip needs to be run from the root of the ruby-build install tree.
require 'pathname'
libs = Pathname.glob('./**/*.bundle')
dylibs = Pathname.glob('./**/*.dylib')
libs.concat dylibs
dylibs.each do |lib|
File.chmod(0755, lib)
end
libs.each do |lib|
next if (File.ftype(lib) == 'link')
result = `otool -L #{lib}`
lines = result.lines
lines.each do |line|
if line =~ /\/openssl\//
line.strip!
line.sub!(/\(.*\)/,'')
next if line.end_with?(':')
puts "*** #{lib} ***"
new_lib = '@executable_path/..' + line.sub(/.*\/openssl\//,'/openssl/')
puts line
puts new_lib
puts Pathname.new(lib).expand_path.to_s.strip
if line.strip == Pathname.new(lib).expand_path.to_s.strip
puts 'id: '
`install_name_tool -id #{new_lib} #{lib}`
else
`install_name_tool -change #{line} #{new_lib} #{lib}`
end
puts
end
end
end
To prepare a package for S3 follow these steps. Consider automating this process.
# Note the "install" directory should contain a directory named "ruby".
# Inside "ruby" should be the install tree, bin, lib, etc.
cd /path/to/ruby/install
tar -czf ruby-2.0.0-p648-darwin.tar.gz ruby
https://www.mongodb.com/dr/fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.2.10.tgz/download
You can put this in your path and it will be sufficient to run openstudio-server outside of PAT. For that purpose I am also successful with brew install mongo.
To prepare a package for S3, start with the package from mongodb.com. We need to rename the package so that it is in a format that PAT expects.
mv mongodb-osx-x86_64-3.2.10 mongo
tar -czf mongodb-3.2.5-darwin.tar.gz mongo
git clone https://github.com/NREL/OpenStudio-server.git
git checkout -t origin/dockerize
cd OpenStudio-server
Build a server package, export it to a staging location, and create a tar.gz. The tar.gz file will be in the export dir
/path/to/ruby/bin/ruby ./bin/openstudio_meta install_gems --export="/full/path/somewhere/openstudioServerExport"
To build server for running tests
rm ./server/.bundle/config
/path/to/ruby/bin/ruby ./bin/openstudio_meta install_gems --with_test_develop
On Mac --export seems to have a bug. A workaround is....
tar --exclude .git -czf "OpenStudio-server-$(git -C OpenStudio-server rev-parse --short=10 HEAD)-darwin.tar.gz" OpenStudio-server
I also hit a problem with libxml-ruby gem. Here is my very hacky hack.
ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2 /usr/local/include/
Install node, npm, bower, and gulp, and make sure they are in your path.
git clone https://github.com/NREL/OpenStudio-PAT.git
npm install
bower install
gulp install-deps
Download the latest OpenStudio iteration installer https://github.com/NREL/OpenStudio/releases and run the installer. In the graphical interface, choose /depend/OpenStudio as the installation prefix. The minimum required components are the ruby bindings and the openstudio cli. App, Pat, Plugin, etc are not required.
npm run build
Start the Pat application in develop mode.
npm run start
In order to avoid forcing PAT developers to build OpenStudio, pre-packaged OpenStudio installers are provided periodically. These are posted in the pat-dependencies2 bucket on s3, the packages contain the same directory structure as the OpenStudio installer so the development version of PAT sees the same layout as the installed version. To create these packages from a full OpenStudio installer:
- Run the full OpenStudio installer, select only the Ruby API, CLI, and EnergyPlus components
- Rename the top level installation name from 'openstudio-X.X.X' to 'OpenStudio'
- Create an archive with
tar -zcvf OpenStudio2-X.X.X.X-win32.tar.gz OpenStudioortar -zcvf OpenStudio2-X.X.X.X-darwin.tar.gz OpenStudio - Update manifest.json in OpenStudio-PAT repo