2017-05-26 04:48:44 +08:00
|
|
|
#!/usr/bin/python
|
|
|
|
#
|
|
|
|
# csprojtom4.py
|
|
|
|
#
|
|
|
|
# This source file is part of the FoundationDB open source project
|
|
|
|
#
|
|
|
|
# Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
2018-02-22 02:25:11 +08:00
|
|
|
#
|
2017-05-26 04:48:44 +08:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
2018-02-22 02:25:11 +08:00
|
|
|
#
|
2017-05-26 04:48:44 +08:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2018-02-22 02:25:11 +08:00
|
|
|
#
|
2017-05-26 04:48:44 +08:00
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
|
2018-06-21 04:44:24 +08:00
|
|
|
from __future__ import print_function
|
2017-05-26 04:48:44 +08:00
|
|
|
import sys
|
|
|
|
|
|
|
|
if len(sys.argv) != 2:
|
2018-06-21 04:44:24 +08:00
|
|
|
print( """Usage:
|
|
|
|
%s [input]""" % sys.argv[0] )
|
2018-01-25 11:06:58 +08:00
|
|
|
sys.exit()
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
csproj = sys.argv[1]
|
|
|
|
|
|
|
|
from xml.dom.minidom import parse
|
|
|
|
|
|
|
|
try:
|
2018-01-25 11:06:58 +08:00
|
|
|
dom = parse(csproj)
|
2017-05-26 04:48:44 +08:00
|
|
|
except:
|
2018-06-21 04:44:24 +08:00
|
|
|
print( "ERROR: Unable to open CSProj file %s" % csproj )
|
2018-01-25 11:06:58 +08:00
|
|
|
sys.exit()
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
outputType = dom.getElementsByTagName("OutputType")[0].childNodes[0].data
|
|
|
|
assemblyName = dom.getElementsByTagName("AssemblyName")[0].childNodes[0].data
|
|
|
|
|
|
|
|
if outputType == "Exe":
|
2018-06-21 04:44:24 +08:00
|
|
|
print( "define(`GENTARGET', `bin/%s.exe')dnl" % assemblyName )
|
|
|
|
print( "define(`GENOUTPUTTYPE', `exe')dnl" )
|
2017-05-26 04:48:44 +08:00
|
|
|
elif outputType == "Library":
|
2018-06-21 04:44:24 +08:00
|
|
|
print( "define(`GENTARGET', `bin/%s.dll')dnl" % assemblyName )
|
|
|
|
print( "define(`GENOUTPUTTYPE', `library')dnl" )
|
2017-05-26 04:48:44 +08:00
|
|
|
else:
|
2018-06-21 04:44:24 +08:00
|
|
|
print( "ERROR: Unable to determine output type" )
|
2018-01-25 11:06:58 +08:00
|
|
|
sys.exit()
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2018-01-25 11:06:58 +08:00
|
|
|
sources = [node.getAttribute("Include").replace('\\', '/') for node in
|
|
|
|
dom.getElementsByTagName("Compile")]
|
|
|
|
assemblies = [node.getAttribute("Include") for node in
|
|
|
|
dom.getElementsByTagName("Reference")]
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2018-06-21 04:44:24 +08:00
|
|
|
print( "define(`GENSOURCES', `%s')dnl" % ' '.join(sources) )
|
|
|
|
print( "define(`GENREFERENCES', `%s')dnl" % ','.join(assemblies) )
|