├── BLADE_ROOT ├── INSTALL.txt ├── LICENSE.TXT ├── README.markdown ├── README.txt ├── doc ├── FAQ.markdown └── HelloWorld.markdown ├── example ├── hello_world │ ├── BUILD │ ├── Makefile │ ├── cfg │ │ └── pebble.ini │ ├── client.cpp │ ├── hello.pebble │ └── server.cpp ├── pebble_cmdline │ ├── BUILD │ ├── Makefile │ └── server.cpp ├── pebble_ctrl_cmd │ ├── BUILD │ ├── Makefile │ ├── cfg │ │ └── pebble.ini │ └── server.cpp ├── pebble_idl │ ├── BUILD │ ├── Makefile │ ├── client.cpp │ ├── idl.pebble │ ├── idlex.pebble │ └── server.cpp ├── pebble_server │ ├── BUILD │ ├── Makefile │ ├── calculator.pebble │ ├── client.cpp │ └── server.cpp ├── protobuf_rpc │ ├── BUILD │ ├── Makefile │ ├── calculator.proto │ ├── client.cpp │ └── server.cpp ├── rollback_rpc │ ├── BUILD │ ├── Makefile │ ├── calculator.pebble │ ├── client.cpp │ └── server.cpp └── threadpool │ ├── BUILD │ ├── Makefile │ └── server.cpp ├── src ├── client │ ├── BUILD │ ├── README.txt │ ├── pebble_client.cpp │ └── pebble_client.h ├── common │ ├── BUILD │ ├── README.txt │ ├── base64.cpp │ ├── base64.h │ ├── blocking_queue.h │ ├── condition_variable.cpp │ ├── condition_variable.h │ ├── coroutine.cpp │ ├── coroutine.h │ ├── coroutine_system_hook.cpp │ ├── cpu.cpp │ ├── cpu.h │ ├── dir_util.cpp │ ├── dir_util.h │ ├── error.cpp │ ├── error.h │ ├── file_util.cpp │ ├── file_util.h │ ├── ini_reader.cpp │ ├── ini_reader.h │ ├── log.cpp │ ├── log.h │ ├── memory.cpp │ ├── memory.h │ ├── mutex.h │ ├── net_util.cpp │ ├── net_util.h │ ├── platform.h │ ├── random.cpp │ ├── random.h │ ├── sha1.cpp │ ├── sha1.h │ ├── string_utility.cpp │ ├── string_utility.h │ ├── thread.cpp │ ├── thread.h │ ├── thread_pool.cpp │ ├── thread_pool.h │ ├── time_utility.cpp │ ├── time_utility.h │ ├── timer.cpp │ ├── timer.h │ └── uncopyable.h ├── extension │ ├── README.txt │ ├── extension.h │ ├── redis │ │ ├── BUILD │ │ ├── redis_co.cpp │ │ └── redis_co.h │ └── zookeeper │ │ ├── BUILD │ │ ├── naming_handler.cpp │ │ ├── naming_handler.inh │ │ ├── zookeeper_cache.cpp │ │ ├── zookeeper_cache.inh │ │ ├── zookeeper_client.cpp │ │ ├── zookeeper_client.h │ │ ├── zookeeper_error.h │ │ ├── zookeeper_log.cpp │ │ ├── zookeeper_log.inh │ │ ├── zookeeper_naming.cpp │ │ └── zookeeper_naming.h ├── framework │ ├── BUILD │ ├── README.txt │ ├── broadcast.pebble │ ├── broadcast_mgr.cpp │ ├── broadcast_mgr.h │ ├── broadcast_mgr.inh │ ├── channel_mgr.cpp │ ├── channel_mgr.h │ ├── dr │ │ ├── BUILD │ │ ├── common │ │ │ ├── common.h │ │ │ ├── dr_define.h │ │ │ ├── field_pack.cpp │ │ │ ├── field_pack.h │ │ │ ├── fp_util.h │ │ │ ├── reflection.h │ │ │ ├── reflection_local.h │ │ │ └── to_string.h │ │ ├── protocol │ │ │ ├── base64_utils.cpp │ │ │ ├── base64_utils.h │ │ │ ├── binary_protocol.h │ │ │ ├── binary_protocol.tcc │ │ │ ├── bson_protocol.cpp │ │ │ ├── bson_protocol.h │ │ │ ├── json_protocol.cpp │ │ │ ├── json_protocol.h │ │ │ ├── protocol.h │ │ │ ├── protocol_exception.h │ │ │ ├── protocol_tap.h │ │ │ ├── rapidjson_protocol.cpp │ │ │ ├── rapidjson_protocol.h │ │ │ └── virtual_protocol.h │ │ ├── serialize.cpp │ │ ├── serialize.h │ │ └── transport │ │ │ ├── buffer_transport.cpp │ │ │ ├── buffer_transport.h │ │ │ ├── transport.h │ │ │ ├── transport_exception.cpp │ │ │ ├── transport_exception.h │ │ │ └── virtual_transport.h │ ├── event_handler.cpp │ ├── event_handler.inh │ ├── exception.pebble │ ├── gdata_api.cpp │ ├── gdata_api.h │ ├── gdata_err.h │ ├── message.cpp │ ├── message.h │ ├── monitor.h │ ├── naming.cpp │ ├── naming.h │ ├── net_message.cpp │ ├── net_message.h │ ├── options.cpp │ ├── options.h │ ├── pebble_rpc.cpp │ ├── pebble_rpc.h │ ├── processor.cpp │ ├── processor.h │ ├── protobuf_rpc_head.pebble │ ├── raw_message_driver.cpp │ ├── raw_message_driver.h │ ├── register_error.cpp │ ├── register_error.h │ ├── router.cpp │ ├── router.h │ ├── rpc.cpp │ ├── rpc.h │ ├── rpc_plugin.cpp │ ├── rpc_plugin.inh │ ├── rpc_util.cpp │ ├── rpc_util.inh │ ├── session.cpp │ ├── session.h │ ├── stat.cpp │ ├── stat.h │ ├── stat_manager.cpp │ ├── stat_manager.h │ ├── when_all.cpp │ └── when_all.h └── server │ ├── BUILD │ ├── README.txt │ ├── cfg │ └── pebble.ini │ ├── control.pebble │ ├── control_client.cpp │ ├── error_parser.cpp │ ├── pebble.h │ ├── pebble_cmdline.cpp │ ├── pebble_cmdline.h │ ├── pebble_server.cpp │ └── pebble_server.h ├── thirdparty ├── gflags-2.0 │ ├── AUTHORS │ ├── COPYING │ ├── ChangeLog │ ├── INSTALL │ ├── Makefile.am │ ├── Makefile.in │ ├── NEWS │ ├── README │ ├── README_windows.txt │ ├── aclocal.m4 │ ├── config.guess │ ├── config.sub │ ├── configure │ ├── configure.ac │ ├── depcomp │ ├── doc │ │ ├── designstyle.css │ │ └── gflags.html │ ├── gflags.sln │ ├── install-sh │ ├── libtool │ ├── ltmain.sh │ ├── m4 │ │ ├── ac_have_attribute.m4 │ │ ├── acx_pthread.m4 │ │ ├── google_namespace.m4 │ │ ├── libtool.m4 │ │ ├── ltoptions.m4 │ │ ├── ltsugar.m4 │ │ ├── ltversion.m4 │ │ ├── lt~obsolete.m4 │ │ ├── namespaces.m4 │ │ └── stl_namespace.m4 │ ├── missing │ ├── packages │ │ ├── deb.sh │ │ ├── deb │ │ │ ├── changelog │ │ │ ├── compat │ │ │ ├── control │ │ │ ├── copyright │ │ │ ├── docs │ │ │ ├── libgflags-dev.dirs │ │ │ ├── libgflags-dev.install │ │ │ ├── libgflags0.dirs │ │ │ ├── libgflags0.install │ │ │ └── rules │ │ ├── rpm.sh │ │ └── rpm │ │ │ └── rpm.spec │ ├── src │ │ ├── BUILD │ │ ├── config.h │ │ ├── config.h.in │ │ ├── config_for_unittests.h │ │ ├── config_linux.h │ │ ├── gflags.cc │ │ ├── gflags │ │ │ ├── gflags.h │ │ │ ├── gflags.h.in │ │ │ ├── gflags_completions.h │ │ │ ├── gflags_completions.h.in │ │ │ ├── gflags_declare.h │ │ │ └── gflags_declare.h.in │ │ ├── gflags_completions.cc │ │ ├── gflags_completions.sh │ │ ├── gflags_nc.cc │ │ ├── gflags_reporting.cc │ │ ├── gflags_strip_flags_test.cc │ │ ├── gflags_strip_flags_test.sh │ │ ├── gflags_unittest-main.cc │ │ ├── gflags_unittest.cc │ │ ├── gflags_unittest.sh │ │ ├── gflags_unittest_flagfile │ │ ├── gflags_unittest_main.cc │ │ ├── google │ │ │ ├── gflags.h │ │ │ └── gflags_completions.h │ │ ├── mutex.h │ │ ├── util.h │ │ └── windows │ │ │ ├── config.h │ │ │ ├── gflags │ │ │ ├── gflags.h │ │ │ ├── gflags_completions.h │ │ │ └── gflags_declare.h │ │ │ ├── port.cc │ │ │ └── port.h │ └── vsprojects │ │ ├── gflags_unittest │ │ └── gflags_unittest.vcproj │ │ └── libgflags │ │ ├── libgflags.vcproj │ │ ├── libgflags_mt_2005.vcproj │ │ └── libgflags_mt_2008.vcproj ├── gflags │ ├── BUILD │ ├── ChangeLog │ ├── gflags.h │ ├── gflags.py │ ├── gflags_completions.h │ ├── gflags_declare.h │ ├── gflags_test.cpp │ ├── linux_include │ │ ├── gflags.h │ │ └── gflags_completions.h │ └── windows_include │ │ ├── gflags.h │ │ └── gflags_completions.h ├── hiredis │ ├── BUILD │ ├── adapters │ │ ├── ae.h │ │ ├── glib.h │ │ ├── ivykis.h │ │ ├── libev.h │ │ ├── libevent.h │ │ ├── libuv.h │ │ ├── macosx.h │ │ └── qt.h │ ├── async.h │ ├── dict.h │ ├── fmacros.h │ ├── hiredis.h │ ├── lib │ │ └── libhiredis.a │ ├── lib64_release │ ├── net.h │ ├── read.h │ ├── sds.h │ └── win32.h ├── libev │ ├── BUILD │ ├── include │ │ ├── config.h │ │ ├── ev++.h │ │ ├── ev.h │ │ ├── ev_vars.h │ │ ├── ev_wrap.h │ │ └── event.h │ ├── lib │ │ └── libev.a │ └── lib64_release ├── protobuf │ ├── BUILD │ ├── README.txt │ ├── bin │ │ └── protoc │ ├── include │ │ └── google │ │ │ └── protobuf │ │ │ ├── compiler │ │ │ ├── code_generator.h │ │ │ ├── command_line_interface.h │ │ │ ├── cpp │ │ │ │ └── cpp_generator.h │ │ │ ├── importer.h │ │ │ ├── java │ │ │ │ └── java_generator.h │ │ │ ├── parser.h │ │ │ ├── plugin.h │ │ │ ├── plugin.pb.h │ │ │ ├── plugin.proto │ │ │ └── python │ │ │ │ └── python_generator.h │ │ │ ├── descriptor.h │ │ │ ├── descriptor.pb.h │ │ │ ├── descriptor.proto │ │ │ ├── descriptor_database.h │ │ │ ├── dynamic_message.h │ │ │ ├── extension_set.h │ │ │ ├── generated_enum_reflection.h │ │ │ ├── generated_message_reflection.h │ │ │ ├── generated_message_util.h │ │ │ ├── io │ │ │ ├── coded_stream.h │ │ │ ├── gzip_stream.h │ │ │ ├── printer.h │ │ │ ├── strtod.h │ │ │ ├── tokenizer.h │ │ │ ├── zero_copy_stream.h │ │ │ ├── zero_copy_stream_impl.h │ │ │ └── zero_copy_stream_impl_lite.h │ │ │ ├── message.h │ │ │ ├── message_lite.h │ │ │ ├── reflection_ops.h │ │ │ ├── repeated_field.h │ │ │ ├── service.h │ │ │ ├── stubs │ │ │ ├── atomicops.h │ │ │ ├── atomicops_internals_arm_gcc.h │ │ │ ├── atomicops_internals_arm_qnx.h │ │ │ ├── atomicops_internals_atomicword_compat.h │ │ │ ├── atomicops_internals_macosx.h │ │ │ ├── atomicops_internals_mips_gcc.h │ │ │ ├── atomicops_internals_pnacl.h │ │ │ ├── atomicops_internals_x86_gcc.h │ │ │ ├── atomicops_internals_x86_msvc.h │ │ │ ├── common.h │ │ │ ├── once.h │ │ │ ├── platform_macros.h │ │ │ ├── stl_util.h │ │ │ ├── template_util.h │ │ │ └── type_traits.h │ │ │ ├── text_format.h │ │ │ ├── unknown_field_set.h │ │ │ ├── wire_format.h │ │ │ ├── wire_format_lite.h │ │ │ └── wire_format_lite_inl.h │ └── lib64_release │ │ ├── libprotobuf-lite.a │ │ ├── libprotobuf.a │ │ └── libprotoc.a ├── rapidjson │ ├── allocators.h │ ├── document.h │ ├── encodedstream.h │ ├── encodings.h │ ├── error │ │ ├── en.h │ │ └── error.h │ ├── filereadstream.h │ ├── filewritestream.h │ ├── internal │ │ ├── biginteger.h │ │ ├── diyfp.h │ │ ├── dtoa.h │ │ ├── ieee754.h │ │ ├── itoa.h │ │ ├── meta.h │ │ ├── pow10.h │ │ ├── stack.h │ │ ├── strfunc.h │ │ └── strtod.h │ ├── memorybuffer.h │ ├── memorystream.h │ ├── msinttypes │ │ ├── inttypes.h │ │ └── stdint.h │ ├── prettywriter.h │ ├── rapidjson.h │ ├── reader.h │ ├── stringbuffer.h │ └── writer.h └── zookeeper │ ├── BUILD │ ├── include │ ├── proto.h │ ├── recordio.h │ ├── zookeeper.h │ ├── zookeeper.jute.h │ ├── zookeeper_log.h │ └── zookeeper_version.h │ ├── lib64_release │ └── libzookeeper_st.a │ └── version.txt ├── tools ├── blade │ ├── COPYING │ ├── ChangeLog │ ├── OWNERS │ ├── README │ ├── blade │ ├── blade.conf │ ├── blade.zip │ ├── bladefunctions │ ├── bootstrap.py │ ├── cpplint.py │ ├── dist_blade │ ├── doc │ │ ├── blade.pdf │ │ ├── blade.ppt │ │ └── blade_user_manual.pdf │ ├── genlibbuild │ ├── google-libs.conf │ ├── install │ ├── lsnobuild │ ├── lsrc │ ├── merge-static-libs │ ├── opensource-release.sh │ ├── opensource.conf │ ├── src │ │ ├── blade │ │ │ ├── __init__.py │ │ │ ├── __main__.py │ │ │ ├── argparse.py │ │ │ ├── binary_runner.py │ │ │ ├── blade.py │ │ │ ├── blade_main.py │ │ │ ├── blade_platform.py │ │ │ ├── blade_util.py │ │ │ ├── build_environment.py │ │ │ ├── build_rules.py │ │ │ ├── cc_targets.py │ │ │ ├── command_args.py │ │ │ ├── configparse.py │ │ │ ├── console.py │ │ │ ├── cu_targets.py │ │ │ ├── dependency_analyzer.py │ │ │ ├── fbthrift_helper.py │ │ │ ├── fbthrift_library.py │ │ │ ├── gen_rule_target.py │ │ │ ├── java_jar_target.py │ │ │ ├── java_targets.py │ │ │ ├── lex_yacc_target.py │ │ │ ├── load_build_files.py │ │ │ ├── proto_library_target.py │ │ │ ├── py_targets.py │ │ │ ├── resource_library_target.py │ │ │ ├── rules_generator.py │ │ │ ├── scons_helper.py │ │ │ ├── swig_library_target.py │ │ │ ├── target.py │ │ │ ├── test_runner.py │ │ │ ├── test_scheduler.py │ │ │ ├── thrift_helper.py │ │ │ └── thrift_library.py │ │ └── test │ │ │ ├── blade_main_test.py │ │ │ ├── blade_test.py │ │ │ ├── cc_binary_test.py │ │ │ ├── cc_library_test.py │ │ │ ├── cc_plugin_test.py │ │ │ ├── cc_test_test.py │ │ │ ├── gen_rule_test.py │ │ │ ├── html_test_runner.py │ │ │ ├── java_jar_test.py │ │ │ ├── lex_yacc_test.py │ │ │ ├── load_builds_test.py │ │ │ ├── prebuild_cc_library_test.py │ │ │ ├── proto_library_test.py │ │ │ ├── query_target_test.py │ │ │ ├── resource_library_test.py │ │ │ ├── runalltests.sh │ │ │ ├── runtest.sh │ │ │ ├── swig_library_test.py │ │ │ ├── target_dependency_test.py │ │ │ ├── test_target_test.py │ │ │ └── testdata │ │ │ ├── BLADE_ROOT.TEST │ │ │ ├── test_cc_binary │ │ │ ├── BUILD.TEST │ │ │ ├── plowercase.cpp │ │ │ ├── puppercase.cpp │ │ │ └── string_main.cpp │ │ │ ├── test_cc_library │ │ │ ├── BUILD.TEST │ │ │ ├── blade_string.cpp │ │ │ ├── plowercase.cpp │ │ │ └── puppercase.cpp │ │ │ ├── test_cc_plugin │ │ │ ├── BUILD.TEST │ │ │ ├── plowercase.cpp │ │ │ ├── puppercase.cpp │ │ │ └── string_plugin.cpp │ │ │ ├── test_cc_test │ │ │ ├── BUILD.TEST │ │ │ ├── plowercase.cpp │ │ │ ├── puppercase.cpp │ │ │ └── string_test.cpp │ │ │ ├── test_dependency │ │ │ ├── BUILD.TEST │ │ │ ├── java │ │ │ │ ├── BUILD.TEST │ │ │ │ └── lib │ │ │ │ │ └── BUILD.TEST │ │ │ └── test │ │ │ │ └── BUILD.TEST │ │ │ ├── test_gen_rule │ │ │ ├── BUILD.TEST │ │ │ ├── plowercase.cpp │ │ │ └── puppercase.cpp │ │ │ ├── test_java_jar │ │ │ ├── BUILD.TEST │ │ │ ├── java │ │ │ │ ├── BUILD.TEST │ │ │ │ └── lib │ │ │ │ │ ├── BUILD.TEST │ │ │ │ │ └── junit.jar │ │ │ ├── poppy_client.i │ │ │ ├── rpc_meta_info.proto │ │ │ ├── rpc_option.proto │ │ │ └── rpc_server.cc │ │ │ ├── test_lex_yacc │ │ │ ├── BUILD.TEST │ │ │ ├── line_parser.ll │ │ │ ├── line_parser.yy │ │ │ └── plowercase.cpp │ │ │ ├── test_loadbuilds │ │ │ └── BUILD.TEST │ │ │ ├── test_prebuild_cc_library │ │ │ ├── BUILD.TEST │ │ │ └── puppercase.cpp │ │ │ ├── test_proto_library │ │ │ ├── BUILD.TEST │ │ │ ├── plowercase.cpp │ │ │ ├── rpc_meta_info.proto │ │ │ └── rpc_option.proto │ │ │ ├── test_query │ │ │ ├── BUILD.TEST │ │ │ ├── java │ │ │ │ ├── BUILD.TEST │ │ │ │ └── lib │ │ │ │ │ └── BUILD.TEST │ │ │ └── test │ │ │ │ └── BUILD.TEST │ │ │ ├── test_resource_library │ │ │ ├── BUILD.TEST │ │ │ ├── forms.js │ │ │ ├── plowercase.cpp │ │ │ └── poppy.html │ │ │ ├── test_swig_library │ │ │ ├── BUILD.TEST │ │ │ ├── plowercase.cpp │ │ │ └── poppy_client.i │ │ │ ├── test_test_runner │ │ │ ├── BUILD.TEST │ │ │ ├── plowercase.cpp │ │ │ ├── puppercase.cpp │ │ │ ├── string_test.cpp │ │ │ └── string_test_2.cpp │ │ │ └── thirdparty │ │ │ ├── gtest │ │ │ └── BUILD.TEST │ │ │ └── protobuf │ │ │ └── BUILD.TEST │ ├── typhoon.conf │ └── vim │ │ ├── ftdetect │ │ └── blade.vim │ │ ├── indent │ │ └── blade.vim │ │ └── syntax │ │ └── blade.vim ├── compiler │ ├── dr │ │ ├── BUILD │ │ ├── CMakeLists.txt │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── README.md │ │ ├── compiler.sln │ │ ├── compiler.vcxproj │ │ ├── compiler.vcxproj.filters │ │ ├── readme.txt │ │ ├── src │ │ │ ├── generate │ │ │ │ ├── t_as3_generator.cc │ │ │ │ ├── t_c_glib_generator.cc │ │ │ │ ├── t_cocoa_generator.cc │ │ │ │ ├── t_cpp_client_generator.cc │ │ │ │ ├── t_cpp_generator.cc │ │ │ │ ├── t_csharp_generator.cc │ │ │ │ ├── t_d_generator.cc │ │ │ │ ├── t_delphi_generator.cc │ │ │ │ ├── t_erl_generator.cc │ │ │ │ ├── t_generator.cc │ │ │ │ ├── t_generator.h │ │ │ │ ├── t_generator_registry.h │ │ │ │ ├── t_go_generator.cc │ │ │ │ ├── t_gv_generator.cc │ │ │ │ ├── t_hs_generator.cc │ │ │ │ ├── t_html_generator.cc │ │ │ │ ├── t_html_generator.h │ │ │ │ ├── t_java_generator.cc │ │ │ │ ├── t_javame_generator.cc │ │ │ │ ├── t_js_generator.cc │ │ │ │ ├── t_json_generator.cc │ │ │ │ ├── t_lua_generator.cc │ │ │ │ ├── t_ocaml_generator.cc │ │ │ │ ├── t_oop_generator.h │ │ │ │ ├── t_perl_generator.cc │ │ │ │ ├── t_php_generator.cc │ │ │ │ ├── t_py_generator.cc │ │ │ │ ├── t_rb_generator.cc │ │ │ │ ├── t_st_generator.cc │ │ │ │ └── t_xsd_generator.cc │ │ │ ├── globals.h │ │ │ ├── logging.h │ │ │ ├── main.cc │ │ │ ├── main.h │ │ │ ├── md5.c │ │ │ ├── md5.h │ │ │ ├── parse │ │ │ │ ├── parse.cc │ │ │ │ ├── t_attributes.h │ │ │ │ ├── t_base_type.h │ │ │ │ ├── t_const.h │ │ │ │ ├── t_const_value.h │ │ │ │ ├── t_container.h │ │ │ │ ├── t_doc.h │ │ │ │ ├── t_enum.h │ │ │ │ ├── t_enum_value.h │ │ │ │ ├── t_field.h │ │ │ │ ├── t_function.h │ │ │ │ ├── t_list.h │ │ │ │ ├── t_map.h │ │ │ │ ├── t_program.h │ │ │ │ ├── t_scope.h │ │ │ │ ├── t_service.h │ │ │ │ ├── t_set.h │ │ │ │ ├── t_struct.h │ │ │ │ ├── t_type.h │ │ │ │ ├── t_typedef.cc │ │ │ │ └── t_typedef.h │ │ │ ├── platform.h │ │ │ ├── thriftl.cc │ │ │ ├── thriftl.ll │ │ │ ├── thrifty.cc │ │ │ ├── thrifty.hh │ │ │ ├── thrifty.yy │ │ │ └── windows │ │ │ │ ├── config.h │ │ │ │ ├── version.h │ │ │ │ └── version.h.in │ │ ├── version.h │ │ └── version.h.in │ └── pb │ │ ├── BUILD │ │ └── src │ │ ├── cpp_generator.cpp │ │ ├── cpp_generator.h │ │ ├── cpp_generator_helpers.h │ │ └── cpp_plugin.cpp ├── release │ ├── README.txt │ ├── copy_release.sh │ └── pack_release.sh ├── scons │ └── scons-2.3.4.tar.gz └── zookeeper │ └── zookeeper-3.4.6.tar.gz └── version.inh /BLADE_ROOT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/BLADE_ROOT -------------------------------------------------------------------------------- /INSTALL.txt: -------------------------------------------------------------------------------- 1 | 开发环境搭建和使用说明: 2 | 3 | 4 | 请确保机器已安装python 2.6以上版本。 5 | 6 | 一、编译 7 | 1、如何安装blade 8 | blade的内容已经放在目录tools/blade下 9 | 10 | cd blade 11 | ./install 12 | source ~/.bash_profile 13 | 14 | 2、如何安装scons 15 | scons2.3.4的内容已经放在目录tools/scons下 16 | 17 | cd scons 18 | tar xvf scons-2.3.4.tar.gz 19 | cd scons-2.3.4 20 | python setup.py install 21 | 22 | blade依赖scons 2.0以上版本。如有其他需要,可以到下面地址下载: 23 | http://www.scons.org/download.php 24 | 25 | 3、编译所有内容 26 | 进入项目根目录 27 | blade build ... 28 | 注:blade是一个编译工具,其文档在:tools/blade/doc 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/LICENSE.TXT -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | 项目目前是存档状态,感谢您对腾讯开源项目的关注!您可以继续fork后更新迭代,感谢理解和支持;如果您有其他疑问,建议请发送邮件:tencentopen@tencent.com 与我们联系 2 | 3 | ----- 4 | 5 | 6 | # 分布式开发框架Pebble使用说明 7 | 8 | ---------- 9 | ## 简介 10 | 11 | Pebble定位为一个好用、可靠、高性能、易扩展的分布式开发框架,支持多种使用方式: 12 | 13 | 14 | - 使用完整的pebble框架 15 | - 独立使用各pebble子模块 16 | - 在其他框架中嵌入pebble框架。 17 | 18 | Pebble具备良好的扩展性,可非常方便的扩展对接现有系统。基于该框架,可以让开发者只需专注于业务逻辑的实现,而不需要关注基础功能的开发,如网络通信,数据存储,集群管理等。使用pebble配套的运营系统,可方便的进行游戏开区开服,版本升级,扩容缩容等操作。 19 | 20 | ## 功能 21 | 22 | - **通信**:提供了基于消息的通信接口,默认自带TCP/UDP网络库,用户可方便的对接到其他网络库或消息队列服务。 23 | 24 | - **服务管理**:有了服务管理功能,客户端无需手工配置服务器端的地址即可通信。每一个服务(service)都有一个唯一的名字,服务由一组具体的函数组成,每个服务器进程可以管理多个服务。Pebble提供了名字服务接口,使用Pebble框架,服务端可方便的将服务地址注册到名字服务器,客户端可以方便的从名字服务器拉取到服务的地址信息。我们提供了基于[ZooKeeper](http://zookeeper.apache.org)的名字服务参考实现,用户也可以很方便的扩展自己的名字服务。 25 | 26 | - **集群管理**:基于Zookeeper的名字服务实现,服务进程启动后,会自动与ZooKeeper之间维持心跳。客户端会定时从ZooKeeper获取服务器端的地址信息,一旦服务进程故障,客户端会自动将其从服务列表中去除。同理,增加服务进程也是一样。从而可方便的实现集群状态管理,可方便的对服务器进行扩容和缩容。 27 | 28 | - **RPC**:同时支持Thrift和ProtoBuf两种IDL,一致的RPC编程接口,支持同步、异步、并行调用,用户可以很方便的扩展支持其他IDL。 29 | 30 | - **协程**:协程可降低异步代码的复杂度,让代码看起来像同步一样,同时具有异步的性能。开发框架很好的集成了协程的功能,RPC服务处理默认在一个协程里面。当服务器端收到客户端的RPC请求时,系统会自动为你创建协程,请注意不要调用阻塞操作。如果要调用阻塞操作,需要将其修改为以协程的方式调用,否则整个server的处理能力会受到影响。 31 | 32 | - **广播**:广播是游戏业务的一个常见需求。pebble支持服务器端server之间的广播,也支持多服务器与多手机客户端之间的广播。无论是手机客户端还是后台服务器,只要大家加入一个相同的频道(channel),就可以做到一呼百应。广播功能是在RPC的基础上实现,所以它的编程体验与RPC是一致的。 33 | 34 | - **进程框架**:它是一个单线程的开发框架,集成了上述功能。内置统计上报、过载保护、控制命令等功能,使用我们的框架,只需要调用少量接口,即可快速开发出游戏后台server。 35 | 36 | - **配套工具**:自带了控制命令工具,方便集中运维与调试。 37 | 38 | 39 | ## 技术交流 40 | 41 | QQ群:231407428 42 | 43 | ----- 44 | 45 | 46 | Copyright ©1998 - 2015 Tencent. All Rights Reserved. 47 | 48 | 腾讯公司 版权所有 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /doc/FAQ.markdown: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/doc/FAQ.markdown -------------------------------------------------------------------------------- /doc/HelloWorld.markdown: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/doc/HelloWorld.markdown -------------------------------------------------------------------------------- /example/hello_world/BUILD: -------------------------------------------------------------------------------- 1 | gen_rule( 2 | name = 'gen_hello', 3 | srcs = [ 4 | 'hello.pebble', 5 | ], 6 | cmd = '$BUILD_DIR/tools/compiler/dr/pebble -r -out $BUILD_DIR/example/hello_world --gen cpp $SRCS', 7 | deps = [ 8 | '//tools/compiler/dr:pebble', 9 | ], 10 | outs = [ 11 | 'hello.cpp', 12 | 'hello_HelloWorld.cpp', 13 | 'hello.h', 14 | 'hello_HelloWorld.h', 15 | 'hello_HelloWorld.inh', 16 | ], 17 | ) 18 | 19 | cc_library( 20 | name = 'hello', 21 | srcs = [ 22 | 'hello.cpp', 23 | 'hello_HelloWorld.cpp', 24 | ], 25 | incs = [ 26 | ], 27 | deps = [ 28 | ':gen_hello', 29 | '//src/framework/:pebble_framework', 30 | ] 31 | ) 32 | 33 | cc_binary( 34 | name = 'client', 35 | srcs = [ 36 | 'client.cpp', 37 | ], 38 | incs = [ 39 | ], 40 | deps = [ 41 | ':hello', 42 | '//src/client/:pebble_client', 43 | ], 44 | ) 45 | cc_binary( 46 | name = 'server', 47 | srcs = [ 48 | 'server.cpp', 49 | ], 50 | incs = [ 51 | ], 52 | deps = [ 53 | ':hello', 54 | '//src/server/:pebble_server', 55 | '//thirdparty/gflags:gflags', 56 | ], 57 | ) 58 | 59 | gen_rule( 60 | name = 'cp_cfg', 61 | srcs = [ 62 | 'cfg', 63 | ], 64 | cmd = 'cp $BUILD_DIR/../example/hello_world/cfg -rf $BUILD_DIR/example/hello_world', 65 | deps = [ 66 | ':server', 67 | ], 68 | outs = [ 69 | 'pebble.ini', 70 | ], 71 | ) 72 | 73 | -------------------------------------------------------------------------------- /example/hello_world/Makefile: -------------------------------------------------------------------------------- 1 | # make file for examples 2 | 3 | BASE_PATH = ../.. 4 | PEBBLE = $(BASE_PATH)/tools/pebble 5 | 6 | INC_PATH = $(BASE_PATH)/include 7 | LIB_PATH = $(BASE_PATH)/lib 8 | PEBBLE_LIB = $(LIB_PATH)/pebble 9 | THIRDPATY = $(LIB_PATH)/thirdparty 10 | 11 | PEBBLE_IDL = hello.pebble 12 | PEBBLE_SRC = hello.cpp hello_HelloWorld.cpp 13 | PEBBLE_H = hello.h hello_HelloWorld.h hello_HelloWorld.inh 14 | PEBBLE_OBJ = $(subst .cpp,.o, $(PEBBLE_SRC)) 15 | 16 | SERVER_SRC = server.cpp 17 | SERVER_OBJ = $(subst .cpp,.o, $(SERVER_SRC)) 18 | SERVER = server 19 | 20 | CLIENT_SRC = client.cpp 21 | CLIENT_OBJ = $(subst .cpp,.o, $(CLIENT_SRC)) 22 | CLIENT = client 23 | 24 | INC_FLAGS = -I$(BASE_PATH) -I$(INC_PATH)/pebble -I$(INC_PATH)/thirdparty 25 | 26 | LD_FLAGS = -L$(PEBBLE_LIB) -L$(THIRDPATY) \ 27 | -lpebble -lgflags 28 | LD_FLAGS_CLIENT = -L$(PEBBLE_LIB) -L$(THIRDPATY) \ 29 | -lpebble_client 30 | 31 | CC_FLAGS = -g -Wall -Werror $(INC_FLAGS) 32 | 33 | CC = g++ 34 | 35 | .PHONY: all clean 36 | 37 | all: $(SERVER) $(CLIENT) 38 | 39 | $(SERVER): $(PEBBLE_OBJ) $(SERVER_OBJ) 40 | $(CC) -o $@ $^ $(LD_FLAGS) 41 | 42 | $(CLIENT): $(PEBBLE_OBJ) $(CLIENT_OBJ) 43 | $(CC) -o $@ $^ $(LD_FLAGS_CLIENT) 44 | 45 | $(PEBBLE_SRC): $(PEBBLE_IDL) 46 | $(PEBBLE) -r -out ./ --gen cpp $< 47 | 48 | %.o: %.cpp 49 | $(CC) -o $@ -c $< $(CC_FLAGS) 50 | 51 | clean: 52 | rm -rf $(SERVER) $(CLIENT) ./*.o ./log $(PEBBLE_SRC) $(PEBBLE_H) 53 | 54 | -------------------------------------------------------------------------------- /example/hello_world/cfg/pebble.ini: -------------------------------------------------------------------------------- 1 | [app] 2 | ; 和应用相关的配置,当程序由分布式计算平台管理时,下面配置均由运营系统分配。开发者测试时可自行配置。 3 | app_id = 0 ; 应用ID 4 | app_key = app_key ; 应用的key,和app_id对应,为此程序在名字服务等中的密钥 5 | instance_id = 0 ; 应用的实例ID 6 | unit_id = 0; 7 | program_id = 0; 8 | ;ctrl_cmd_address = http://127.0.0.1:8800/0/control ; 控制命令监听地址 9 | ctrl_cmd_address = tcp://127.0.0.1:9000 ; 控制命令监听地址 10 | ;ctrl_cmd_address = udp://127.0.0.1:9001 ; 控制命令监听地址 11 | ;ctrl_cmd_address = tbuspp://0.control/0 ; 控制命令监听地址 12 | 13 | [coroutine] 14 | stack_size = 0xffff; 协程栈大小(单位字节),默认为256K 15 | 16 | [log] 17 | device = FILE ; 打印输出方式 { FILE、STDOUT } 18 | priority = INFO ; 打印级别 { TRACE, DEBUG, INFO, ERROR, FATAL } 19 | file_size = 10 ; 单个log文件的最大大小,单位为"M bytes" 20 | roll_num = 10 ; 日志文件滚动个数 21 | log_path = ./log ; 日志文件存储路径 22 | 23 | [stat] 24 | report_cycle_s = 60 ; 统计输出周期,单位为秒 25 | report_to_gdata = 2 ; 是否上报给告警分析系统 { 0:不上报 1:逐条上报 2:按统计输出周期上报 } 26 | gdata_id = 7 ; 由告警分析系统分配的框架的业务id 27 | gdata_log_id = 10 ; 由告警分析系统分配的框架的日志id 28 | gdata_log_path = ./log/gdata ; 告警分析上报写本地文件路径 29 | 30 | [flow_control] 31 | enable = 1 ; 是否打开流控,0 - 关闭,其它 - 打开 32 | task_threshold = 10000 ; 系统处理消息门限 33 | message_expire_ms = 10000 ; 消息过期时间(单位ms) 34 | 35 | [broadcast] 36 | relay_address = ; 接收其他server转发的广播消息的监听地址 37 | zk_host = ; 广播的频道信息存储在zk上,zk地址格式为 ip:port,多个地址之间使用','分隔 38 | zk_connect_timeout_ms = 20000 ; 与zk连接的超时时间,单位ms,建议设置区间为 [2000, 20000] 39 | -------------------------------------------------------------------------------- /example/hello_world/hello.pebble: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/example/hello_world/hello.pebble -------------------------------------------------------------------------------- /example/pebble_cmdline/BUILD: -------------------------------------------------------------------------------- 1 | 2 | cc_binary( 3 | name = 'server', 4 | srcs = [ 5 | 'server.cpp', 6 | ], 7 | incs = [ 8 | '../../thirdparty/gflags', 9 | ], 10 | deps = [ 11 | '#pthread', 12 | '//src/server/:pebble_server', 13 | '//thirdparty/gflags:gflags', 14 | ], 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /example/pebble_cmdline/Makefile: -------------------------------------------------------------------------------- 1 | # make file for examples 2 | 3 | BASE_PATH = ../.. 4 | 5 | INC_PATH = $(BASE_PATH)/include 6 | LIB_PATH = $(BASE_PATH)/lib 7 | PEBBLE_LIB = $(LIB_PATH)/pebble 8 | THIRDPATY = $(LIB_PATH)/thirdparty 9 | 10 | 11 | SERVER_SRC = server.cpp 12 | SERVER_OBJ = $(subst .cpp,.o, $(SERVER_SRC)) 13 | SERVER = server 14 | 15 | 16 | INC_FLAGS = -I$(BASE_PATH) -I$(INC_PATH)/pebble -I$(INC_PATH)/thirdparty 17 | 18 | LD_FLAGS = -L$(PEBBLE_LIB) -L$(THIRDPATY) \ 19 | -lpebble -lgflags 20 | 21 | CC_FLAGS = -g -Wall -Werror $(INC_FLAGS) 22 | 23 | CC = g++ 24 | 25 | .PHONY: all clean 26 | 27 | all: $(SERVER) 28 | 29 | $(SERVER): $(SERVER_OBJ) 30 | $(CC) -o $@ $^ $(LD_FLAGS) 31 | 32 | %.o: %.cpp 33 | $(CC) -o $@ -c $< $(CC_FLAGS) 34 | 35 | clean: 36 | rm -rf $(SERVER) ./*.o ./*.pid ./log 37 | 38 | -------------------------------------------------------------------------------- /example/pebble_cmdline/server.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include "gflags/gflags.h" 19 | #include "server/pebble_cmdline.h" 20 | #include "server/pebble.h" 21 | 22 | 23 | #define ASSERT_EQ(expected, actual) \ 24 | if ((expected) != (actual)) { \ 25 | fprintf(stderr, "(%s:%d)(%s) %d != %d\n", \ 26 | __FILE__, __LINE__, __FUNCTION__, (expected), (actual)); \ 27 | exit(1); \ 28 | } 29 | 30 | // 用户自定义命令行参数: 增加一行定义即可 31 | DEFINE_string(port, "8800", "service listen port."); 32 | 33 | int main(int argc, char** argv) { 34 | // 在程序开始处处理命令行参数 35 | pebble::CmdLineHandler cmdline_handler; 36 | cmdline_handler.SetVersion("pebble cmdline test 0.1.0"); 37 | int ret = cmdline_handler.Process(argc, argv); 38 | ASSERT_EQ(0, ret); 39 | 40 | // 获取用户自定义命令行参数 41 | std::cout << "cmd para port = " << FLAGS_port << std::endl; 42 | 43 | // 启动pebble server 44 | pebble::PebbleServer server; 45 | ret = server.Init(); 46 | ASSERT_EQ(0, ret); 47 | 48 | server.Serve(); 49 | 50 | return 0; 51 | } 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /example/pebble_ctrl_cmd/BUILD: -------------------------------------------------------------------------------- 1 | 2 | cc_binary( 3 | name = 'server', 4 | srcs = [ 5 | 'server.cpp', 6 | ], 7 | incs = [ 8 | ], 9 | deps = [ 10 | '#pthread', 11 | '//src/server/:pebble_server', 12 | ], 13 | ) 14 | 15 | gen_rule( 16 | name = 'cp_cfg', 17 | srcs = [ 18 | 'cfg', 19 | ], 20 | cmd = 'cp $BUILD_DIR/../example/pebble_ctrl_cmd/cfg -rf $BUILD_DIR/example/pebble_ctrl_cmd', 21 | deps = [ 22 | ':server', 23 | ], 24 | outs = [ 25 | 'pebble.ini', 26 | ], 27 | ) 28 | 29 | -------------------------------------------------------------------------------- /example/pebble_ctrl_cmd/Makefile: -------------------------------------------------------------------------------- 1 | # make file for examples 2 | 3 | BASE_PATH = ../.. 4 | 5 | INC_PATH = $(BASE_PATH)/include 6 | LIB_PATH = $(BASE_PATH)/lib 7 | PEBBLE_LIB = $(LIB_PATH)/pebble 8 | THIRDPATY = $(LIB_PATH)/thirdparty 9 | 10 | 11 | SERVER_SRC = server.cpp 12 | SERVER_OBJ = $(subst .cpp,.o, $(SERVER_SRC)) 13 | SERVER = server 14 | 15 | 16 | INC_FLAGS = -I$(BASE_PATH) -I$(INC_PATH)/pebble -I$(INC_PATH)/thirdparty 17 | 18 | LD_FLAGS = -L$(PEBBLE_LIB) -L$(THIRDPATY) \ 19 | -lpebble -lhttp_protocol_api -ltbuspp -ltbuspp_proto -lprotobuf -lmysqlpp -lmysqlclient -lz -lpthread 20 | 21 | CC_FLAGS = -g -Wall -Werror $(INC_FLAGS) 22 | 23 | CC = g++ 24 | 25 | .PHONY: all clean 26 | 27 | all: $(SERVER) 28 | 29 | $(SERVER): $(SERVER_OBJ) 30 | $(CC) -o $@ $^ $(LD_FLAGS) 31 | 32 | %.o: %.cpp 33 | $(CC) -o $@ -c $< $(CC_FLAGS) 34 | 35 | clean: 36 | rm -rf $(SERVER) ./*.o ./*.pid ./log 37 | 38 | -------------------------------------------------------------------------------- /example/pebble_ctrl_cmd/cfg/pebble.ini: -------------------------------------------------------------------------------- 1 | [app] 2 | ; 和应用相关的配置,当程序由分布式计算平台管理时,下面配置均由运营系统分配。开发者测试时可自行配置。 3 | app_id = 0 ; 应用ID 4 | app_key = app_key ; 应用的key,和app_id对应,为此程序在名字服务等中的密钥 5 | instance_id = 0 ; 应用的实例ID 6 | unit_id = 0; 7 | program_id = 0; 8 | ;ctrl_cmd_address = http://127.0.0.1:8800/0/control ; 控制命令监听地址 9 | ctrl_cmd_address = tcp://127.0.0.1:9000 ; 控制命令监听地址 10 | ;ctrl_cmd_address = udp://127.0.0.1:9001 ; 控制命令监听地址 11 | ;ctrl_cmd_address = tbuspp://0.control/0 ; 控制命令监听地址 12 | 13 | [coroutine] 14 | stack_size = 0xffff; 协程栈大小(单位字节),默认为256K 15 | 16 | [log] 17 | device = FILE ; 打印输出方式 { FILE、STDOUT } 18 | priority = INFO ; 打印级别 { TRACE, DEBUG, INFO, ERROR, FATAL } 19 | file_size = 10 ; 单个log文件的最大大小,单位为"M bytes" 20 | roll_num = 10 ; 日志文件滚动个数 21 | log_path = ./log ; 日志文件存储路径 22 | 23 | [stat] 24 | report_cycle_s = 60 ; 统计输出周期,单位为秒 25 | report_to_gdata = 2 ; 是否上报给告警分析系统 { 0:不上报 1:逐条上报 2:按统计输出周期上报 } 26 | gdata_id = 7 ; 由告警分析系统分配的框架的业务id 27 | gdata_log_id = 10 ; 由告警分析系统分配的框架的日志id 28 | gdata_log_path = ./log/gdata ; 告警分析上报写本地文件路径 29 | 30 | [flow_control] 31 | enable = 1 ; 是否打开流控,0 - 关闭,其它 - 打开 32 | task_threshold = 10000 ; 系统处理消息门限 33 | message_expire_ms = 10000 ; 消息过期时间(单位ms) 34 | 35 | [broadcast] 36 | relay_address = ; 接收其他server转发的广播消息的监听地址 37 | zk_host = ; 广播的频道信息存储在zk上,zk地址格式为 ip:port,多个地址之间使用','分隔 38 | zk_connect_timeout_ms = 20000 ; 与zk连接的超时时间,单位ms,建议设置区间为 [2000, 20000] 39 | -------------------------------------------------------------------------------- /example/pebble_idl/BUILD: -------------------------------------------------------------------------------- 1 | gen_rule( 2 | name = 'gen_idl', 3 | srcs = [ 4 | 'idl.pebble', 5 | ], 6 | cmd = '$BUILD_DIR/tools/compiler/dr/pebble -out $BUILD_DIR/example/pebble_idl --gen cpp $SRCS', 7 | deps = [ 8 | '//tools/compiler/dr:pebble', 9 | ], 10 | outs = [ 11 | 'idl.cpp', 12 | 'idl.h', 13 | 'idl_UserInfoManager.h', 14 | 'idl_UserInfoManager.inh', 15 | 'idl_UserInfoManager.cpp', 16 | ], 17 | ) 18 | 19 | gen_rule( 20 | name = 'gen_idlex', 21 | srcs = [ 22 | 'idlex.pebble', 23 | ], 24 | cmd = '$BUILD_DIR/tools/compiler/dr/pebble -out $BUILD_DIR/example/pebble_idl --gen cpp $SRCS', 25 | deps = [ 26 | '//tools/compiler/dr:pebble', 27 | ], 28 | outs = [ 29 | 'idlex.cpp', 30 | 'idlex.h', 31 | 'idlex_UserInfoManagerEx.h', 32 | 'idlex_UserInfoManagerEx.inh', 33 | 'idlex_UserInfoManagerEx.cpp', 34 | ], 35 | ) 36 | 37 | cc_library( 38 | name = 'idl', 39 | srcs = [ 40 | 'idl.cpp', 41 | 'idl_UserInfoManager.cpp', 42 | 'idlex.cpp', 43 | 'idlex_UserInfoManagerEx.cpp', 44 | ], 45 | incs = [ 46 | ], 47 | deps = [ 48 | ':gen_idl', 49 | ':gen_idlex', 50 | '//src/framework/:pebble_framework', 51 | ] 52 | ) 53 | 54 | cc_binary( 55 | name = 'client', 56 | srcs = [ 57 | 'client.cpp', 58 | ], 59 | incs = [ 60 | ], 61 | deps = [ 62 | ':idl', 63 | '#pthread', 64 | '//src/server/:pebble_server', 65 | ], 66 | ) 67 | cc_binary( 68 | name = 'server', 69 | srcs = [ 70 | 'server.cpp', 71 | ], 72 | incs = [ 73 | ], 74 | deps = [ 75 | ':idl', 76 | '#pthread', 77 | '//src/server/:pebble_server', 78 | ], 79 | ) 80 | 81 | -------------------------------------------------------------------------------- /example/pebble_idl/Makefile: -------------------------------------------------------------------------------- 1 | # make file for examples 2 | 3 | BASE_PATH = ../.. 4 | PEBBLE = $(BASE_PATH)/tools/pebble 5 | 6 | INC_PATH = $(BASE_PATH)/include 7 | LIB_PATH = $(BASE_PATH)/lib 8 | PEBBLE_LIB = $(LIB_PATH)/pebble 9 | THIRDPATY = $(LIB_PATH)/thirdparty 10 | 11 | PEBBLE_IDL = idlex.pebble 12 | PEBBLE_SRC = idl.cpp idlex.cpp idl_UserInfoManager.cpp idlex_UserInfoManagerEx.cpp 13 | PEBBLE_H = idl.h idlex.h idl_UserInfoManager.h idl_UserInfoManager.inh idlex_UserInfoManagerEx.inh idlex_UserInfoManagerEx.h 14 | PEBBLE_OBJ = $(subst .cpp,.o, $(PEBBLE_SRC)) 15 | 16 | SERVER_SRC = server.cpp 17 | SERVER_OBJ = $(subst .cpp,.o, $(SERVER_SRC)) 18 | SERVER = server 19 | 20 | CLIENT_SRC = client.cpp 21 | CLIENT_OBJ = $(subst .cpp,.o, $(CLIENT_SRC)) 22 | CLIENT = client 23 | 24 | INC_FLAGS = -I$(BASE_PATH) -I$(INC_PATH)/pebble -I$(INC_PATH)/thirdparty 25 | 26 | LD_FLAGS = -L$(PEBBLE_LIB) -L$(THIRDPATY) \ 27 | -lpebble 28 | 29 | CC_FLAGS = -g -Wall -Werror $(INC_FLAGS) 30 | 31 | CC = g++ 32 | 33 | .PHONY: all clean 34 | 35 | all: $(SERVER) $(CLIENT) 36 | 37 | $(SERVER): $(PEBBLE_OBJ) $(SERVER_OBJ) 38 | $(CC) -o $@ $^ $(LD_FLAGS) 39 | 40 | $(CLIENT): $(PEBBLE_OBJ) $(CLIENT_OBJ) 41 | $(CC) -o $@ $^ $(LD_FLAGS) 42 | 43 | $(PEBBLE_SRC): $(PEBBLE_IDL) 44 | $(PEBBLE) -r -out ./ --gen cpp $< 45 | 46 | %.o: %.cpp 47 | $(CC) -o $@ -c $< $(CC_FLAGS) 48 | 49 | clean: 50 | rm -rf $(SERVER) $(CLIENT) ./*.o ./log $(PEBBLE_SRC) $(PEBBLE_H) 51 | 52 | -------------------------------------------------------------------------------- /example/pebble_idl/idl.pebble: -------------------------------------------------------------------------------- 1 | 2 | /**************************************************** 3 | pebble IDL语法说明 4 | 1. 支持基本数据类型: 5 | void 6 | bool true or false 7 | byte 8位字节 8 | i16 16位有符号整数 9 | i32 32位有符号整数 10 | i64 64位有符号整数 11 | i16(u) 16位无符号整数 12 | i32(u) 32位无符号整数 13 | i64(u) 64位无符号整数 14 | double 64位浮点数 15 | string 字符串 16 | binary 未编码的字节序列 17 | list 指定类型的元素列表 18 | set 指定类型的元素结合,集合中元素唯一 19 | map 两种类型元素的映射 20 | 21 | 2. 支持enum、struct、union 22 | 3. 支持service定义 23 | 4. 支持include其他IDL文件(引用其中的数据结构或service) 24 | 5. 其他关键字 25 | typedef 26 | const 27 | oneway 单向请求(不需要响应) 28 | required 必选字段 29 | optional 可选字段 30 | & 引用标识 31 | ****************************************************/ 32 | 33 | // 指定名字空间 34 | namespace cpp example 35 | 36 | 37 | /* 定义常量,对复杂数据类型或struct的值使用json格式描述 */ 38 | const i32 MAX_HEAD_LEN = 128 39 | const i32 MAX_DATA_LEN = 1024 40 | const string VERSION = "1.0.0" 41 | 42 | 43 | # 定义枚举,同C语言定义,枚举值为32位有符号整数,可以指定值,不指定时默认从1开始 44 | enum ErrorCode { 45 | NO_ERROR = 0, 46 | INVALID_PARAM = -1, 47 | NOT_FOUND = -2, 48 | MISSING_RESULT = -3, 49 | SYSTEM_ERROR = -99, 50 | } 51 | 52 | 53 | // 定义struct,每个字段需要指定唯一的序号(整形),每个字段默认都是必选的,可以使用optional 54 | // 修饰可选字段,可选字段需要显式设置才会被序列化 55 | struct UserInfo { 56 | 1: string name, 57 | 2: i32 age, 58 | } 59 | struct Message { 60 | 1: i32 _result = ErrorCode.NO_ERROR, // 可以给字段附默认值 61 | 2: UserInfo _user, 62 | 3: optional string _comment, 63 | } 64 | 65 | // 定义服务,服务包含一个或多个接口定义,服务之间可以继承 66 | service UserInfoManager { 67 | Message get_user(1: i64(u) id) (timeoutms=1000), // 支持给每个接口指定超时时间,不指定时默认为10s 68 | 69 | i64(u) add_user(1: UserInfo user, 2: string comment) (timeoutms=2000), 70 | } 71 | 72 | -------------------------------------------------------------------------------- /example/pebble_idl/idlex.pebble: -------------------------------------------------------------------------------- 1 | 2 | // 可以引用其他IDL文件中定义的数据结构和服务,默认在当前目录下查找引用文件, 3 | // 也可以在代码生成工具指定搜索路径,如 ./pebble -I ../../include 4 | include "idl.pebble" 5 | 6 | // 名字空间可以和include的不同 7 | namespace cpp example_ex 8 | 9 | 10 | // 使用extends扩展其他服务,这里扩展了idl.pebble文件中定义的UserInfoManager服务,写法为'extends idl.UserInfoManager' 11 | service UserInfoManagerEx extends idl.UserInfoManager { 12 | // oneway 消息表示单向请求,不需要等待任何应答 13 | oneway void delete_user(1: i64(u) id), 14 | 15 | // 可以引用其他IDL文件中定义的数据结构,这里引用了idl.pebble文件中定义的Message,写法为'idl.Message' 16 | list get_user_list(1: list ids), 17 | } 18 | 19 | -------------------------------------------------------------------------------- /example/pebble_server/BUILD: -------------------------------------------------------------------------------- 1 | gen_rule( 2 | name = 'gen_calculator', 3 | srcs = [ 4 | 'calculator.pebble', 5 | ], 6 | cmd = '$BUILD_DIR/tools/compiler/dr/pebble -r -out $BUILD_DIR/example/pebble_server --gen cpp $SRCS', 7 | deps = [ 8 | '//tools/compiler/dr:pebble', 9 | ], 10 | outs = [ 11 | 'calculator.cpp', 12 | 'calculator_Calculator.cpp', 13 | 'calculator.h', 14 | 'calculator_Calculator.h', 15 | 'calculator_Calculator.inh', 16 | ], 17 | ) 18 | 19 | cc_library( 20 | name = 'calculator', 21 | srcs = [ 22 | 'calculator.cpp', 23 | 'calculator_Calculator.cpp', 24 | ], 25 | incs = [ 26 | ], 27 | deps = [ 28 | ':gen_calculator', 29 | '//src/framework/:pebble_framework', 30 | ] 31 | ) 32 | 33 | cc_binary( 34 | name = 'client', 35 | srcs = [ 36 | 'client.cpp', 37 | ], 38 | incs = [ 39 | ], 40 | deps = [ 41 | ':calculator', 42 | '//src/client/:pebble_client', 43 | ], 44 | ) 45 | cc_binary( 46 | name = 'server', 47 | srcs = [ 48 | 'server.cpp', 49 | ], 50 | incs = [ 51 | ], 52 | deps = [ 53 | ':calculator', 54 | '//src/server/:pebble_server', 55 | ], 56 | ) 57 | 58 | -------------------------------------------------------------------------------- /example/pebble_server/Makefile: -------------------------------------------------------------------------------- 1 | # make file for examples 2 | 3 | BASE_PATH = ../.. 4 | PEBBLE = $(BASE_PATH)/tools/pebble 5 | 6 | INC_PATH = $(BASE_PATH)/include 7 | LIB_PATH = $(BASE_PATH)/lib 8 | PEBBLE_LIB = $(LIB_PATH)/pebble 9 | THIRDPATY = $(LIB_PATH)/thirdparty 10 | 11 | PEBBLE_IDL = calculator.pebble 12 | PEBBLE_SRC = calculator.cpp calculator_Calculator.cpp 13 | PEBBLE_H = calculator.h calculator_Calculator.h calculator_Calculator.inh 14 | PEBBLE_OBJ = $(subst .cpp,.o, $(PEBBLE_SRC)) 15 | 16 | SERVER_SRC = server.cpp 17 | SERVER_OBJ = $(subst .cpp,.o, $(SERVER_SRC)) 18 | SERVER = server 19 | 20 | CLIENT_SRC = client.cpp 21 | CLIENT_OBJ = $(subst .cpp,.o, $(CLIENT_SRC)) 22 | CLIENT = client 23 | 24 | INC_FLAGS = -I$(BASE_PATH) -I$(INC_PATH)/pebble -I$(INC_PATH)/thirdparty 25 | 26 | LD_FLAGS = -L$(PEBBLE_LIB) -L$(THIRDPATY) \ 27 | -lpebble 28 | LD_FLAGS_CLIENT = -L$(PEBBLE_LIB) -L$(THIRDPATY) \ 29 | -lpebble_client 30 | 31 | CC_FLAGS = -g -Wall -Werror $(INC_FLAGS) 32 | 33 | CC = g++ 34 | 35 | .PHONY: all clean 36 | 37 | all: $(SERVER) $(CLIENT) 38 | 39 | $(SERVER): $(PEBBLE_OBJ) $(SERVER_OBJ) 40 | $(CC) -o $@ $^ $(LD_FLAGS) 41 | 42 | $(CLIENT): $(PEBBLE_OBJ) $(CLIENT_OBJ) 43 | $(CC) -o $@ $^ $(LD_FLAGS_CLIENT) 44 | 45 | $(PEBBLE_SRC): $(PEBBLE_IDL) 46 | $(PEBBLE) -r -out ./ --gen cpp $< 47 | 48 | %.o: %.cpp 49 | $(CC) -o $@ -c $< $(CC_FLAGS) 50 | 51 | clean: 52 | rm -rf $(SERVER) $(CLIENT) ./*.o ./log $(PEBBLE_SRC) $(PEBBLE_H) 53 | 54 | -------------------------------------------------------------------------------- /example/pebble_server/calculator.pebble: -------------------------------------------------------------------------------- 1 | 2 | namespace cpp example 3 | 4 | service Calculator { 5 | i32 add(1: i32 a, 2: i32 b), 6 | } 7 | 8 | -------------------------------------------------------------------------------- /example/protobuf_rpc/BUILD: -------------------------------------------------------------------------------- 1 | 2 | gen_rule( 3 | name = 'gen_calculator_message', 4 | srcs = [ 5 | 'calculator.proto', 6 | ], 7 | cmd = '$BUILD_DIR/../thirdparty/protobuf/bin/protoc --cpp_out=$BUILD_DIR/ $SRCS', 8 | deps = [ 9 | ], 10 | outs = [ 11 | 'calculator.pb.cc', 12 | 'calculator.pb.h', 13 | ], 14 | ) 15 | 16 | gen_rule( 17 | name = 'gen_calculator_rpc', 18 | srcs = [ 19 | 'calculator.proto', 20 | ], 21 | cmd = '$BUILD_DIR/../thirdparty/protobuf/bin/protoc --plugin=protoc-gen-rpc=$BUILD_DIR/tools/compiler/pb/protobuf_rpc --rpc_out=$BUILD_DIR/ $SRCS', 22 | deps = [ 23 | '//tools/compiler/pb:protobuf_rpc', 24 | ], 25 | outs = [ 26 | 'calculator.rpc.pb.cc', 27 | 'calculator.rpc.pb.h', 28 | 'calculator.rpc.pb.inh', 29 | ], 30 | ) 31 | 32 | cc_library( 33 | name = 'calculator', 34 | srcs = [ 35 | 'calculator.pb.cc', 36 | 'calculator.rpc.pb.cc', 37 | ], 38 | incs = [ 39 | '../../thirdparty/protobuf/include/', 40 | ], 41 | deps = [ 42 | ':gen_calculator_message', 43 | ':gen_calculator_rpc', 44 | '//src/framework/:pebble_framework', 45 | ] 46 | ) 47 | 48 | cc_binary( 49 | name = 'client', 50 | srcs = [ 51 | 'client.cpp', 52 | ], 53 | incs = [ 54 | '../../thirdparty/protobuf/include/', 55 | ], 56 | deps = [ 57 | ':calculator', 58 | '//src/client/:pebble_client', 59 | ], 60 | ) 61 | cc_binary( 62 | name = 'server', 63 | srcs = [ 64 | 'server.cpp', 65 | ], 66 | incs = [ 67 | '../../thirdparty/protobuf/include/', 68 | ], 69 | deps = [ 70 | ':calculator', 71 | '//src/server/:pebble_server', 72 | ], 73 | ) 74 | 75 | -------------------------------------------------------------------------------- /example/protobuf_rpc/Makefile: -------------------------------------------------------------------------------- 1 | # make file for examples 2 | 3 | BASE_PATH = ../.. 4 | PROTOC = $(BASE_PATH)/tools/protoc 5 | PB_RPC_PLUGIN = $(BASE_PATH)/tools/protobuf_rpc 6 | 7 | INC_PATH = $(BASE_PATH)/include 8 | LIB_PATH = $(BASE_PATH)/lib 9 | PEBBLE_LIB = $(LIB_PATH)/pebble 10 | THIRDPATY = $(LIB_PATH)/thirdparty 11 | 12 | PROTOBUF_IDL = calculator.proto 13 | PROTOBUF_SRC = calculator.pb.cc calculator.rpc.pb.cc 14 | PROTOBUF_H = calculator.pb.h calculator.rpc.pb.h calculator.rpc.pb.inh 15 | PROTOBUF_OBJ = $(subst .cc,.o, $(PROTOBUF_SRC)) 16 | 17 | SERVER_SRC = server.cpp 18 | SERVER_OBJ = $(subst .cpp,.o, $(SERVER_SRC)) 19 | SERVER = server 20 | 21 | CLIENT_SRC = client.cpp 22 | CLIENT_OBJ = $(subst .cpp,.o, $(CLIENT_SRC)) 23 | CLIENT = client 24 | 25 | INC_FLAGS = -I$(BASE_PATH) -I$(INC_PATH)/pebble -I$(INC_PATH)/thirdparty 26 | 27 | LD_FLAGS = -L$(PEBBLE_LIB) -L$(THIRDPATY) \ 28 | -lpebble -lprotobuf 29 | LD_FLAGS_CLIENT = -L$(PEBBLE_LIB) -L$(THIRDPATY) \ 30 | -lpebble_client -lprotobuf 31 | 32 | CC_FLAGS = -g -Wall -Werror $(INC_FLAGS) 33 | 34 | CC = g++ 35 | 36 | .PHONY: all clean 37 | 38 | all: $(SERVER) $(CLIENT) 39 | 40 | $(SERVER): $(PROTOBUF_OBJ) $(SERVER_OBJ) 41 | $(CC) -o $@ $^ $(LD_FLAGS) 42 | 43 | $(CLIENT): $(PROTOBUF_OBJ) $(CLIENT_OBJ) 44 | $(CC) -o $@ $^ $(LD_FLAGS_CLIENT) 45 | 46 | $(PROTOBUF_SRC): $(PROTOBUF_IDL) 47 | $(PROTOC) --cpp_out=./ $< 48 | $(PROTOC) --plugin=protoc-gen-rpc=$(PB_RPC_PLUGIN) --rpc_out=./ $< 49 | 50 | %.o: %.cpp 51 | $(CC) $(CC_FLAGS) -o $@ -c $< 52 | 53 | %.o: %.cc 54 | $(CC) $(CC_FLAGS) -o $@ -c $< 55 | 56 | clean: 57 | rm -rf $(SERVER) $(CLIENT) ./*.o ./log $(PROTOBUF_SRC) $(PROTOBUF_H) 58 | 59 | -------------------------------------------------------------------------------- /example/protobuf_rpc/calculator.proto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/example/protobuf_rpc/calculator.proto -------------------------------------------------------------------------------- /example/rollback_rpc/BUILD: -------------------------------------------------------------------------------- 1 | gen_rule( 2 | name = 'gen_calculator', 3 | srcs = [ 4 | 'calculator.pebble', 5 | ], 6 | cmd = '$BUILD_DIR/tools/compiler/dr/pebble -r -out $BUILD_DIR/example/rollback_rpc --gen cpp $SRCS', 7 | deps = [ 8 | '//tools/compiler/dr:pebble', 9 | ], 10 | outs = [ 11 | 'calculator.cpp', 12 | 'calculator_Calculator.cpp', 13 | 'calculator_PushService.cpp', 14 | 'calculator.h', 15 | 'calculator_Calculator.h', 16 | 'calculator_Calculator.inh', 17 | 'calculator_PushService.h', 18 | 'calculator_PushService.inh', 19 | ], 20 | ) 21 | 22 | cc_library( 23 | name = 'calculator', 24 | srcs = [ 25 | 'calculator.cpp', 26 | 'calculator_Calculator.cpp', 27 | 'calculator_PushService.cpp', 28 | ], 29 | incs = [ 30 | ], 31 | deps = [ 32 | ':gen_calculator', 33 | '//src/framework/:pebble_framework', 34 | ] 35 | ) 36 | 37 | cc_binary( 38 | name = 'client', 39 | srcs = [ 40 | 'client.cpp', 41 | ], 42 | incs = [ 43 | ], 44 | deps = [ 45 | ':calculator', 46 | '//src/client/:pebble_client', 47 | ], 48 | ) 49 | cc_binary( 50 | name = 'server', 51 | srcs = [ 52 | 'server.cpp', 53 | ], 54 | incs = [ 55 | ], 56 | deps = [ 57 | ':calculator', 58 | '//src/server/:pebble_server', 59 | ], 60 | ) 61 | 62 | -------------------------------------------------------------------------------- /example/rollback_rpc/Makefile: -------------------------------------------------------------------------------- 1 | # make file for examples 2 | 3 | BASE_PATH = ../.. 4 | PEBBLE = $(BASE_PATH)/tools/pebble 5 | 6 | INC_PATH = $(BASE_PATH)/include 7 | LIB_PATH = $(BASE_PATH)/lib 8 | PEBBLE_LIB = $(LIB_PATH)/pebble 9 | THIRDPATY = $(LIB_PATH)/thirdparty 10 | 11 | PEBBLE_IDL = calculator.pebble 12 | PEBBLE_SRC = calculator.cpp calculator_Calculator.cpp calculator_PushService.cpp 13 | PEBBLE_H = calculator.h calculator_Calculator.h calculator_Calculator.inh calculator_PushService.h calculator_PushService.inh 14 | PEBBLE_OBJ = $(subst .cpp,.o, $(PEBBLE_SRC)) 15 | 16 | SERVER_SRC = server.cpp 17 | SERVER_OBJ = $(subst .cpp,.o, $(SERVER_SRC)) 18 | SERVER = server 19 | 20 | CLIENT_SRC = client.cpp 21 | CLIENT_OBJ = $(subst .cpp,.o, $(CLIENT_SRC)) 22 | CLIENT = client 23 | 24 | INC_FLAGS = -I$(BASE_PATH) -I$(INC_PATH)/pebble -I$(INC_PATH)/thirdparty 25 | 26 | LD_FLAGS = -L$(PEBBLE_LIB) -L$(THIRDPATY) \ 27 | -lpebble 28 | LD_FLAGS_CLIENT = -L$(PEBBLE_LIB) -L$(THIRDPATY) \ 29 | -lpebble_client 30 | 31 | CC_FLAGS = -g -Wall -Werror $(INC_FLAGS) 32 | 33 | CC = g++ 34 | 35 | .PHONY: all clean 36 | 37 | all: $(SERVER) $(CLIENT) 38 | 39 | $(SERVER): $(PEBBLE_OBJ) $(SERVER_OBJ) 40 | $(CC) -o $@ $^ $(LD_FLAGS) 41 | 42 | $(CLIENT): $(PEBBLE_OBJ) $(CLIENT_OBJ) 43 | $(CC) -o $@ $^ $(LD_FLAGS_CLIENT) 44 | 45 | $(PEBBLE_SRC): $(PEBBLE_IDL) 46 | $(PEBBLE) -r -out ./ --gen cpp $< 47 | 48 | %.o: %.cpp 49 | $(CC) -o $@ -c $< $(CC_FLAGS) 50 | 51 | clean: 52 | rm -rf $(SERVER) $(CLIENT) ./*.o ./log $(PEBBLE_SRC) $(PEBBLE_H) 53 | 54 | -------------------------------------------------------------------------------- /example/rollback_rpc/calculator.pebble: -------------------------------------------------------------------------------- 1 | 2 | namespace cpp example 3 | 4 | service Calculator { 5 | i32 add(1: i32 a, 2: i32 b), 6 | } 7 | 8 | service PushService { 9 | oneway void push(1: string data), 10 | } -------------------------------------------------------------------------------- /example/threadpool/BUILD: -------------------------------------------------------------------------------- 1 | 2 | cc_binary( 3 | name = 'server', 4 | srcs = [ 5 | 'server.cpp', 6 | ], 7 | incs = [ 8 | ], 9 | deps = [ 10 | '#pthread', 11 | '//src/common/:pebble_common', 12 | ], 13 | ) 14 | 15 | -------------------------------------------------------------------------------- /example/threadpool/Makefile: -------------------------------------------------------------------------------- 1 | # make file for examples 2 | 3 | BASE_PATH = ../.. 4 | 5 | INC_PATH = $(BASE_PATH)/include 6 | LIB_PATH = $(BASE_PATH)/lib 7 | PEBBLE_LIB = $(LIB_PATH)/pebble 8 | 9 | 10 | SERVER_SRC = server.cpp 11 | SERVER_OBJ = $(subst .cpp,.o, $(SERVER_SRC)) 12 | SERVER = server 13 | 14 | 15 | INC_FLAGS = -I$(BASE_PATH) -I$(INC_PATH)/pebble 16 | 17 | LD_FLAGS = -L$(PEBBLE_LIB) \ 18 | -lpebble -lpthread 19 | 20 | CC_FLAGS = -g -Wall -Werror $(INC_FLAGS) 21 | 22 | CC = g++ 23 | 24 | .PHONY: all clean 25 | 26 | all: $(SERVER) 27 | 28 | $(SERVER): $(PEBBLE_OBJ) $(SERVER_OBJ) 29 | $(CC) -o $@ $^ $(LD_FLAGS) 30 | 31 | %.o: %.cpp 32 | $(CC) -o $@ -c $< $(CC_FLAGS) 33 | 34 | clean: 35 | rm -rf $(SERVER) ./*.o 36 | 37 | -------------------------------------------------------------------------------- /example/threadpool/server.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | #include 15 | 16 | #include "common/thread_pool.h" 17 | 18 | void mytask(int id) { 19 | std::cout << "my task " << id << std::endl; 20 | } 21 | 22 | 23 | int main(int argc, const char** argv) { 24 | 25 | pebble::ThreadPool pool; 26 | pool.Init(5); 27 | 28 | for (int i = 0; i < 10; i++) { 29 | cxx::function task = cxx::bind(mytask, i); 30 | pool.AddTask(task); 31 | } 32 | 33 | return 0; 34 | } 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/client/BUILD: -------------------------------------------------------------------------------- 1 | 2 | cc_library( 3 | name = 'pebble_client', 4 | srcs = [ 5 | 'pebble_client.cpp', 6 | ], 7 | incs = [ 8 | ], 9 | deps = [ 10 | '//src/framework/:pebble_framework', 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /src/client/README.txt: -------------------------------------------------------------------------------- 1 | pebble client 2 | ---------------------------------- 3 | 本目录为Pebble给game server提供的SDK参考实现,支持RPC、路由、名字功能,使用体验和PebbleServer一致。 4 | pebble client只依赖pebble framework,可以pebble extension配合使用 5 | 6 | user application 7 | -------------------------------------------- 8 | pebble client | pebble extension 9 | -------------------------------------------- 10 | pebble framework 11 | ----------------------| 12 | pebble common | zookeeper tbuspp 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/common/BUILD: -------------------------------------------------------------------------------- 1 | 2 | cc_library( 3 | name = 'pebble_common', 4 | srcs = [ 5 | 'base64.cpp', 6 | 'condition_variable.cpp', 7 | 'coroutine.cpp', 8 | 'coroutine_system_hook.cpp', 9 | 'cpu.cpp', 10 | 'dir_util.cpp', 11 | 'error.cpp', 12 | 'file_util.cpp', 13 | 'ini_reader.cpp', 14 | 'log.cpp', 15 | 'memory.cpp', 16 | 'net_util.cpp', 17 | 'sha1.cpp', 18 | 'string_utility.cpp', 19 | 'thread.cpp', 20 | 'thread_pool.cpp', 21 | 'timer.cpp', 22 | 'time_utility.cpp', 23 | 'random.cpp', 24 | ], 25 | extra_cppflags = [ 26 | '--std=c++0x', 27 | ], 28 | incs = [ 29 | ], 30 | deps = [ 31 | ], 32 | ) 33 | -------------------------------------------------------------------------------- /src/common/README.txt: -------------------------------------------------------------------------------- 1 | pebble common库 2 | ---------------------------------- 3 | 本目录放置基础的工具、算法等,完全和业务及框架无关,可以在任何项目中使用。 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/common/base64.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | 15 | #ifndef _PEBBLE_COMMON_BASE64_H_ 16 | #define _PEBBLE_COMMON_BASE64_H_ 17 | 18 | #include 19 | 20 | namespace pebble { 21 | 22 | 23 | class Base64 24 | { 25 | public: 26 | Base64() {} 27 | virtual ~Base64() {} 28 | 29 | static bool Encode(const std::string& src, std::string* dst); 30 | 31 | static bool Decode(const std::string& src, std::string* dst); 32 | 33 | private: 34 | // 根据在Base64编码表中的序号求得某个字符 35 | static inline char Base2Chr(unsigned char n); 36 | 37 | // 求得某个字符在Base64编码表中的序号 38 | static inline unsigned char Chr2Base(char c); 39 | 40 | inline static int Base64EncodeLen(int n); 41 | inline static int Base64DecodeLen(int n); 42 | }; 43 | 44 | } // namespace pebble 45 | 46 | #endif // _PEBBLE_COMMON_BASE64_H_ 47 | 48 | -------------------------------------------------------------------------------- /src/common/condition_variable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | 15 | #ifndef _PEBBLE_COMMON_CONDITION_VARIABLE_H_ 16 | #define _PEBBLE_COMMON_CONDITION_VARIABLE_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "common/mutex.h" 22 | 23 | namespace pebble { 24 | 25 | 26 | class ConditionVariable 27 | { 28 | public: 29 | ConditionVariable(); 30 | ~ConditionVariable(); 31 | 32 | void Signal(); 33 | 34 | void Broadcast(); 35 | 36 | void Wait(Mutex* mutex); 37 | 38 | // If timeout_in_ms < 0, it means infinite waiting until condition is signaled 39 | // by another thread 40 | int TimedWait(Mutex* mutex, int timeout_in_ms = -1); 41 | private: 42 | void CheckValid() const; 43 | private: 44 | pthread_cond_t m_hCondition; 45 | }; 46 | 47 | } // namespace pebble 48 | 49 | #endif // _PEBBLE_COMMON_CONDITION_VARIABLE_H_ 50 | 51 | -------------------------------------------------------------------------------- /src/common/cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | 15 | #ifndef _PEBBLE_COMMON_CPU_H_ 16 | #define _PEBBLE_COMMON_CPU_H_ 17 | 18 | 19 | namespace pebble { 20 | 21 | /// @brief 获取当前进程的cpu使用时间 22 | long long GetCurCpuTime(); 23 | 24 | /// @brief 获取整个系统的cpu使用时间 25 | long long GetTotalCpuTime(); 26 | 27 | /// @brief 计算进程的cpu使用率 28 | /// @param cur_cpu_time_start 当前进程cpu使用时间段-start 29 | /// @param cur_cpu_time_stop 当前进程cpu使用时间段-stop 30 | /// @param total_cpu_time_start 整个系统cpu使用时间段-start 31 | /// @param total_cpu_time_start 整个系统cpu使用时间段-stop 32 | float CalculateCurCpuUseage(long long cur_cpu_time_start, long long cur_cpu_time_stop, 33 | long long total_cpu_time_start, long long total_cpu_time_stop); 34 | 35 | } // namespace pebble 36 | 37 | #endif // _PEBBLE_COMMON_CPU_H_ -------------------------------------------------------------------------------- /src/common/dir_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | 15 | #ifndef _PEBBLE_COMMON_DIR_UTIL_H_ 16 | #define _PEBBLE_COMMON_DIR_UTIL_H_ 17 | 18 | #include 19 | 20 | namespace pebble { 21 | 22 | class DirUtil { 23 | public: 24 | /// @brief 创建目录,仅在目录不存在时创建(同mkdir) 25 | /// @param path 要创建的目录 26 | /// @return 0成功,非0失败 27 | static int MakeDir(const std::string& path); 28 | 29 | /// @brief 创建多级目录,连同父目录一起创建(同mkdir -p) 30 | /// @param path 要创建的目录 31 | /// @return 0成功,非0失败 32 | static int MakeDirP(const std::string& path); 33 | 34 | static const char* GetLastError() { 35 | return m_last_error; 36 | } 37 | 38 | private: 39 | static char m_last_error[256]; 40 | }; 41 | 42 | } // namespace pebble 43 | 44 | #endif // _PEBBLE_COMMON_DIR_UTIL_H_ 45 | 46 | -------------------------------------------------------------------------------- /src/common/error.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | #include "common/error.h" 15 | 16 | 17 | namespace pebble { 18 | 19 | // 避免全局变量构造、析构顺序问题 20 | static cxx::unordered_map * g_error_string_map = NULL; 21 | struct ErrorInfo { 22 | ErrorInfo() { 23 | g_error_string_map = &_error_info; 24 | } 25 | ~ErrorInfo() { 26 | g_error_string_map = NULL; 27 | } 28 | cxx::unordered_map _error_info; 29 | }; 30 | 31 | const char* GetErrorString(int32_t error_code) { 32 | if (0 == error_code) return "no error"; 33 | 34 | if (!g_error_string_map) { 35 | return "error module not inited."; 36 | } 37 | 38 | cxx::unordered_map::iterator it = g_error_string_map->find(error_code); 39 | if (it != g_error_string_map->end()) { 40 | return it->second; 41 | } 42 | 43 | return "unregister error description"; 44 | } 45 | 46 | void SetErrorString(int32_t error_code, const char* error_string) { 47 | static ErrorInfo s_error_info; 48 | (*g_error_string_map)[error_code] = error_string; 49 | } 50 | 51 | } // namespace pebble 52 | 53 | -------------------------------------------------------------------------------- /src/common/file_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | 15 | #ifndef _PEBBLE_COMMON_FILE_UTIL_H_ 16 | #define _PEBBLE_COMMON_FILE_UTIL_H_ 17 | 18 | #include 19 | #include 20 | #include "common/platform.h" 21 | 22 | namespace pebble { 23 | 24 | std::string GetSelfName(); 25 | 26 | class RollUtil { 27 | public: 28 | RollUtil(); 29 | RollUtil(const std::string& path, const std::string& name); 30 | ~RollUtil(); 31 | FILE* GetFile(); 32 | int32_t SetFileName(const std::string& name); 33 | int32_t SetFilePath(const std::string& path); 34 | int32_t SetFileSize(uint32_t file_size); 35 | int32_t SetRollNum(uint32_t roll_num); 36 | const char* GetLastError() { 37 | return m_last_error; 38 | } 39 | 40 | void Close(); 41 | void Flush(); 42 | 43 | private: 44 | void Roll(); 45 | 46 | private: 47 | char m_last_error[256]; 48 | std::string m_path; 49 | std::string m_name; 50 | uint32_t m_file_size; 51 | uint32_t m_roll_num; 52 | FILE* m_file; 53 | }; 54 | 55 | } // namespace pebble 56 | 57 | #endif // _PEBBLE_COMMON_FILE_UTIL_H_ -------------------------------------------------------------------------------- /src/common/memory.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "common/memory.h" 21 | 22 | 23 | namespace pebble { 24 | 25 | int GetCurMemoryUsage(int* vm_size_kb, int* rss_size_kb) { 26 | if (!vm_size_kb || !rss_size_kb) { 27 | return -1; 28 | } 29 | 30 | char file_name[64] = { 0 }; 31 | snprintf(file_name, sizeof(file_name), "/proc/%d/status", getpid()); 32 | 33 | FILE* pid_status = fopen(file_name, "r"); 34 | if (!pid_status) { 35 | return -1; 36 | } 37 | 38 | int ret = 0; 39 | char line[256] = { 0 }; 40 | char tmp[32] = { 0 }; 41 | fseek(pid_status, 0, SEEK_SET); 42 | for (int i = 0; i < 16; i++) { 43 | if (fgets(line, sizeof(line), pid_status) == NULL) { 44 | ret = -2; 45 | break; 46 | } 47 | 48 | if (strstr(line, "VmSize") != NULL) { 49 | sscanf(line, "%s %d", tmp, vm_size_kb); 50 | } else if (strstr(line, "VmRSS") != NULL) { 51 | sscanf(line, "%s %d", tmp, rss_size_kb); 52 | } 53 | } 54 | 55 | fclose(pid_status); 56 | 57 | return ret; 58 | } 59 | 60 | } // namespace pebble 61 | -------------------------------------------------------------------------------- /src/common/memory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | 15 | #ifndef _PEBBLE_COMMON_MEMORY_H_ 16 | #define _PEBBLE_COMMON_MEMORY_H_ 17 | 18 | 19 | namespace pebble { 20 | 21 | /// @brief 获取进程当前内存使用情况 22 | /// @param vm_size_kb 输出参数,虚存,单位为K 23 | /// @param rss_size_kb 输出参数,物理内存,单位为K 24 | int GetCurMemoryUsage(int* vm_size_kb, int* rss_size_kb); 25 | 26 | } // namespace pebble 27 | 28 | #endif // _PEBBLE_COMMON_MEMORY_H_ -------------------------------------------------------------------------------- /src/common/net_util.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/src/common/net_util.cpp -------------------------------------------------------------------------------- /src/common/net_util.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/src/common/net_util.h -------------------------------------------------------------------------------- /src/common/random.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | #include 15 | #include 16 | #include "common/random.h" 17 | 18 | namespace common { 19 | 20 | TrueRandom::TrueRandom() 21 | : m_fd(-1) { 22 | m_fd = open("/dev/urandom", O_RDONLY, 0); 23 | if (m_fd < 0) { 24 | abort(); 25 | } 26 | } 27 | 28 | TrueRandom::~TrueRandom() { 29 | close(m_fd); 30 | m_fd = -1; 31 | } 32 | 33 | bool TrueRandom::NextBytes(void* buffer, size_t size) { 34 | return read(m_fd, buffer, size) == static_cast(size); 35 | } 36 | 37 | uint32_t TrueRandom::NextUInt32() { 38 | uint32_t random = -1; 39 | NextBytes(&random, sizeof(random)); 40 | return random; 41 | } 42 | 43 | uint32_t TrueRandom::NextUInt32(uint32_t max_random) { 44 | return NextUInt32() % max_random; 45 | } 46 | 47 | } // namespace common 48 | -------------------------------------------------------------------------------- /src/common/random.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | #ifndef SRC_COMMON_RANDOM_H 15 | #define SRC_COMMON_RANDOM_H 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include "common/uncopyable.h" 21 | 22 | namespace common { 23 | 24 | class TrueRandom { 25 | DECLARE_UNCOPYABLE(TrueRandom); 26 | 27 | public: 28 | TrueRandom(); 29 | ~TrueRandom(); 30 | 31 | uint32_t NextUInt32(); 32 | 33 | uint32_t NextUInt32(uint32_t max_random); 34 | 35 | bool NextBytes(void* buffer, size_t size); 36 | 37 | private: 38 | int32_t m_fd; 39 | }; // class TrueRandom 40 | 41 | } // namespace common 42 | 43 | #endif // SRC_COMMON_RANDOM_H 44 | -------------------------------------------------------------------------------- /src/common/thread.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | 15 | #include "thread.h" 16 | 17 | namespace pebble { 18 | 19 | Thread::Thread() { 20 | m_thread_id = 0; 21 | } 22 | 23 | Thread::~Thread() { 24 | } 25 | static void* ThreadEntry(void* arg) { 26 | Thread* thread = reinterpret_cast(arg); 27 | 28 | thread->Run(); 29 | 30 | return NULL; 31 | } 32 | 33 | bool Thread::Start() { 34 | if (::pthread_create(&m_thread_id, NULL, ThreadEntry, this) != 0) { 35 | return false; 36 | } 37 | 38 | return true; 39 | } 40 | 41 | bool Thread::Join() { 42 | return (::pthread_join(m_thread_id, NULL) == 0); 43 | } 44 | 45 | 46 | void Thread::Exit() { 47 | ::pthread_exit(NULL); 48 | } 49 | 50 | } // namespace pebble 51 | -------------------------------------------------------------------------------- /src/common/thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | 15 | #ifndef _PEBBLE_COMMON_THREAD_H_ 16 | #define _PEBBLE_COMMON_THREAD_H_ 17 | 18 | #include 19 | 20 | namespace pebble { 21 | 22 | 23 | class Thread 24 | { 25 | public: 26 | Thread(); 27 | virtual ~Thread(); 28 | 29 | virtual void Run() = 0; 30 | 31 | bool Start(); 32 | 33 | bool Join(); 34 | 35 | void Exit(); 36 | private: 37 | ::pthread_t m_thread_id; 38 | }; 39 | 40 | } // namespace pebble 41 | 42 | 43 | #endif // _PEBBLE_COMMON_THREAD_H_ 44 | 45 | -------------------------------------------------------------------------------- /src/common/time_utility.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | 15 | #ifndef _PEBBLE_COMMON_TIME_UTILITY_H_ 16 | #define _PEBBLE_COMMON_TIME_UTILITY_H_ 17 | 18 | #include 19 | 20 | #include "common/platform.h" 21 | 22 | namespace pebble { 23 | 24 | class TimeUtility { 25 | public: 26 | // 得到当前的毫秒 27 | static int64_t GetCurrentMS(); 28 | 29 | // 得到当前的微妙 30 | static int64_t GetCurrentUS(); 31 | 32 | // 得到字符串形式的时间 格式:2015-04-10 10:11:12 33 | static std::string GetStringTime(); 34 | 35 | // 得到字符串形式的详细时间 格式: 2015-04-10 10:11:12.967151 36 | static const char* GetStringTimeDetail(); 37 | 38 | // 将字符串格式(2015-04-10 10:11:12)的时间,转为time_t(时间戳) 39 | static time_t GetTimeStamp(const std::string &time); 40 | 41 | // 取得两个时间戳字符串t1-t2的时间差,精确到秒,时间格式为2015-04-10 10:11:12 42 | static time_t GetTimeDiff(const std::string &t1, const std::string &t2); 43 | }; 44 | 45 | } // namespace pebble 46 | 47 | #endif // _PEBBLE_COMMON_TIME_UTILITY_H_ 48 | -------------------------------------------------------------------------------- /src/common/uncopyable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | 15 | #ifndef SRC_COMMON_UNCOPYABLE_H 16 | #define SRC_COMMON_UNCOPYABLE_H 17 | #pragma once 18 | 19 | namespace pebble { 20 | 21 | class Uncopyable { 22 | protected: 23 | Uncopyable() {} 24 | ~Uncopyable() {} 25 | 26 | private: 27 | Uncopyable(const Uncopyable&); 28 | const Uncopyable& operator=(const Uncopyable&); 29 | }; // class Uncopyable 30 | 31 | 32 | #define DECLARE_UNCOPYABLE(Class) \ 33 | private: \ 34 | Class(const Class&); \ 35 | const Class& operator=(const Class&); 36 | 37 | } // namespace common 38 | 39 | #endif // SRC_COMMON_BASE_UNCOPYABLE_H 40 | -------------------------------------------------------------------------------- /src/extension/README.txt: -------------------------------------------------------------------------------- 1 | pebble extension 2 | ---------------------------------- 3 | 本目录为Pebble框架的扩展实现,如基于zookeeper的名字服务,基于tbuspp的消息队列等 4 | pebble extension依赖pebble framework,可以独立使用扩展的功能部分,也可以配合pebble server一起使用。 5 | 6 | 7 | user application 8 | -------------------------------------------- 9 | pebble server | pebble extension 10 | -------------------------------------------- 11 | pebble framework 12 | ----------------------| 13 | pebble common | zookeeper tbuspp 14 | -------------------------------------------------------------------------------- /src/extension/redis/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = 'pebble_redis', 3 | srcs = [ 4 | 'redis_co.cpp', 5 | ], 6 | incs = [ 7 | '../../../thirdparty/hiredis/', 8 | ], 9 | deps = [ 10 | '//src/common/:pebble_common', 11 | ], 12 | ) 13 | -------------------------------------------------------------------------------- /src/extension/zookeeper/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = 'pebble_zookeeper', 3 | srcs = [ 4 | 'naming_handler.cpp', 5 | 'zookeeper_cache.cpp', 6 | 'zookeeper_client.cpp', 7 | 'zookeeper_log.cpp', 8 | 'zookeeper_naming.cpp', 9 | ], 10 | incs = [ 11 | ], 12 | deps = [ 13 | '//src/common/:pebble_common', 14 | '//thirdparty/zookeeper:zookeeper_st', 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /src/framework/README.txt: -------------------------------------------------------------------------------- 1 | pebble framework 2 | ---------------------------------- 3 | 本目录放置pebble框架核心内容,主要包括pebble的机制定义和实现,如message、processor、rpc、路由、名字、统计、过载保护、广播、并发等接口定义和机制实现 4 | framework仅依赖pebble common库,可以很方便的进行扩展。 5 | 6 | 7 | pebble framework 8 | ------------------- 9 | pebble common 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/framework/broadcast.pebble: -------------------------------------------------------------------------------- 1 | namespace cpp pebble 2 | 3 | /// @brief 内置广播服务,用于server间广播事件的转发 4 | service _PebbleBroadcast { 5 | /// @brief 用于server间传递广播事件 6 | /// @param channel 频道 7 | /// @param message 需要广播出去的消息,已经经过编码 8 | /// @param encode_type message的编码格式 9 | oneway void OnRelay(1:string channel, 2:string message), 10 | } 11 | 12 | -------------------------------------------------------------------------------- /src/framework/broadcast_mgr.inh: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | #ifndef _PEBBLE_EXTENSION_BROADCAST_MGR_INH_ 15 | #define _PEBBLE_EXTENSION_BROADCAST_MGR_INH_ 16 | 17 | #include 18 | 19 | #include "src/framework/broadcast__PebbleBroadcast.h" 20 | 21 | 22 | namespace pebble { 23 | 24 | class BroadcastMgr; 25 | 26 | // server间中转广播消息服务,内部使用 27 | class BroadcastRelayHandler : public _PebbleBroadcastCobSvIf { 28 | public: 29 | BroadcastRelayHandler(BroadcastMgr* broadcast_mgr) : m_broadcast_mgr(broadcast_mgr) {} 30 | virtual ~BroadcastRelayHandler() {} 31 | 32 | virtual void OnRelay(const std::string& channel, const std::string& message); 33 | 34 | private: 35 | BroadcastMgr* m_broadcast_mgr; 36 | }; 37 | 38 | } // namespace pebble 39 | 40 | #endif // _PEBBLE_EXTENSION_BROADCAST_MGR_INH_ 41 | -------------------------------------------------------------------------------- /src/framework/dr/BUILD: -------------------------------------------------------------------------------- 1 | 2 | cc_library( 3 | name = 'pebble_dr', 4 | srcs = [ 5 | 'serialize.cpp', 6 | 'common/field_pack.cpp', 7 | 'protocol/base64_utils.cpp', 8 | 'protocol/json_protocol.cpp', 9 | 'protocol/rapidjson_protocol.cpp', 10 | 'protocol/bson_protocol.cpp', 11 | 'transport/transport_exception.cpp', 12 | 'transport/buffer_transport.cpp', 13 | ], 14 | incs = [ 15 | ], 16 | deps = [ 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /src/framework/dr/common/dr_define.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | 15 | #ifndef PEBBLE_DR_DEFINE_H 16 | #define PEBBLE_DR_DEFINE_H 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | 23 | namespace pebble { 24 | namespace dr { 25 | namespace protocol { 26 | 27 | /** 28 | * Enumerated definition of the message types that the Thrift protocol 29 | * supports. 30 | */ 31 | enum TMessageType { 32 | T_CALL = 1, 33 | T_REPLY = 2, 34 | T_EXCEPTION = 3, 35 | T_ONEWAY = 4, 36 | }; 37 | } // namespace protocol 38 | 39 | } // namespace dr 40 | } // namespace pebble 41 | 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/framework/dr/protocol/base64_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef PEBBLE_DR_PROTOCOL_TBASE64UTILS_H 21 | #define PEBBLE_DR_PROTOCOL_TBASE64UTILS_H 22 | 23 | #include 24 | #include 25 | 26 | namespace pebble { namespace dr { namespace protocol { 27 | 28 | // in must be at least len bytes 29 | // len must be 1, 2, or 3 30 | // buf must be a buffer of at least 4 bytes and may not overlap in 31 | // the data is not padded with '='; the caller can do this if desired 32 | void base64_encode(const uint8_t *in, uint32_t len, uint8_t *buf); 33 | 34 | // buf must be a buffer of at least 4 bytes and contain base64 encoded values 35 | // buf will be changed to contain output bytes 36 | // len is number of bytes to consume from input (must be 2, 3, or 4) 37 | // no '=' padding should be included in the input 38 | void base64_decode(uint8_t *buf, uint32_t len); 39 | 40 | }}} // pebble::dr::protocol 41 | 42 | #endif // PEBBLE_DR_PROTOCOL_TBASE64UTILS_H 43 | -------------------------------------------------------------------------------- /src/framework/dr/protocol/binary_protocol.tcc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/src/framework/dr/protocol/binary_protocol.tcc -------------------------------------------------------------------------------- /src/framework/dr/transport/transport_exception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include "framework/dr/transport/transport_exception.h" 21 | 22 | 23 | 24 | namespace pebble { namespace dr { namespace transport { 25 | 26 | const char* TTransportException::what() const throw() { 27 | if (message_.empty()) { 28 | switch (type_) { 29 | case UNKNOWN : return "TTransportException: Unknown transport exception"; 30 | case NOT_OPEN : return "TTransportException: Transport not open"; 31 | case TIMED_OUT : return "TTransportException: Timed out"; 32 | case END_OF_FILE : return "TTransportException: End of file"; 33 | case INTERRUPTED : return "TTransportException: Interrupted"; 34 | case BAD_ARGS : return "TTransportException: Invalid arguments"; 35 | case CORRUPTED_DATA : return "TTransportException: Corrupted Data"; 36 | case INTERNAL_ERROR : return "TTransportException: Internal error"; 37 | case BUFF_NOT_ENOUGH: return "TTransportException: Buff not enough"; 38 | case SEND_FAILED : return "TTransportException: Send failed"; 39 | default : return "TTransportException: (Invalid exception type)"; 40 | } 41 | } else { 42 | return message_.c_str(); 43 | } 44 | } 45 | 46 | 47 | } // namespace transport 48 | } // namespace dr 49 | } // namespace pebble 50 | 51 | -------------------------------------------------------------------------------- /src/framework/exception.pebble: -------------------------------------------------------------------------------- 1 | 2 | namespace cpp pebble 3 | 4 | struct Exception { 5 | 1: string message, 6 | 2: i32 type, 7 | } 8 | -------------------------------------------------------------------------------- /src/framework/gdata_err.h: -------------------------------------------------------------------------------- 1 | #ifndef _PEBBLE_EXTENSION_GDATA_ERR_H_ 2 | #define _PEBBLE_EXTENSION_GDATA_ERR_H_ 3 | 4 | 5 | namespace pebble { 6 | namespace oss { 7 | 8 | #define DATA_LOG_SUCCESS 0 9 | 10 | enum DATALOGERROR 11 | { 12 | DATA_API_ERR_START_ERRNO = -20000, /*错误代码起始标志*/ 13 | DATA_API_ERR_CREATE_CTX_LOG = -20001, /*初始化日志文件失败*/ 14 | DATA_API_ERR_CREATE_CAT_LOG = -2002, /*获取日志类别失败*/ 15 | DATA_API_ERR_CREATE_FILE_PATH = -20003, /*创建日志保存路径失败*/ 16 | DATA_API_ERR_END_ERRNO = -20004, /*错误代码结束标志*/ 17 | }; 18 | 19 | 20 | class CDataLogErr 21 | { 22 | public: 23 | /** 24 | * 根据错误代码获取错误信息 25 | * @param[in] err_code 错误代码 26 | * 27 | * @return 错误信息串的指针 28 | */ 29 | static const char* DataLogErrMsg(int err_code) { 30 | switch (err_code) { 31 | case 0: 32 | return "no error"; 33 | case DATA_API_ERR_CREATE_CTX_LOG: 34 | return "create log ctx failed"; 35 | case DATA_API_ERR_CREATE_CAT_LOG: 36 | return "create log cat failed"; 37 | case DATA_API_ERR_CREATE_FILE_PATH: 38 | return "create log file path failed"; 39 | default: 40 | return "unknown error"; 41 | } 42 | } 43 | }; 44 | }// namespace oss 45 | }// namespace pebble 46 | #endif // _PEBBLE_EXTENSION_GDATA_ERR_H_ 47 | 48 | -------------------------------------------------------------------------------- /src/framework/protobuf_rpc_head.pebble: -------------------------------------------------------------------------------- 1 | 2 | namespace cpp pebble 3 | 4 | /** 5 | * 为避免pebble对PB版本的依赖,在PB RPC实现上需要的一些数据不使用PB来描述,使用Pebbble IDL进行描述 6 | * 这部分不对用户可见,用户界面可以使用任何版本PB,保证无兼容性问题。 7 | */ 8 | 9 | // PB RPC 消息头定义 10 | struct ProtoBufRpcHead { 11 | 1: optional i32 version, // 版本号,因通过序号可以做版本兼容,这里用optional 12 | 2: i32 msg_type, // 消息类型,请求、响应、异常、ONEWAY 13 | 3: i64(u) session_id, // 会话ID,用于请求、响应配对 14 | 4: string function_name, // 请求的服务,格式为service_name.function_name 15 | 5: optional i32 timeout_ms, // 请求超时时间,单位ms 16 | 6: optional i64(u) timestamp, // 消息产生时间戳 17 | } 18 | -------------------------------------------------------------------------------- /src/framework/register_error.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | #include "common/coroutine.h" 15 | #include "common/timer.h" 16 | #include "framework/channel_mgr.h" 17 | #include "framework/message.h" 18 | #include "framework/naming.h" 19 | #include "framework/pebble_rpc.h" 20 | #include "framework/processor.h" 21 | #include "framework/router.h" 22 | #include "framework/rpc.h" 23 | #include "framework/rpc_util.inh" 24 | #include "framework/session.h" 25 | 26 | 27 | namespace pebble { 28 | 29 | void RegisterErrorString() { 30 | // common 31 | TimerErrorStringRegister::RegisterErrorString(); 32 | CoroutineErrorStringRegister::RegisterErrorString(); 33 | 34 | // framework 35 | ChannelErrorStringRegister::RegisterErrorString(); 36 | MessageErrorStringRegister::RegisterErrorString(); 37 | NamingErrorStringRegister::RegisterErrorString(); 38 | ProcessorErrorStringRegister::RegisterErrorString(); 39 | RouterErrorStringRegister::RegisterErrorString(); 40 | RpcErrorStringRegister::RegisterErrorString(); 41 | SessionErrorStringRegister::RegisterErrorString(); 42 | RpcUtilErrorStringRegister::RegisterErrorString(); 43 | PebbleRpcErrorStringRegister::RegisterErrorString(); 44 | } 45 | 46 | } // namespace pebble 47 | -------------------------------------------------------------------------------- /src/framework/register_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | 15 | #ifndef _PEBBLE_FRAMEWORK_REGISTER_ERROR_H_ 16 | #define _PEBBLE_FRAMEWORK_REGISTER_ERROR_H_ 17 | 18 | 19 | namespace pebble { 20 | 21 | /// @brief 注册framework、common库的错误描述 22 | /// * 若单独使用common库,需要自己注册common库的错误描述 23 | /// * 对于扩展模块,在安装时注册 24 | void RegisterErrorString(); 25 | 26 | } // namespace pebble 27 | 28 | #endif // _PEBBLE_FRAMEWORK_REGISTER_ERROR_H_ -------------------------------------------------------------------------------- /src/framework/rpc_plugin.inh: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | #ifndef _PEBBLE_FRAMEWORK_RPC_PLUGIN_INH_ 15 | #define _PEBBLE_FRAMEWORK_RPC_PLUGIN_INH_ 16 | 17 | #include "framework/rpc.h" 18 | 19 | namespace pebble { 20 | 21 | class PebbleRpc; 22 | 23 | class RpcPlugin { 24 | public: 25 | virtual ~RpcPlugin() {} 26 | /// @brief @see Rpc::HeadEncode 27 | virtual int32_t HeadEncode(const RpcHead& rpc_head, uint8_t* buff, uint32_t buff_len) = 0; 28 | /// @brief @see Rpc::HeadDecode 29 | virtual int32_t HeadDecode(const uint8_t* buff, uint32_t buff_len, RpcHead* rpc_head) = 0; 30 | }; 31 | 32 | class ThriftRpcPlugin : public RpcPlugin { 33 | public: 34 | ThriftRpcPlugin(PebbleRpc* pebble_rpc) : m_pebble_rpc(pebble_rpc) {} 35 | virtual ~ThriftRpcPlugin() {} 36 | 37 | virtual int32_t HeadEncode(const RpcHead& rpc_head, uint8_t* buff, uint32_t buff_len); 38 | 39 | virtual int32_t HeadDecode(const uint8_t* buff, uint32_t buff_len, RpcHead* rpc_head); 40 | 41 | private: 42 | PebbleRpc* m_pebble_rpc; 43 | }; 44 | 45 | class ProtoBufRpcPlugin : public RpcPlugin { 46 | public: 47 | explicit ProtoBufRpcPlugin(PebbleRpc* pebble_rpc) : m_pebble_rpc(pebble_rpc) {} 48 | virtual ~ProtoBufRpcPlugin() {} 49 | 50 | virtual int32_t HeadEncode(const RpcHead& rpc_head, uint8_t* buff, uint32_t buff_len); 51 | 52 | virtual int32_t HeadDecode(const uint8_t* buff, uint32_t buff_len, RpcHead* rpc_head); 53 | 54 | private: 55 | PebbleRpc* m_pebble_rpc; 56 | }; 57 | 58 | } // namespace pebble 59 | 60 | #endif // _PEBBLE_FRAMEWORK_RPC_PLUGIN_INH_ -------------------------------------------------------------------------------- /src/server/README.txt: -------------------------------------------------------------------------------- 1 | pebble server 2 | ---------------------------------- 3 | 本目录为Pebble框架后台server的参考实现,具备基本的程序框架、命令行、控制命令等能力 4 | pebble server只依赖pebble framework,但是可以pebble extension配合使用 5 | 6 | user application 7 | -------------------------------------------- 8 | pebble server | pebble extension 9 | -------------------------------------------- 10 | pebble framework 11 | ----------------------| 12 | pebble common | zookeeper tbuspp 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/server/cfg/pebble.ini: -------------------------------------------------------------------------------- 1 | [app] 2 | app_id = 0 3 | app_key = app_key 4 | instance_id = 0 5 | unit_id = 0 6 | program_id = 0 7 | ;ctrl_cmd_address = 8 | 9 | [coroutine] 10 | stack_size = 262144 11 | 12 | [log] 13 | device = FILE 14 | priority = INFO 15 | file_size = 10 16 | roll_num = 10 17 | log_path = ./log 18 | 19 | [stat] 20 | report_cycle_s = 60 21 | report_to_gdata = 2 ; { 0:don't report 1:report by message 2:report by cycle } 22 | gdata_id = 7 23 | gdata_log_id = 10 24 | gdata_log_path = ./log/gdata 25 | 26 | [flow_control] 27 | enable = 1 28 | task_threshold = 10000 29 | message_expire_ms = 10000 30 | 31 | [broadcast] 32 | relay_address = ; address for receive broadcast message 33 | zk_host = ; ip:port[,ip:port] 34 | zk_connect_timeout_ms = 30000 ; [2000, 40000] -------------------------------------------------------------------------------- /src/server/control.pebble: -------------------------------------------------------------------------------- 1 | 2 | namespace cpp pebble 3 | 4 | // 控制命令请求结构定义 5 | struct ControlRequest { 6 | 1: string command, // 控制命令 7 | 2: optional list options, // 命令选项 8 | } 9 | 10 | // 控制命令响应结构定义 11 | struct ControlResponse { 12 | 1: i32 ret_code, // 处理结果,一般0为成功 13 | 2: string data, // 结果描述或数据 14 | } 15 | 16 | service _PebbleControl { 17 | ControlResponse RunCommand(1: ControlRequest req), 18 | } 19 | -------------------------------------------------------------------------------- /src/server/error_parser.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | #include 15 | #include 16 | 17 | #include "common/error.h" 18 | #include "framework/register_error.h" 19 | 20 | /** 21 | * 错误码解析工具 22 | */ 23 | int main(int argc, char* argv[]) { 24 | if (argc != 2) { 25 | std::cout << "usage : " << argv[0] << " error_code" << std::endl 26 | // << " " << argv[0] << " -a" << std::endl // 暂不支持查询全部错误码 27 | ; 28 | return -1; 29 | } 30 | 31 | const char* begin = argv[1]; 32 | char* end = NULL; 33 | 34 | int error_code = strtol(begin, &end, 0); 35 | if (end > begin) { 36 | pebble::RegisterErrorString(); 37 | std::cout << error_code << " : " << pebble::GetErrorString(error_code) << std::endl; 38 | } else { 39 | std::cout << "can't parse " << argv[1] << std::endl; 40 | } 41 | 42 | return 0; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/server/pebble.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | 15 | #ifndef _PEBBLE_SERVER_PEBBLE_H_ 16 | #define _PEBBLE_SERVER_PEBBLE_H_ 17 | 18 | 19 | #include "common/coroutine.h" 20 | #include "common/ini_reader.h" 21 | #include "common/log.h" 22 | #include "common/string_utility.h" 23 | #include "common/timer.h" 24 | #include "common/time_utility.h" 25 | #include "extension/extension.h" 26 | #include "framework/broadcast_mgr.h" 27 | #include "framework/message.h" 28 | #include "framework/monitor.h" 29 | #include "framework/naming.h" 30 | #include "framework/options.h" 31 | #include "framework/pebble_rpc.h" 32 | #include "framework/router.h" 33 | #include "framework/session.h" 34 | #include "framework/stat.h" 35 | #include "framework/when_all.h" 36 | #include "server/pebble_cmdline.h" 37 | #include "server/pebble_server.h" 38 | #include "framework/when_all.h" 39 | 40 | 41 | #endif // _PEBBLE_SERVER_PEBBLE_H_ 42 | -------------------------------------------------------------------------------- /src/server/pebble_cmdline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | #ifndef _PEBBLE_EXTENSION_PEBBLE_CMDLINE_H_ 15 | #define _PEBBLE_EXTENSION_PEBBLE_CMDLINE_H_ 16 | 17 | #include 18 | 19 | #include "common/platform.h" 20 | 21 | 22 | namespace pebble { 23 | 24 | class CmdLineHandler { 25 | public: 26 | CmdLineHandler(); 27 | virtual ~CmdLineHandler(); 28 | 29 | /// @brief 设置业务程序的版本号 30 | /// @param version 业务程序的版本号字符串 31 | void SetVersion(const char* version); 32 | 33 | /// @brief 处理命令行参数 34 | /// @return 0 成功,非0失败 35 | virtual int Process(int argc, char** argv); 36 | 37 | /// @brief 返回命令行参数 --conf_file 的值 38 | const char* ConfigFile() const; 39 | 40 | private: 41 | void MakeDaemon(); 42 | int OnStart(); 43 | int OnStop(); 44 | int OnReload(); 45 | int ReadPidFile(int* pid); 46 | int WritePidFile(); 47 | 48 | private: 49 | std::string m_pid_file; 50 | std::string m_conf_file; 51 | bool m_set_version; 52 | }; 53 | 54 | } // namespace pebble 55 | 56 | #endif // _PEBBLE_EXTENSION_PEBBLE_CMDLINE_H_ 57 | 58 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/AUTHORS: -------------------------------------------------------------------------------- 1 | google-gflags@googlegroups.com 2 | 3 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/README: -------------------------------------------------------------------------------- 1 | This repository contains a C++ of the Google commandline flags module. 2 | Documentation for the C++ implementation is in doc/. The python version of 3 | gflags is now shipped seperately as it is completely independent of this 4 | module. 5 | 6 | See INSTALL for (generic) installation instructions for C++: basically 7 | ./configure && make && make install 8 | 9 | See README_windows.txt for instructions on using under windows. 10 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/README_windows.txt: -------------------------------------------------------------------------------- 1 | You can compile this under Windows, if you want. The solution file 2 | (for VC 7.1 and later) is in this directory. 3 | 4 | I've been told the following steps work to compile this under win64: 5 | 1) Open the provided solution file 6 | 2) Click on the Win32 target (on the right of Debug/Release) 7 | 3) Choose Configuration Manager 8 | 4) In Active Solution Platforms, choose New... 9 | 5) In "Type of select the new platform", choose x64. 10 | In "Copy settings from:" choose Win32. 11 | 6) Ok and then Close 12 | 13 | I don't know very much about how to install DLLs on Windows, so you'll 14 | have to figure out that part for yourself. If you choose to just 15 | re-use the existing .sln, make sure you set the IncludeDir's 16 | appropriately! Look at the properties for libgflags.dll. 17 | 18 | You can also create a static library of gflags. To do this, add 19 | /D GFLAGS_DLL_DECL= /D GFLAGS_DLL_DECLARE_FLAG= /D GFLAGS_DLL_DEFINE_FLAG= 20 | to the compile line of every gflags .cc file. 21 | 22 | If you create a static library that *uses* flags (that is, DEFINEs or 23 | DECLAREs flags), you will need to add the following to every .cc file 24 | that defines or declares a flag (it's safe to add them to every .cc 25 | file in your project): 26 | /D GFLAGS_DLL_DECLARE_FLAG= /D GFLAGS_DLL_DEFINE_FLAG= 27 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/gflags.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libgflags", "vsprojects\libgflags\libgflags.vcproj", "{FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gflags_unittest", "vsprojects\gflags_unittest\gflags_unittest.vcproj", "{4B263748-5F0F-468C-8C5C-ED2682BB6BE3}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC} = {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC} 9 | EndProjectSection 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfiguration) = preSolution 13 | Debug = Debug 14 | Release = Release 15 | EndGlobalSection 16 | GlobalSection(ProjectDependencies) = postSolution 17 | EndGlobalSection 18 | GlobalSection(ProjectConfiguration) = postSolution 19 | {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}.Debug.ActiveCfg = Debug|Win32 20 | {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}.Debug.Build.0 = Debug|Win32 21 | {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}.Release.ActiveCfg = Release|Win32 22 | {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}.Release.Build.0 = Release|Win32 23 | {4B263748-5F0F-468C-8C5C-ED2682BB6BE3}.Debug.ActiveCfg = Debug|Win32 24 | {4B263748-5F0F-468C-8C5C-ED2682BB6BE3}.Debug.Build.0 = Debug|Win32 25 | {4B263748-5F0F-468C-8C5C-ED2682BB6BE3}.Release.ActiveCfg = Release|Win32 26 | {4B263748-5F0F-468C-8C5C-ED2682BB6BE3}.Release.Build.0 = Release|Win32 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | EndGlobalSection 30 | GlobalSection(ExtensibilityAddIns) = postSolution 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/m4/ac_have_attribute.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([AX_C___ATTRIBUTE__], [ 2 | AC_MSG_CHECKING(for __attribute__) 3 | AC_CACHE_VAL(ac_cv___attribute__, [ 4 | AC_TRY_COMPILE( 5 | [#include 6 | static void foo(void) __attribute__ ((unused)); 7 | void foo(void) { exit(1); }], 8 | [], 9 | ac_cv___attribute__=yes, 10 | ac_cv___attribute__=no 11 | )]) 12 | if test "$ac_cv___attribute__" = "yes"; then 13 | AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__]) 14 | fi 15 | AC_MSG_RESULT($ac_cv___attribute__) 16 | ]) 17 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/m4/google_namespace.m4: -------------------------------------------------------------------------------- 1 | # Allow users to override the namespace we define our application's classes in 2 | # Arg $1 is the default namespace to use if --enable-namespace isn't present. 3 | 4 | # In general, $1 should be 'google', so we put all our exported symbols in a 5 | # unique namespace that is not likely to conflict with anyone else. However, 6 | # when it makes sense -- for instance, when publishing stl-like code -- you 7 | # may want to go with a different default, like 'std'. 8 | 9 | # We guarantee the invariant that GOOGLE_NAMESPACE starts with ::, 10 | # unless it's the empty string. Thus, it's always safe to do 11 | # GOOGLE_NAMESPACE::foo and be sure you're getting the foo that's 12 | # actually in the google namespace, and not some other namespace that 13 | # the namespace rules might kick in. 14 | 15 | AC_DEFUN([AC_DEFINE_GOOGLE_NAMESPACE], 16 | [google_namespace_default=[$1] 17 | AC_ARG_ENABLE(namespace, [ --enable-namespace=FOO to define these Google 18 | classes in the FOO namespace. --disable-namespace 19 | to define them in the global namespace. Default 20 | is to define them in namespace $1.], 21 | [case "$enableval" in 22 | yes) google_namespace="$google_namespace_default" ;; 23 | no) google_namespace="" ;; 24 | *) google_namespace="$enableval" ;; 25 | esac], 26 | [google_namespace="$google_namespace_default"]) 27 | if test -n "$google_namespace"; then 28 | ac_google_namespace="::$google_namespace" 29 | ac_google_start_namespace="namespace $google_namespace {" 30 | ac_google_end_namespace="}" 31 | else 32 | ac_google_namespace="" 33 | ac_google_start_namespace="" 34 | ac_google_end_namespace="" 35 | fi 36 | AC_DEFINE_UNQUOTED(GOOGLE_NAMESPACE, $ac_google_namespace, 37 | Namespace for Google classes) 38 | AC_DEFINE_UNQUOTED(_START_GOOGLE_NAMESPACE_, $ac_google_start_namespace, 39 | Puts following code inside the Google namespace) 40 | AC_DEFINE_UNQUOTED(_END_GOOGLE_NAMESPACE_, $ac_google_end_namespace, 41 | Stops putting the code inside the Google namespace) 42 | ]) 43 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # Generated from ltversion.in. 11 | 12 | # serial 3017 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.2.6b]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3017]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.2.6b' 20 | macro_revision='1.3017' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/m4/namespaces.m4: -------------------------------------------------------------------------------- 1 | # Checks whether the compiler implements namespaces 2 | AC_DEFUN([AC_CXX_NAMESPACES], 3 | [AC_CACHE_CHECK(whether the compiler implements namespaces, 4 | ac_cv_cxx_namespaces, 5 | [AC_LANG_SAVE 6 | AC_LANG_CPLUSPLUS 7 | AC_TRY_COMPILE([namespace Outer { 8 | namespace Inner { int i = 0; }}], 9 | [using namespace Outer::Inner; return i;], 10 | ac_cv_cxx_namespaces=yes, 11 | ac_cv_cxx_namespaces=no) 12 | AC_LANG_RESTORE]) 13 | if test "$ac_cv_cxx_namespaces" = yes; then 14 | AC_DEFINE(HAVE_NAMESPACES, 1, [define if the compiler implements namespaces]) 15 | fi]) 16 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/m4/stl_namespace.m4: -------------------------------------------------------------------------------- 1 | # We check what namespace stl code like vector expects to be executed in 2 | 3 | AC_DEFUN([AC_CXX_STL_NAMESPACE], 4 | [AC_CACHE_CHECK( 5 | what namespace STL code is in, 6 | ac_cv_cxx_stl_namespace, 7 | [AC_REQUIRE([AC_CXX_NAMESPACES]) 8 | AC_LANG_SAVE 9 | AC_LANG_CPLUSPLUS 10 | AC_TRY_COMPILE([#include ], 11 | [vector t; return 0;], 12 | ac_cv_cxx_stl_namespace=none) 13 | AC_TRY_COMPILE([#include ], 14 | [std::vector t; return 0;], 15 | ac_cv_cxx_stl_namespace=std) 16 | AC_LANG_RESTORE]) 17 | if test "$ac_cv_cxx_stl_namespace" = none; then 18 | AC_DEFINE(STL_NAMESPACE,, 19 | [the namespace where STL code like vector<> is defined]) 20 | fi 21 | if test "$ac_cv_cxx_stl_namespace" = std; then 22 | AC_DEFINE(STL_NAMESPACE,std, 23 | [the namespace where STL code like vector<> is defined]) 24 | fi 25 | ]) 26 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/packages/deb/compat: -------------------------------------------------------------------------------- 1 | 4 2 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/packages/deb/control: -------------------------------------------------------------------------------- 1 | Source: gflags 2 | Priority: optional 3 | Maintainer: Google Inc. and others 4 | Build-Depends: debhelper (>= 4.0.0), binutils 5 | Standards-Version: 3.6.1 6 | 7 | Package: libgflags-dev 8 | Section: libdevel 9 | Architecture: any 10 | Depends: libgflags0 (= ${Source-Version}) 11 | Description: a library that implements commandline flags 12 | processing. As such it's a replacement for getopt(). It has increased 13 | flexibility, including built-in support for C++ types like string, and 14 | the ability to define flags in the source file in which they're used. 15 | The devel package contains static and debug libraries and header files 16 | for developing applications that use the gflags package. 17 | 18 | Package: libgflags0 19 | Section: libs 20 | Architecture: any 21 | Depends: ${shlibs:Depends} 22 | Description: a library that implements commandline flags 23 | processing. As such it's a replacement for getopt(). It has increased 24 | flexibility, including built-in support for C++ types like string, and 25 | the ability to define flags in the source file in which they're used. 26 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/packages/deb/copyright: -------------------------------------------------------------------------------- 1 | This package was debianized by Craig Silverstein 2 | on Wed, 25 Jan 2012 15:09:14 -0800. 3 | 4 | It was downloaded from http://code.google.com/p/gflags/downloads/list 5 | 6 | Upstream Author: google-gflags@google.com 7 | 8 | Copyright (c) 2006, Google Inc. 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are 13 | met: 14 | 15 | * Redistributions of source code must retain the above copyright 16 | notice, this list of conditions and the following disclaimer. 17 | * Redistributions in binary form must reproduce the above 18 | copyright notice, this list of conditions and the following disclaimer 19 | in the documentation and/or other materials provided with the 20 | distribution. 21 | * Neither the name of Google Inc. nor the names of its 22 | contributors may be used to endorse or promote products derived from 23 | this software without specific prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/packages/deb/docs: -------------------------------------------------------------------------------- 1 | AUTHORS 2 | COPYING 3 | ChangeLog 4 | INSTALL 5 | NEWS 6 | README 7 | doc/designstyle.css 8 | doc/gflags.html 9 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/packages/deb/libgflags-dev.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | usr/lib/pkgconfig 3 | usr/include 4 | usr/include/google 5 | usr/include/gflags 6 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/packages/deb/libgflags-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/google/* 2 | usr/include/gflags/* 3 | usr/lib/lib*.so 4 | usr/lib/lib*.a 5 | usr/lib/*.la 6 | usr/lib/pkgconfig/*.pc 7 | debian/tmp/usr/include/google/* 8 | debian/tmp/usr/include/gflags/* 9 | debian/tmp/usr/lib/lib*.so 10 | debian/tmp/usr/lib/lib*.a 11 | debian/tmp/usr/lib/*.la 12 | debian/tmp/usr/lib/pkgconfig/*.pc 13 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/packages/deb/libgflags0.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | usr/bin 3 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/packages/deb/libgflags0.install: -------------------------------------------------------------------------------- 1 | usr/lib/lib*.so.* 2 | debian/tmp/usr/lib/lib*.so.* 3 | usr/bin/* 4 | debian/tmp/usr/bin/* 5 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/src/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = 'gflags', 3 | srcs = [ 4 | 'gflags.cc', 5 | 'gflags_reporting.cc', 6 | 'gflags_completions.cc', 7 | ], 8 | incs = '.', 9 | deps = '#pthread', 10 | warning = 'no', 11 | defs = ['STRIP_FLAG_HELP'], 12 | ) 13 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/src/config.h: -------------------------------------------------------------------------------- 1 | #ifdef WIN32 2 | // windows system 3 | #include "./windows/config.h" 4 | #else 5 | // linux system 6 | #include "config_linux.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/src/gflags_unittest_flagfile: -------------------------------------------------------------------------------- 1 | --test_flag=1 2 | --test_flag=2 3 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/src/google/gflags.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Header files have moved from the google directory to the gflags 31 | // directory. This forwarding file is provided only for backwards 32 | // compatibility. Use gflags/gflags.h in all new code. 33 | 34 | #include 35 | -------------------------------------------------------------------------------- /thirdparty/gflags-2.0/src/google/gflags_completions.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Header files have moved from the google directory to the gflags 31 | // directory. This forwarding file is provided only for backwards 32 | // compatibility. Use gflags/gflags_completions.h in all new code. 33 | 34 | #include 35 | -------------------------------------------------------------------------------- /thirdparty/gflags/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = 'gflags', 3 | deps = '//thirdparty/gflags-2.0/src:gflags' 4 | ) 5 | 6 | -------------------------------------------------------------------------------- /thirdparty/gflags/ChangeLog: -------------------------------------------------------------------------------- 1 | 2012-04-01 phongchen 2 | * 改进: --help 时支持输出彩色 3 | 4 | 2012-06-01 phongchen 5 | * 升级: 到 2.0 6 | * 修改问题: gflags.h 中的 guard 宏 BASE_COMMANDLINEFLAGS_H_跟perftools 中的冲突,改回 GFLAGS_GFLAGS_H 7 | 8 | -------------------------------------------------------------------------------- /thirdparty/gflags/gflags.h: -------------------------------------------------------------------------------- 1 | #include "thirdparty/gflags-2.0/src/gflags/gflags.h" 2 | -------------------------------------------------------------------------------- /thirdparty/gflags/gflags_completions.h: -------------------------------------------------------------------------------- 1 | #include "thirdparty/gflags-2.0/src/gflags/gflags_completions.h" 2 | -------------------------------------------------------------------------------- /thirdparty/gflags/gflags_declare.h: -------------------------------------------------------------------------------- 1 | #include "thirdparty/gflags-2.0/src/gflags/gflags_declare.h" 2 | -------------------------------------------------------------------------------- /thirdparty/gflags/gflags_test.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Tencent Inc. 2 | // All rights reserved. 3 | // 4 | // Author: CHEN Feng 5 | // Created: 2012-06-01 6 | 7 | #include "thirdparty/gflags/gflags.h" 8 | #include "thirdparty/gtest/gtest.h" 9 | -------------------------------------------------------------------------------- /thirdparty/hiredis/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = 'hiredis', 3 | deps = [ 4 | '//thirdparty/libev/:ev', 5 | ], 6 | prebuilt = True 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /thirdparty/hiredis/fmacros.h: -------------------------------------------------------------------------------- 1 | #ifndef __HIREDIS_FMACRO_H 2 | #define __HIREDIS_FMACRO_H 3 | 4 | #if defined(__linux__) 5 | #define _BSD_SOURCE 6 | #define _DEFAULT_SOURCE 7 | #endif 8 | 9 | #if defined(__sun__) 10 | #define _POSIX_C_SOURCE 200112L 11 | #elif defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__) 12 | #define _XOPEN_SOURCE 600 13 | #else 14 | #define _XOPEN_SOURCE 15 | #endif 16 | 17 | #if __APPLE__ && __MACH__ 18 | #define _OSX 19 | #endif 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /thirdparty/hiredis/lib/libhiredis.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/thirdparty/hiredis/lib/libhiredis.a -------------------------------------------------------------------------------- /thirdparty/hiredis/lib64_release: -------------------------------------------------------------------------------- 1 | link lib/ -------------------------------------------------------------------------------- /thirdparty/hiredis/win32.h: -------------------------------------------------------------------------------- 1 | #ifndef _WIN32_HELPER_INCLUDE 2 | #define _WIN32_HELPER_INCLUDE 3 | #ifdef _MSC_VER 4 | 5 | #ifndef inline 6 | #define inline __inline 7 | #endif 8 | 9 | #ifndef va_copy 10 | #define va_copy(d,s) ((d) = (s)) 11 | #endif 12 | 13 | #ifndef snprintf 14 | #define snprintf c99_snprintf 15 | 16 | __inline int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap) 17 | { 18 | int count = -1; 19 | 20 | if (size != 0) 21 | count = _vsnprintf_s(str, size, _TRUNCATE, format, ap); 22 | if (count == -1) 23 | count = _vscprintf(format, ap); 24 | 25 | return count; 26 | } 27 | 28 | __inline int c99_snprintf(char* str, size_t size, const char* format, ...) 29 | { 30 | int count; 31 | va_list ap; 32 | 33 | va_start(ap, format); 34 | count = c99_vsnprintf(str, size, format, ap); 35 | va_end(ap); 36 | 37 | return count; 38 | } 39 | #endif 40 | 41 | #endif 42 | #endif -------------------------------------------------------------------------------- /thirdparty/libev/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = 'ev', 3 | deps = [ 4 | ], 5 | prebuilt = True 6 | ) 7 | 8 | -------------------------------------------------------------------------------- /thirdparty/libev/lib/libev.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/thirdparty/libev/lib/libev.a -------------------------------------------------------------------------------- /thirdparty/libev/lib64_release: -------------------------------------------------------------------------------- 1 | link lib/ -------------------------------------------------------------------------------- /thirdparty/protobuf/BUILD: -------------------------------------------------------------------------------- 1 | 2 | cc_library( 3 | name = 'protobuf', 4 | prebuilt = True, 5 | ) 6 | 7 | cc_library( 8 | name = 'protoc', 9 | prebuilt = True, 10 | deps = [ 11 | ':protobuf', 12 | ], 13 | ) 14 | -------------------------------------------------------------------------------- /thirdparty/protobuf/README.txt: -------------------------------------------------------------------------------- 1 | ./configure --enable-shared=no --with-pic=yes 2 | 3 | make 4 | 5 | make install 6 | -------------------------------------------------------------------------------- /thirdparty/protobuf/bin/protoc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/thirdparty/protobuf/bin/protoc -------------------------------------------------------------------------------- /thirdparty/protobuf/lib64_release/libprotobuf-lite.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/thirdparty/protobuf/lib64_release/libprotobuf-lite.a -------------------------------------------------------------------------------- /thirdparty/protobuf/lib64_release/libprotobuf.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/thirdparty/protobuf/lib64_release/libprotobuf.a -------------------------------------------------------------------------------- /thirdparty/protobuf/lib64_release/libprotoc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/thirdparty/protobuf/lib64_release/libprotoc.a -------------------------------------------------------------------------------- /thirdparty/rapidjson/internal/strfunc.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ 16 | #define RAPIDJSON_INTERNAL_STRFUNC_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | RAPIDJSON_NAMESPACE_BEGIN 21 | namespace internal { 22 | 23 | //! Custom strlen() which works on different character types. 24 | /*! \tparam Ch Character type (e.g. char, wchar_t, short) 25 | \param s Null-terminated input string. 26 | \return Number of characters in the string. 27 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. 28 | */ 29 | template 30 | inline SizeType StrLen(const Ch* s) { 31 | const Ch* p = s; 32 | while (*p) ++p; 33 | return SizeType(p - s); 34 | } 35 | 36 | } // namespace internal 37 | RAPIDJSON_NAMESPACE_END 38 | 39 | #endif // RAPIDJSON_INTERNAL_STRFUNC_H_ 40 | -------------------------------------------------------------------------------- /thirdparty/zookeeper/BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = 'zookeeper_st', 3 | prebuilt = True 4 | ) 5 | 6 | -------------------------------------------------------------------------------- /thirdparty/zookeeper/include/proto.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef PROTO_H_ 19 | #define PROTO_H_ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #define ZOO_NOTIFY_OP 0 26 | #define ZOO_CREATE_OP 1 27 | #define ZOO_DELETE_OP 2 28 | #define ZOO_EXISTS_OP 3 29 | #define ZOO_GETDATA_OP 4 30 | #define ZOO_SETDATA_OP 5 31 | #define ZOO_GETACL_OP 6 32 | #define ZOO_SETACL_OP 7 33 | #define ZOO_GETCHILDREN_OP 8 34 | #define ZOO_SYNC_OP 9 35 | #define ZOO_PING_OP 11 36 | #define ZOO_GETCHILDREN2_OP 12 37 | #define ZOO_CHECK_OP 13 38 | #define ZOO_MULTI_OP 14 39 | #define ZOO_CLOSE_OP -11 40 | #define ZOO_SETAUTH_OP 100 41 | #define ZOO_SETWATCHES_OP 101 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif /*PROTO_H_*/ 48 | -------------------------------------------------------------------------------- /thirdparty/zookeeper/include/zookeeper_log.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #ifndef THIRDPARTY_ZOOKEEPER_INCLUDE_ZOOKEEPER_LOG_H_ 20 | #define THIRDPARTY_ZOOKEEPER_INCLUDE_ZOOKEEPER_LOG_H_ 21 | 22 | #include 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | extern ZOOAPI ZooLogLevel logLevel; 29 | #define LOGSTREAM getLogStream() 30 | 31 | #define LOG_ERROR(x) if (logLevel >= ZOO_LOG_LEVEL_ERROR) \ 32 | log_message(ZOO_LOG_LEVEL_ERROR, __LINE__, __func__, format_log_message x) 33 | #define LOG_WARN(x) if (logLevel >= ZOO_LOG_LEVEL_WARN) \ 34 | log_message(ZOO_LOG_LEVEL_WARN, __LINE__, __func__, format_log_message x) 35 | #define LOG_INFO(x) if (logLevel >= ZOO_LOG_LEVEL_INFO) \ 36 | log_message(ZOO_LOG_LEVEL_INFO, __LINE__, __func__, format_log_message x) 37 | #define LOG_DEBUG(x) if (logLevel == ZOO_LOG_LEVEL_DEBUG) \ 38 | log_message(ZOO_LOG_LEVEL_DEBUG, __LINE__, __func__, format_log_message x) 39 | 40 | ZOOAPI void log_message(ZooLogLevel curLevel, int line, const char* funcName, 41 | const char* message); 42 | 43 | ZOOAPI const char* format_log_message(const char* format, ...); 44 | 45 | FILE* getLogStream(); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif // THIRDPARTY_ZOOKEEPER_INCLUDE_ZOOKEEPER_LOG_H_ 52 | -------------------------------------------------------------------------------- /thirdparty/zookeeper/include/zookeeper_version.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef ZOOKEEPER_VERSION_H_ 19 | #define ZOOKEEPER_VERSION_H_ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | #define ZOO_MAJOR_VERSION 3 26 | #define ZOO_MINOR_VERSION 4 27 | #define ZOO_PATCH_VERSION 6 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif /* ZOOKEEPER_VERSION_H_ */ 34 | -------------------------------------------------------------------------------- /thirdparty/zookeeper/lib64_release/libzookeeper_st.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/thirdparty/zookeeper/lib64_release/libzookeeper_st.a -------------------------------------------------------------------------------- /thirdparty/zookeeper/version.txt: -------------------------------------------------------------------------------- 1 | build from 3.4.6 2 | -------------------------------------------------------------------------------- /tools/blade/COPYING: -------------------------------------------------------------------------------- 1 | Copyright 2012, Tencent Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Tencent Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | ---------------------------------------------------------------------------- 31 | iQIYI Copyright declaration: 32 | 33 | iQIYI 公司授予腾讯公司永久的,全球性的,非排他性的,免费的,免版税的, 34 | 不可撤销的版权许可,把对blade支持thrift的所做的修改贡献给腾讯公司的开 35 | 源项目 Blade (https://code.google.com/p/typhoon-blade/),允许其合并到 36 | 项目代码中。iQIYI 公司愿意在遵守Blade所选择的开源License的基础上,保 37 | 留对贡献代码的版权。 38 | -------------------------------------------------------------------------------- /tools/blade/ChangeLog: -------------------------------------------------------------------------------- 1 | 2012-08-21 Tencent Inc. 2 | 3 | * blade: version 1.0 4 | * initialize opensource release 5 | 6 | 2012-12-25 Tencent Inc. 7 | 8 | * Add is_debug for build_target 9 | * Add prompt message to source bashrc after install blade 10 | * Skip making duplicate prebuit lib symlink and remove useless warning 11 | * Add graphviz output to blade query command. 12 | * Do not exit when symlink existed 13 | * Fixed loop dependency detecting in recursive method 14 | * Updated user manual-config part of blade_user_manual.pdf 15 | * Allow libs in global config files starts with '//' 16 | 17 | 2013-02-21 Tencent Inc. 18 | 19 | * Fix readlink compatible issue, enable run blade on MAC. 20 | * Add cpp_flags, c_flags, cxx_flags to cc_config 21 | * Dump the CC CPP CXX LD at startup 22 | * Add prompt message to source bashrc after install blade 23 | * Refactoring configure 24 | * Add -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 25 | to enable full functional stdint.h and inttypes.h for C++ 26 | 27 | 2013-03-21 Tencent Inc. 28 | 29 | * Make test run easier and python 2.6 compatible. 30 | * Fix problem of no response to ctrl-c when run tests 31 | * Support --gcov for gcc 3.x 32 | * Enlarge the size of stack size warning to 64+8k 33 | 34 | 2013-04-23 Tencent Inc. 35 | 36 | * Support thrift_library (thanks iQIYI) 37 | * Add 'warnings' option to cc_config, so you can custom warning, 38 | see the blade.conf for example. 39 | * Add 'export_incs' to cc_library, see example/extra for usage, thanks to 40 | whuwxl. 41 | * Fix bug of detecting ccache installation. thanks to yeshunping. 42 | 43 | 2013-05-25 Tencent Inc. 44 | * Add cc_config:optimize config option, see blade.conf 45 | * Fix command line parsing bug on python 2.7.0. 46 | * Support python 2.4 now. 47 | * Th install command support zsh. 48 | * Integrate cpplint in to blade, thanks to yehsunping. 49 | * Update Documentations. 50 | 51 | Copyright 2012, 2013 Tencent, Inc. 52 | -------------------------------------------------------------------------------- /tools/blade/OWNERS: -------------------------------------------------------------------------------- 1 | michaelpeng 2 | phongchen 3 | -------------------------------------------------------------------------------- /tools/blade/blade.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/blade.zip -------------------------------------------------------------------------------- /tools/blade/bootstrap.py: -------------------------------------------------------------------------------- 1 | 2 | """This is the entry point to load and run blade package. 3 | """ 4 | 5 | 6 | import sys 7 | import os.path 8 | 9 | # Load package from blade.zip or source dir? 10 | blade_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'blade.zip')) 11 | # blade_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src/blade')) 12 | sys.path.insert(0, blade_path) 13 | import blade_main 14 | 15 | 16 | blade_main.main(blade_path) 17 | 18 | -------------------------------------------------------------------------------- /tools/blade/cpplint.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/cpplint.py -------------------------------------------------------------------------------- /tools/blade/dist_blade: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # make_blade_zip 3 | # AUTHOR: Michael 4 | # DATE: Dec 17 2011 5 | # REV: 1.1.A (Valid are A, B, D, T and P) 6 | # (For Alpha, Beta, Dev, Test and Production) 7 | # 8 | # PLATFORM: Linux 9 | # PURPOSE : This script is used to make blade sources to be a zip ball. 10 | # REV LIST: 11 | # DATE: Dec 17 2011 12 | # BY : Michaelpeng 13 | # MODIFICATION: Created 14 | 15 | 16 | function make_blade_zip() 17 | { 18 | blade_dir=$(cd $(dirname $0) && pwd) 19 | cd $blade_dir 20 | 21 | echo "Blade directory: ${blade_dir}" 22 | src_dir='./src/blade' 23 | dist_file_path=${blade_dir}'/blade.zip' 24 | 25 | cd $src_dir 26 | 27 | zip blade.zip ./*.py 28 | mv ./blade.zip ${dist_file_path} 29 | 30 | cd $blade_dir 31 | 32 | echo 'Done' 33 | } 34 | 35 | make_blade_zip 36 | 37 | -------------------------------------------------------------------------------- /tools/blade/doc/blade.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/doc/blade.pdf -------------------------------------------------------------------------------- /tools/blade/doc/blade.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/doc/blade.ppt -------------------------------------------------------------------------------- /tools/blade/doc/blade_user_manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/doc/blade_user_manual.pdf -------------------------------------------------------------------------------- /tools/blade/genlibbuild: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # generate BUILD file for library dir 3 | 4 | shopt -s nullglob 5 | 6 | libname=$(basename $(pwd)) 7 | 8 | echo -e "# generated by $(basename $0)\n" 9 | 10 | # generate proto_library 11 | for src in *.proto; do 12 | echo -e "proto_library(\n name = '${src/./_}',\n srcs = '$src'\n)\n" 13 | done 14 | 15 | # generate cc_library 16 | test_src_pattern='_test\.c.*$' 17 | echo -e "cc_library(\n name = '$libname',\n srcs = [" 18 | for src in *.{c,cc,cpp,cxx}; do 19 | if ! [[ $src =~ $test_src_pattern ]]; then 20 | echo " '$src'," 21 | fi 22 | done 23 | echo -e " ]\n)\n" 24 | 25 | # generate cc_test 26 | for src in *_test.{c,cc,cpp,cxx}; do 27 | echo -e "\ncc_test(\n name = '${src/.*/}',\n srcs = ['$src'],\n deps = [':$libname']\n)\n" 28 | done 29 | 30 | 31 | -------------------------------------------------------------------------------- /tools/blade/install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | blade_dir=$(cd $(dirname $0) && pwd) 4 | cd $blade_dir 5 | 6 | echo -n "Installing vim scripts..." 7 | mkdir -p ~/.vim/{syntax,ftdetect,indent} 8 | ln -sf $blade_dir/vim/ftdetect/blade.vim ~/.vim/ftdetect/ 9 | ln -sf $blade_dir/vim/syntax/blade.vim ~/.vim/syntax/ 10 | ln -sf $blade_dir/vim/indent/blade.vim ~/.vim/indent/ 11 | 12 | if [ ! -f ~/.vimrc ]; then 13 | touch ~/.vimrc 14 | fi 15 | 16 | if ! grep "set filetype=blade" ~/.vimrc 2>&1 >/dev/null; then 17 | cat >> ~/.vimrc << END 18 | augroup filetype 19 | autocmd! BufRead,BufNewFile BUILD set filetype=blade 20 | augroup end 21 | END 22 | fi 23 | echo ", Done." 24 | 25 | mkdir -p ~/bin 26 | echo -n "Installing blade auxiliary tools..." 27 | ln -sf $blade_dir/{cpplint.py,genlibbuild,lsnobuild,lsrc,merge-static-libs,bladefunctions} ~/bin 28 | if [ ! -f ~/.bashrc ] || ! grep "bladefunctions" ~/.bashrc 2>&1 >/dev/null; then 29 | echo "test -s ~/bin/bladefunctions && . ~/bin/bladefunctions || true" >> ~/.bashrc 30 | fi 31 | echo ", Done." 32 | 33 | echo -n "Installing blade..." 34 | ln -sf $blade_dir/blade ~/bin 35 | echo ", Done." 36 | 37 | if ! echo $PATH | grep "$HOME/bin" &> /dev/null; then 38 | echo 'export PATH=~/bin:$PATH' >> ~/.profile 39 | 40 | if echo $SHELL | grep "zsh" &> /dev/null; then 41 | echo 'export PATH=~/bin:$PATH' >> ~/.zshrc 42 | fi 43 | fi 44 | 45 | echo -e "\033[1;32mAll successful, please log in again or source ~/.profile manually\033[0m" 46 | -------------------------------------------------------------------------------- /tools/blade/lsnobuild: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # list Makefiles without corresponding BUILD 3 | 4 | find -name Makefile | \ 5 | while read f; do 6 | if [ ! -f "`dirname $f`/BUILD" ] ; then 7 | echo $f; 8 | fi 9 | done 10 | -------------------------------------------------------------------------------- /tools/blade/lsrc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # list srcs as BUILD file format, except test files. 3 | 4 | shopt -s nullglob 5 | 6 | first=1 7 | 8 | function output () 9 | { 10 | local src_pattern='\w+\.(c|cc|cpp)$' 11 | local test_pattern='[-_](unit)?test\.c*' 12 | # all sources except tests 13 | if [[ $1 =~ $src_pattern && \ 14 | ! $1 =~ $test_pattern ]]; then 15 | if [ $first -eq 0 ]; then 16 | echo -en ",\n" 17 | else 18 | first=0 19 | fi 20 | echo -n " '$1'" 21 | fi 22 | } 23 | 24 | function handle_dir () 25 | { 26 | local dir 27 | dir=$1 28 | if [ ! -z "$dir" ]; then 29 | if [ "$dir" = '.' ]; then 30 | dir= 31 | elif ! [[ "$dir" =~ /$ ]]; then 32 | dir=$dir/ 33 | fi 34 | fi 35 | for src in $dir*.{c,cc,cpp,cxx}; do 36 | output $src 37 | done 38 | } 39 | 40 | function handle_entry () 41 | { 42 | for entry in $@; do 43 | if [ -d $entry ]; then 44 | handle_dir $entry 45 | else 46 | output $entry 47 | fi 48 | done 49 | } 50 | 51 | echo -e ' srcs = [' 52 | 53 | if [ $# -eq 0 ]; then 54 | handle_entry *.* 55 | else 56 | handle_entry $@ 57 | fi 58 | 59 | echo -e '\n ]' 60 | -------------------------------------------------------------------------------- /tools/blade/merge-static-libs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | if [ $# -lt 1 ]; then 6 | echo "Usage [build arguments]" 7 | exit 1; 8 | fi 9 | 10 | target_pattern="^:[A-Za-z0-9+_.-]+$" 11 | 12 | if [[ ! "$1" =~ $target_pattern ]]; then 13 | echo "Invalid target name, can only be :name" 14 | fi 15 | 16 | # :poppy -> poppy 17 | name=${1/:/} 18 | 19 | blade build $@ 20 | source `dirname $0`/bladefunctions 21 | wd=`pwd` 22 | root=`_find_project_root` 23 | relwd="${wd/${root}/}" 24 | 25 | o=`blade query "$1" --deps` 26 | cd $root 27 | 28 | libname="$wd/lib${name}.a" 29 | rm -f "$libname" 30 | ar -q "$libname" 31 | macname="merge-$$.mac" 32 | echo "OPEN $libname" > $macname 33 | echo "ADDLIB blade-bin$relwd/lib$name.a" >> $macname 34 | 35 | libpattern="^[A-Za-z0-9+_./-]+:[A-Za-z0-9+_.-]+$" 36 | syslibpattern="^.+" 37 | 38 | echo "$o" | while read line; do 39 | if [[ "$line" =~ $libpattern ]]; then 40 | lib="blade-bin/${line/://lib}.a" 41 | echo "ADDLIB $lib" >> $macname 42 | else 43 | if [[ -n "$line" ]]; then 44 | if [[ "$line" =~ $syslibpattern ]]; then 45 | echo -e "\033[1;33m$line is a system library and then can't be merged,"\ 46 | "don't forget to link it\033[m" 47 | else 48 | echo -e "\033[1;33mIgnore unknown libname: $line\033[m" 49 | fi 50 | fi 51 | fi 52 | done 53 | echo "SAVE" >> $macname 54 | echo "END" >> $macname 55 | 56 | ar -M < $macname 57 | ranlib $libname 58 | rm $macname 59 | echo "$libname generated" 60 | -------------------------------------------------------------------------------- /tools/blade/opensource-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Author: CHEN Feng 3 | # Make opensource release package 4 | 5 | set -e 6 | 7 | if [ $# -ne 1 ]; then 8 | echo "$0 " >&2 9 | exit 1 10 | fi 11 | 12 | version="$1" 13 | 14 | blade_dir=$(cd $(dirname $0) && pwd) 15 | cd $blade_dir 16 | 17 | ./dist_blade 18 | 19 | cd .. 20 | mv blade/blade.conf blade.conf.org 21 | cp blade/opensource.conf blade/blade.conf 22 | tar cjvf blade-$version.tbz blade 23 | 24 | # Restore blade.conf 25 | mv blade.conf.org blade/blade.conf 26 | 27 | echo 'Done' 28 | 29 | -------------------------------------------------------------------------------- /tools/blade/src/blade/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/blade/__init__.py -------------------------------------------------------------------------------- /tools/blade/src/blade/__main__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | 4 | """About main entry 5 | 6 | Main entry is placed to __main__.py, cause we need to pack 7 | the python sources to a zip ball and invoke the blade through 8 | command line in this way: python blade.zip 9 | 10 | """ 11 | 12 | 13 | import sys 14 | from blade_main import main 15 | 16 | 17 | if __name__ == '__main__': 18 | main(sys.argv[0]) 19 | -------------------------------------------------------------------------------- /tools/blade/src/blade/build_rules.py: -------------------------------------------------------------------------------- 1 | """ 2 | Manage symbols can be used in BUILD files. 3 | """ 4 | 5 | 6 | __build_rules = {} 7 | 8 | 9 | def register_variable(name, value): 10 | """Register a variable that accessiable in BUILD file """ 11 | __build_rules[name] = value 12 | 13 | 14 | def register_function(f): 15 | """Register a function as a build function that callable in BUILD file """ 16 | register_variable(f.__name__, f) 17 | 18 | 19 | def get_all(): 20 | """Get the globals dict""" 21 | return __build_rules 22 | -------------------------------------------------------------------------------- /tools/blade/src/blade/console.py: -------------------------------------------------------------------------------- 1 | """ 2 | This is the util module which provides command functions. 3 | 4 | """ 5 | 6 | 7 | import os 8 | import sys 9 | 10 | 11 | # Global color enabled or not 12 | color_enabled = (sys.stdout.isatty() and 13 | os.environ['TERM'] not in ('emacs', 'dumb')) 14 | 15 | 16 | # _colors 17 | _colors = {} 18 | _colors['red'] = '\033[1;31m' 19 | _colors['green'] = '\033[1;32m' 20 | _colors['yellow'] = '\033[1;33m' 21 | _colors['blue'] = '\033[1;34m' 22 | _colors['purple'] = '\033[1;35m' 23 | _colors['cyan'] = '\033[1;36m' 24 | _colors['white'] = '\033[1;37m' 25 | _colors['gray'] = '\033[1;38m' 26 | _colors['end'] = '\033[0m' 27 | 28 | 29 | def colors(name): 30 | """Return ansi console control sequence from color name""" 31 | if color_enabled: 32 | return _colors[name] 33 | return '' 34 | 35 | 36 | def error(msg): 37 | """dump error message. """ 38 | msg = 'Blade(error): ' + msg 39 | if color_enabled: 40 | msg = _colors['red'] + msg + _colors['end'] 41 | print >>sys.stderr, msg 42 | 43 | 44 | def error_exit(msg, code=1): 45 | """dump error message and exit. """ 46 | error(msg) 47 | sys.exit(code) 48 | 49 | 50 | def warning(msg): 51 | """dump warning message but continue. """ 52 | msg = 'Blade(warning): ' + msg 53 | if color_enabled: 54 | msg = _colors['yellow'] + msg + _colors['end'] 55 | print >>sys.stderr, msg 56 | 57 | 58 | def info(msg, prefix=True): 59 | """dump info message. """ 60 | if prefix: 61 | msg = 'Blade(info): ' + msg 62 | if color_enabled: 63 | msg = _colors['cyan'] + msg + _colors['end'] 64 | print >>sys.stderr, msg 65 | -------------------------------------------------------------------------------- /tools/blade/src/test/cc_binary_test.py: -------------------------------------------------------------------------------- 1 | """ 2 | This is the test module for cc_binary target. 3 | 4 | """ 5 | 6 | 7 | import blade_test 8 | 9 | 10 | class TestCcBinary(blade_test.TargetTest): 11 | """Test cc_binary """ 12 | def setUp(self): 13 | """setup method. """ 14 | self.doSetUp('test_cc_binary') 15 | 16 | def testGenerateRules(self): 17 | """Test that rules are generated correctly. """ 18 | self.all_targets = self.blade.analyze_targets() 19 | self.rules_buf = self.blade.generate_build_rules() 20 | 21 | cc_library_lower = (self.target_path, 'lowercase') 22 | cc_library_upper = (self.target_path, 'uppercase') 23 | cc_library_string = (self.target_path, 'string_main_prog') 24 | 25 | self.assertTrue(cc_library_lower in self.all_targets.keys()) 26 | self.assertTrue(cc_library_upper in self.all_targets.keys()) 27 | self.assertTrue(cc_library_string in self.all_targets.keys()) 28 | 29 | self.assertTrue(self.dryRun()) 30 | 31 | com_lower_line = '' 32 | com_upper_line = '' 33 | com_string_line = '' 34 | string_main_depends_libs = '' 35 | for line in self.scons_output: 36 | if 'plowercase.cpp.o -c' in line: 37 | com_lower_line = line 38 | if 'puppercase.cpp.o -c' in line: 39 | com_upper_line = line 40 | if 'string_main.cpp.o -c' in line: 41 | com_string_line = line 42 | if 'string_main_prog' in line: 43 | string_main_depends_libs = line 44 | 45 | self.assertCxxFlags(com_lower_line) 46 | self.assertCxxFlags(com_upper_line) 47 | self.assertCxxFlags(com_string_line) 48 | 49 | self.assertLinkFlags(string_main_depends_libs) 50 | self.assertTrue('liblowercase.a' in string_main_depends_libs) 51 | self.assertTrue('libuppercase.a' in string_main_depends_libs) 52 | 53 | 54 | if __name__ == '__main__': 55 | blade_test.run(TestCcBinary) 56 | -------------------------------------------------------------------------------- /tools/blade/src/test/cc_plugin_test.py: -------------------------------------------------------------------------------- 1 | """ 2 | This is the test module for cc_plugin target. 3 | 4 | """ 5 | 6 | 7 | import blade_test 8 | 9 | 10 | class TestCcPlugin(blade_test.TargetTest): 11 | """Test cc_plugin """ 12 | def setUp(self): 13 | """setup method. """ 14 | self.doSetUp('test_cc_plugin') 15 | 16 | def testGenerateRules(self): 17 | """Test that rules are generated correctly. """ 18 | self.all_targets = self.blade.analyze_targets() 19 | self.rules_buf = self.blade.generate_build_rules() 20 | 21 | cc_library_lower = (self.target_path, 'lowercase') 22 | cc_library_upper = (self.target_path, 'uppercase') 23 | cc_library_string = (self.target_path, 'string_plugin') 24 | self.command_file = 'cmds.tmp' 25 | 26 | self.assertTrue(cc_library_lower in self.all_targets.keys()) 27 | self.assertTrue(cc_library_upper in self.all_targets.keys()) 28 | self.assertTrue(cc_library_string in self.all_targets.keys()) 29 | 30 | self.assertTrue(self.dryRun()) 31 | 32 | com_lower_line = '' 33 | com_upper_line = '' 34 | com_string_line = '' 35 | string_main_depends_libs = '' 36 | for line in self.scons_output: 37 | if 'plowercase.cpp.o -c' in line: 38 | com_lower_line = line 39 | if 'puppercase.cpp.o -c' in line: 40 | com_upper_line = line 41 | if 'string_plugin.cpp.o -c' in line: 42 | com_string_line = line 43 | if 'libstring_plugin.so' in line: 44 | string_plugin_depends_libs = line 45 | 46 | self.assertCxxFlags(com_lower_line) 47 | self.assertCxxFlags(com_upper_line) 48 | self.assertCxxFlags(com_string_line) 49 | 50 | self.assertDynamicLinkFlags(string_plugin_depends_libs) 51 | self.assertTrue('-Wl,-Bsymbolic' in string_plugin_depends_libs) 52 | self.assertTrue('liblowercase.a' in string_plugin_depends_libs) 53 | self.assertTrue('libuppercase.a' in string_plugin_depends_libs) 54 | 55 | 56 | if __name__ == '__main__': 57 | blade_test.run(TestCcPlugin) 58 | -------------------------------------------------------------------------------- /tools/blade/src/test/cc_test_test.py: -------------------------------------------------------------------------------- 1 | """ 2 | This is the test module for cc_test target. 3 | 4 | """ 5 | 6 | 7 | import blade_test 8 | 9 | 10 | class TestCcTest(blade_test.TargetTest): 11 | """Test cc_test """ 12 | def setUp(self): 13 | """setup method. """ 14 | self.doSetUp('test_cc_test') 15 | 16 | def testGenerateRules(self): 17 | """Test that rules are generated correctly. """ 18 | self.all_targets = self.blade.analyze_targets() 19 | self.rules_buf = self.blade.generate_build_rules() 20 | 21 | cc_library_lower = (self.target_path, 'lowercase') 22 | cc_library_upper = (self.target_path, 'uppercase') 23 | cc_library_string = (self.target_path, 'string_test_main') 24 | self.command_file = 'cmds.tmp' 25 | 26 | self.assertTrue(cc_library_lower in self.all_targets.keys()) 27 | self.assertTrue(cc_library_upper in self.all_targets.keys()) 28 | self.assertTrue(cc_library_string in self.all_targets.keys()) 29 | 30 | self.assertTrue(self.dryRun()) 31 | 32 | com_lower_line = '' 33 | com_upper_line = '' 34 | com_string_line = '' 35 | string_main_depends_libs = '' 36 | for line in self.scons_output: 37 | if 'plowercase.cpp.o -c' in line: 38 | com_lower_line = line 39 | if 'puppercase.cpp.o -c' in line: 40 | com_upper_line = line 41 | if 'string_test.cpp.o -c' in line: 42 | com_string_line = line 43 | if 'string_test_main' in line: 44 | string_main_depends_libs = line 45 | 46 | self.assertCxxFlags(com_lower_line) 47 | self.assertCxxFlags(com_upper_line) 48 | self.assertCxxFlags(com_string_line) 49 | 50 | self.assertLinkFlags(string_main_depends_libs) 51 | self.assertTrue('liblowercase.a' in string_main_depends_libs) 52 | self.assertTrue('libuppercase.a' in string_main_depends_libs) 53 | 54 | 55 | if __name__ == '__main__': 56 | blade_test.run(TestCcTest) 57 | -------------------------------------------------------------------------------- /tools/blade/src/test/gen_rule_test.py: -------------------------------------------------------------------------------- 1 | """ 2 | This is the test module for cc_gen_rule target. 3 | 4 | """ 5 | 6 | 7 | import blade_test 8 | 9 | 10 | class TestGenRule(blade_test.TargetTest): 11 | """Test gen_rule """ 12 | def setUp(self): 13 | """setup method. """ 14 | self.doSetUp('test_gen_rule') 15 | 16 | def testGenerateRules(self): 17 | """Test that rules are generated correctly. """ 18 | self.all_targets = self.blade.analyze_targets() 19 | self.rules_buf = self.blade.generate_build_rules() 20 | 21 | cc_library_lower = (self.target_path, 'lowercase') 22 | cc_library_upper = (self.target_path, 'uppercase') 23 | gen_rule = (self.target_path, 'process_media') 24 | self.command_file = 'cmds.tmp' 25 | 26 | self.assertTrue(cc_library_lower in self.all_targets.keys()) 27 | self.assertTrue(cc_library_upper in self.all_targets.keys()) 28 | self.assertTrue(gen_rule in self.all_targets.keys()) 29 | 30 | self.assertTrue(self.dryRun()) 31 | 32 | com_lower_line = '' 33 | com_upper_line = '' 34 | 35 | lower_so_index = 0 36 | gen_rule_index = 0 37 | upper_so_index = 0 38 | index = 0 39 | 40 | for line in self.scons_output: 41 | index += 1 42 | if 'plowercase.cpp.o -c' in line: 43 | com_lower_line = line 44 | if 'puppercase.cpp.o -c' in line: 45 | com_upper_line = line 46 | if 'echo' in line: 47 | gen_rule_index = index 48 | if 'liblowercase.so -m64' in line: 49 | lower_so_index = index 50 | if 'libuppercase.so -m64' in line: 51 | upper_so_index = index 52 | 53 | self.assertCxxFlags(com_lower_line) 54 | self.assertCxxFlags(com_upper_line) 55 | 56 | self.assertTrue(gen_rule_index > lower_so_index) 57 | self.assertTrue(upper_so_index, gen_rule_index) 58 | 59 | 60 | if __name__ == '__main__': 61 | blade_test.run(TestGenRule) 62 | -------------------------------------------------------------------------------- /tools/blade/src/test/load_builds_test.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | This is the TestLoadBuilds module which tests the loading 4 | function of blade. 5 | 6 | """ 7 | 8 | 9 | import blade_test 10 | 11 | 12 | class TestLoadBuilds(blade_test.TargetTest): 13 | """Test load builds. """ 14 | def setUp(self): 15 | """setup method. """ 16 | self.doSetUp('test_loadbuilds') 17 | 18 | def testAllCommandTargets(self): 19 | """Test that all targets in the test project BUILD files 20 | 21 | are in the all command targets list. 22 | 23 | """ 24 | proto_library = (self.target_path, 'rpc_meta_info_proto') 25 | cc_library = (self.target_path, 'poppy') 26 | static_resource = (self.target_path, 'static_resource') 27 | cc_test = (self.target_path, 'rpc_channel_test') 28 | swig_library = (self.target_path, 'poppy_client') 29 | lex_yacc_library = (self.target_path, 'parser') 30 | cc_plugin = (self.target_path, 'meter_business') 31 | gen_rule = (self.target_path, 'search_service_echo') 32 | java_jar = (self.target_path, 'poppy_java_client') 33 | cc_binary = (self.target_path, 'echoserver') 34 | 35 | target_list = [] 36 | l = target_list 37 | l.append(proto_library) 38 | l.append(cc_library) 39 | l.append(static_resource) 40 | l.append(cc_test) 41 | l.append(swig_library) 42 | l.append(lex_yacc_library) 43 | l.append(cc_plugin) 44 | l.append(gen_rule) 45 | l.append(java_jar) 46 | l.append(cc_binary) 47 | 48 | target_count = 0 49 | for target in target_list: 50 | if target in self.all_command_targets: 51 | target_count += 1 52 | else: 53 | self.fail(msg='(%s, %s) not in all command targets, failed' % ( 54 | target[0], target[1])) 55 | break 56 | 57 | self.assertEqual(target_count, 10) 58 | 59 | if __name__ == '__main__': 60 | blade_test.run(TestLoadBuilds) 61 | -------------------------------------------------------------------------------- /tools/blade/src/test/prebuild_cc_library_test.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | This is the test module for prebuild_cc_library target. 4 | 5 | """ 6 | 7 | 8 | import blade_test 9 | 10 | 11 | class TestPrebuildCcLibrary(blade_test.TargetTest): 12 | """Test cc_library """ 13 | def setUp(self): 14 | """setup method. """ 15 | self.doSetUp('test_prebuild_cc_library') 16 | 17 | def testGenerateRules(self): 18 | """Test that rules are generated correctly. 19 | 20 | Scons can use the rules for dry running. 21 | 22 | """ 23 | self.all_targets = self.blade.analyze_targets() 24 | self.rules_buf = self.blade.generate_build_rules() 25 | 26 | cc_library_lower = (self.target_path, 'lowercase') 27 | cc_library_upper = (self.target_path, 'uppercase') 28 | 29 | self.assertTrue(cc_library_lower in self.all_targets.keys()) 30 | self.assertTrue(cc_library_upper in self.all_targets.keys()) 31 | 32 | self.assertTrue(self.dryRun()) 33 | 34 | copy_lower_line = '' 35 | com_upper_line = '' 36 | upper_depends_libs = '' 37 | for line in self.scons_output: 38 | if 'Copy' in line: 39 | copy_lower_line = line 40 | if 'puppercase.cpp.o -c' in line: 41 | com_upper_line = line 42 | if 'libuppercase.so -m64' in line: 43 | upper_depends_libs = line 44 | 45 | self.assertTrue('test_prebuild_cc_library/liblowercase.so' in copy_lower_line) 46 | self.assertTrue('lib64_release/liblowercase.so' in copy_lower_line) 47 | 48 | self.assertTrue('-Wall -Wextra' in com_upper_line) 49 | self.assertTrue('-Wframe-larger-than=69632' in com_upper_line) 50 | self.assertTrue('-Werror=overloaded-virtual' in com_upper_line) 51 | 52 | self.assertTrue(upper_depends_libs) 53 | self.assertTrue('libuppercase.so -m64' in upper_depends_libs) 54 | self.assertTrue('liblowercase.so' in upper_depends_libs) 55 | 56 | 57 | if __name__ == '__main__': 58 | blade_test.run(TestPrebuildCcLibrary) 59 | -------------------------------------------------------------------------------- /tools/blade/src/test/query_target_test.py: -------------------------------------------------------------------------------- 1 | """ 2 | This is the test module to test query function of blade. 3 | 4 | """ 5 | 6 | 7 | import blade_test 8 | 9 | 10 | class TestQuery(blade_test.TargetTest): 11 | """Test cc_library """ 12 | def setUp(self): 13 | """setup method. """ 14 | self.doSetUp('test_query', full_targets=['...'], command='query') 15 | self.query_targets = ['test_query:poppy'] 16 | self.all_targets = self.blade.get_build_targets() 17 | 18 | def testQueryCorrectly(self): 19 | """Test query targets dependency relationship correctly. """ 20 | self.assertTrue(self.all_targets) 21 | result_map = {} 22 | result_map = self.blade.query_helper(self.query_targets) 23 | all_targets = self.blade.get_build_targets() 24 | query_key = ('test_query', 'poppy') 25 | self.assertTrue(query_key in result_map.keys()) 26 | deps = result_map.get(query_key, [])[0] 27 | depended_by = result_map.get(query_key, [])[1] 28 | 29 | self.assertTrue(deps) 30 | self.assertTrue(depended_by) 31 | 32 | dep_one_key = ('test_query', 'rpc_meta_info_proto') 33 | dep_second_key = ('test_query', 'static_resource') 34 | self.assertTrue(dep_one_key in deps) 35 | self.assertTrue(dep_second_key in deps) 36 | 37 | depended_one_key = ('test_query', 'poppy_client') 38 | depended_second_key = ('test_query', 'poppy_mock') 39 | self.assertTrue(depended_one_key in depended_by) 40 | self.assertTrue(depended_second_key in depended_by) 41 | 42 | 43 | if __name__ == '__main__': 44 | blade_test.run(TestQuery) 45 | -------------------------------------------------------------------------------- /tools/blade/src/test/runalltests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2011 Tencent Inc. 4 | # All rights reserved. 5 | # 6 | # Author: CHEN Feng 7 | # Created: Feb 22, 2013 8 | # 9 | # Script to setup, run and cleanup testing. 10 | 11 | exec `dirname $0`/runtest.sh blade_main_test.py $@ 12 | -------------------------------------------------------------------------------- /tools/blade/src/test/runtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2011 Tencent Inc. 4 | # All rights reserved. 5 | # 6 | # Author: CHEN Feng 7 | # Created: Feb 22, 2013 8 | # 9 | # Script to setup, run and cleanup testing. 10 | 11 | if [ $# -lt 1 ]; then 12 | echo "Usage: $1 " >&2 13 | exit 1 14 | fi 15 | 16 | function cleanup() 17 | { 18 | # Cleanup BLADE_ROOT and BUILDs to avoid ran by 'blade build ...' on upper dirs 19 | find testdata -name BUILD | xargs rm 20 | rm -rf testdata/BLADE_ROOT 21 | 22 | # Cleanup generated files 23 | rm -rf testdata/{BLADE_ROOT,blade-bin,build64_release/,.blade.test.stamp,.sconsign.dblite,blade_tests_detail,.Building.lock} SConstruct 24 | rm -f *.pyc ../blade/*.pyc 25 | } 26 | 27 | cd `dirname $0` 28 | 29 | # Cleanup before running 30 | rm -rf testdata/blade-bin/ testdata/build64_release/ 31 | 32 | for f in `find testdata -name BUILD.TEST`; do 33 | cp $f ${f%.TEST} 34 | done 35 | cp testdata/BLADE_ROOT.TEST testdata/BLADE_ROOT 36 | 37 | python -B $@ 38 | exit_code=$? 39 | 40 | cleanup 41 | 42 | exit $exit_code 43 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_binary/BUILD.TEST: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name='lowercase', 3 | srcs=[ 4 | 'plowercase.cpp' 5 | ], 6 | deps=['#pthread'], 7 | warning='yes', 8 | defs=['LOWER_DEF'], 9 | incs=['include'], 10 | optimize=['O3'], 11 | always_optimize=True, 12 | link_all_symbols=1 13 | ) 14 | 15 | 16 | cc_library( 17 | name='uppercase', 18 | srcs=[ 19 | 'puppercase.cpp' 20 | ], 21 | deps=['#dl'], 22 | link_all_symbols=1 23 | ) 24 | 25 | 26 | cc_binary( 27 | name='string_main_prog', 28 | srcs=[ 29 | 'string_main.cpp' 30 | ], 31 | deps=[ 32 | ':lowercase', 33 | ':uppercase', 34 | '#pthread', 35 | '#dl' 36 | ], 37 | warning='yes', 38 | defs=['BLADE_STR_DEF'], 39 | #dynamic_link=1 40 | ) 41 | 42 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_binary/plowercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_cc_binary/plowercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_binary/puppercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_cc_binary/puppercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_binary/string_main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_cc_binary/string_main.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_library/BUILD.TEST: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name='lowercase', 3 | srcs=[ 4 | 'plowercase.cpp' 5 | ], 6 | deps=['#pthread'], 7 | warning='yes', 8 | defs=['LOWER_DEF'], 9 | incs=['include'], 10 | optimize=['O3'], 11 | always_optimize=True, 12 | link_all_symbols=1 13 | ) 14 | 15 | 16 | cc_library( 17 | name='uppercase', 18 | srcs=[ 19 | 'puppercase.cpp' 20 | ], 21 | deps=['#dl'], 22 | link_all_symbols=1 23 | ) 24 | 25 | 26 | cc_library( 27 | name='blade_string', 28 | srcs=[ 29 | 'blade_string.cpp' 30 | ], 31 | deps=[ 32 | ':lowercase', 33 | ':uppercase', 34 | '#pthread', 35 | '#dl' 36 | ], 37 | warning='no', 38 | defs=['BLADE_STR_DEF'] 39 | ) 40 | 41 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_library/blade_string.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_cc_library/blade_string.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_library/plowercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_cc_library/plowercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_library/puppercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_cc_library/puppercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_plugin/BUILD.TEST: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name='lowercase', 3 | srcs=[ 4 | 'plowercase.cpp' 5 | ], 6 | deps=['#pthread'], 7 | warning='yes', 8 | defs=['LOWER_DEF'], 9 | incs=['include'], 10 | optimize=['O3'], 11 | always_optimize=True, 12 | link_all_symbols=1 13 | ) 14 | 15 | 16 | cc_library( 17 | name='uppercase', 18 | srcs=[ 19 | 'puppercase.cpp' 20 | ], 21 | deps=['#dl'], 22 | link_all_symbols=1 23 | ) 24 | 25 | 26 | cc_plugin( 27 | name='string_plugin', 28 | srcs=[ 29 | 'string_plugin.cpp' 30 | ], 31 | deps=[ 32 | ':lowercase', 33 | ':uppercase', 34 | '#pthread', 35 | '#dl' 36 | ], 37 | defs=['BLADE_STR_DEF'], 38 | extra_linkflags='-Wl,-Bsymbolic' 39 | ) 40 | 41 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_plugin/plowercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_cc_plugin/plowercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_plugin/puppercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_cc_plugin/puppercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_plugin/string_plugin.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_cc_plugin/string_plugin.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_test/BUILD.TEST: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name='lowercase', 3 | srcs=[ 4 | 'plowercase.cpp' 5 | ], 6 | deps=['#pthread'], 7 | warning='yes', 8 | defs=['LOWER_DEF'], 9 | incs=['include'], 10 | optimize=['O3'], 11 | always_optimize=True, 12 | link_all_symbols=1 13 | ) 14 | 15 | 16 | cc_library( 17 | name='uppercase', 18 | srcs=[ 19 | 'puppercase.cpp' 20 | ], 21 | deps=['#dl'], 22 | link_all_symbols=1 23 | ) 24 | 25 | 26 | cc_test( 27 | name='string_test_main', 28 | srcs=[ 29 | 'string_test.cpp' 30 | ], 31 | deps=[ 32 | ':lowercase', 33 | ':uppercase', 34 | '#pthread', 35 | '#dl' 36 | ], 37 | warning='yes', 38 | defs=['BLADE_STR_DEF'], 39 | #dynamic_link=1 40 | ) 41 | 42 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_test/plowercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_cc_test/plowercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_test/puppercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_cc_test/puppercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_cc_test/string_test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_cc_test/string_test.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_dependency/BUILD.TEST: -------------------------------------------------------------------------------- 1 | proto_library( 2 | name = 'rpc_option_proto', 3 | srcs = 'rpc_option.proto' 4 | ) 5 | 6 | proto_library( 7 | name = 'rpc_meta_info_proto', 8 | srcs = 'rpc_meta_info.proto', 9 | deps = ':rpc_option_proto' 10 | ) 11 | 12 | resource_library( 13 | name = 'static_resource', 14 | srcs = [ 15 | 'static/favicon.ico', 16 | 'static/forms.html', 17 | 'static/forms.js', 18 | 'static/jquery-1.4.2.min.js', 19 | 'static/jquery.json-2.2.min.js', 20 | 'static/methods.html', 21 | 'static/poppy.html' 22 | ], 23 | deps = ['#pthread'] 24 | ) 25 | 26 | cc_library( 27 | name = 'poppy', 28 | srcs = [ 29 | 'address_resolver.cc', 30 | 'rpc_builtin_service.cc', 31 | 'rpc_channel.cc', 32 | 'rpc_channel_impl.cc', 33 | 'rpc_client.cc', 34 | 'rpc_connection_group.cc', 35 | 'rpc_controller.cc', 36 | 'rpc_error_code.cc', 37 | 'rpc_form.cc', 38 | 'rpc_handler.cc', 39 | 'rpc_http_channel.cc', 40 | 'rpc_json.cc', 41 | 'rpc_request_queue.cc', 42 | 'rpc_server.cc', 43 | 'rpc_server_session_pool.cc', 44 | 'stats_registry.cc', 45 | ], 46 | deps = [ 47 | ':rpc_meta_info_proto', 48 | ':rpc_option_proto', 49 | ':static_resource', 50 | ] 51 | ) 52 | 53 | cc_library( 54 | name = 'poppy_mock', 55 | srcs = [ 56 | 'rpc_mock_channel.cc', 57 | ], 58 | deps = [ 59 | ':poppy', 60 | ], 61 | link_all_symbols = 1, 62 | ) 63 | 64 | cc_library( 65 | name = 'poppy_swig_wrap', 66 | srcs = [], 67 | prebuilt=1 68 | ) 69 | 70 | cc_test( 71 | name = 'rpc_channel_test', 72 | srcs = 'rpc_channel_test.cc', 73 | deps = ':poppy' 74 | ) 75 | 76 | swig_library( 77 | name = 'poppy_client', 78 | srcs = [ 79 | 'poppy_client.i' 80 | ], 81 | deps = [ 82 | ':poppy_swig_wrap', 83 | ':poppy' 84 | ], 85 | warning = 'yes', 86 | java_package = 'com.soso.poppy.swig', 87 | java_lib_packed = 1 88 | ) 89 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_dependency/java/BUILD.TEST: -------------------------------------------------------------------------------- 1 | java_jar( 2 | name = 'poppy_java_client', 3 | srcs = [ 4 | 'src/com/soso/poppy' 5 | ], 6 | deps = [ 7 | '//test_dependency:rpc_meta_info_proto', 8 | '//test_dependency:rpc_option_proto', 9 | './lib:log4j', 10 | './lib:netty', 11 | './lib:protobuf-java', 12 | './lib:snappy-java', 13 | './lib:junit', 14 | './lib:zookeeper' 15 | ] 16 | ) 17 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_dependency/java/lib/BUILD.TEST: -------------------------------------------------------------------------------- 1 | java_jar( 2 | name = 'log4j', 3 | srcs = [], 4 | deps = [], 5 | prebuilt = 1 6 | ) 7 | 8 | java_jar( 9 | name = 'netty', 10 | srcs = [], 11 | deps = [], 12 | prebuilt = 1 13 | ) 14 | 15 | java_jar( 16 | name = 'protobuf-java', 17 | srcs = [], 18 | deps = [], 19 | prebuilt = 1 20 | ) 21 | 22 | java_jar( 23 | name = 'snappy-java', 24 | srcs = [], 25 | deps = [], 26 | prebuilt = 1 27 | ) 28 | 29 | java_jar( 30 | name = 'zookeeper', 31 | srcs = [], 32 | deps = [], 33 | prebuilt = 1 34 | ) 35 | 36 | java_jar( 37 | name = 'junit', 38 | srcs = [], 39 | deps = [], 40 | prebuilt = 1 41 | ) 42 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_dependency/test/BUILD.TEST: -------------------------------------------------------------------------------- 1 | cc_binary( 2 | name = 'echoserver', 3 | srcs = [ 4 | 'echo_server.cc' 5 | ], 6 | deps = [ 7 | '//test_dependency:poppy' 8 | ] 9 | ) 10 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_gen_rule/BUILD.TEST: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name='lowercase', 3 | srcs=[ 4 | 'plowercase.cpp' 5 | ], 6 | deps=['#pthread'], 7 | warning='yes', 8 | defs=['LOWER_DEF'], 9 | incs=['include'], 10 | optimize=['O3'], 11 | always_optimize=True, 12 | link_all_symbols=1 13 | ) 14 | 15 | gen_rule( 16 | name='process_media', 17 | outs='process.tmp', 18 | cmd='echo this_is_the_process_gen_rule', 19 | deps=[':lowercase'] 20 | ) 21 | 22 | 23 | cc_library( 24 | name='uppercase', 25 | srcs=[ 26 | 'puppercase.cpp' 27 | ], 28 | deps=['#dl', 29 | ':process_media' 30 | ] 31 | ) 32 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_gen_rule/plowercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_gen_rule/plowercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_gen_rule/puppercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_gen_rule/puppercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_java_jar/BUILD.TEST: -------------------------------------------------------------------------------- 1 | proto_library( 2 | name = 'rpc_option_proto', 3 | srcs = 'rpc_option.proto' 4 | ) 5 | 6 | proto_library( 7 | name = 'rpc_meta_info_proto', 8 | srcs = 'rpc_meta_info.proto', 9 | deps = ':rpc_option_proto' 10 | ) 11 | 12 | cc_library( 13 | name = 'poppy', 14 | srcs = [ 15 | 'rpc_server.cc' 16 | ], 17 | deps = [ 18 | ':rpc_meta_info_proto', 19 | ':rpc_option_proto' 20 | ] 21 | ) 22 | 23 | swig_library( 24 | name = 'poppy_client', 25 | srcs = [ 26 | 'poppy_client.i' 27 | ], 28 | deps = [ 29 | ':poppy' 30 | ], 31 | warning = 'yes', 32 | java_package = 'com.soso.poppy.swig', 33 | java_lib_packed = 1 34 | ) 35 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_java_jar/java/BUILD.TEST: -------------------------------------------------------------------------------- 1 | java_jar( 2 | name = 'poppy_java_client', 3 | srcs = [ 4 | 'src/com/soso/poppy' 5 | ], 6 | deps = [ 7 | '//test_java_jar:rpc_meta_info_proto', 8 | '//test_java_jar:rpc_option_proto', 9 | '//test_java_jar:poppy_client', 10 | './lib:junit' 11 | ] 12 | ) 13 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_java_jar/java/lib/BUILD.TEST: -------------------------------------------------------------------------------- 1 | java_jar( 2 | name = 'log4j', 3 | srcs = [], 4 | deps = [], 5 | prebuilt = 1 6 | ) 7 | 8 | java_jar( 9 | name = 'netty', 10 | srcs = [], 11 | deps = [], 12 | prebuilt = 1 13 | ) 14 | 15 | java_jar( 16 | name = 'protobuf-java', 17 | srcs = [], 18 | deps = [], 19 | prebuilt = 1 20 | ) 21 | 22 | java_jar( 23 | name = 'snappy-java', 24 | srcs = [], 25 | deps = [], 26 | prebuilt = 1 27 | ) 28 | 29 | java_jar( 30 | name = 'zookeeper', 31 | srcs = [], 32 | deps = [], 33 | prebuilt = 1 34 | ) 35 | 36 | java_jar( 37 | name = 'junit', 38 | srcs = [], 39 | deps = [], 40 | prebuilt = 1 41 | ) 42 | 43 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_java_jar/java/lib/junit.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_java_jar/java/lib/junit.jar -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_java_jar/poppy_client.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_java_jar/poppy_client.i -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_java_jar/rpc_meta_info.proto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_java_jar/rpc_meta_info.proto -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_java_jar/rpc_option.proto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_java_jar/rpc_option.proto -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_java_jar/rpc_server.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_java_jar/rpc_server.cc -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_lex_yacc/BUILD.TEST: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name='lowercase', 3 | srcs=[ 4 | 'plowercase.cpp' 5 | ], 6 | deps=['#pthread'], 7 | defs=['LOWER_DEF'], 8 | incs=['include'], 9 | optimize=['O3'], 10 | always_optimize=True, 11 | ) 12 | 13 | lex_yacc_library( 14 | name = "parser", 15 | srcs = [ 16 | 'line_parser.ll', 17 | 'line_parser.yy' 18 | ], 19 | deps = [':lowercase'], 20 | recursive=1 21 | ) 22 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_lex_yacc/line_parser.ll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_lex_yacc/line_parser.ll -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_lex_yacc/line_parser.yy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_lex_yacc/line_parser.yy -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_lex_yacc/plowercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_lex_yacc/plowercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_loadbuilds/BUILD.TEST: -------------------------------------------------------------------------------- 1 | proto_library( 2 | name = 'rpc_meta_info_proto', 3 | srcs = 'rpc_meta_info.proto', 4 | ) 5 | 6 | resource_library( 7 | name = 'static_resource', 8 | srcs = [ 9 | 'form.js' 10 | ] 11 | ) 12 | 13 | cc_library( 14 | name = 'poppy', 15 | srcs = [], 16 | deps = [ 17 | ':rpc_meta_info_proto', 18 | ':static_resource', 19 | ] 20 | ) 21 | 22 | cc_library( 23 | name = 'poppy_mock', 24 | srcs = [ 25 | 'rpc_mock_channel.cc', 26 | ], 27 | deps = [ 28 | ':poppy', 29 | ], 30 | link_all_symbols=True 31 | ) 32 | 33 | cc_library( 34 | name = 'poppy_swig_wrap', 35 | srcs = [], 36 | prebuilt =True 37 | ) 38 | 39 | cc_test( 40 | name = 'rpc_channel_test', 41 | srcs = 'rpc_channel_test.cc', 42 | deps = ':poppy' 43 | ) 44 | 45 | swig_library( 46 | name = 'poppy_client', 47 | srcs = ['poppy_client.i'], 48 | deps = [':poppy_swig_wrap'], 49 | warning = 'yes', 50 | java_package='com.soso.poppy.swig', 51 | java_lib_packed=True 52 | ) 53 | 54 | java_jar( 55 | name = 'poppy_java_client', 56 | srcs = ['src/com/soso/poppy'], 57 | deps = [] 58 | ) 59 | 60 | cc_binary( 61 | name = 'echoserver', 62 | srcs = [ 63 | 'echo_server.cc' 64 | ], 65 | deps = [ 66 | ':poppy' 67 | ] 68 | ) 69 | 70 | lex_yacc_library( 71 | name = "parser", 72 | srcs = [ 73 | 'line_parser.ll', 74 | 'line_parser.yy' 75 | ], 76 | deps = [], 77 | recursive=1 78 | ) 79 | 80 | cc_plugin( 81 | name='meter_business', 82 | srcs=[], 83 | deps=['#pthread'] 84 | ) 85 | 86 | gen_rule( 87 | name='search_service_echo', 88 | cmd='echo search_service', 89 | outs='search_service.c' 90 | ) 91 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_prebuild_cc_library/BUILD.TEST: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name='lowercase', 3 | srcs=[], 4 | deps=[], 5 | prebuilt=1 6 | ) 7 | 8 | cc_library( 9 | name='uppercase', 10 | srcs=[ 11 | 'puppercase.cpp' 12 | ], 13 | deps=[':lowercase'], 14 | link_all_symbols=1 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_prebuild_cc_library/puppercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_prebuild_cc_library/puppercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_proto_library/BUILD.TEST: -------------------------------------------------------------------------------- 1 | proto_library( 2 | name = 'rpc_option_proto', 3 | srcs = 'rpc_option.proto' 4 | ) 5 | 6 | proto_library( 7 | name = 'rpc_meta_info_proto', 8 | srcs = 'rpc_meta_info.proto', 9 | deps = ':rpc_option_proto' 10 | ) 11 | 12 | cc_library( 13 | name='lowercase', 14 | srcs=[ 15 | 'plowercase.cpp' 16 | ], 17 | deps=[ 18 | '#pthread', 19 | ':rpc_meta_info_proto', 20 | ':rpc_option_proto' 21 | ], 22 | defs=['LOWER_DEF'], 23 | incs=['include'], 24 | optimize=['O3'], 25 | always_optimize=True, 26 | ) 27 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_proto_library/plowercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_proto_library/plowercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_proto_library/rpc_meta_info.proto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_proto_library/rpc_meta_info.proto -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_proto_library/rpc_option.proto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_proto_library/rpc_option.proto -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_query/BUILD.TEST: -------------------------------------------------------------------------------- 1 | proto_library( 2 | name = 'rpc_option_proto', 3 | srcs = 'rpc_option.proto' 4 | ) 5 | 6 | proto_library( 7 | name = 'rpc_meta_info_proto', 8 | srcs = 'rpc_meta_info.proto', 9 | deps = ':rpc_option_proto' 10 | ) 11 | 12 | resource_library( 13 | name = 'static_resource', 14 | srcs = [ 15 | 'static/favicon.ico', 16 | 'static/forms.html', 17 | 'static/forms.js', 18 | 'static/jquery-1.4.2.min.js', 19 | 'static/jquery.json-2.2.min.js', 20 | 'static/methods.html', 21 | 'static/poppy.html' 22 | ], 23 | deps = ['#pthread'] 24 | ) 25 | 26 | cc_library( 27 | name = 'poppy', 28 | srcs = [ 29 | 'address_resolver.cc', 30 | 'rpc_builtin_service.cc', 31 | 'rpc_channel.cc', 32 | 'rpc_channel_impl.cc', 33 | 'rpc_client.cc', 34 | 'rpc_connection_group.cc', 35 | 'rpc_controller.cc', 36 | 'rpc_error_code.cc', 37 | 'rpc_form.cc', 38 | 'rpc_handler.cc', 39 | 'rpc_http_channel.cc', 40 | 'rpc_json.cc', 41 | 'rpc_request_queue.cc', 42 | 'rpc_server.cc', 43 | 'rpc_server_session_pool.cc', 44 | 'stats_registry.cc', 45 | ], 46 | deps = [ 47 | ':rpc_meta_info_proto', 48 | ':rpc_option_proto', 49 | ':static_resource', 50 | ] 51 | ) 52 | 53 | cc_library( 54 | name = 'poppy_mock', 55 | srcs = [ 56 | 'rpc_mock_channel.cc', 57 | ], 58 | deps = [ 59 | ':poppy', 60 | ], 61 | link_all_symbols = 1, 62 | ) 63 | 64 | cc_library( 65 | name = 'poppy_swig_wrap', 66 | srcs = [], 67 | prebuilt=1 68 | ) 69 | 70 | cc_test( 71 | name = 'rpc_channel_test', 72 | srcs = 'rpc_channel_test.cc', 73 | deps = ':poppy' 74 | ) 75 | 76 | swig_library( 77 | name = 'poppy_client', 78 | srcs = [ 79 | 'poppy_client.i' 80 | ], 81 | deps = [ 82 | ':poppy_swig_wrap', 83 | ':poppy' 84 | ], 85 | warning = 'yes', 86 | java_package = 'com.soso.poppy.swig', 87 | java_lib_packed = 1 88 | ) 89 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_query/java/BUILD.TEST: -------------------------------------------------------------------------------- 1 | java_jar( 2 | name = 'poppy_java_client', 3 | srcs = [ 4 | 'src/com/soso/poppy' 5 | ], 6 | deps = [ 7 | '//test_dependency:rpc_meta_info_proto', 8 | '//test_dependency:rpc_option_proto', 9 | './lib:log4j', 10 | './lib:netty', 11 | './lib:protobuf-java', 12 | './lib:snappy-java', 13 | './lib:junit', 14 | './lib:zookeeper' 15 | ] 16 | ) 17 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_query/java/lib/BUILD.TEST: -------------------------------------------------------------------------------- 1 | java_jar( 2 | name = 'log4j', 3 | srcs = [], 4 | deps = [], 5 | prebuilt = 1 6 | ) 7 | 8 | java_jar( 9 | name = 'netty', 10 | srcs = [], 11 | deps = [], 12 | prebuilt = 1 13 | ) 14 | 15 | java_jar( 16 | name = 'protobuf-java', 17 | srcs = [], 18 | deps = [], 19 | prebuilt = 1 20 | ) 21 | 22 | java_jar( 23 | name = 'snappy-java', 24 | srcs = [], 25 | deps = [], 26 | prebuilt = 1 27 | ) 28 | 29 | java_jar( 30 | name = 'zookeeper', 31 | srcs = [], 32 | deps = [], 33 | prebuilt = 1 34 | ) 35 | 36 | java_jar( 37 | name = 'junit', 38 | srcs = [], 39 | deps = [], 40 | prebuilt = 1 41 | ) 42 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_query/test/BUILD.TEST: -------------------------------------------------------------------------------- 1 | cc_binary( 2 | name = 'echoserver', 3 | srcs = [ 4 | 'echo_server.cc' 5 | ], 6 | deps = [ 7 | '//test_dependency:poppy' 8 | ] 9 | ) 10 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_resource_library/BUILD.TEST: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name='lowercase', 3 | srcs=[ 4 | 'plowercase.cpp' 5 | ], 6 | deps=[ 7 | '#pthread', 8 | ':static_resource' 9 | ], 10 | warning='yes', 11 | defs=['LOWER_DEF'], 12 | incs=['include'], 13 | ) 14 | 15 | resource_library( 16 | name = 'static_resource', 17 | srcs = [ 18 | 'forms.js', 19 | 'poppy.html' 20 | ] 21 | ) 22 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_resource_library/forms.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_resource_library/forms.js -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_resource_library/plowercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_resource_library/plowercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_resource_library/poppy.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_resource_library/poppy.html -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_swig_library/BUILD.TEST: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name='lowercase', 3 | srcs=[ 4 | 'plowercase.cpp' 5 | ], 6 | deps=[ 7 | '#pthread' 8 | ], 9 | defs=['LOWER_DEF'], 10 | incs=['include'], 11 | ) 12 | 13 | swig_library( 14 | name='poppy_client', 15 | srcs=[ 16 | 'poppy_client.i' 17 | ], 18 | deps=[ 19 | ':lowercase' 20 | ], 21 | warning='yes', 22 | java_package='com.soso.poppy.swig', 23 | java_lib_packed=1 24 | ) 25 | 26 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_swig_library/plowercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_swig_library/plowercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_swig_library/poppy_client.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_swig_library/poppy_client.i -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_test_runner/BUILD.TEST: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name='lowercase', 3 | srcs=[ 4 | 'plowercase.cpp' 5 | ], 6 | deps=['#pthread'], 7 | warning='yes', 8 | defs=['LOWER_DEF'], 9 | incs=['include'], 10 | optimize=['O3'], 11 | always_optimize=True, 12 | link_all_symbols=1 13 | ) 14 | 15 | 16 | cc_library( 17 | name='uppercase', 18 | srcs=[ 19 | 'puppercase.cpp' 20 | ], 21 | deps=['#dl'], 22 | link_all_symbols=1 23 | ) 24 | 25 | 26 | cc_test( 27 | name='string_test_main', 28 | srcs=[ 29 | 'string_test.cpp' 30 | ], 31 | deps=[ 32 | ':lowercase', 33 | ':uppercase', 34 | '#pthread', 35 | '#dl' 36 | ], 37 | warning='yes', 38 | defs=['BLADE_STR_DEF'], 39 | #dynamic_link=1 40 | ) 41 | 42 | cc_test( 43 | name='string_test_main_2', 44 | srcs=[ 45 | 'string_test_2.cpp' 46 | ], 47 | deps=[ 48 | ':lowercase', 49 | ':uppercase', 50 | '#pthread', 51 | '#dl' 52 | ], 53 | warning='yes', 54 | defs=['BLADE_STR_DEF'], 55 | #dynamic_link=1 56 | ) 57 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_test_runner/plowercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_test_runner/plowercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_test_runner/puppercase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_test_runner/puppercase.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_test_runner/string_test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_test_runner/string_test.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/test_test_runner/string_test_2.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/blade/src/test/testdata/test_test_runner/string_test_2.cpp -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/thirdparty/gtest/BUILD.TEST: -------------------------------------------------------------------------------- 1 | cc_library(name = 'gtest', 2 | ) 3 | 4 | cc_library(name = 'gtest_main', 5 | ) 6 | 7 | -------------------------------------------------------------------------------- /tools/blade/src/test/testdata/thirdparty/protobuf/BUILD.TEST: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = 'protobuf', 3 | ) 4 | 5 | cc_library( 6 | name = 'protoc', 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /tools/blade/typhoon.conf: -------------------------------------------------------------------------------- 1 | # Configure file for using blade in typhoon 2 | 3 | cc_test_config( 4 | dynamic_link=False, 5 | heap_check='', 6 | gperftools_libs=['thirdparty/perftools:tcmalloc'], 7 | gperftools_debug_libs=['thirdparty/perftools:tcmalloc_debug'], 8 | gtest_libs=['thirdparty/gtest:gtest'], 9 | gtest_main_libs=['thirdparty/gtest:gtest_main'] 10 | ) 11 | 12 | distcc_config( 13 | enabled=False 14 | ) 15 | 16 | link_config( 17 | link_on_tmp=False, 18 | enable_dccc=False 19 | ) 20 | 21 | proto_library_config( 22 | protoc='thirdparty/protobuf/bin/protoc', 23 | protobuf_libs=['thirdparty/protobuf:protobuf'], 24 | protobuf_path='thirdparty', 25 | protobuf_incs = 'thirdparty', 26 | protobuf_php_path='thirdparty/Protobuf-PHP/library', 27 | protoc_php_plugin='thirdparty/Protobuf-PHP/protoc-gen-php.php' 28 | ) 29 | 30 | cc_config( 31 | extra_incs='thirdparty' 32 | ) 33 | 34 | java_config( 35 | source_version='1.6', 36 | target_version='1.6' 37 | ) 38 | -------------------------------------------------------------------------------- /tools/blade/vim/ftdetect/blade.vim: -------------------------------------------------------------------------------- 1 | " This is the Vim filetype detect script for Blaze. 2 | " put it into you ~/.vim/ftdetect/ 3 | 4 | augroup filetype 5 | autocmd! BufRead,BufNewFile BUILD setfiletype blade 6 | augroup end 7 | 8 | -------------------------------------------------------------------------------- /tools/blade/vim/syntax/blade.vim: -------------------------------------------------------------------------------- 1 | " This is the Vim syntax file for Blaze. 2 | " Usage: 3 | " 4 | " 1. cp blade.vim ~/.vim/syntax/ 5 | " 2. Add the following to ~/.vimrc: 6 | " 7 | " augroup filetype 8 | " au! BufRead,BufNewFile BUILD setfiletype blade 9 | " augroup end 10 | " 11 | " Or just create a new file called ~/.vim/ftdetect/blade.vim with the 12 | " previous lines on it. 13 | 14 | if version < 600 15 | syntax clear 16 | elseif exists("b:current_syntax") 17 | finish 18 | endif 19 | 20 | " Read the python syntax to start with 21 | if version < 600 22 | so :p:h/python.vim 23 | else 24 | runtime! syntax/python.vim 25 | unlet b:current_syntax 26 | endif 27 | 28 | syn case match 29 | 30 | " Sorted by alphabet order 31 | syn keyword bladeTarget cc_binary cc_library cc_plugin cc_test cc_benchmark cu_binary cu_library 32 | syn keyword bladeTarget enable_if gen_rule lex_yacc_library proto_library java_jar 33 | syn keyword bladeTarget resource_library swig_library 34 | 35 | " Sorted by alphabet order 36 | syn keyword bladeArg always_run cmd defs deprecated deps dynamic_link export_incs 37 | syn keyword bladeArg exclusive export_dynamic extra_cppflags extra_linkflags 38 | syn keyword bladeArg heap_check heap_check_debug incs link_all_symbols 39 | syn keyword bladeArg name optimize outs prebuilt prefix srcs suffix testdata warning 40 | 41 | if version >= 508 || !exists("did_blade_syn_inits") 42 | if version < 508 43 | let did_blade_syn_inits = 1 44 | command! -nargs=+ HiLink hi link 45 | else 46 | command! -nargs=+ HiLink hi def link 47 | endif 48 | 49 | HiLink bladeTarget Function 50 | HiLink bladeArg Special 51 | delcommand HiLink 52 | endif 53 | 54 | let b:current_syntax = "blade" 55 | 56 | -------------------------------------------------------------------------------- /tools/compiler/dr/BUILD: -------------------------------------------------------------------------------- 1 | #lex_yacc_library( 2 | # name = 'parser', 3 | # srcs = [ 4 | # 'thriftl.ll', 5 | # 'thrifty.yy' 6 | # ], 7 | # deps = [ 8 | # 9 | # ] 10 | #) 11 | 12 | cc_binary( 13 | name = 'pebble', 14 | srcs = [ 15 | 'src/main.cc', 16 | 'src/thriftl.cc', 17 | 'src/thrifty.cc', 18 | 'src/md5.c', 19 | 'src/parse/t_typedef.cc', 20 | 'src/parse/parse.cc', 21 | 'src/generate/t_generator.cc', 22 | 'src/generate/t_cpp_generator.cc', 23 | 'src/generate/t_cpp_client_generator.cc', 24 | 'src/generate/t_csharp_generator.cc', 25 | 'src/generate/t_js_generator.cc', 26 | 'src/generate/t_lua_generator.cc', 27 | #'src/generate/t_as3_generator.cc', 28 | #'src/generate/t_cocoa_generator.cc', 29 | #'src/generate/t_c_glib_generator.cc', 30 | #'src/generate/t_delphi_generator.cc', 31 | #'src/generate/t_d_generator.cc', 32 | #'src/generate/t_erl_generator.cc', 33 | #'src/generate/t_go_generator.cc', 34 | #'src/generate/t_gv_generator.cc', 35 | #'src/generate/t_hs_generator.cc', 36 | #'src/generate/t_html_generator.cc', 37 | #'src/generate/t_javame_generator.cc', 38 | #'src/generate/t_java_generator.cc', 39 | 'src/generate/t_json_generator.cc', 40 | #'src/generate/t_ocaml_generator.cc', 41 | #'src/generate/t_perl_generator.cc', 42 | #'src/generate/t_php_generator.cc', 43 | #'src/generate/t_py_generator.cc', 44 | #'src/generate/t_rb_generator.cc', 45 | #'src/generate/t_st_generator.cc', 46 | #'src/generate/t_xsd_generator.cc' 47 | ], 48 | incs = [ 49 | ], 50 | deps = [ 51 | 52 | ] 53 | ) 54 | 55 | -------------------------------------------------------------------------------- /tools/compiler/dr/compiler.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compiler", "compiler.vcxproj", "{89975A1A-F799-4556-98B8-64E30AB39A90}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {89975A1A-F799-4556-98B8-64E30AB39A90}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {89975A1A-F799-4556-98B8-64E30AB39A90}.Debug|Win32.Build.0 = Debug|Win32 14 | {89975A1A-F799-4556-98B8-64E30AB39A90}.Release|Win32.ActiveCfg = Release|Win32 15 | {89975A1A-F799-4556-98B8-64E30AB39A90}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /tools/compiler/dr/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/compiler/dr/readme.txt -------------------------------------------------------------------------------- /tools/compiler/dr/src/logging.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef T_LOGGING_H 21 | #define T_LOGGING_H 22 | 23 | #include 24 | 25 | /** 26 | * Parse debugging output, used to print helpful info 27 | */ 28 | void pdebug(const char* fmt, ...); 29 | 30 | /** 31 | * Parser warning 32 | */ 33 | void pwarning(int level, const char* fmt, ...); 34 | 35 | /** 36 | * Print verbose output message 37 | */ 38 | void pverbose(const char* fmt, ...); 39 | 40 | /** 41 | * Failure! 42 | */ 43 | void failure(const char* fmt, ...); 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /tools/compiler/dr/src/parse/parse.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include "t_type.h" 21 | #include "t_typedef.h" 22 | 23 | #include "../md5.h" 24 | #include "../main.h" 25 | 26 | void t_type::generate_fingerprint() { 27 | if (! has_fingerprint()) { 28 | pdebug("generating fingerprint for %s", get_name().c_str()); 29 | std::string material = get_fingerprint_material(); 30 | md5_state_t ctx; 31 | md5_init(&ctx); 32 | md5_append(&ctx, (md5_byte_t*)(material.data()), (int)material.size()); 33 | md5_finish(&ctx, (md5_byte_t*)fingerprint_); 34 | } 35 | } 36 | 37 | t_type* t_type::get_true_type() { 38 | t_type* type = this; 39 | while (type->is_typedef()) { 40 | type = ((t_typedef*)type)->get_type(); 41 | } 42 | return type; 43 | } 44 | -------------------------------------------------------------------------------- /tools/compiler/dr/src/parse/t_attributes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | 15 | #ifndef T_ATTRIBUTES_H 16 | #define T_ATTRIBUTES_H 17 | 18 | #include 19 | #include 20 | 21 | class t_program; 22 | 23 | class t_attributes : public t_type { 24 | public: 25 | t_attributes(t_program* program) : 26 | t_type(program) {} 27 | 28 | virtual std::string get_fingerprint_material() const { 29 | throw "BUG: Can't get fingerprint material for attributes."; 30 | } 31 | 32 | bool set_attribute(std::string name, std::map attribute_pairs) { 33 | if (attributes_.find(name) != attributes_.end()) { 34 | return false; 35 | } 36 | attributes_[name] = attribute_pairs; 37 | return true; 38 | } 39 | 40 | std::map > attributes_; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /tools/compiler/dr/src/parse/t_const.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef T_CONST_H 21 | #define T_CONST_H 22 | 23 | #include "t_type.h" 24 | #include "t_const_value.h" 25 | 26 | /** 27 | * A const is a constant value defined across languages that has a type and 28 | * a value. The trick here is that the declared type might not match the type 29 | * of the value object, since that is not determined until after parsing the 30 | * whole thing out. 31 | * 32 | */ 33 | class t_const : public t_doc { 34 | public: 35 | t_const(t_type* type, std::string name, t_const_value* value) : 36 | type_(type), 37 | name_(name), 38 | value_(value) {} 39 | 40 | t_type* get_type() const { 41 | return type_; 42 | } 43 | 44 | std::string get_name() const { 45 | return name_; 46 | } 47 | 48 | t_const_value* get_value() const { 49 | return value_; 50 | } 51 | 52 | private: 53 | t_type* type_; 54 | std::string name_; 55 | t_const_value* value_; 56 | }; 57 | 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /tools/compiler/dr/src/parse/t_container.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef T_CONTAINER_H 21 | #define T_CONTAINER_H 22 | 23 | #include "t_type.h" 24 | 25 | class t_container : public t_type { 26 | public: 27 | t_container() : 28 | cpp_name_(), 29 | has_cpp_name_(false) {} 30 | 31 | virtual ~t_container() {} 32 | 33 | void set_cpp_name(std::string cpp_name) { 34 | cpp_name_ = cpp_name; 35 | has_cpp_name_ = true; 36 | } 37 | 38 | bool has_cpp_name() { 39 | return has_cpp_name_; 40 | } 41 | 42 | std::string get_cpp_name() { 43 | return cpp_name_; 44 | } 45 | 46 | bool is_container() const { 47 | return true; 48 | } 49 | 50 | private: 51 | std::string cpp_name_; 52 | bool has_cpp_name_; 53 | 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /tools/compiler/dr/src/parse/t_doc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef T_DOC_H 21 | #define T_DOC_H 22 | 23 | #include "../globals.h" 24 | #include "../logging.h" 25 | 26 | /** 27 | * Documentation stubs 28 | * 29 | */ 30 | class t_doc { 31 | 32 | public: 33 | t_doc() : has_doc_(false) {} 34 | 35 | void set_doc(const std::string& doc) { 36 | doc_ = doc; 37 | has_doc_ = true; 38 | if( (g_program_doctext_lineno == g_doctext_lineno) && (g_program_doctext_status == STILL_CANDIDATE)) { 39 | g_program_doctext_status = ALREADY_PROCESSED; 40 | pdebug("%s","program doctext set to ALREADY_PROCESSED"); 41 | } 42 | } 43 | 44 | const std::string& get_doc() const { 45 | return doc_; 46 | } 47 | 48 | bool has_doc() { 49 | return has_doc_; 50 | } 51 | 52 | private: 53 | std::string doc_; 54 | bool has_doc_; 55 | 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /tools/compiler/dr/src/parse/t_enum_value.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef T_ENUM_VALUE_H 21 | #define T_ENUM_VALUE_H 22 | 23 | #include 24 | #include "t_doc.h" 25 | 26 | /** 27 | * A constant. These are used inside of enum definitions. Constants are just 28 | * symbol identifiers that may or may not have an explicit value associated 29 | * with them. 30 | * 31 | */ 32 | class t_enum_value : public t_doc { 33 | public: 34 | t_enum_value(std::string name, int value) : 35 | name_(name), 36 | value_(value) {} 37 | 38 | ~t_enum_value() {} 39 | 40 | const std::string& get_name() const { 41 | return name_; 42 | } 43 | 44 | int get_value() const { 45 | return value_; 46 | } 47 | 48 | std::map annotations_; 49 | 50 | private: 51 | std::string name_; 52 | int value_; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /tools/compiler/dr/src/parse/t_list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef T_LIST_H 21 | #define T_LIST_H 22 | 23 | #include "t_container.h" 24 | 25 | /** 26 | * A list is a lightweight container type that just wraps another data type. 27 | * 28 | */ 29 | class t_list : public t_container { 30 | public: 31 | t_list(t_type* elem_type) : 32 | elem_type_(elem_type) {} 33 | 34 | t_type* get_elem_type() const { 35 | return elem_type_; 36 | } 37 | 38 | bool is_list() const { 39 | return true; 40 | } 41 | 42 | virtual std::string get_fingerprint_material() const { 43 | return "list<" + elem_type_->get_fingerprint_material() + ">"; 44 | } 45 | 46 | virtual void generate_fingerprint() { 47 | t_type::generate_fingerprint(); 48 | elem_type_->generate_fingerprint(); 49 | } 50 | 51 | private: 52 | t_type* elem_type_; 53 | }; 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /tools/compiler/dr/src/parse/t_map.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef T_MAP_H 21 | #define T_MAP_H 22 | 23 | #include "t_container.h" 24 | 25 | /** 26 | * A map is a lightweight container type that just wraps another two data 27 | * types. 28 | * 29 | */ 30 | class t_map : public t_container { 31 | public: 32 | t_map(t_type* key_type, t_type* val_type) : 33 | key_type_(key_type), 34 | val_type_(val_type) {} 35 | 36 | t_type* get_key_type() const { 37 | return key_type_; 38 | } 39 | 40 | t_type* get_val_type() const { 41 | return val_type_; 42 | } 43 | 44 | bool is_map() const { 45 | return true; 46 | } 47 | 48 | virtual std::string get_fingerprint_material() const { 49 | return "map<" + key_type_->get_fingerprint_material() + 50 | "," + val_type_->get_fingerprint_material() + ">"; 51 | } 52 | 53 | virtual void generate_fingerprint() { 54 | t_type::generate_fingerprint(); 55 | key_type_->generate_fingerprint(); 56 | val_type_->generate_fingerprint(); 57 | } 58 | 59 | private: 60 | t_type* key_type_; 61 | t_type* val_type_; 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /tools/compiler/dr/src/parse/t_service.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef T_SERVICE_H 21 | #define T_SERVICE_H 22 | 23 | #include "t_function.h" 24 | #include 25 | 26 | class t_program; 27 | 28 | /** 29 | * A service consists of a set of functions. 30 | * 31 | */ 32 | class t_service : public t_type { 33 | public: 34 | t_service(t_program* program) : 35 | t_type(program), 36 | extends_(NULL) {} 37 | 38 | bool is_service() const { 39 | return true; 40 | } 41 | 42 | void set_extends(t_service* extends) { 43 | extends_ = extends; 44 | } 45 | 46 | void add_function(t_function* func) { 47 | std::vector::const_iterator iter; 48 | for (iter = functions_.begin(); iter != functions_.end(); iter++) { 49 | if (func->get_name() == (*iter)->get_name()) { 50 | throw "Function " + func->get_name() + " is already defined"; 51 | } 52 | } 53 | functions_.push_back(func); 54 | } 55 | 56 | const std::vector& get_functions() const { 57 | return functions_; 58 | } 59 | 60 | t_service* get_extends() { 61 | return extends_; 62 | } 63 | 64 | virtual std::string get_fingerprint_material() const { 65 | // Services should never be used in fingerprints. 66 | throw "BUG: Can't get fingerprint material for service."; 67 | } 68 | 69 | private: 70 | std::vector functions_; 71 | t_service* extends_; 72 | }; 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /tools/compiler/dr/src/parse/t_set.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef T_SET_H 21 | #define T_SET_H 22 | 23 | #include "t_container.h" 24 | 25 | /** 26 | * A set is a lightweight container type that just wraps another data type. 27 | * 28 | */ 29 | class t_set : public t_container { 30 | public: 31 | t_set(t_type* elem_type) : 32 | elem_type_(elem_type) {} 33 | 34 | t_type* get_elem_type() const { 35 | return elem_type_; 36 | } 37 | 38 | bool is_set() const { 39 | return true; 40 | } 41 | 42 | virtual std::string get_fingerprint_material() const { 43 | return "set<" + elem_type_->get_fingerprint_material() + ">"; 44 | } 45 | 46 | virtual void generate_fingerprint() { 47 | t_type::generate_fingerprint(); 48 | elem_type_->generate_fingerprint(); 49 | } 50 | 51 | private: 52 | t_type* elem_type_; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /tools/compiler/dr/src/parse/t_typedef.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | #include 20 | 21 | #include "t_typedef.h" 22 | #include "t_program.h" 23 | 24 | t_type* t_typedef::get_type() const { 25 | if (type_ == NULL) { 26 | t_type* type = get_program()->scope()->get_type(symbolic_); 27 | if (type == NULL) { 28 | printf("Type \"%s\" not defined\n", symbolic_.c_str()); 29 | exit(1); 30 | } 31 | return type; 32 | } 33 | return type_; 34 | } 35 | -------------------------------------------------------------------------------- /tools/compiler/dr/src/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /** 21 | * define for mkdir,since the method signature 22 | * is different for the non-POSIX MinGW 23 | */ 24 | 25 | #ifdef _MSC_VER 26 | #include "windows/config.h" 27 | #endif 28 | 29 | #ifdef _WIN32 30 | #include 31 | #include 32 | #else 33 | #include 34 | #include 35 | #endif 36 | 37 | #ifdef _WIN32 38 | #define MKDIR(x) mkdir(x) 39 | #else 40 | #define MKDIR(x) mkdir(x, S_IRWXU | S_IRWXG | S_IRWXO) 41 | #endif 42 | 43 | #ifdef PATH_MAX 44 | #define THRIFT_PATH_MAX PATH_MAX 45 | #else 46 | #define THRIFT_PATH_MAX MAX_PATH 47 | #endif 48 | -------------------------------------------------------------------------------- /tools/compiler/dr/src/windows/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef _THRIFT_WINDOWS_CONFIG_H_ 21 | #define _THRIFT_WINDOWS_CONFIG_H_ 1 22 | 23 | #if defined(_MSC_VER) && (_MSC_VER > 1200) 24 | #pragma once 25 | #endif // _MSC_VER 26 | 27 | #ifndef _WIN32 28 | #error "This is a Windows header only" 29 | #endif 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #define strtoll(begin_ptr, end_ptr, length) _strtoi64(begin_ptr, end_ptr, length) 36 | 37 | #define PRIu64 "I64d" 38 | #define PRIi64 "I64d" 39 | 40 | // squelch deprecation warnings 41 | #pragma warning(disable:4996) 42 | // squelch bool conversion performance warning 43 | #pragma warning(disable:4800) 44 | 45 | 46 | #endif // _THRIFT_WINDOWS_CONFIG_H_ 47 | -------------------------------------------------------------------------------- /tools/compiler/dr/src/windows/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef _THRIFT_WINDOWS_VERSION_H_ 21 | #define _THRIFT_WINDOWS_VERSION_H_ 1 22 | 23 | #if defined(_MSC_VER) && (_MSC_VER > 1200) 24 | #pragma once 25 | #endif // _MSC_VER 26 | 27 | #ifndef _WIN32 28 | #error "This is a Windows header only" 29 | #endif 30 | 31 | #define PEBBLE_VERSION "0.1.0" 32 | 33 | #endif // _THRIFT_WINDOWS_VERSION_H_ 34 | -------------------------------------------------------------------------------- /tools/compiler/dr/src/windows/version.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #ifndef _THRIFT_WINDOWS_VERSION_H_ 21 | #define _THRIFT_WINDOWS_VERSION_H_ 1 22 | 23 | #if defined(_MSC_VER) && (_MSC_VER > 1200) 24 | #pragma once 25 | #endif // _MSC_VER 26 | 27 | #ifndef _WIN32 28 | #error "This is a Windows header only" 29 | #endif 30 | 31 | #define THRIFT_VERSION "@PACKAGE_VERSION@" 32 | 33 | #endif // _THRIFT_WINDOWS_VERSION_H_ 34 | -------------------------------------------------------------------------------- /tools/compiler/dr/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | 14 | #include "pebble_version.inh" 15 | #include "version.inh" 16 | 17 | 18 | -------------------------------------------------------------------------------- /tools/compiler/dr/version.h.in: -------------------------------------------------------------------------------- 1 | #define THRIFT_VERSION "@PACKAGE_VERSION@" 2 | -------------------------------------------------------------------------------- /tools/compiler/pb/BUILD: -------------------------------------------------------------------------------- 1 | cc_binary( 2 | name = 'protobuf_rpc', 3 | srcs = [ 4 | 'src/cpp_generator.cpp', 5 | 'src/cpp_plugin.cpp', 6 | ], 7 | incs = [ 8 | '../../../thirdparty/protobuf/include/', 9 | ], 10 | deps = [ 11 | '//src/common:pebble_common', 12 | '//thirdparty/protobuf:protoc', 13 | ] 14 | ) 15 | 16 | cc_binary( 17 | name = 'protobuf_rpc_client', 18 | srcs = [ 19 | 'src/cpp_generator.cpp', 20 | 'src/cpp_plugin.cpp', 21 | ], 22 | incs = [ 23 | '../../../thirdparty/protobuf/include/', 24 | ], 25 | deps = [ 26 | '//src/common:pebble_common', 27 | '//thirdparty/protobuf:protoc', 28 | ], 29 | defs = ['__RPC_CLIENT__'], 30 | ) 31 | 32 | -------------------------------------------------------------------------------- /tools/release/README.txt: -------------------------------------------------------------------------------- 1 | 发布: 2 | 1. trunk/目录下各模块编译通过 3 | 2. 执行trunk/tools/release下copy_release.sh拷贝必要文件到trunk/release目录 4 | 3. 确认trunk/release/x86_64/example下各个例子可编译通过后,可用pack_release.sh打包 5 | 6 | -------------------------------------------------------------------------------- /tools/release/pack_release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pebble_home=../.. 4 | 5 | function pack_release_files() 6 | { 7 | cd $pebble_home/release/x86_64/doc 8 | zip -m -r ./doc.zip ./* 9 | cd - 10 | tar -C $pebble_home -zvcf PEBBLE-$1_X86_64_Release.tar.gz release/ --exclude=.svn 11 | } 12 | 13 | release_name=`date +%Y%m%d%H%M%S` 14 | if [ $# -gt 0 ] 15 | then 16 | release_name=$1_$release_name 17 | fi 18 | 19 | pack_release_files $release_name 20 | 21 | -------------------------------------------------------------------------------- /tools/scons/scons-2.3.4.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/scons/scons-2.3.4.tar.gz -------------------------------------------------------------------------------- /tools/zookeeper/zookeeper-3.4.6.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tencent/Pebble/68315f176d9e328a233ace29b7579a829f89879f/tools/zookeeper/zookeeper-3.4.6.tar.gz -------------------------------------------------------------------------------- /version.inh: -------------------------------------------------------------------------------- 1 | /* 2 | * Tencent is pleased to support the open source community by making Pebble available. 3 | * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. 4 | * Licensed under the MIT License (the "License"); you may not use this file except in compliance 5 | * with the License. You may obtain a copy of the License at 6 | * http://opensource.org/licenses/MIT 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License 8 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 9 | * or implied. See the License for the specific language governing permissions and limitations under 10 | * the License. 11 | * 12 | */ 13 | #ifndef _VERSOIN_INH_ 14 | #define _VERSOIN_INH_ 15 | #define PEBBLE_VERSION "1.0.1" 16 | #endif 17 | --------------------------------------------------------------------------------