From a10c48182ff1f8c67d4632ab32d9d19a5f255978 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 1 May 2014 09:44:39 -0700 Subject: [PATCH] Move .proto and generated sources --- Builds/VisualStudio2013/RippleD.vcxproj | 30 ++++--- .../VisualStudio2013/RippleD.vcxproj.filters | 22 +++-- SConstruct | 9 ++- site_scons/site_tools/protoc.py | 80 ++++++++++--------- src/ripple/proto/.gitignore | 4 + .../protocol => ripple/proto}/ripple.proto | 0 src/ripple_overlay/api/Message.h | 2 +- 7 files changed, 86 insertions(+), 61 deletions(-) create mode 100644 src/ripple/proto/.gitignore rename src/{ripple_data/protocol => ripple/proto}/ripple.proto (100%) diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index 369297b569..c5260c38ea 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -19,7 +19,6 @@ - @@ -188,6 +187,7 @@ true true + true true @@ -2727,6 +2727,7 @@ + @@ -3192,17 +3193,6 @@ - - Document - protoc --cpp_out=$(RepoDir)\build\proto -I=$(RepoDir)\src\ripple_data\protocol\ "$(RepoDir)\src\ripple_data\protocol\%(Filename)%(Extension)" - protoc --cpp_out=$(RepoDir)\build\proto -I=$(RepoDir)\src\ripple_data\protocol\ "$(RepoDir)\src\ripple_data\protocol\%(Filename)%(Extension)" - protoc --cpp_out=$(RepoDir)\build\proto -I=$(RepoDir)\src\ripple_data\protocol\ "$(RepoDir)\src\ripple_data\protocol\%(Filename)%(Extension)" - protoc --cpp_out=$(RepoDir)\build\proto -I=$(RepoDir)\src\ripple_data\protocol\ "$(RepoDir)\src\ripple_data\protocol\%(Filename)%(Extension)" - $(RepoDir)\build\proto\%(Filename).pb.h;$(RepoDir)\build\proto\%(Filename).pb.cc - $(RepoDir)\build\proto\%(Filename).pb.h;$(RepoDir)\build\proto\%(Filename).pb.cc - $(RepoDir)\build\proto\%(Filename).pb.h;$(RepoDir)\build\proto\%(Filename).pb.cc - $(RepoDir)\build\proto\%(Filename).pb.h;$(RepoDir)\build\proto\%(Filename).pb.cc - @@ -3227,6 +3217,22 @@ + + false + Document + protoc --cpp_out=%(RelativeDir) --proto_path=%(RelativeDir) %(Identity) + protoc --cpp_out=%(RelativeDir) --proto_path=%(RelativeDir) %(Identity) + protoc --cpp_out=%(RelativeDir) --proto_path=%(RelativeDir) %(Identity) + protoc --cpp_out=%(RelativeDir) --proto_path=%(RelativeDir) %(Identity) + %(RelativeDir)%(Filename).pb.h;%(RelativeDir)%(Filename).pb.cc + %(RelativeDir)%(Filename).pb.h;%(RelativeDir)%(Filename).pb.cc + %(RelativeDir)%(Filename).pb.h;%(RelativeDir)%(Filename).pb.cc + %(RelativeDir)%(Filename).pb.h;%(RelativeDir)%(Filename).pb.cc + protoc --cpp_out=%(RelativeDir) --proto_path=%(RelativeDir) %(Identity) + protoc --cpp_out=%(RelativeDir) --proto_path=%(RelativeDir) %(Identity) + protoc --cpp_out=%(RelativeDir) --proto_path=%(RelativeDir) %(Identity) + protoc --cpp_out=%(RelativeDir) --proto_path=%(RelativeDir) %(Identity) + diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters index f69af7a5b0..5af79e0667 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters @@ -331,6 +331,9 @@ {f8e935e2-e54d-4681-9e7d-7e4a01192d6b} + + {ae6e40a1-a2ff-4a9e-b510-92192b96db44} + @@ -876,9 +879,6 @@ [2] Old Ripple\ripple_app - - [2] Old Ripple\ripple_data\protocol - [2] Old Ripple\ripple_basics @@ -1722,6 +1722,9 @@ [2] Old Ripple\ripple_app\misc + + [1] Ripple\proto + @@ -3345,11 +3348,9 @@ [2] Old Ripple\ripple_app\misc - - - - [2] Old Ripple\ripple_data\protocol - + + [1] Ripple\proto + @@ -3473,4 +3474,9 @@ [2] Old Ripple\ripple_overlay + + + [1] Ripple\proto + + \ No newline at end of file diff --git a/SConstruct b/SConstruct index e997deb32d..ea8ff8a4c6 100644 --- a/SConstruct +++ b/SConstruct @@ -210,8 +210,7 @@ INCLUDE_PATHS = [ '.', 'src/leveldb', 'src/leveldb/port', - 'src/leveldb/include', - 'build/proto' + 'src/leveldb/include' ] # if BOOST_HOME: @@ -446,8 +445,10 @@ for var in config_vars: sys.stdout.write("\nBuilding:\n") -PROTO_SRCS = env.Protoc([], 'src/ripple_data/protocol/ripple.proto', PROTOCOUTDIR='build/proto', PROTOCPYTHONOUTDIR=None) -env.Clean(PROTO_SRCS, 'site_scons/site_tools/protoc.pyc') +PROTO_SRCS = env.Protoc([], 'src/ripple/proto/ripple.proto', + PROTOCOUTDIR='src/ripple/proto', + PROTOCPROTOPATH=['src/ripple/proto'], + PROTOCPYTHONOUTDIR=None) # Only tag actual Ripple files. TAG_SRCS = copy.copy(COMPILED_FILES) diff --git a/site_scons/site_tools/protoc.py b/site_scons/site_tools/protoc.py index 4ca4270fdf..5c52b36b35 100644 --- a/site_scons/site_tools/protoc.py +++ b/site_scons/site_tools/protoc.py @@ -1,13 +1,38 @@ -#!python +# +# Copyright (c) 2009 Scott Stafford +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +# Author : Scott Stafford +# Date : 2009-12-09 20:36:14 +# +# Changes : Vinnie Falco +# Date : 2014--4-25 + """ protoc.py: Protoc Builder for SCons -This Builder invokes protoc to generate C++ and Python -from a .proto file. +This Builder invokes protoc to generate C++ and Python from a .proto file. NOTE: Java is not currently supported. - -From: http://www.scons.org/wiki/ProtocBuilder """ __author__ = "Scott Stafford" @@ -25,42 +50,25 @@ import os.path protocs = 'protoc' ProtocAction = SCons.Action.Action('$PROTOCCOM', '$PROTOCCOMSTR') -def ProtocEmitter(target, source, env): - dirOfCallingSConscript = Dir('.').srcnode() - env.Prepend(PROTOCPROTOPATH = dirOfCallingSConscript.path) - - source_with_corrected_path = [] - for src in source: - commonprefix = os.path.commonprefix([dirOfCallingSConscript.path, src.srcnode().path]) - if len(commonprefix)>0: - source_with_corrected_path.append( src.srcnode().path[len(commonprefix + os.sep):] ) - else: - source_with_corrected_path.append( src.srcnode().path ) - - source = source_with_corrected_path - - for src in source: - modulename = os.path.splitext(os.path.basename(src))[0] - if env['PROTOCOUTDIR']: - base = os.path.join(env['PROTOCOUTDIR'] , modulename) - target.extend( [ base + '.pb.cc', base + '.pb.h' ] ) - - if env['PROTOCPYTHONOUTDIR']: - base = os.path.join(env['PROTOCPYTHONOUTDIR'] , modulename) - target.append( base + '_pb2.py' ) +def ProtocEmitter(target, source, env): + PROTOCOUTDIR = env['PROTOCOUTDIR'] + PROTOCPYTHONOUTDIR = env['PROTOCPYTHONOUTDIR'] + for source_path in [str(x) for x in source]: + base = os.path.splitext(os.path.basename(source_path))[0] + if PROTOCOUTDIR: + target.extend([os.path.join(PROTOCOUTDIR, base + '.pb.cc'), + os.path.join(PROTOCOUTDIR, base + '.pb.h')]) + if PROTOCPYTHONOUTDIR: + target.append(os.path.join(PROTOCPYTHONOUTDIR, base + '_pb2.py')) try: target.append(env['PROTOCFDSOUT']) except KeyError: pass - # XXX KLUDGE: Force things to be right. - env['PROTOCOUTDIR'] = 'build/proto' - env['PROTOCPROTOPATH'] = ['src/ripple_data/protocol'] - - #~ print "PROTOC SOURCE:", [str(s) for s in source] - #~ print "PROTOC TARGET:", [str(s) for s in target] + #print "PROTOC SOURCE:", [str(s) for s in source] + #print "PROTOC TARGET:", [str(s) for s in target] return target, source @@ -75,7 +83,7 @@ def generate(env): except KeyError: bld = ProtocBuilder env['BUILDERS']['Protoc'] = bld - + env['PROTOC'] = env.Detect(protocs) or 'protoc' env['PROTOCFLAGS'] = SCons.Util.CLVar('') env['PROTOCPROTOPATH'] = SCons.Util.CLVar('') @@ -85,4 +93,4 @@ def generate(env): env['PROTOCSRCSUFFIX'] = '.proto' def exists(env): - return env.Detect(protocs) + return env.Detect(protocs) \ No newline at end of file diff --git a/src/ripple/proto/.gitignore b/src/ripple/proto/.gitignore new file mode 100644 index 0000000000..a4fc49d583 --- /dev/null +++ b/src/ripple/proto/.gitignore @@ -0,0 +1,4 @@ +# These files are generated by protoc and should not be part of the repository. + +*.pb.cc +*.pb.h diff --git a/src/ripple_data/protocol/ripple.proto b/src/ripple/proto/ripple.proto similarity index 100% rename from src/ripple_data/protocol/ripple.proto rename to src/ripple/proto/ripple.proto diff --git a/src/ripple_overlay/api/Message.h b/src/ripple_overlay/api/Message.h index 99796ba8ac..b767e83efc 100644 --- a/src/ripple_overlay/api/Message.h +++ b/src/ripple_overlay/api/Message.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_OVERLAY_MESSAGE_H_INCLUDED #define RIPPLE_OVERLAY_MESSAGE_H_INCLUDED -#include "ripple.pb.h" +#include "../../ripple/proto/ripple.pb.h" #include "../beast/modules/beast_core/system/BeforeBoost.h" #include