forked from simul/Platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetup.py
More file actions
68 lines (59 loc) · 2.45 KB
/
Setup.py
File metadata and controls
68 lines (59 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import os
import shlex, subprocess
import sys
import configparser
from pathlib import Path
import os, fnmatch
from git import Repo
def find(pattern, path):
result = []
for root, dirs, files in os.walk(path):
for name in files:
if fnmatch.fnmatch(name, pattern):
result.append(name)
return result
#read a .properties file without section headers.
def add_section_header(properties_file, header_name):
# configparser.ConfigParser requires at least one section header in a properties file.
# Our properties file doesn't have one, so add a header to it on the fly.
yield '[{}]\n'.format(header_name)
for line in properties_file:
yield line
def read_config_file(filename):
config = configparser.RawConfigParser()
if not os.path.isfile(filename):
file = open(filename, "w+", encoding="utf_8")
else:
file = open(filename, encoding="utf_8")
config.read_file(add_section_header(file, 'asection'), source=filename)
return config['asection']
def cmake(src,build_path,flags):
wd=os.getcwd()
Path(build_path).mkdir(True,exist_ok=True)
os.chdir(build_path)
cmakeCmd = ["cmake.exe", '-G','Visual Studio 16 2019', os.path.relpath(src, build_path)]
retCode = subprocess.check_call(cmakeCmd+flags, stderr=subprocess.STDOUT, shell=True)
sln=find('*.sln','.')[0]
#print(MSBUILD+'/p:Configuration=Release'+'/p:Platform=x64'+sln)
pid=subprocess.Popen([MSBUILD,'/p:Configuration=Release','/p:Platform=x64',sln])
os.chdir(wd)
def GetMSBuild():
VSW=os.environ['ProgramFiles(x86)']+'/Microsoft Visual Studio/Installer/vswhere.exe'
process = subprocess.Popen([VSW,'-latest','-requires','Microsoft.Component.MSBuild','-find','MSBuild\\**\\Bin\\MSBuild.exe'], stdout=subprocess.PIPE)
MSB = process.stdout.readline().strip()
process.poll()
return MSB
def execute():
repo = Repo(os.getcwd())
sms = repo.submodules
for sm in sms:
sm.update()
glfwflags=["-DGLFW_BUILD_DOCS=false","-DGLFW_BUILD_EXAMPLES=false","-DGLFW_BUILD_TESTS=false","-DGLFW_INSTALL=false","-DCMAKE_C_FLAGS_DEBUG=/MTd /Zi /Ob0 /Od /RTC1","-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG","-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=../lib"]
cmake('External/glfw','External/glfw/build_md',glfwflags)
cmake('External/glfw','External/glfw/build_mt',glfwflags+["-DUSE_MSVC_RUNTIME_LIBRARY_DLL=false"])
platform_flags=[]
cmake('.','build',platform_flags)
version=read_config_file('version.properties')
user=read_config_file('user.properties')
MSBUILD=user.get('MSBUILD',GetMSBuild())
execute()