Skip to content

Commit a59de85

Browse files
committed
Improve single&multi platform release
1 parent 8b82622 commit a59de85

File tree

7 files changed

+28
-26
lines changed

7 files changed

+28
-26
lines changed

SConstruct

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import print_function
2-
import os, shutil
2+
import re
3+
import os
4+
import shutil
35
from datetime import datetime
46
from functools import partial
57
from SCons.Errors import UserError
@@ -119,6 +121,9 @@ if env["gdnative_include_dir"]:
119121
if env["gdnative_wrapper_lib"]:
120122
env["gdnative_wrapper_lib"] = File(env["gdnative_wrapper_lib"])
121123

124+
env["build_name"] = '%s-%s' % (env['platform'], env["backend"])
125+
env["build_dir"] = Dir("#build/%s" % env["build_name"])
126+
122127

123128
### Plaform-specific stuff ###
124129

@@ -234,11 +239,15 @@ def extract_version():
234239

235240

236241
def generate_build_dir_hook(path):
237-
shutil.copy(
238-
"misc/single_build_pythonscript.gdnlib",
239-
os.path.join(path, "pythonscript.gdnlib"),
240-
)
242+
with open("misc/single_build_pythonscript.gdnlib") as fd:
243+
gdnlib = fd.read().replace(env['build_name'], '')
244+
# Single platform vs multi-platform one have not the same layout
245+
gdnlib = re.sub(r'(res://pythonscript/)(x11|windows|osx)-(64|32)-(cpython|pypy)/', r'\1', gdnlib)
246+
with open(os.path.join(path, "pythonscript.gdnlib"), "w") as fd:
247+
fd.write(gdnlib)
248+
241249
shutil.copy("misc/release_LICENSE.txt", os.path.join(path, "LICENSE.txt"))
250+
242251
with open("misc/release_README.txt") as fd:
243252
readme = fd.read().format(
244253
version=extract_version(), date=datetime.utcnow().strftime("%Y-%m-%d")
@@ -338,7 +347,7 @@ env.AlwaysBuild("example")
338347
def generate_release(target, source, env):
339348
base_name, format = target[0].abspath.rsplit(".", 1)
340349
shutil.make_archive(
341-
base_name, format, base_dir="pythonscript", root_dir=source[0].abspath
350+
base_name, format, root_dir=source[0].abspath
342351
)
343352

344353

platforms/osx-64/SCsub

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Import("env")
77

88

99
env["bits"] = "64"
10-
env["build_dir"] = Dir("#build/osx-64-%s" % env["backend"])
1110
env.Append(CFLAGS="-m64")
1211
env.Append(LINKFLAGS="-m64")
1312

platforms/windows-32/SCsub

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Import("env")
1212

1313

1414
env["bits"] = "32"
15-
env["build_dir"] = Dir("#build/windows-32-%s" % env["backend"])
1615

1716

1817
### Godot binary (to run tests) ###

platforms/windows-64/SCsub

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Import("env")
1212

1313

1414
env["bits"] = "64"
15-
env["build_dir"] = Dir("#build/windows-64-%s" % env["backend"])
1615

1716

1817
### Godot binary (to run tests) ###

platforms/x11-32/SCsub

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Import("env")
77

88

99
env["bits"] = "32"
10-
env["build_dir"] = Dir("#build/x11-32-%s" % env["backend"])
1110
env.Append(CFLAGS="-m32")
1211
env.Append(LINKFLAGS="-m32")
1312

platforms/x11-64/SCsub

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Import("env")
77

88

99
env["bits"] = "64"
10-
env["build_dir"] = Dir("#build/x11-64-%s" % env["backend"])
1110
env.Append(CFLAGS="-m64")
1211
env.Append(LINKFLAGS="-m64")
1312

tools/multi_platform_release.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"""
88

99
import argparse
10+
import datetime
1011
import os
1112
import shutil
1213
from urllib.request import urlretrieve
@@ -21,7 +22,6 @@
2122
"cpython": ["osx-64", "windows-32", "windows-64", "x11-64"],
2223
"pypy": ["osx-64", "windows-32", "x11-64"],
2324
}
24-
DEFAULT_PLATFORMS = ["osx-64", "windows-32", "windows-64", "x11-64"]
2525

2626

2727
def fetch_build(src, version, target):
@@ -50,12 +50,6 @@ def extract_build(target, zipobj, dst):
5050
return zipobj
5151

5252

53-
def extract_bonuses(zipobj, dst):
54-
zipobj.extract("README.txt", dst)
55-
zipobj.extract("LICENSE.txt", dst)
56-
return zipobj
57-
58-
5953
def pipeline_executor(target, version, src, dst):
6054

6155
print("%s - fetch build..." % target)
@@ -76,14 +70,18 @@ def orchestrator(targets, version, src, dst, buildzip):
7670
if not future.cancelled():
7771
future.result() # Raise exception if any
7872

79-
if extract_bonuses:
80-
print("add bonuses...")
81-
shutil.copy(
82-
"%s/../misc/release_pythonscript.gdnlib" % BASEDIR,
83-
"%s/pythonscript.gdnlib" % dst,
73+
print("add bonuses...")
74+
shutil.copy(
75+
"%s/../misc/release_pythonscript.gdnlib" % BASEDIR,
76+
"%s/pythonscript.gdnlib" % dst,
77+
)
78+
shutil.copy("%s/../misc/release_LICENSE.txt" % BASEDIR, "%s/LICENSE.txt" % dst)
79+
with open("%s/../misc/release_README.txt" % BASEDIR) as fd:
80+
readme = fd.read().format(
81+
version=version, date=datetime.utcnow().strftime("%Y-%m-%d")
8482
)
85-
shutil.copy("%s/../misc/release_LICENSE.txt" % BASEDIR, "%s/LICENSE.txt" % dst)
86-
shutil.copy("%s/../misc/release_README.txt" % BASEDIR, "%s/README.txt" % dst)
83+
with open("%s/README.txt" % dst, 'w') as fd:
84+
fd.write(readme)
8785

8886
if buildzip:
8987
print("zipping result...")
@@ -105,7 +103,7 @@ def main():
105103
try:
106104
shutil.os.mkdir(dst)
107105
shutil.os.mkdir("%s/pythonscript" % dst)
108-
except:
106+
except Exception:
109107
pass
110108
platforms = args.platforms or DEFAULT_PLATFORMS_PER_BACKEND[args.backend]
111109
targets = ["%s-%s" % (p, args.backend) for p in platforms]

0 commit comments

Comments
 (0)