Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Switch build system to gyp #28

Merged
merged 1 commit into from
Feb 3, 2014
Merged
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
/build
/xcode
*.sublime-*
config.gypi
config.mk
.DS_Store
19 changes: 0 additions & 19 deletions CMakeLists.txt

This file was deleted.

45 changes: 45 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
-include config.mk

BUILDTYPE ?= Release
PYTHON ?= python
V ?= 1

all: out/Makefile llmr

config.gypi: configure
$(PYTHON) ./configure

llmr: config.gypi out/Makefile llmr.gyp
$(MAKE) -C out BUILDTYPE=Release V=$(V) llmr-osx

# build OS X app with pure make
app: config.gypi src macosx/llmr-app.gyp
deps/run_gyp macosx/llmr-app.gyp -Goutput_dir=./out/ --depth=. --generator-output=./build/macosx-make -f make
make -C build/macosx-make
open build/macosx-make/out/Release/llmr.app

xcode: config.gypi llmr.gyp config.gypi
deps/run_gyp llmr.gyp -Goutput_dir=./out/ --depth=. --generator-output=./ -f xcode

# build OS X with xcodebuild
xapp: xcode config.gypi src macosx/llmr-app.gyp
deps/run_gyp macosx/llmr-app.gyp -Goutput_dir=./out/ --depth=. --generator-output=./ -f xcode
xcodebuild -project ./macosx/llmr-app.xcodeproj
open macosx/build/Release/llmr.app

out/Makefile: common.gypi llmr.gyp config.gypi

clean:
-rm -rf out
-rm -rf build
-rm -rf macosx/build

distclean:
-rm -f config.gypi
-rm -f config.mk
-rm -rf llmr.xcodeproj

test: all
echo test

.PHONY: test
63 changes: 54 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,69 @@
An OpenGL renderer for [Mapbox vector tiles](https://www.mapbox.com/blog/vector-tiles),
implemented in C++, targeting iOS & OSX.
implemented in C++, targeting iOS & OS X.

# Build instructions

## Mac OS X
## OS X

You may need to install [glfw3](http://www.glfw.org/docs/latest/):
Install boost and [glfw3](http://www.glfw.org/docs/latest/):

```
brew install boost
brew install homebrew/versions/glfw3
```

```
mkdir xcode
cd xcode
cmake .. -G Xcode
```
Then configure the project:

./configure

Options include:

- --boost=/usr/local
- --glfw3=/usr/local (by default pkg-config will be used)

Then you can build the OS X app with make:

make app

Or generate a dual iOS/OS X-compatible Xcode project for `libllmr` to include as a subproject:

make xcode # then open llmr.xcodeproj

## Ubuntu

Install a `-std=c++11` capable compiler

sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
sudo apt-get install gcc-4.8 g++-4.8

Install boost (we only need headers):

sudo apt-get install libboost-dev

Install glfw3 dependencies:

sudo apt-get install cmake libxi-dev libglu1-mesa-dev x11proto-randr-dev x11proto-xext-dev libxrandr-dev x11proto-xf86vidmode-dev libxxf86vm-dev libglu1-mesa-dev freeglut3-dev mesa-common-dev

Install glfw3:

git clone https://github.com/glfw/glfw.git
cd glfw
mkdir build
cd build
cmake ../
make
sudo make install
cd ../../

Build `libllmr`:

Then open the xcode project and build.
git clone git@github.com:mapbox/llmr-native.git
cd llmr-native
export CXX="g++-4.8"
./configure
make

Note: build will not compile until https://github.com/mapbox/llmr-native/issues/26 is fixed.

# Style protobuf

Expand Down
28 changes: 28 additions & 0 deletions common.gypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
'target_defaults': {
'default_configuration': 'Release',
'xcode_settings': {
'CLANG_CXX_LIBRARY': 'libc++',
'CLANG_CXX_LANGUAGE_STANDARD':'c++11',
'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
'ONLY_ACTIVE_ARCH': 1
},
'cflags':['-std=c++11'],
'configurations': {
'Debug': {
'cflags': [ '-g', '-O0', '-I<(boost_root)/include' ],
'defines': [ 'DEBUG' ],
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS': [ '-g', '-I<(boost_root)/include' ]
}
},
'Release': {
'cflags': [ '-O3', '-I<(boost_root)/include' ],
'defines': [ 'NDEBUG' ],
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS': [ '-I<(boost_root)/include' ]
}
}
}
}
}
113 changes: 113 additions & 0 deletions configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/usr/bin/env python
import optparse
import os
import pprint
import re
import shlex
import subprocess
import sys

root_dir = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(root_dir, 'deps', 'gyp', 'pylib'))
import gyp

# parse our options
parser = optparse.OptionParser()

parser.add_option("--debug",
action="store_true",
dest="debug",
help="Also build debug build")

parser.add_option("--boost",
action="store",
dest="boost_root",
help="Path to boost (defaults to /usr/local)")

parser.add_option("--glfw3",
action="store",
dest="glfw3",
help="Path to gflw3 (defaults to using pkg-config)")

(options, args) = parser.parse_args()

def pkg_config(pkg):
cmd = os.popen('pkg-config --libs %s' % pkg, 'r')
libs = cmd.readline().strip()
ret = cmd.close()
if (ret): return None

cmd = os.popen('pkg-config --cflags %s' % pkg, 'r')
cflags = cmd.readline().strip()
ret = cmd.close()
if (ret): return None

return (libs, cflags)

def configure_llmr(o):
if options.boost_root:
o['variables']['boost_root'] = options.boost_root
else:
o['variables']['boost_root'] = '/usr/local'
o['target_defaults']['default_configuration'] = 'Debug' if options.debug else 'Release'

def configure_glfw3(o):
if options.glfw3:
o['variables']['glfw3_libraries'] = '-L'+os.path.join(options.glfw3,'lib')
o['variables']['glfw3_libraries'] += '-lglfw3'
o['variables']['glfw3_cflags'] += '-I'+os.path.join(options.glfw3,'lib')
else:
ret = pkg_config('glfw3')
if not ret:
sys.stderr.write('could not find glfw3 with pkg-config')
sys.exit(-1)
o['variables']['glfw3_libraries'] = ret[0].split()
o['variables']['glfw3_cflags'] = ret[1].split()

def write(filename, data):
filename = os.path.join(root_dir, filename)
print "creating ", filename
f = open(filename, 'w+')
f.write(data)

output = {
'variables': { 'python': sys.executable },
'target_defaults' : {
'include_dirs': [],
'libraries': [],
'defines': [],
'cflags': []
}
}

def run_gyp(args):
rc = gyp.main(args)
if rc != 0:
print 'Error running GYP'
sys.exit(rc)

if __name__ == '__main__':
configure_llmr(output)
configure_glfw3(output)
pprint.pprint(output, indent=2)

write('config.gypi', "# Do not edit. Generated by the configure script.\n" +
pprint.pformat(output, indent=2) + "\n")

config = {
'BUILDTYPE': 'Debug' if options.debug else 'Release',
'PYTHON': sys.executable,
}
config = '\n'.join(map('='.join, config.iteritems())) + '\n'

write('config.mk',
'# Do not edit. Generated by the configure script.\n' + config)

gyp_args = []
gyp_args.extend(['-f', 'make'])
gyp_args.append(os.path.join(os.path.abspath(root_dir), 'llmr.gyp'))
gyp_args.append('--depth=' + root_dir)
output_dir = os.path.join(os.path.abspath(root_dir), 'out')
gyp_args.extend(['--generator-output', output_dir])
gyp_args.extend(['-Goutput_dir=' + output_dir])
run_gyp(gyp_args)
1 change: 1 addition & 0 deletions deps/gyp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pyc
27 changes: 27 additions & 0 deletions deps/gyp/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2009 Google Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 change: 1 addition & 0 deletions deps/gyp/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
Loading