관리-도구
편집 파일: SchemaPrinterMain.cpp.cxxcodebuilder
# Phusion Passenger - https://www.phusionpassenger.com/ # Copyright (c) 2017 Phusion Holding B.V. # # "Passenger", "Phusion Passenger" and "Union Station" are registered # trademarks of Phusion Holding B.V. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. SCAN_FILES = Dir['src/**/*.{h,cpp}'] def main class_names, headers = find_all_schemas comment copyright_header_for(__FILE__), 1 separator comment %q{ SchemaPrinterMain.cpp is automatically generated from SchemaPrinterMain.cpp.cxxcodebuilder, using "BEGIN ConfigKit schema" magic comments from various C++ source files. Edits to SchemaPrinterMain.cpp will be lost. To update SchemaPrinterMain.cpp: rake apache2 -OR- rake nginx To force regeneration of SchemaPrinterMain.cpp: rm -f src/schema_printer/SchemaPrinterMain.cpp rake src/schema_printer/SchemaPrinterMain.cpp } separator add_code %Q{ #include <ev++.h> // include first in order to avoid macro clash on EV_ERROR #include <iostream> } headers.each do |header| add_code %Q{ #include <#{header_path_to_include_path(header)}> } end separator function 'int main(int argc, char *argv[])' do add_code %Q{ Passenger::Json::Value doc(Passenger::Json::objectValue); } separator class_names.each do |name| add_code %Q{ doc[#{name.inspect}] = #{name}().inspect(); } end separator add_code %Q{ std::cout << doc.toStyledString() << std::endl; return 0; } end end def header_path_to_include_path(path) path.sub(%r{^src/(cxx_supportlib|agent)/}, '') end def scan_class_names_in(path) result = [] lines = File.open(path, 'r:utf-8') do |f| f.read.split("\n") end lines.each do |line| if line =~ /BEGIN ConfigKit schema: (.+)/ result << $1 end end result end def find_all_schemas all_names = [] all_headers = [] SCAN_FILES.each do |path| names = scan_class_names_in(path) if !names.empty? all_names.concat(names) all_headers << path end end [all_names.sort, all_headers.sort] end main