Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
Platform-independent core collection
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
18
Issues
18
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Platform-independent core collection
Commits
13c5a2bd
Commit
13c5a2bd
authored
Dec 15, 2022
by
Dimitris Lampridis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: add version info from tag to gen_sourceid.py
parent
9f42c8dd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
gen_sourceid.py
tools/gen_sourceid.py
+9
-0
No files found.
tools/gen_sourceid.py
View file @
13c5a2bd
...
...
@@ -8,6 +8,7 @@
with
open
(
"sourceid_{}_pkg.vhd"
.
format
(
project
),
"w"
)
as
f
:
import
subprocess
import
time
import
re
# Extract current commit id.
try
:
...
...
@@ -26,6 +27,12 @@ with open("sourceid_{}_pkg.vhd".format(project), "w") as f:
except
:
dirty
=
True
try
:
version
=
re
.
search
(
"
\
d+
\
.
\
d+
\
.
\
d+"
,
tag
)
major
,
minor
,
patch
=
[
int
(
x
)
for
x
in
version
.
group
()
.
split
(
'.'
)]
except
:
major
=
minor
=
patch
=
0
if
dirty
:
# There is no room for a dirty flag, just erase half of the bytes, so
# that's obvious it's not a real sha1, and still leaves enough to
...
...
@@ -42,4 +49,6 @@ with open("sourceid_{}_pkg.vhd".format(project), "w") as f:
f
.
write
(
"package sourceid_{}_pkg is
\n
"
.
format
(
project
))
f
.
write
(
" constant sourceid : std_logic_vector(127 downto 0) :=
\n
"
)
f
.
write
(
' x"{}";
\n
'
.
format
(
sourceid
))
f
.
write
(
" constant version : std_logic_vector(31 downto 0) := "
)
f
.
write
(
'x"{:02x}{:02x}{:04x}";
\n
'
.
format
(
major
&
0xff
,
minor
&
0xff
,
patch
&
0xffff
))
f
.
write
(
'end sourceid_{}_pkg;
\n
'
.
format
(
project
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment