diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | bin/build-shaders.js | 12 | ||||
-rwxr-xr-x | configure | 117 | ||||
-rw-r--r-- | linux/llmr-app.gyp | 9 | ||||
-rw-r--r-- | llmr.gyp | 32 |
5 files changed, 56 insertions, 115 deletions
diff --git a/.gitignore b/.gitignore index bc11cf95a5..b8cbcf58ea 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,4 @@ /bin/node_modules /include/llmr/shader/shaders.hpp /include/llmr/style/resources.hpp -/src/shader/shaders.cpp /src/style/resources.cpp diff --git a/bin/build-shaders.js b/bin/build-shaders.js index dd8eaad8c2..7e43a8f730 100755 --- a/bin/build-shaders.js +++ b/bin/build-shaders.js @@ -5,7 +5,7 @@ var fs = require('fs'); var path = require('path'); var glsl = require('glsl-optimizer'); -module.exports = function(param) { +module.exports = function(shader_type, root) { var name; var shaders = {}; @@ -30,10 +30,10 @@ module.exports = function(param) { if (glsl) { var preamble = ''; var target = glsl.TARGET_OPENGL; - if (param == 'gles2') { + if (shader_type == 'gles2') { target = glsl.TARGET_OPENGLES20; preamble = 'precision highp float;'; - } else if (param == 'gles3') { + } else if (shader_type == 'gles3') { target = glsl.TARGET_OPENGLES30; preamble = 'precision highp float;'; } else { @@ -113,8 +113,10 @@ module.exports = function(param) { code += lines.join(',\n'); code += '\n};\n'; - fs.writeFileSync('src/shader/shaders.cpp', code); + fs.writeFileSync(path.join(root, 'src/shader/shaders_' + shader_type + '.cpp'), code); }; -module.exports(process.argv[2]); +var root = path.resolve(process.argv[2] || '.'); +module.exports('gl', root); +module.exports('gles2', root); @@ -8,8 +8,6 @@ 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() @@ -19,42 +17,27 @@ parser.add_option("--debug", dest="debug", help="Also build debug build") +parser.add_option("--pkg-config-root", + action="store", + dest="pkgconfig_root", + help="Path to pkg-config directory") + 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)") - -parser.add_option("--png", - action="store", - dest="png", - help="Path to png (defaults to using pkg-config)") - -parser.add_option("--png-includes", - action="store", - dest="png_includes", - help="Path to png includes") - -parser.add_option("--png-libpath", - action="store", - dest="png_libpath", - help="Path to png libs") - (options, args) = parser.parse_args() -def pkg_config(pkg): - cmd = os.popen('pkg-config --static --libs %s' % pkg, 'r') - libs = cmd.readline().strip() - ret = cmd.close() +def pkg_config(pkg, pkgconfig_root): + env = os.environ.copy() + env["PKG_CONFIG_PATH"] = pkgconfig_root + cmd = subprocess.Popen(['pkg-config', '--static', '--libs', pkg], stdout=subprocess.PIPE, env=env) + libs, ret = cmd.communicate() if (ret): return None - cmd = os.popen('pkg-config --cflags %s' % pkg, 'r') - cflags = cmd.readline().strip() - ret = cmd.close() + cmd = subprocess.Popen(['pkg-config', '--cflags', pkg], stdout=subprocess.PIPE, env=env) + cflags, red = cmd.communicate() if (ret): return None return (libs, cflags) @@ -67,46 +50,28 @@ def configure_llmr(o): o['target_defaults']['default_configuration'] = 'Debug' if options.debug else 'Release' def configure_glfw3(o): - if options.glfw3: - libpath = os.path.join(options.glfw3,'lib') - if os.path.exists(libpath): - o['variables']['glfw3_libraries'] = ['-L'+libpath] - o['variables']['glfw3_libraries'] += ['-lglfw3'] - incpath = os.path.join(options.glfw3,'include') - if os.path.exists(incpath): - o['variables']['glfw3_cflags'] = ['-I'+incpath] - 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() + ret = pkg_config('glfw3', options.pkgconfig_root) + 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 configure_png(o): - if options.png or options.png_libpath or options.png_includes: - libpath = None - if options.png_libpath: - libpath = options.png_libpath - elif options.png: - libpath = os.path.join(options.png,'lib') - if libpath and os.path.exists(libpath): - o['variables']['png_libraries'] = ['-L'+libpath] - o['variables']['png_libraries'] += ['-lpng','-lz'] - incpath = None - if options.png_includes: - incpath = options.png_includes - elif options.png: - incpath = os.path.join(options.png,'include') - if incpath and os.path.exists(incpath): - o['variables']['png_cflags'] = ['-I'+incpath] - else: - ret = pkg_config('libpng') - if not ret: - sys.stderr.write('could not find libpng with pkg-config') - sys.exit(-1) - o['variables']['png_libraries'] = ret[0].split() - o['variables']['png_cflags'] = ret[1].split() + ret = pkg_config('libpng', options.pkgconfig_root) + if not ret: + sys.stderr.write('could not find png with pkg-config') + sys.exit(-1) + o['variables']['png_libraries'] = ret[0].split() + o['variables']['png_cflags'] = ret[1].split() + +def configure_curl(o): + ret = pkg_config('libcurl', options.pkgconfig_root) + if not ret: + sys.stderr.write('could not find curl with pkg-config') + sys.exit(-1) + o['variables']['curl_libraries'] = ret[0].split() + o['variables']['curl_cflags'] = ret[1].split() def write(filename, data): filename = os.path.join(root_dir, filename) @@ -124,16 +89,11 @@ output = { } } -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) configure_png(output) + configure_curl(output) pprint.pprint(output, indent=2) write('config.gypi', "# Do not edit. Generated by the configure script.\n" + @@ -146,13 +106,4 @@ if __name__ == '__main__': 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) + '# Do not edit. Generated by the configure script.\n' + config)
\ No newline at end of file diff --git a/linux/llmr-app.gyp b/linux/llmr-app.gyp index 0fa77085e9..a6de3c2799 100644 --- a/linux/llmr-app.gyp +++ b/linux/llmr-app.gyp @@ -36,11 +36,12 @@ 'SUPPORTED_PLATFORMS':'macosx', 'OTHER_CPLUSPLUSFLAGS':[ '<@(glfw3_cflags)' + '<@(curl_cflags)' ], 'OTHER_LDFLAGS': [ '-stdlib=libc++', '<@(glfw3_libraries)', - '-lcurl', + '<@(curl_libraries)', ], 'SDKROOT': 'macosx', 'INFOPLIST_FILE': '../macosx/Info.plist', @@ -54,12 +55,12 @@ 'link_settings': { 'libraries': [ '<@(glfw3_libraries)', - '-lcurl' + '<@(curl_libraries)', ], }, 'cflags': [ - '<@(png_cflags)', - '<@(glfw3_cflags)' + '<@(glfw3_cflags)', + '<@(curl_cflags)' ], }] ], @@ -5,7 +5,7 @@ ], 'targets': [ { - 'target_name': 'shaders_gl', + 'target_name': 'shaders', 'type': 'none', 'actions': [ { @@ -15,26 +15,10 @@ ], 'outputs': [ 'include/llmr/shader/shaders.hpp', - 'src/shader/shaders.cpp' + '<(SHARED_INTERMEDIATE_DIR)/src/shader/shaders_gl.cpp', + '<(SHARED_INTERMEDIATE_DIR)/src/shader/shaders_gles2.cpp', ], - 'action': ['bin/build-shaders.js', 'gl'], - } - ] - }, - { - 'target_name': 'shaders_gles2', - 'type': 'none', - 'actions': [ - { - 'action_name': 'Build Shaders', - 'inputs': [ - '<!@(find src -name "*.glsl")' - ], - 'outputs': [ - 'include/llmr/shader/shaders.hpp', - 'src/shader/shaders.cpp' - ], - 'action': ['bin/build-shaders.js', 'gles2'], + 'action': ['bin/build-shaders.js', '<(SHARED_INTERMEDIATE_DIR)'], } ] }, @@ -61,7 +45,7 @@ 'type': 'static_library', 'dependencies': [ 'build_stylesheet', - 'shaders_gl', + 'shaders', ], 'sources': [ '<!@(find src -name "*.cpp")', @@ -70,6 +54,8 @@ '<!@(find include -name "*.hpp")', '<!@(find include -name "*.h")', '<!@(find src -name "*.glsl")', + 'include/llmr/shader/shaders.hpp', + '<(SHARED_INTERMEDIATE_DIR)/src/shader/shaders_gl.cpp', 'bin/style.js' ], 'xcode_settings': { @@ -120,7 +106,7 @@ 'type': 'static_library', 'dependencies': [ 'build_stylesheet', - 'shaders_gles2', + 'shaders', ], 'sources': [ '<!@(find src -name "*.cpp")', @@ -129,6 +115,8 @@ '<!@(find include -name "*.hpp")', '<!@(find include -name "*.h")', '<!@(find src -name "*.glsl")', + 'include/llmr/shader/shaders.hpp', + '<(SHARED_INTERMEDIATE_DIR)/src/shader/shaders_gles2.cpp', 'bin/style.js' ], 'xcode_settings': { |