Skip to content

Commit

Permalink
parameterize resolve i64
Browse files Browse the repository at this point in the history
  • Loading branch information
cl1337 committed Oct 5, 2018
1 parent 59e39cf commit bd91c8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion codegen/runner/pre-steps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ for config_file in ${config_files}; do
sed "s|$ABS_IDL_DIR\/\(.*\)\/.*.thrift|$ABS_GENCODE_DIR/\1|" | \
sort | uniq | xargs
)
"$RESOLVE_I64_BINARY" "$thrift_file"
"$RESOLVE_I64_BINARY" "$thrift_file" "idl" "json.type"
target_dirs+=" $gen_code_dir"
done
done
Expand Down
11 changes: 7 additions & 4 deletions scripts/resolve_i64/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,18 @@ func getDirName() string {

func main() {
thriftFile := os.Args[1]
stripPath := os.Args[2]
annotationJSType := os.Args[3]

module, err := compile.Compile(thriftFile)
if err != nil {
panic(fmt.Sprintf("Failed to parse thrift file: %s", thriftFile))
}
meta := &Meta{}

s := strings.TrimSuffix(thriftFile, ".thrift")
// TODO use os.Args[2] instead of hard-coded path
s = strings.Replace(s, "/idl/", "/build/gen-code/", 1)
//s = strings.Replace(s, "/idl/", "/build/gen-code/", 1)
s = strings.Replace(s, stripPath, "/build/gen-code/", 1)
meta.PackageName = filepath.Base(s)

for _, typeDef := range module.Types {
Expand All @@ -114,10 +117,10 @@ func main() {
}

i64Struct.TypedefType = refType[1:]
if typThriftAnnotation["json.type"] == "Long" {
if typThriftAnnotation[annotationJSType] == "Long" {
i64Struct.IsLong = true
}
if typThriftAnnotation["json.type"] == "Date" {
if typThriftAnnotation[annotationJSType] == "Date" {
i64Struct.IsTimestamp = true
}
}
Expand Down

0 comments on commit bd91c8c

Please sign in to comment.