Skip to content

Commit b39d328

Browse files
authored
Create get_idf_ver.py
1 parent 763d61e commit b39d328

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tools/get_idf_ver.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import argparse
2+
import os
3+
import re
4+
import sys
5+
6+
def main(ver_file_path):
7+
with open(ver_file_path, encoding="utf8") as fp:
8+
pattern = r"set\(IDF_VERSION_(MAJOR|MINOR|PATCH) (\d+)\)"
9+
matches = re.findall(pattern, fp.read())
10+
idf_version = str(".".join([match[1] for match in matches]))
11+
os.environ["IDF_VERSION"] = idf_version
12+
return idf_version
13+
14+
if __name__ == "__main__":
15+
parser = argparse.ArgumentParser()
16+
parser.add_argument(
17+
"-p",
18+
"--path",
19+
dest="ver_file_path",
20+
required=True,
21+
help="Full path to the ESP-IDF cmake version file \"version.cmake\"",
22+
)
23+
args = parser.parse_args()
24+
25+
sys.exit(main(args.ver_file_path))

0 commit comments

Comments
 (0)