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

Gyp #21

Closed
wants to merge 30 commits into from
Closed

Gyp #21

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
88e1c9e
add gyp build system components
Jan 30, 2014
b74ede8
Add gyp itself
Jan 30, 2014
ba330cd
add working common.gypi
Jan 30, 2014
4cca130
use boost_root variable
Jan 30, 2014
1f22fbf
call our own gyp wrapper to ensure we use localy copy of gyp
Jan 30, 2014
738c823
adapt generation to work for both osx and ios
Jan 30, 2014
e6c4f41
fix the make build
Jan 30, 2014
2b9bac5
update readme
Jan 30, 2014
fa21b51
Merge branch 'master' of github.com:mapbox/llmr-native into gyp
Jan 30, 2014
a37f65a
append proper gyp path
kkaefer Jan 30, 2014
0b1bf6b
Merge branch 'master' into gyp
kkaefer Jan 30, 2014
7dd8ee4
minor Apple grammar
incanus Jan 30, 2014
a3406e2
ensure headers land in xcode project
Jan 30, 2014
8b647c0
correctly declard -stdlib=c++
Jan 30, 2014
c3f30e8
correct way to require clang on mac
Jan 30, 2014
44920c6
break apart two targets code xcode: ios/mac
Jan 30, 2014
4119af7
Merge branch 'gyp' of github.com:mapbox/llmr-native into gyp
incanus Jan 31, 2014
ee31606
don't share OS X deployment target between both iOS & OS X; build onl…
incanus Jan 31, 2014
0032327
Xcode likes to manage its own architectures
incanus Jan 31, 2014
b28a656
no need to copy headers anyplace
incanus Jan 31, 2014
8984b16
fix apparent Xcode bug with literal /usr/local/include on sim
incanus Feb 1, 2014
99459aa
remove old CMake stuff
incanus Feb 1, 2014
0b30d26
Merge branch 'master' of github.com:mapbox/llmr-native into gyp
Feb 1, 2014
1beb8b4
ensure flags are respected by putting in C++ flags instead
Feb 1, 2014
eaa99b8
clean up Makefile and configure
Feb 1, 2014
fa95016
by default 'make' build just osx lib
Feb 1, 2014
83e1ab1
add instructions for building on Ubuntu
Feb 3, 2014
e3256c3
ensure -std=c++11 on linux - refs #27
Feb 3, 2014
027e638
Merge branch 'master' of github.com:mapbox/llmr-native into gyp
Feb 3, 2014
ce54e27
Merge branch 'master' of github.com:mapbox/llmr-native into gyp
Feb 3, 2014
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