From 4d149a69339d079d345a49b3055228779f9930ff Mon Sep 17 00:00:00 2001 From: Grigory Buteyko Date: Thu, 27 Jun 2024 21:33:37 +0300 Subject: [PATCH 1/3] tiny tweaks --- Makefile | 7 ------- internal/tlcodegen/tlgen.go | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Makefile b/Makefile index cfe0005d..ac7ccc15 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,6 @@ tlo-bootstrap: build --copyrightPath=./COPYRIGHT \ --pkgPath=github.com/vkcom/tl/internal/tlast/gentlo/tl \ --basicPkgPath=github.com/vkcom/tl/pkg/basictl \ - --generateRPCCode=false \ --outdir=./internal/tlast/gentlo \ ./internal/tlast/tls.tl @@ -53,7 +52,6 @@ gen_check: build --basicPkgPath=$(BASIC_TL_PATH) \ --generateByteVersions=$(TL_BYTE_VERSIONS) \ --generateLegacyJsonRead=false \ - --generateRPCCode=false \ ./$(TLS_PATH)/schema.tl .PHONY: gen @@ -74,7 +72,6 @@ goldmaster_nocompile: build --generateByteVersions=cases_bytes. \ --generateRandomCode \ --generateLegacyJsonRead=false \ - --generateRPCCode=false \ ./$(TLS_PATH)/cases.tl @./target/bin/tlgen --language=go --split-internal -v \ --copyrightPath=./COPYRIGHT \ @@ -86,7 +83,6 @@ goldmaster_nocompile: build --generateByteVersions=$(TL_BYTE_VERSIONS) \ --generateRandomCode \ --generateLegacyJsonRead=false \ - --generateRPCCode=false \ --canonicalFormPath=./$(TLS_PATH)/goldmaster_canonical.tl \ ./$(TLS_PATH)/goldmaster.tl ./$(TLS_PATH)/goldmaster2.tl ./$(TLS_PATH)/goldmaster3.tl @./target/bin/tlgen --language=go -v \ @@ -100,7 +96,6 @@ goldmaster_nocompile: build --tloPath=./$(TLOS_PATH)/goldmaster.tlo \ --generateRandomCode \ --generateLegacyJsonRead=false \ - --generateRPCCode=false \ --canonicalFormPath=./$(TLS_PATH)/goldmaster_canonical.tl \ ./$(TLS_PATH)/goldmaster.tl ./$(TLS_PATH)/goldmaster2.tl ./$(TLS_PATH)/goldmaster3.tl @@ -116,7 +111,6 @@ gen_tlo: build # do not set --basicPkgPath, or you'll have hard time updating ba @./target/bin/tlgen --language=go \ --copyrightPath=./COPYRIGHT \ --pkgPath=github.com/vkcom/tl/internal/tlast/gentlo/tl \ - --generateRPCCode=false \ --outdir=./internal/tlast/gentlo \ ./internal/tlast/tls.tl @@ -138,7 +132,6 @@ qtpl: cpp: build @./target/bin/tlgen -language=cpp -v \ --outdir=./$(GEN_PATH)/cpp \ - --generateRPCCode=false \ --basicPkgPath=$(BASIC_TL_PATH) \ ./$(TLS_PATH)/cpp.tl g++ -o $(GEN_PATH)/test_cpp $(GEN_PATH)/test_cpp.cpp $(GEN_PATH)/cpp/all.cpp -std=c++17 -O3 -Wno-noexcept-type -g -Wall -Wextra -Werror=return-type -Wno-unused-parameter diff --git a/internal/tlcodegen/tlgen.go b/internal/tlcodegen/tlgen.go index d575bd17..5a1750c2 100644 --- a/internal/tlcodegen/tlgen.go +++ b/internal/tlcodegen/tlgen.go @@ -740,7 +740,7 @@ func GenerateCode(tl tlast.TL, options Gen2Options) (*Gen2, error) { case "": // linting case "go": if options.GenerateRPCCode && options.BasicRPCPath == "" { - return nil, fmt.Errorf("--basicRPCPath must be specified or set --generateRPCCode=false if you don't use rpc code") + return nil, fmt.Errorf("--basicRPCPath must be specified if --generateRPCCode is set") } options.TLPackageNameFull = strings.TrimSpace(options.TLPackageNameFull) options.TLPackageNameFull = strings.TrimSuffix(options.TLPackageNameFull, "/") From d1d58174ca09900cd78b9d44ec7d9d656c35b766 Mon Sep 17 00:00:00 2001 From: Grigory Buteyko Date: Thu, 27 Jun 2024 22:50:11 +0300 Subject: [PATCH 2/3] schema commit, timestamp, url passed, simplified work with marker file --- Makefile | 4 ++ cmd/tlgen/main.go | 9 +--- cmd/tlgen/main2.go | 27 ++++++----- internal/tlast/tlgen_tlo.go | 22 +++------ internal/tlcodegen/qt_tljson_html.qtpl | 9 +++- internal/tlcodegen/qt_tljson_html.qtpl.go | 20 +++++++- .../test/gen/cases/tlgen2_version.txt | 5 +- .../test/gen/goldmaster/tlgen2_version.txt | 5 +- .../tlcodegen/test/gen/goldmaster/tljson.html | 4 +- .../gen/goldmaster_nosplit/tlgen2_version.txt | 5 +- .../test/gen/goldmaster_nosplit/tljson.html | 4 +- internal/tlcodegen/tlgen.go | 46 ++++++++----------- 12 files changed, 92 insertions(+), 68 deletions(-) diff --git a/Makefile b/Makefile index ac7ccc15..29588ce5 100644 --- a/Makefile +++ b/Makefile @@ -78,6 +78,8 @@ goldmaster_nocompile: build --outdir=./$(GEN_PATH)/goldmaster \ --generateSchemaDocumentation \ --schemaURL="https://github.com/VKCOM/tl/blob/master/internal/tlcodegen/test/tls/goldmaster.tl" \ + --schemaCommit=abcdefgh \ + --schemaTimestamp=301812000 \ --pkgPath=github.com/vkcom/tl/$(GEN_PATH)/goldmaster/tl \ --basicPkgPath=$(BASIC_TL_PATH) \ --generateByteVersions=$(TL_BYTE_VERSIONS) \ @@ -90,6 +92,8 @@ goldmaster_nocompile: build --outdir=./$(GEN_PATH)/goldmaster_nosplit \ --generateSchemaDocumentation \ --schemaURL="https://github.com/VKCOM/tl/blob/master/internal/tlcodegen/test/tls/goldmaster.tl" \ + --schemaCommit=abcdefgh \ + --schemaTimestamp=301812000 \ --pkgPath=github.com/vkcom/tl/$(GEN_PATH)/goldmaster_nosplit/tl \ --basicPkgPath=$(BASIC_TL_PATH) \ --generateByteVersions=$(TL_BYTE_VERSIONS) \ diff --git a/cmd/tlgen/main.go b/cmd/tlgen/main.go index 33dc1d27..83add7ee 100644 --- a/cmd/tlgen/main.go +++ b/cmd/tlgen/main.go @@ -7,20 +7,13 @@ package main import ( - "fmt" "log" - "runtime/debug" "github.com/vkcom/tl/internal/tlcodegen" ) func main() { - bi, ok := debug.ReadBuildInfo() - if !ok { - log.Printf("Failed to read build info") - return - } - fmt.Printf("tlgen version: %+v\n", bi.Main.Version) + log.Printf("tlgen version: %s", tlcodegen.TLGenVersion()) log.SetFlags(0) diff --git a/cmd/tlgen/main2.go b/cmd/tlgen/main2.go index 1a492790..f067a549 100644 --- a/cmd/tlgen/main2.go +++ b/cmd/tlgen/main2.go @@ -64,7 +64,11 @@ func parseFlags(opt *tlcodegen.Gen2Options) { flag.BoolVar(&opt.SchemaDocumentation, "generateSchemaDocumentation", false, "whether to generate .html representation of schema in to tljson.html file") flag.StringVar(&opt.SchemaURL, "schemaURL", "", - "template for url to current schema if documentation is generated") + "url of schema (for documentation)") + flag.UintVar(&opt.SchemaTimestamp, "schemaTimestamp", 0, + "timestamp of schema (for documentation, TLO version)") + flag.StringVar(&opt.SchemaCommit, "schemaCommit", "", + "commit of schema (for documentation)") // C++ flag.StringVar(&opt.RootCPPNamespace, "cpp-namespace", "", @@ -80,8 +84,6 @@ func parseFlags(opt *tlcodegen.Gen2Options) { } func run(opt tlcodegen.Gen2Options) { - var commit, version = tlcodegen.TLGenBuildInfo() - log.Printf("tlgen version: %s, commit: %s", version, commit) if err := runMain(&opt); err != nil { var parseError *tlast.ParseError if errors.As(err, &parseError) { @@ -89,25 +91,28 @@ func run(opt tlcodegen.Gen2Options) { } else { log.Println(err.Error()) } - log.Printf("TL Generation Failed") - os.Exit(1) - } else { if opt.Language == "" { - log.Printf("TL Linter Success") + log.Printf("TL Linter Failed") } else { - log.Printf("TL Generation Success") + log.Printf("TL Generation Failed") } + os.Exit(1) + return + } + if opt.Language == "" { + log.Printf("TL Linter Success") + } else { + log.Printf("TL Generation Success") } } func runMain(opt *tlcodegen.Gen2Options) error { var ast tlast.TL var fullAst tlast.TL - var args []string if opt.ErrorWriter == nil { opt.ErrorWriter = os.Stdout } - args = append(args, flag.Args()...) + args := flag.Args() if len(args) == 0 { return fmt.Errorf("specify 1 or more input TL schema filenames after flags") } @@ -143,7 +148,7 @@ func runMain(opt *tlcodegen.Gen2Options) error { if opt.Verbose { log.Print("generating tlo file") } - s, err := fullAst.GenerateTLO() + s, err := fullAst.GenerateTLO(uint32(opt.SchemaTimestamp)) if err != nil { return fmt.Errorf("error on generating tlo: %w", err) } diff --git a/internal/tlast/tlgen_tlo.go b/internal/tlast/tlgen_tlo.go index ec55ef38..17378d0d 100644 --- a/internal/tlast/tlgen_tlo.go +++ b/internal/tlast/tlgen_tlo.go @@ -98,7 +98,7 @@ func (ps *paramScope) find(f func(e param) bool) (param, bool) { return param{}, false } -func (tl TL) GenerateTLO() (tls.SchemaV4, error) { +func (tl TL) GenerateTLO(version uint32) (tls.SchemaV4, error) { allCombinators := make(map[string]*Combinator, len(tl)) for i, comb := range tl { allCombinators[comb.Construct.Name.String()] = tl[i] @@ -291,9 +291,13 @@ func (tl TL) GenerateTLO() (tls.SchemaV4, error) { v4B, _ := functions[j].AsV4() return v4A.Id < v4B.Id }) + date := version + if version == 0 { + date = uint32(time.Now().Unix()) + } return tls.SchemaV4{ - Version: 0, // always 0 - Date: int32(time.Now().Unix()), + Version: int32(version), // TODO - must be changed to # in tl definition + Date: int32(date), // TODO - must be changed to # in tl definition TypesNum: uint32(len(types)), Types: types, ConstructorNum: uint32(len(constructors)), @@ -303,18 +307,6 @@ func (tl TL) GenerateTLO() (tls.SchemaV4, error) { }, nil } -func (tl TL) GenerateTLOBytes() ([]byte, error) { - s, err := tl.GenerateTLO() - if err != nil { - return nil, err - } - res, err := s.WriteBoxed(nil) - if err != nil { - return nil, fmt.Errorf("can't write TLO boxed: %w", err) - } - return res, nil -} - func typeRefToTypeExpr(mc paramScope, allCombinators map[string]*Combinator, tlsTypes map[string]*tls.Type, t *TypeRef, bare bool) tls.TypeExpr { if typeExpr, ok := builtinTypeExprUnions[t.Type.String()]; ok { return typeExpr diff --git a/internal/tlcodegen/qt_tljson_html.qtpl b/internal/tlcodegen/qt_tljson_html.qtpl index 4763e182..6c054ab2 100644 --- a/internal/tlcodegen/qt_tljson_html.qtpl +++ b/internal/tlcodegen/qt_tljson_html.qtpl @@ -1,6 +1,7 @@ {% package tlcodegen %} {% import "fmt" %} +{% import "time" %} {% import "strings" %} {%- func tlJSON(gen *Gen2, tlgenVersion string) -%} @@ -16,7 +17,13 @@ diff --git a/internal/tlcodegen/qt_tljson_html.qtpl.go b/internal/tlcodegen/qt_tljson_html.qtpl.go index 9520b06c..b857a2ab 100644 --- a/internal/tlcodegen/qt_tljson_html.qtpl.go +++ b/internal/tlcodegen/qt_tljson_html.qtpl.go @@ -5,6 +5,8 @@ package tlcodegen import "fmt" +import "time" + import "strings" import ( @@ -34,9 +36,23 @@ func streamtlJSON(qw422016 *qt422016.Writer, gen *Gen2, tlgenVersion string) { qw422016.N().S(` `) if gen.options.SchemaURL != "" { - qw422016.N().S(`
  • TL schema
  • + qw422016.N().S(`">url +`) + } + if gen.options.SchemaCommit != "" { + qw422016.N().S(`
  • TL schema commit: `) + qw422016.E().S(gen.options.SchemaCommit) + qw422016.N().S(`
  • +`) + } + if gen.options.SchemaTimestamp != 0 { + qw422016.N().S(`
  • TL schema version: `) + qw422016.E().V(gen.options.SchemaTimestamp) + qw422016.N().S(` (`) + qw422016.E().V(time.Unix(int64(gen.options.SchemaTimestamp), 0).UTC()) + qw422016.N().S(`)
  • `) } qw422016.N().S(`
  • TLJSON mapping rules: TLJSON.md
  • diff --git a/internal/tlcodegen/test/gen/cases/tlgen2_version.txt b/internal/tlcodegen/test/gen/cases/tlgen2_version.txt index 849df800..43132ca3 100644 --- a/internal/tlcodegen/test/gen/cases/tlgen2_version.txt +++ b/internal/tlcodegen/test/gen/cases/tlgen2_version.txt @@ -1 +1,4 @@ -tlgen2 version (devel) +tlgen version: (devel) +schema commit: +schema version: 0 (1970-01-01 00:00:00 +0000 UTC) +schema url: diff --git a/internal/tlcodegen/test/gen/goldmaster/tlgen2_version.txt b/internal/tlcodegen/test/gen/goldmaster/tlgen2_version.txt index 849df800..91543cde 100644 --- a/internal/tlcodegen/test/gen/goldmaster/tlgen2_version.txt +++ b/internal/tlcodegen/test/gen/goldmaster/tlgen2_version.txt @@ -1 +1,4 @@ -tlgen2 version (devel) +tlgen version: (devel) +schema commit: abcdefgh +schema version: 301812000 (1979-07-26 04:40:00 +0000 UTC) +schema url: https://github.com/VKCOM/tl/blob/master/internal/tlcodegen/test/tls/goldmaster.tl diff --git a/internal/tlcodegen/test/gen/goldmaster/tljson.html b/internal/tlcodegen/test/gen/goldmaster/tljson.html index b3691c79..b2f0ef42 100644 --- a/internal/tlcodegen/test/gen/goldmaster/tljson.html +++ b/internal/tlcodegen/test/gen/goldmaster/tljson.html @@ -9,7 +9,9 @@

    Schema

    Functions

    diff --git a/internal/tlcodegen/test/gen/goldmaster_nosplit/tlgen2_version.txt b/internal/tlcodegen/test/gen/goldmaster_nosplit/tlgen2_version.txt index 849df800..91543cde 100644 --- a/internal/tlcodegen/test/gen/goldmaster_nosplit/tlgen2_version.txt +++ b/internal/tlcodegen/test/gen/goldmaster_nosplit/tlgen2_version.txt @@ -1 +1,4 @@ -tlgen2 version (devel) +tlgen version: (devel) +schema commit: abcdefgh +schema version: 301812000 (1979-07-26 04:40:00 +0000 UTC) +schema url: https://github.com/VKCOM/tl/blob/master/internal/tlcodegen/test/tls/goldmaster.tl diff --git a/internal/tlcodegen/test/gen/goldmaster_nosplit/tljson.html b/internal/tlcodegen/test/gen/goldmaster_nosplit/tljson.html index b3691c79..b2f0ef42 100644 --- a/internal/tlcodegen/test/gen/goldmaster_nosplit/tljson.html +++ b/internal/tlcodegen/test/gen/goldmaster_nosplit/tljson.html @@ -9,7 +9,9 @@

    Schema

    Functions

    diff --git a/internal/tlcodegen/tlgen.go b/internal/tlcodegen/tlgen.go index 5a1750c2..fef0c8c1 100644 --- a/internal/tlcodegen/tlgen.go +++ b/internal/tlcodegen/tlgen.go @@ -16,6 +16,7 @@ import ( "sort" "strings" "sync/atomic" + "time" "golang.org/x/exp/slices" @@ -46,10 +47,11 @@ const ( const TlJSONHTML = "tljson.html" -// Do not forget to bump version when making changes. -// We do not want repository hash, because it advances automatically each time ANYTHING in repository changes, not only tlgen2. -// And we do not want stable checksum of go files tlgen folder, because checksums are not comparable and there is no idea how old that version is -const buildVersionString = "tlgen2 version " +const buildVersionFormat = `tlgen version: %s +schema url: %s +schema commit: %s +schema version: %d (%v) +` var ( errSeeHere = fmt.Errorf("see here") @@ -66,17 +68,11 @@ type LocalResolveContext struct { overrideFileName string // used for unions and built-in vectors and tuples, so they are defined in the file of argument } -func TLGenBuildInfo() (commit string, version string) { +func TLGenVersion() string { if info, ok := debug.ReadBuildInfo(); ok { - for _, setting := range info.Settings { - if setting.Key == "vcs.revision" { - commit = setting.Value - break - } - } - version = info.Main.Version + return info.Main.Version } - return commit, version + return "" } // checkArgsCollision checks if passed name is already used in local context. @@ -325,6 +321,8 @@ type Gen2Options struct { GenerateLegacyJsonRead bool SchemaDocumentation bool SchemaURL string + SchemaTimestamp uint // for TLO version/date + SchemaCommit string // C++ RootCPPNamespace string @@ -666,7 +664,14 @@ func (gen *Gen2) WriteToDir(outdir string) error { if len(relativeFiles) != 0 && !relativeFiles[markerFile] { return fmt.Errorf("outdir %q not empty and has no %q marker file, please clean manually", outdir, markerFile) } - delete(relativeFiles, markerFile) // special treatment, never delete it + markerContent := fmt.Sprintf(buildVersionFormat, + strings.TrimSpace(TLGenVersion()), + strings.TrimSpace(gen.options.SchemaCommit), + gen.options.SchemaTimestamp, time.Unix(int64(gen.options.SchemaTimestamp), 0).UTC(), + strings.TrimSpace(gen.options.SchemaURL)) + if err := gen.addCodeFile(markerFile, markerContent); err != nil { + return err + } notTouched := 0 written := 0 deleted := 0 @@ -691,16 +696,6 @@ func (gen *Gen2) WriteToDir(outdir string) error { return fmt.Errorf("error writing file %q: %w", f, err) } } - if len(gen.Code) == 0 || written != 0 || len(relativeFiles) != 0 { - // motivation - do not modify marker file if no code changed. Greatly reduces efforts to refactor tlgen. - f := filepath.Join(outdir, markerFile) - _, version := TLGenBuildInfo() - code := buildVersionString + strings.TrimSpace(version) + "\n" // many editors insist on empty line at the end - written++ - if err := os.WriteFile(f, []byte(code), 0644); err != nil { - return fmt.Errorf("error writing file %q: %w", f, err) - } - } for filepathName := range relativeFiles { deleted++ f := filepath.Join(outdir, filepathName) @@ -1187,8 +1182,7 @@ func GenerateCode(tl tlast.TL, options Gen2Options) (*Gen2, error) { } if options.SchemaDocumentation { - _, version := TLGenBuildInfo() - if err := gen.addCodeFile(TlJSONHTML, tlJSON(gen, version)); err != nil { + if err := gen.addCodeFile(TlJSONHTML, tlJSON(gen, TLGenVersion())); err != nil { return nil, err } } From f535a568182a5d71c48a887e702d5801cd692641 Mon Sep 17 00:00:00 2001 From: Grigory Buteyko Date: Thu, 27 Jun 2024 23:09:09 +0300 Subject: [PATCH 3/3] schema commit, mark file writing simplification --- Makefile | 4 ++-- internal/tlcodegen/test/gen/cases/tlgen2_version.txt | 2 +- internal/tlcodegen/test/gen/goldmaster/tlgen2_version.txt | 4 ++-- internal/tlcodegen/test/gen/goldmaster/tljson.html | 4 ++-- .../tlcodegen/test/gen/goldmaster_nosplit/tlgen2_version.txt | 4 ++-- internal/tlcodegen/test/gen/goldmaster_nosplit/tljson.html | 4 ++-- internal/tlcodegen/tlgen.go | 5 +++-- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 29588ce5..59678b5f 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ goldmaster_nocompile: build --generateSchemaDocumentation \ --schemaURL="https://github.com/VKCOM/tl/blob/master/internal/tlcodegen/test/tls/goldmaster.tl" \ --schemaCommit=abcdefgh \ - --schemaTimestamp=301812000 \ + --schemaTimestamp=301822800 \ --pkgPath=github.com/vkcom/tl/$(GEN_PATH)/goldmaster/tl \ --basicPkgPath=$(BASIC_TL_PATH) \ --generateByteVersions=$(TL_BYTE_VERSIONS) \ @@ -93,7 +93,7 @@ goldmaster_nocompile: build --generateSchemaDocumentation \ --schemaURL="https://github.com/VKCOM/tl/blob/master/internal/tlcodegen/test/tls/goldmaster.tl" \ --schemaCommit=abcdefgh \ - --schemaTimestamp=301812000 \ + --schemaTimestamp=301822800 \ --pkgPath=github.com/vkcom/tl/$(GEN_PATH)/goldmaster_nosplit/tl \ --basicPkgPath=$(BASIC_TL_PATH) \ --generateByteVersions=$(TL_BYTE_VERSIONS) \ diff --git a/internal/tlcodegen/test/gen/cases/tlgen2_version.txt b/internal/tlcodegen/test/gen/cases/tlgen2_version.txt index 43132ca3..e431bfc0 100644 --- a/internal/tlcodegen/test/gen/cases/tlgen2_version.txt +++ b/internal/tlcodegen/test/gen/cases/tlgen2_version.txt @@ -1,4 +1,4 @@ tlgen version: (devel) +schema url: schema commit: schema version: 0 (1970-01-01 00:00:00 +0000 UTC) -schema url: diff --git a/internal/tlcodegen/test/gen/goldmaster/tlgen2_version.txt b/internal/tlcodegen/test/gen/goldmaster/tlgen2_version.txt index 91543cde..c2f0f1ff 100644 --- a/internal/tlcodegen/test/gen/goldmaster/tlgen2_version.txt +++ b/internal/tlcodegen/test/gen/goldmaster/tlgen2_version.txt @@ -1,4 +1,4 @@ tlgen version: (devel) -schema commit: abcdefgh -schema version: 301812000 (1979-07-26 04:40:00 +0000 UTC) schema url: https://github.com/VKCOM/tl/blob/master/internal/tlcodegen/test/tls/goldmaster.tl +schema commit: abcdefgh +schema version: 301822800 (1979-07-26 07:40:00 +0000 UTC) diff --git a/internal/tlcodegen/test/gen/goldmaster/tljson.html b/internal/tlcodegen/test/gen/goldmaster/tljson.html index b2f0ef42..3b4dbc66 100644 --- a/internal/tlcodegen/test/gen/goldmaster/tljson.html +++ b/internal/tlcodegen/test/gen/goldmaster/tljson.html @@ -10,8 +10,8 @@

    Schema

    • tlgen version: (devel)
    • TL schema url
    • -
    • TL schema version 301812000 (1979-07-26 04:40:00 +0000 UTC)
    • -
    • TL schema commit abcdefgh
    • +
    • TL schema commit: abcdefgh
    • +
    • TL schema version: 301822800 (1979-07-26 07:40:00 +0000 UTC)
    • TLJSON mapping rules: TLJSON.md

    Functions

    diff --git a/internal/tlcodegen/test/gen/goldmaster_nosplit/tlgen2_version.txt b/internal/tlcodegen/test/gen/goldmaster_nosplit/tlgen2_version.txt index 91543cde..c2f0f1ff 100644 --- a/internal/tlcodegen/test/gen/goldmaster_nosplit/tlgen2_version.txt +++ b/internal/tlcodegen/test/gen/goldmaster_nosplit/tlgen2_version.txt @@ -1,4 +1,4 @@ tlgen version: (devel) -schema commit: abcdefgh -schema version: 301812000 (1979-07-26 04:40:00 +0000 UTC) schema url: https://github.com/VKCOM/tl/blob/master/internal/tlcodegen/test/tls/goldmaster.tl +schema commit: abcdefgh +schema version: 301822800 (1979-07-26 07:40:00 +0000 UTC) diff --git a/internal/tlcodegen/test/gen/goldmaster_nosplit/tljson.html b/internal/tlcodegen/test/gen/goldmaster_nosplit/tljson.html index b2f0ef42..3b4dbc66 100644 --- a/internal/tlcodegen/test/gen/goldmaster_nosplit/tljson.html +++ b/internal/tlcodegen/test/gen/goldmaster_nosplit/tljson.html @@ -10,8 +10,8 @@

    Schema

    • tlgen version: (devel)
    • TL schema url
    • -
    • TL schema version 301812000 (1979-07-26 04:40:00 +0000 UTC)
    • -
    • TL schema commit abcdefgh
    • +
    • TL schema commit: abcdefgh
    • +
    • TL schema version: 301822800 (1979-07-26 07:40:00 +0000 UTC)
    • TLJSON mapping rules: TLJSON.md

    Functions

    diff --git a/internal/tlcodegen/tlgen.go b/internal/tlcodegen/tlgen.go index fef0c8c1..3983ebbf 100644 --- a/internal/tlcodegen/tlgen.go +++ b/internal/tlcodegen/tlgen.go @@ -666,9 +666,9 @@ func (gen *Gen2) WriteToDir(outdir string) error { } markerContent := fmt.Sprintf(buildVersionFormat, strings.TrimSpace(TLGenVersion()), + strings.TrimSpace(gen.options.SchemaURL), strings.TrimSpace(gen.options.SchemaCommit), - gen.options.SchemaTimestamp, time.Unix(int64(gen.options.SchemaTimestamp), 0).UTC(), - strings.TrimSpace(gen.options.SchemaURL)) + gen.options.SchemaTimestamp, time.Unix(int64(gen.options.SchemaTimestamp), 0).UTC()) if err := gen.addCodeFile(markerFile, markerContent); err != nil { return err } @@ -692,6 +692,7 @@ func (gen *Gen2) WriteToDir(outdir string) error { continue } } + written++ if err := os.WriteFile(f, []byte(code), 0644); err != nil { return fmt.Errorf("error writing file %q: %w", f, err) }