$v){ $inc[$k] = "\"$v\""; } $p = basename($file, '.php'); echo("doing==>:$p\n"); $rpcs = array(); foreach($mod['cmds'] as $cmd){ $rpc = "\t\t#rpc{"; $rpc .= "\n\t\t\tcode = {$cmd['code']}"; $rpc .= "\n\t\t\t,log_title = \"{$cmd['desc']}\""; $rpc .= "\n\t\t\t,req_desc = \"{$cmd['desc']}\""; if($cmd['client']) $rpc .= "\n\t\t\t,req = ".fun_fields($cmd['client']); $rpc .= "\n\t\t\t,reply_desc = \"{$cmd['desc']}返回结果\""; if($cmd['server']) $rpc .= "\n\t\t\t,reply = ".fun_fields($cmd['server']); $rpc .= "\n\t\t}"; $rpcs[] = $rpc; } $str = "%%-----------------------------------------"; $str .= "\n%% "; $str .= "\n%% "; $str .= "\n%%-----------------------------------------"; $str .= "\n-module($p)."; $str .= "\n-export(["; $str .= "\n\t\tinfo/0"; $str .= "\n\t\t,cfg/0"; $str .= "\n\t]"; $str .= "\n)."; $str .= "\n-include(\"protocol.hrl\")."; $str .= "\n"; $str .= "\ninfo() -> {"; $str .= "\n\t\t\"\""; $str .= "\n\t\t,[".implode(',',$inc)."]"; $str .= "\n\t}."; $str .= "\n"; $str .= "\ncfg() -> "; $str .= "\n\t[\n"; $str .= implode(",\n", $rpcs); $str .= "\n\t]."; file_put_contents("../cfg/$p.erl", $str); } }