d
This commit is contained in:
1 parent
a0f8e2d31e
commit
49cee91239
106 files changed
+112
-12
No files matched your search
File renamed without changes.
Executable
+55
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
from argparse import ArgumentParser
|
||||
from generation.generateStructure import *
|
||||
from generation.shortenName import *
|
||||
from generation.Result import *
|
||||
from parsing.parseLines import *
|
||||
from parsing.Structure import *
|
||||
|
||||
DIR = os.path.dirname(os.path.realpath(sys.argv[0]))
|
||||
|
||||
# Импорт из общей для всех генераторов директории.
|
||||
sys.path.append(f"{DIR}/../common")
|
||||
from modulePaths import *
|
||||
from readFile import *
|
||||
|
||||
parser = ArgumentParser(prog='generate v2')
|
||||
parser.add_argument('module', type=str,
|
||||
help='the name of the module to generate')
|
||||
parser.add_argument('-i', '--input', type=str,
|
||||
help='The path and name of the input file')
|
||||
parser.add_argument('-o', '--output', type=str,
|
||||
help='The path of the output files')
|
||||
parser.add_argument('-s', '--source', type=str,
|
||||
help='The path of the source files')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
(PATH, MODULE) = modulePaths(args.module)
|
||||
|
||||
print(f"Generating platform for module '{PATH}'...")
|
||||
|
||||
FILE_IN = args.input or f"{DIR}/../../../Modules/{PATH}/{MODULE}.yml"
|
||||
DIR_OUT = args.output or f"{DIR}/../../../Modules/{PATH}/src/"
|
||||
FILE_OUT = os.path.join(DIR_OUT, f"{MODULE}.Generated.swift")
|
||||
FILE_OUT_V1 = os.path.join(DIR_OUT, f"{MODULE}.SectionGenerated.swift")
|
||||
MODULE_SRC = args.source or f"{DIR}/../../../Modules/{PATH}/src"
|
||||
|
||||
# Удаляем первую версию генерированного файла при его наличии.
|
||||
if os.path.isfile(FILE_OUT_V1):
|
||||
os.remove(FILE_OUT_V1)
|
||||
|
||||
# Читаем файл и разбираем его на ключи-значения.
|
||||
lines = readFile(FILE_IN)
|
||||
structure = Structure()
|
||||
parseLines(lines, structure)
|
||||
|
||||
# Генерируем код.
|
||||
result = Result(DIR, PATH, MODULE, readFile, shortenName, MODULE_SRC, structure)
|
||||
generateStructure(result)
|
||||
|
||||
# Сохраняем файл.
|
||||
with open(FILE_OUT, "w") as file:
|
||||
file.write(result.file)
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from argparse import ArgumentParser
|
||||
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument('module', type=str,
|
||||
help='the name of the module to generate')
|
||||
parser.add_argument('-i', '--input', type=str,
|
||||
help='The path and name of the input file')
|
||||
|
||||
args, _ = parser.parse_known_args()
|
||||
DIR = os.path.dirname(os.path.realpath(sys.argv[0]))
|
||||
|
||||
# Импорт из общей для всех генераторов директории.
|
||||
sys.path.append(f"{DIR}/common")
|
||||
from modulePaths import *
|
||||
|
||||
|
||||
(PATH, MODULE) = modulePaths(args.module)
|
||||
|
||||
FILE_IN = args.input or f"{DIR}/../../Modules/{PATH}/{MODULE}.yml"
|
||||
|
||||
# Запускаем указанную в файле YML версию генератора.
|
||||
with open(FILE_IN) as file:
|
||||
ln = file.readline().rstrip()
|
||||
version = ln[-1]
|
||||
cmd = f"{DIR}/{version}/generate"
|
||||
subprocess.call(args=[cmd] + sys.argv[1:])
|
||||
File renamed without changes.
Symlink
+1
@@ -0,0 +1 @@
|
||||
/Users/mk/m/u/Utilities/platform/2/generation
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
/Users/mk/m/u/Utilities/platform/2/parsing
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
/Users/mk/m/u/Utilities/platform/2/templates
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
/Users/mk/m/u/Utilities/platform/common
|
||||
Reference in new issue
Block a user