Skip to content

Commit

Permalink
schema commit, mark file writing simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
hrissan committed Jun 27, 2024
1 parent d1d5817 commit f535a56
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand All @@ -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) \
Expand Down
2 changes: 1 addition & 1 deletion internal/tlcodegen/test/gen/cases/tlgen2_version.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tlgen version: (devel)
schema url:
schema commit:
schema version: 0 (1970-01-01 00:00:00 +0000 UTC)
schema url:
4 changes: 2 additions & 2 deletions internal/tlcodegen/test/gen/goldmaster/tlgen2_version.txt
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions internal/tlcodegen/test/gen/goldmaster/tljson.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ <h1>Schema</h1>
<ul>
<li>tlgen version: (devel)</li>
<li><abbr>TL</abbr> schema <a href="https://github.com/VKCOM/tl/blob/master/internal/tlcodegen/test/tls/goldmaster.tl">url</a></li>
<li><abbr>TL</abbr> schema version 301812000 (1979-07-26 04:40:00 +0000 UTC)</li>
<li><abbr>TL</abbr> schema commit abcdefgh</li>
<li><abbr>TL</abbr> schema commit: abcdefgh</li>
<li><abbr>TL</abbr> schema version: 301822800 (1979-07-26 07:40:00 +0000 UTC)</li>
<li><abbr>TL</abbr><abbr>JSON</abbr> mapping rules: <a href="https://github.com/VKCOM/tl/blob/master/TLJSON.md">TLJSON.md</a></li>
</ul>
<h1>Functions</h1>
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions internal/tlcodegen/test/gen/goldmaster_nosplit/tljson.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ <h1>Schema</h1>
<ul>
<li>tlgen version: (devel)</li>
<li><abbr>TL</abbr> schema <a href="https://github.com/VKCOM/tl/blob/master/internal/tlcodegen/test/tls/goldmaster.tl">url</a></li>
<li><abbr>TL</abbr> schema version 301812000 (1979-07-26 04:40:00 +0000 UTC)</li>
<li><abbr>TL</abbr> schema commit abcdefgh</li>
<li><abbr>TL</abbr> schema commit: abcdefgh</li>
<li><abbr>TL</abbr> schema version: 301822800 (1979-07-26 07:40:00 +0000 UTC)</li>
<li><abbr>TL</abbr><abbr>JSON</abbr> mapping rules: <a href="https://github.com/VKCOM/tl/blob/master/TLJSON.md">TLJSON.md</a></li>
</ul>
<h1>Functions</h1>
Expand Down
5 changes: 3 additions & 2 deletions internal/tlcodegen/tlgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
}
Expand Down

0 comments on commit f535a56

Please sign in to comment.