| 1 |
from distutils.errors import DistutilsPlatformError |
|---|
| 2 |
import sys |
|---|
| 3 |
from dcompiler import _infraDir |
|---|
| 4 |
import os.path |
|---|
| 5 |
|
|---|
| 6 |
def make_pydmain(outputFile, projname): |
|---|
| 7 |
mainTemplatePath = os.path.join(_infraDir, 'd', 'pydmain_template.d') |
|---|
| 8 |
if not os.path.isfile(mainTemplatePath): |
|---|
| 9 |
raise DistutilsPlatformError( |
|---|
| 10 |
"Required supporting code file %s is missing." % mainTemplatePath |
|---|
| 11 |
) |
|---|
| 12 |
mainTemplate = open(mainTemplatePath).read() |
|---|
| 13 |
mainFileContent = mainTemplate % {'modulename' : projname} |
|---|
| 14 |
mainFile = open(outputFile, 'w') |
|---|
| 15 |
mainFile.write(mainFileContent) |
|---|
| 16 |
mainFile.close() |
|---|
| 17 |
|
|---|
| 18 |
def make_pyddef(outputFile, projname): |
|---|
| 19 |
defTemplatePath = os.path.join(_infraDir, 'd', |
|---|
| 20 |
'python_dll_def.def_template' |
|---|
| 21 |
) |
|---|
| 22 |
if not os.path.isfile(defTemplatePath): |
|---|
| 23 |
raise DistutilsFileError('Required def template file "%s" is' |
|---|
| 24 |
' missing.' % defTemplatePath |
|---|
| 25 |
) |
|---|
| 26 |
f = open(defTemplatePath, 'rb') |
|---|
| 27 |
try: |
|---|
| 28 |
defTemplate = f.read() |
|---|
| 29 |
finally: |
|---|
| 30 |
f.close() |
|---|
| 31 |
defFileContent = defTemplate % projname |
|---|
| 32 |
f = file(outputFile, 'wb') |
|---|
| 33 |
try: |
|---|
| 34 |
f.write(defFileContent) |
|---|
| 35 |
finally: |
|---|
| 36 |
f.close() |
|---|
| 37 |
|
|---|
| 38 |
if __name__ == '__main__': |
|---|
| 39 |
make_pydmain(sys.argv[2], sys.argv[1]) |
|---|
| 40 |
make_pyddef(sys.argv[3], sys.argv[1]) |
|---|