From 9819699105afd9efdc204a7eeba66675a94cd3df Mon Sep 17 00:00:00 2001 From: Ryan Alexander Date: Mon, 4 Aug 2014 13:56:23 -0700 Subject: [PATCH 1/8] Add include for std::free from --- sol/demangle.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sol/demangle.hpp b/sol/demangle.hpp index 77de1311..694a2be2 100644 --- a/sol/demangle.hpp +++ b/sol/demangle.hpp @@ -24,6 +24,7 @@ #include #include +#include #if defined(__GNUC__) || defined(__clang__) #include @@ -41,7 +42,7 @@ std::string get_type_name(const std::type_info& id) { int status; char* unmangled = abi::__cxa_demangle(id.name(), 0, 0, &status); std::string realname = unmangled; - free(unmangled); + std::free(unmangled); return realname; } From 6f52eb532e3a58dd7cecfb50f38856f8d27a7170 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 4 Aug 2014 18:26:45 -0400 Subject: [PATCH 2/8] Update bootstrap.py to handle external lua directories and linking on linux. --- bootstrap.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) mode change 100644 => 100755 bootstrap.py diff --git a/bootstrap.py b/bootstrap.py old mode 100644 new mode 100755 index 5a55c467..f417ea17 --- a/bootstrap.py +++ b/bootstrap.py @@ -33,27 +33,35 @@ def replace_extension(f, e): parser = argparse.ArgumentParser() parser.add_argument('--debug', action='store_true', help='compile with debug flags') parser.add_argument('--cxx', metavar='', help='compiler name to use (default: g++)', default='g++') -parser.add_argument('--ci', action='store_true', help='compile under TeamCity CI (internal use only)') +parser.add_argument('--ci', action='store_true', help=argparse.SUPPRESS) +parser.add_argument('--lua-dir', metavar='', help='directory lua is in with include and lib subdirectories') args = parser.parse_args() # general variables include = [ '.', os.path.join('Catch', 'include')] depends = [] cxxflags = [ '-Wall', '-Wextra', '-pedantic', '-pedantic-errors', '-std=c++11' ] -ldflags = [ '-static' ] +ldflags = [] if args.debug: cxxflags.extend(['-g', '-O0']) else: cxxflags.extend(['-DNDEBUG', '-O3']) +if args.lua_dir: + include.extend([os.path.join(args.lua_dir, 'include')]) + ldflags.extend(library_includes([os.path.join(args.lua_dir, 'lib')])) + if args.ci: - ldflags.extend(libraries(['lua5.2', 'dl'])) + ldflags.extend(libraries(['lua5.2'])) ldflags.extend(library_includes(['lib'])) include.extend(['/usr/include/lua5.2', './lua-5.2.2/src', './include']) else: ldflags.extend(libraries(['lua'])) +if 'linux' in sys.platform: + ldflags.extend(libraries(['dl'])) + builddir = 'bin' objdir = 'obj' tests = os.path.join(builddir, 'tests') From 68c89c53b94f0f5cc42994d281678b855f7ebd8b Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 4 Aug 2014 19:29:07 -0400 Subject: [PATCH 3/8] Add uninstall and install targets to ninja. --- bootstrap.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bootstrap.py b/bootstrap.py index f417ea17..c36b4b5f 100755 --- a/bootstrap.py +++ b/bootstrap.py @@ -29,12 +29,21 @@ def replace_extension(f, e): (root, ext) = os.path.splitext(f) return root + e +# Default install dir +install_dir = os.path.join('/usr', 'include') if 'linux' in sys.platform else 'include' + # command line stuff parser = argparse.ArgumentParser() parser.add_argument('--debug', action='store_true', help='compile with debug flags') parser.add_argument('--cxx', metavar='', help='compiler name to use (default: g++)', default='g++') parser.add_argument('--ci', action='store_true', help=argparse.SUPPRESS) parser.add_argument('--lua-dir', metavar='', help='directory lua is in with include and lib subdirectories') +parser.add_argument('--install-dir', metavar='', help='directory to install the headers to', default=install_dir); +parser.epilog = """In order to install sol, administrative privileges might be required. +Note that installation is done through the 'ninja install' command. To uninstall, the +command used is 'ninja uninstall'. The default installation directory for this +system is {}""".format(install_dir) + args = parser.parse_args() # general variables @@ -42,6 +51,15 @@ include = [ '.', os.path.join('Catch', 'include')] depends = [] cxxflags = [ '-Wall', '-Wextra', '-pedantic', '-pedantic-errors', '-std=c++11' ] ldflags = [] +script_dir = os.path.dirname(os.path.realpath(sys.argv[0])) +sol_dir = os.path.join(script_dir, 'sol') +sol_file = os.path.join(script_dir, 'sol.hpp') +copy_command = 'cp -rf {} $in && cp -f {} $in'.format(sol_dir, sol_file) +remove_command = 'rm -rf {} && rm -f {}'.format(os.path.join(args.install_dir, 'sol'), os.path.join(args.install_dir, 'sol.hpp')) +if sys.platform == 'win32': + copy_command = 'robocopy /COPYALL /E {} $in && robocopy /COPYALL {} $in'.format(sol_dir, sol_file) + remove_command = 'rmdir /S /Q {} && erase /F /S /Q /A {}'.format(os.path.join(args.install_dir, 'sol'), + os.path.join(args.install_dir, 'sol.hpp')) if args.debug: cxxflags.extend(['-g', '-O0']) @@ -85,6 +103,8 @@ ninja.rule('compile', command = '$cxx -MMD -MF $out.d -c $cxxflags -Werror $in - ninja.rule('link', command = '$cxx $cxxflags $in -o $out $ldflags', description = 'Creating $out') ninja.rule('runner', command = tests) ninja.rule('example', command = '$cxx $cxxflags $in -o $out $ldflags') +ninja.rule('installer', command = copy_command) +ninja.rule('uninstaller', command = remove_command) ninja.newline() # builds @@ -104,6 +124,8 @@ for f in glob.glob('examples/*.cpp'): ninja.build(tests, 'link', inputs = tests_object_files) ninja.build('tests', 'phony', inputs = tests) +ninja.build('install', 'installer', inputs = args.install_dir) +ninja.build('uninstall', 'uninstaller') ninja.build('examples', 'phony', inputs = examples) ninja.build('run', 'runner', implicit = 'tests') ninja.default('run') From 43e0217a632b145c54a3f81f2fb4b47809f5be4d Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 4 Aug 2014 20:07:06 -0400 Subject: [PATCH 4/8] Add travis-ci integration --- .travis.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..cda801c0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +language: cpp +matrix: + include: + - cpp: gcc + env: COMPILER=g++-4.8 + - cpp: clang + env: COMPILER=clang++ + +branches: + only: + - master + +before_install: + - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test + - sudo add-apt-repository -y ppa:saiarcot895/chromium-beta + - sudo apt-get --yes update + - sudo apt-get --yes install g++-4.8 + - sudo apt-get --yes install ninja-build + - sudo apt-get --yes install liblua5.2-dev + +script: ./bootstrap.py --cxx=$COMPILER && ninja From d24586033481ede3fcc6152bc8e2d134099fd8b5 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 4 Aug 2014 20:08:53 -0400 Subject: [PATCH 5/8] Add --ci flag to travis-ci script --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cda801c0..6f89c438 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,4 +18,4 @@ before_install: - sudo apt-get --yes install ninja-build - sudo apt-get --yes install liblua5.2-dev -script: ./bootstrap.py --cxx=$COMPILER && ninja +script: ./bootstrap.py --ci --cxx=$COMPILER && ninja From 721c6f1dae7d88226a18236e2ce7d41d59f4faac Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 4 Aug 2014 20:53:43 -0400 Subject: [PATCH 6/8] Update .travis.yml --- .travis.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6f89c438..d395fad2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,7 @@ language: cpp -matrix: - include: - - cpp: gcc - env: COMPILER=g++-4.8 - - cpp: clang - env: COMPILER=clang++ +compiler: + - gcc + - clang branches: only: @@ -14,8 +11,8 @@ before_install: - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test - sudo add-apt-repository -y ppa:saiarcot895/chromium-beta - sudo apt-get --yes update - - sudo apt-get --yes install g++-4.8 + - if [ "$CXX" == "g++" ]; then sudo apt-get --yes install g++-4.8; export CXX=g++-4.8; fi - sudo apt-get --yes install ninja-build - sudo apt-get --yes install liblua5.2-dev -script: ./bootstrap.py --ci --cxx=$COMPILER && ninja +script: ./bootstrap.py --ci --cxx=$CXX && ninja From 2ac3e27229ecc16eb567855fc3f60aa535a075c2 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 4 Aug 2014 21:05:47 -0400 Subject: [PATCH 7/8] Update travis script, fix warnings. --- .travis.yml | 2 +- sol/function_types.hpp | 2 +- sol/userdata.hpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index d395fad2..e522e63f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ before_install: - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test - sudo add-apt-repository -y ppa:saiarcot895/chromium-beta - sudo apt-get --yes update - - if [ "$CXX" == "g++" ]; then sudo apt-get --yes install g++-4.8; export CXX=g++-4.8; fi + - sudo apt-get --yes install g++-4.8 - sudo apt-get --yes install ninja-build - sudo apt-get --yes install liblua5.2-dev diff --git a/sol/function_types.hpp b/sol/function_types.hpp index 87ab95dc..857b1027 100644 --- a/sol/function_types.hpp +++ b/sol/function_types.hpp @@ -70,7 +70,7 @@ struct functor { functor(FxArgs&&... fxargs): item(nullptr), invocation(std::forward(fxargs)...) {} template - void operator()(Arg&& arg, Args&&... args) { + void operator()(Arg&& arg, Args&&...) { T& member = *item; (member.*invocation) = std::forward(arg); } diff --git a/sol/userdata.hpp b/sol/userdata.hpp index 34b68f4b..c26d7045 100644 --- a/sol/userdata.hpp +++ b/sol/userdata.hpp @@ -314,13 +314,13 @@ private: }; template -const std::array userdata::metavariablenames = { +const std::array userdata::metavariablenames = {{ "__index", "__newindex" -}; +}}; template -const std::array userdata::metafunctionnames = { +const std::array userdata::metafunctionnames = {{ "__index", "__newindex", "__mode", @@ -340,7 +340,7 @@ const std::array userdata::metafunctionnames = { "__eq", "__lt", "__le", -}; +}}; namespace stack { template From 6774249bb5be47196934ac74a8d669b5ad8dc2bf Mon Sep 17 00:00:00 2001 From: Rapptz Date: Mon, 4 Aug 2014 21:19:16 -0400 Subject: [PATCH 8/8] Ignore some warnings on clang. --- .travis.yml | 1 + bootstrap.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index e522e63f..53800df1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ before_install: - sudo add-apt-repository -y ppa:saiarcot895/chromium-beta - sudo apt-get --yes update - sudo apt-get --yes install g++-4.8 + - if [ "$CXX" == "g++" ]; then export CXX=g++-4.8; fi - sudo apt-get --yes install ninja-build - sudo apt-get --yes install liblua5.2-dev diff --git a/bootstrap.py b/bootstrap.py index c36b4b5f..43bba099 100755 --- a/bootstrap.py +++ b/bootstrap.py @@ -66,6 +66,9 @@ if args.debug: else: cxxflags.extend(['-DNDEBUG', '-O3']) +if args.cxx == 'clang++': + cxxflags.extend(['-Wno-unused-value', '-Wno-constexpr-not-const']) + if args.lua_dir: include.extend([os.path.join(args.lua_dir, 'include')]) ldflags.extend(library_includes([os.path.join(args.lua_dir, 'lib')]))