diff --git a/.gitignore b/.gitignore index d82026a43..e5d81496b 100644 --- a/.gitignore +++ b/.gitignore @@ -39,9 +39,9 @@ SconsBuilder* .scon* .build -# Rake build directory # +# sandbox directory # ####################### -build +sandbox # Eclipse related files # ######################### diff --git a/Rakefile b/Rakefile new file mode 100644 index 000000000..61c6bfbd1 --- /dev/null +++ b/Rakefile @@ -0,0 +1,68 @@ +sandbox = "sandbox" #where to locate builds, server configs and test data +osm_data = "amager" #name of OSM data file + +desc "Rebuild, reprocess OSM data and run server" +task :default => [:build, "data:process", :run] + +desc "Build with Scons" +task :build do + raise "Error while building." unless system "scons" +end + + +file "#{sandbox}/amager.osm.pbf" => "amager.osm.pbf" do |t| + raise unless system "cp #{t.prerequisites.join} #{t.name}" +end + +namespace :data do + desc "Process OSM test data" + task :process => ["#{sandbox}/amager.osm.pbf", :setup] do + prev = Dir.pwd + cd sandbox #we must be in the sandbox folder to use the speedprofile.ini in that folder + raise "Error while extracting data." unless system "./osrm-extract amager.osm.pbf" + raise "Error while preparing data." unless system "./osrm-prepare amager.osrm amager.osrm.restrictions" + cd prev + end + + desc "Download fresh OSM for the test data" + task :download => :setup do + start = Time.now + country = 'denmark' + bbox = 'top=55.6655 left=12.5589 bottom=55.6462 right=12.5963' + area = 'amager' + + raise "Error while downloading data." unless system "curl http://download.geofabrik.de/osm/europe/#{country}.osm.pbf -o #{sandbox}/#{country}.osm.pbf" + raise "Error while cropping data." unless system "osmosis --read-pbf file=#{sandbox}/#{country}.osm.pbf --bounding-box #{bbox} --write-pbf file=#{sandbox}/#{area}.osm.pbf omitmetadata=true" + end +end + +desc "Setup server files" +task :setup => ["#{sandbox}/speedprofile.ini", "#{sandbox}/extractor.ini", "#{sandbox}/server.ini"] + +file "#{sandbox}/speedprofile.ini" => "speedprofile.ini" do |t| + raise unless system "cp #{t.prerequisites.join} #{t.name}" +end + +file "#{sandbox}/extractor.ini" => "extractor.ini" do |t| + raise unless system "cp #{t.prerequisites.join} #{t.name}" +end + +file "#{sandbox}/server.ini" => "server.ini" do |t| + #first time the file is copied, we adjusts server settings to point to data files in our sandbox folder + text = File.read(t.prerequisites.join) + text.gsub!('/opt/osm/germany', "#{Dir.pwd}/sandbox/#{osm_data}") + file = File.new( t.name, "w+") + file.puts text + file.close +end + +desc "Run the OSRM server" +task :run => :setup do + cd sandbox + system "osrm-routed" +end + +desc "Run test" +task :test do + puts "Test would go here..." +end \ No newline at end of file diff --git a/SConstruct b/SConstruct index 5cbab86de..a6a6423b3 100644 --- a/SConstruct +++ b/SConstruct @@ -74,15 +74,20 @@ else: if sys.platform == 'darwin': #Mac OS X env.Append(CPPPATH = ['/usr/include/libxml2'] ) #comes with os x - #assume stxxl and boost are installed via homebrew. - #call out to brew to get the folder locations + #assume dependencies are installed with homebrew, and call out get folder locations import subprocess stxxl_prefix = subprocess.check_output(["brew", "--prefix", "libstxxl"]).strip() - boost_prefix = subprocess.check_output(["brew", "--prefix", "boost"]).strip() env.Append(CPPPATH = [stxxl_prefix+"/include"] ) env.Append(LIBPATH = [stxxl_prefix+"/lib"] ) + + boost_prefix = subprocess.check_output(["brew", "--prefix", "boost"]).strip() env.Append(CPPPATH = [boost_prefix+"/include"] ) env.Append(LIBPATH = [boost_prefix+"/lib"] ) + + #libxml2_prefix = subprocess.check_output(["brew", "--prefix", "libxml2"]).strip() + #env.Append(CPPPATH = [libxml2_prefix+"/include"] ) + #env.Append(LIBPATH = [libxml2_prefix+"/lib"] ) + elif sys.platform.startswith("freebsd"): env.ParseConfig('pkg-config --cflags --libs protobuf') env.Append(CPPPATH = ['/usr/local/include', '/usr/local/include/libxml2']) @@ -105,9 +110,11 @@ else: env.Append(CPPPATH = ['/usr/include', '/usr/include/include', '/usr/include/libxml2/']) -if not conf.CheckHeader('omp.h'): - print "Compiler does not support OpenMP. Exiting" - Exit(-1) +if sys.platform != 'darwin': + if not conf.CheckHeader('omp.h'): + print "Compiler does not support OpenMP. Exiting" + Exit(-1) + if not conf.CheckLibWithHeader('xml2', 'libxml/xmlreader.h', 'CXX'): print "libxml2 library or header not found. Exiting" Exit(-1) @@ -193,8 +200,8 @@ env.Protobuf('DataStructures/pbf-proto/osmformat.proto') env.Append(CCFLAGS = ['-lboost_regex', '-lboost_iostreams', '-lbz2', '-lz', '-lprotobuf']) #env.Append(LINKFLAGS = ['-lboost_system']) -env.Program(target = 'osrm-extract', source = ["extractor.cpp", 'DataStructures/pbf-proto/fileformat.pb.cc', 'DataStructures/pbf-proto/osmformat.pb.cc']) -env.Program(target = 'osrm-prepare', source = ["createHierarchy.cpp", 'Contractor/EdgeBasedGraphFactory.cpp']) -env.Program(target = 'osrm-routed', source = ["routed.cpp", 'Descriptors/DescriptionFactory.cpp']) +env.Program(target = 'sandbox/osrm-extract', source = ["extractor.cpp", 'DataStructures/pbf-proto/fileformat.pb.cc', 'DataStructures/pbf-proto/osmformat.pb.cc']) +env.Program(target = 'sandbox/osrm-prepare', source = ["createHierarchy.cpp", 'Contractor/EdgeBasedGraphFactory.cpp']) +env.Program(target = 'sandbox/osrm-routed', source = ["routed.cpp", 'Descriptors/DescriptionFactory.cpp']) env = conf.Finish() diff --git a/amager.osm.pbf b/amager.osm.pbf new file mode 100644 index 000000000..2d0dfd4bb Binary files /dev/null and b/amager.osm.pbf differ