2017-12-11 18:12:49 -05:00
|
|
|
#! /usr/bin/env python3
|
|
|
|
|
|
|
|
import glob
|
|
|
|
import os
|
|
|
|
import uuid
|
|
|
|
|
|
|
|
dirs = set()
|
|
|
|
|
|
|
|
tlv1 = ""
|
|
|
|
for file in glob.iglob("src/libsodium/**/*.c", recursive=True):
|
|
|
|
file = file.replace("/", "\\")
|
2023-09-11 07:20:01 -04:00
|
|
|
tlv1 = tlv1 + ' <ClCompile Include="..\\..\\{}" />\r\n'.format(file)
|
2017-12-11 18:12:49 -05:00
|
|
|
|
|
|
|
tlv2 = ""
|
|
|
|
for file in glob.iglob("src/libsodium/**/*.h", recursive=True):
|
|
|
|
file = file.replace("/", "\\")
|
2023-09-11 07:20:01 -04:00
|
|
|
tlv2 = tlv2 + ' <ClInclude Include="..\\..\\{}" />\r\n'.format(file)
|
2017-12-11 18:12:49 -05:00
|
|
|
|
|
|
|
tlf1 = ""
|
|
|
|
for file in glob.iglob("src/libsodium/**/*.c", recursive=True):
|
|
|
|
file = file.replace("/", "\\")
|
2023-09-11 07:20:01 -04:00
|
|
|
tlf1 = tlf1 + ' <ClCompile Include="..\\..\\{}">\r\n'.format(file)
|
2017-12-11 18:12:49 -05:00
|
|
|
tlf1 = tlf1 + " <Filter>Source Files</Filter>\r\n"
|
|
|
|
tlf1 = tlf1 + " </ClCompile>\r\n"
|
|
|
|
|
|
|
|
tlf2 = ""
|
|
|
|
for file in glob.iglob("src/libsodium/**/*.h", recursive=True):
|
|
|
|
file = file.replace("/", "\\")
|
2023-09-11 07:20:01 -04:00
|
|
|
tlf2 = tlf2 + ' <ClInclude Include="..\\..\\{}">\r\n'.format(file)
|
2017-12-11 18:12:49 -05:00
|
|
|
tlf2 = tlf2 + " <Filter>Header Files</Filter>\r\n"
|
|
|
|
tlf2 = tlf2 + " </ClInclude>\r\n"
|
|
|
|
|
|
|
|
v1 = ""
|
|
|
|
for file in glob.iglob("src/libsodium/**/*.c", recursive=True):
|
|
|
|
file = file.replace("/", "\\")
|
2019-04-22 13:46:27 -04:00
|
|
|
v1 = v1 + ' <ClCompile Include="..\\..\\..\\..\\{}" />\r\n'.format(file)
|
2017-12-11 18:12:49 -05:00
|
|
|
|
|
|
|
v2 = ""
|
|
|
|
for file in glob.iglob("src/libsodium/**/*.h", recursive=True):
|
|
|
|
file = file.replace("/", "\\")
|
2019-04-22 13:46:27 -04:00
|
|
|
v2 = v2 + ' <ClInclude Include="..\\..\\..\\..\\{}" />\r\n'.format(file)
|
2017-12-11 18:12:49 -05:00
|
|
|
|
|
|
|
f1 = ""
|
|
|
|
for file in glob.iglob("src/libsodium/**/*.c", recursive=True):
|
|
|
|
basedir = os.path.dirname(file).replace("src/libsodium/", "")
|
|
|
|
t = basedir
|
2019-04-22 13:46:27 -04:00
|
|
|
while t != "":
|
2017-12-11 18:12:49 -05:00
|
|
|
dirs.add(t)
|
|
|
|
t = os.path.dirname(t)
|
|
|
|
basedir = basedir.replace("/", "\\")
|
|
|
|
file = file.replace("/", "\\")
|
2019-04-22 13:46:27 -04:00
|
|
|
f1 = f1 + ' <ClCompile Include="..\\..\\..\\..\\{}">\r\n'.format(file)
|
2017-12-11 18:12:49 -05:00
|
|
|
f1 = f1 + " <Filter>{}</Filter>\r\n".format(basedir)
|
|
|
|
f1 = f1 + " </ClCompile>\r\n"
|
|
|
|
|
|
|
|
f2 = ""
|
|
|
|
for file in glob.iglob("src/libsodium/**/*.h", recursive=True):
|
|
|
|
basedir = os.path.dirname(file).replace("src/libsodium/", "")
|
|
|
|
t = basedir
|
2019-04-22 13:46:27 -04:00
|
|
|
while t != "":
|
2017-12-11 18:12:49 -05:00
|
|
|
dirs.add(t)
|
|
|
|
t = os.path.dirname(t)
|
|
|
|
basedir = basedir.replace("/", "\\")
|
|
|
|
file = file.replace("/", "\\")
|
2019-04-22 13:46:27 -04:00
|
|
|
f2 = f2 + ' <ClInclude Include="..\\..\\..\\..\\{}">\r\n'.format(file)
|
2017-12-11 18:12:49 -05:00
|
|
|
f2 = f2 + " <Filter>{}</Filter>\r\n".format(basedir)
|
|
|
|
f2 = f2 + " </ClInclude>\r\n"
|
|
|
|
|
|
|
|
fd = ""
|
|
|
|
dirs = list(dirs)
|
|
|
|
dirs.sort()
|
|
|
|
for dir in dirs:
|
|
|
|
dir = dir.replace("/", "\\")
|
2019-04-22 13:46:27 -04:00
|
|
|
uid = uuid.uuid3(uuid.UUID(bytes=b"LibSodiumMSVCUID"), dir)
|
|
|
|
fd = fd + ' <Filter Include="{}">\r\n'.format(dir)
|
|
|
|
fd = fd + " <UniqueIdentifier>{{{}}}</UniqueIdentifier>\r\n".format(uid)
|
2017-12-11 18:12:49 -05:00
|
|
|
fd = fd + " </Filter>\r\n"
|
|
|
|
|
|
|
|
|
2023-09-10 18:30:40 -04:00
|
|
|
def get_project_configurations(vs_version):
|
|
|
|
projconfig = ""
|
|
|
|
configs = [
|
|
|
|
"DebugDLL",
|
|
|
|
"ReleaseDLL",
|
|
|
|
"DebugLIB",
|
|
|
|
"ReleaseLIB",
|
|
|
|
"DebugLTCG",
|
|
|
|
"ReleaseLTCG",
|
|
|
|
]
|
|
|
|
platforms = ["Win32", "x64"]
|
|
|
|
# add arm64 platform only for v142+ toolchain
|
|
|
|
if vs_version >= 142:
|
|
|
|
platforms.append("ARM64")
|
|
|
|
for config in configs:
|
|
|
|
for platform in platforms:
|
|
|
|
projconfig = (
|
|
|
|
projconfig
|
|
|
|
+ ' <ProjectConfiguration Include="{}|{}">\r\n'.format(
|
|
|
|
config, platform
|
|
|
|
)
|
|
|
|
)
|
|
|
|
projconfig = (
|
|
|
|
projconfig
|
|
|
|
+ " <Configuration>{}</Configuration>\r\n".format(config)
|
|
|
|
)
|
|
|
|
projconfig = projconfig + " <Platform>{}</Platform>\r\n".format(
|
|
|
|
platform
|
|
|
|
)
|
|
|
|
projconfig = projconfig + " </ProjectConfiguration>\r\n"
|
|
|
|
return projconfig
|
|
|
|
|
|
|
|
|
2017-12-11 18:12:49 -05:00
|
|
|
def apply_template(tplfile, outfile, sbox):
|
|
|
|
tpl = ""
|
2019-04-22 13:46:27 -04:00
|
|
|
with open(tplfile, "rb") as fd:
|
2017-12-11 18:12:49 -05:00
|
|
|
tpl = fd.read()
|
|
|
|
for s in sbox.keys():
|
2019-04-22 13:46:27 -04:00
|
|
|
tpl = tpl.replace(
|
|
|
|
str.encode("{{" + s + "}}", "utf8"), str.encode(str.strip(sbox[s]), "utf8")
|
|
|
|
)
|
2017-12-11 18:12:49 -05:00
|
|
|
|
2019-04-22 13:46:27 -04:00
|
|
|
with open(outfile, "wb") as fd:
|
2017-12-11 18:12:49 -05:00
|
|
|
fd.write(tpl)
|
|
|
|
|
2019-04-22 13:46:27 -04:00
|
|
|
|
|
|
|
sbox = {
|
|
|
|
"tlv1": tlv1,
|
|
|
|
"tlv2": tlv2,
|
|
|
|
"tlf1": tlf1,
|
|
|
|
"tlf2": tlf2,
|
|
|
|
"v1": v1,
|
|
|
|
"v2": v2,
|
|
|
|
"f1": f1,
|
|
|
|
"f2": f2,
|
|
|
|
"fd": fd,
|
|
|
|
}
|
2017-12-11 18:12:49 -05:00
|
|
|
|
|
|
|
sd = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
|
2019-04-22 13:46:27 -04:00
|
|
|
apply_template(
|
2023-09-11 07:20:01 -04:00
|
|
|
sd + "/tl_libsodium.vcxproj.filters.tpl",
|
|
|
|
"ci/appveyor/libsodium.vcxproj.filters",
|
|
|
|
sbox,
|
2019-04-22 13:46:27 -04:00
|
|
|
)
|
2017-12-11 18:12:49 -05:00
|
|
|
|
2019-04-03 10:04:39 -04:00
|
|
|
sbox.update({"platform": "v140"})
|
2023-09-10 18:30:40 -04:00
|
|
|
sbox.update({"configurations": get_project_configurations(140)})
|
2023-09-11 07:20:01 -04:00
|
|
|
apply_template(sd + "/tl_libsodium.vcxproj.tpl", "ci/appveyor/libsodium.vcxproj", sbox)
|
2019-04-22 13:46:27 -04:00
|
|
|
|
2021-11-08 16:14:11 -05:00
|
|
|
apply_template(
|
|
|
|
sd + "/libsodium.vcxproj.filters.tpl",
|
|
|
|
"builds/msvc/vs2022/libsodium/libsodium.vcxproj.filters",
|
|
|
|
sbox,
|
|
|
|
)
|
2019-04-22 13:46:27 -04:00
|
|
|
apply_template(
|
|
|
|
sd + "/libsodium.vcxproj.filters.tpl",
|
|
|
|
"builds/msvc/vs2019/libsodium/libsodium.vcxproj.filters",
|
|
|
|
sbox,
|
|
|
|
)
|
|
|
|
apply_template(
|
|
|
|
sd + "/libsodium.vcxproj.filters.tpl",
|
|
|
|
"builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters",
|
|
|
|
sbox,
|
|
|
|
)
|
|
|
|
apply_template(
|
|
|
|
sd + "/libsodium.vcxproj.filters.tpl",
|
|
|
|
"builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters",
|
|
|
|
sbox,
|
|
|
|
)
|
|
|
|
apply_template(
|
|
|
|
sd + "/libsodium.vcxproj.filters.tpl",
|
|
|
|
"builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters",
|
|
|
|
sbox,
|
|
|
|
)
|
|
|
|
apply_template(
|
|
|
|
sd + "/libsodium.vcxproj.filters.tpl",
|
|
|
|
"builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters",
|
|
|
|
sbox,
|
|
|
|
)
|
|
|
|
apply_template(
|
|
|
|
sd + "/libsodium.vcxproj.filters.tpl",
|
|
|
|
"builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters",
|
|
|
|
sbox,
|
|
|
|
)
|
2017-12-11 18:12:49 -05:00
|
|
|
|
2021-11-08 16:14:11 -05:00
|
|
|
sbox.update({"platform": "v143"})
|
2023-09-10 18:30:40 -04:00
|
|
|
sbox.update({"configurations": get_project_configurations(143)})
|
2021-11-08 16:14:11 -05:00
|
|
|
apply_template(
|
|
|
|
sd + "/libsodium.vcxproj.tpl",
|
|
|
|
"builds/msvc/vs2022/libsodium/libsodium.vcxproj",
|
|
|
|
sbox,
|
|
|
|
)
|
|
|
|
|
2019-04-03 08:46:20 -04:00
|
|
|
sbox.update({"platform": "v142"})
|
2023-09-10 18:30:40 -04:00
|
|
|
sbox.update({"configurations": get_project_configurations(142)})
|
2019-04-22 13:46:27 -04:00
|
|
|
apply_template(
|
|
|
|
sd + "/libsodium.vcxproj.tpl",
|
|
|
|
"builds/msvc/vs2019/libsodium/libsodium.vcxproj",
|
|
|
|
sbox,
|
|
|
|
)
|
2019-04-03 08:46:20 -04:00
|
|
|
|
2017-12-11 18:12:49 -05:00
|
|
|
sbox.update({"platform": "v141"})
|
2023-09-10 18:30:40 -04:00
|
|
|
sbox.update({"configurations": get_project_configurations(141)})
|
2019-04-22 13:46:27 -04:00
|
|
|
apply_template(
|
|
|
|
sd + "/libsodium.vcxproj.tpl",
|
|
|
|
"builds/msvc/vs2017/libsodium/libsodium.vcxproj",
|
|
|
|
sbox,
|
|
|
|
)
|
2017-12-11 18:12:49 -05:00
|
|
|
|
|
|
|
sbox.update({"platform": "v140"})
|
2023-09-10 18:30:40 -04:00
|
|
|
sbox.update({"configurations": get_project_configurations(140)})
|
2019-04-22 13:46:27 -04:00
|
|
|
apply_template(
|
|
|
|
sd + "/libsodium.vcxproj.tpl",
|
|
|
|
"builds/msvc/vs2015/libsodium/libsodium.vcxproj",
|
|
|
|
sbox,
|
|
|
|
)
|
2017-12-11 18:12:49 -05:00
|
|
|
|
|
|
|
sbox.update({"platform": "v120"})
|
2023-09-10 18:30:40 -04:00
|
|
|
sbox.update({"configurations": get_project_configurations(120)})
|
2019-04-22 13:46:27 -04:00
|
|
|
apply_template(
|
|
|
|
sd + "/libsodium.vcxproj.tpl",
|
|
|
|
"builds/msvc/vs2013/libsodium/libsodium.vcxproj",
|
|
|
|
sbox,
|
|
|
|
)
|
2017-12-11 18:12:49 -05:00
|
|
|
|
|
|
|
sbox.update({"platform": "v110"})
|
2023-09-10 18:30:40 -04:00
|
|
|
sbox.update({"configurations": get_project_configurations(110)})
|
2019-04-22 13:46:27 -04:00
|
|
|
apply_template(
|
|
|
|
sd + "/libsodium.vcxproj.tpl",
|
|
|
|
"builds/msvc/vs2012/libsodium/libsodium.vcxproj",
|
|
|
|
sbox,
|
|
|
|
)
|
2017-12-11 18:12:49 -05:00
|
|
|
|
|
|
|
sbox.update({"platform": "v100"})
|
2023-09-10 18:30:40 -04:00
|
|
|
sbox.update({"configurations": get_project_configurations(100)})
|
2019-04-22 13:46:27 -04:00
|
|
|
apply_template(
|
|
|
|
sd + "/libsodium.vcxproj.tpl",
|
|
|
|
"builds/msvc/vs2010/libsodium/libsodium.vcxproj",
|
|
|
|
sbox,
|
|
|
|
)
|