0
+ "boost/detail/{limits,endian}.hpp",
0
+ "boost/detail/sp_counted_*",
0
+ "boost/detail/atomic_count*",
0
#include <boost/shared_ptr.hpp>
0
#include <boost/thread.hpp>
0
@@ -6,13 +13,10 @@ PROGRAM_SOURCE = %q{
0
#include <boost/bind.hpp>
0
#include <boost/date_time/posix_time/posix_time.hpp>
0
Dir.chdir(File.dirname(__FILE__) + "/../ext")
0
-File.open("test.cpp", "w") do |f|
0
- f.write(PROGRAM_SOURCE)
0
+# Run the given command, and abort on error.
0
@@ -21,30 +25,78 @@ def sh(*command)
0
- missing_headers = `g++ test.cpp -c -I. 2>&1`.
0
- grep(/error: .*: No such file/).
0
- file = line.sub(/.*error: (.*): .*/, '\1')
0
- File.dirname(source) + "/" + file
0
+def install(source_filename, target_filename)
0
+ command = ["install", "-D", "--mode=u+rw,g+r,o+r", source_filename, target_filename]
0
+def copy_boost_files(*patterns)
0
+ patterns.each do |pattern|
0
+ Dir["#{BOOST_DIR}/#{pattern}"].each do |source|
0
+ if File.directory?(source)
0
+ source.slice!(0 .. BOOST_DIR.size)
0
+ copy_boost_files("#{source}/*")
0
+ target = source.slice(BOOST_DIR.size + 1 .. source.size - 1)
0
+ target.sub!(%r{^libs/thread/}, 'boost/')
0
+ if !File.exist?(target)
0
+ install(source, target)
0
+def copy_essential_files
0
+ copy_boost_files(*ESSENTIALS)
0
+ File.open("test.cpp", "w") do |f|
0
+ f.write(PROGRAM_SOURCE)
0
+ File.unlink("test.cpp") rescue nil
0
+# Compile PROGRAM_SOURCE and copy whatever missing header files the compiler needs.
0
+ missing_headers = `g++ test.cpp -c -I. 2>&1`.
0
+ grep(/error: .*: No such file/).
0
+ file = line.sub(/.*error: (.*): .*/, '\1')
0
+ File.dirname(source) + "/" + file
0
+ missing_headers.each do |header|
0
+ install("#{BOOST_DIR}/#{header}", header)
0
+ done = missing_headers.empty?
0
+ if BOOST_DIR.nil? || BOOST_DIR.empty?
0
+ puts "Usage: copy_boost_headers.rb <boost source directory>"
0
- missing_headers.each do |header|
0
- command = ["install", "-D", "--mode=u+rw,g+r,o+r", "#{boost_dir}/#{header}", header]
0
- done = missing_headers.empty?
0
-sh "cp #{boost_dir}/boost/detail/{limits,endian}.hpp boost/detail/"
0
-sh "cp -R #{boost_dir}/boost/config/* boost/config/"
0
-sh "cp -R #{boost_dir}/boost/detail/sp_counted_* boost/detail/"
0
-sh "cp -R #{boost_dir}/boost/detail/atomic_count* boost/detail/"
0
-sh "mkdir -p boost/src && cp -R #{boost_dir}/libs/thread/src/* boost/src/"
Comments
No one has commented yet.