Skip to content

Commit

Permalink
Improve single&multi platform release
Browse files Browse the repository at this point in the history
  • Loading branch information
touilleMan committed May 1, 2018
1 parent 8b82622 commit a59de85
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 26 deletions.
21 changes: 15 additions & 6 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import print_function
import os, shutil
import re
import os
import shutil
from datetime import datetime
from functools import partial
from SCons.Errors import UserError
Expand Down Expand Up @@ -119,6 +121,9 @@ if env["gdnative_include_dir"]:
if env["gdnative_wrapper_lib"]:
env["gdnative_wrapper_lib"] = File(env["gdnative_wrapper_lib"])

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


### Plaform-specific stuff ###

Expand Down Expand Up @@ -234,11 +239,15 @@ def extract_version():


def generate_build_dir_hook(path):
shutil.copy(
"misc/single_build_pythonscript.gdnlib",
os.path.join(path, "pythonscript.gdnlib"),
)
with open("misc/single_build_pythonscript.gdnlib") as fd:
gdnlib = fd.read().replace(env['build_name'], '')
# Single platform vs multi-platform one have not the same layout
gdnlib = re.sub(r'(res://pythonscript/)(x11|windows|osx)-(64|32)-(cpython|pypy)/', r'\1', gdnlib)
with open(os.path.join(path, "pythonscript.gdnlib"), "w") as fd:
fd.write(gdnlib)

shutil.copy("misc/release_LICENSE.txt", os.path.join(path, "LICENSE.txt"))

with open("misc/release_README.txt") as fd:
readme = fd.read().format(
version=extract_version(), date=datetime.utcnow().strftime("%Y-%m-%d")
Expand Down Expand Up @@ -338,7 +347,7 @@ env.AlwaysBuild("example")
def generate_release(target, source, env):
base_name, format = target[0].abspath.rsplit(".", 1)
shutil.make_archive(
base_name, format, base_dir="pythonscript", root_dir=source[0].abspath
base_name, format, root_dir=source[0].abspath
)


Expand Down
1 change: 0 additions & 1 deletion platforms/osx-64/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Import("env")


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

Expand Down
1 change: 0 additions & 1 deletion platforms/windows-32/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Import("env")


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


### Godot binary (to run tests) ###
Expand Down
1 change: 0 additions & 1 deletion platforms/windows-64/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Import("env")


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


### Godot binary (to run tests) ###
Expand Down
1 change: 0 additions & 1 deletion platforms/x11-32/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Import("env")


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

Expand Down
1 change: 0 additions & 1 deletion platforms/x11-64/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Import("env")


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

Expand Down
28 changes: 13 additions & 15 deletions tools/multi_platform_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import argparse
import datetime
import os
import shutil
from urllib.request import urlretrieve
Expand All @@ -21,7 +22,6 @@
"cpython": ["osx-64", "windows-32", "windows-64", "x11-64"],
"pypy": ["osx-64", "windows-32", "x11-64"],
}
DEFAULT_PLATFORMS = ["osx-64", "windows-32", "windows-64", "x11-64"]


def fetch_build(src, version, target):
Expand Down Expand Up @@ -50,12 +50,6 @@ def extract_build(target, zipobj, dst):
return zipobj


def extract_bonuses(zipobj, dst):
zipobj.extract("README.txt", dst)
zipobj.extract("LICENSE.txt", dst)
return zipobj


def pipeline_executor(target, version, src, dst):

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

if extract_bonuses:
print("add bonuses...")
shutil.copy(
"%s/../misc/release_pythonscript.gdnlib" % BASEDIR,
"%s/pythonscript.gdnlib" % dst,
print("add bonuses...")
shutil.copy(
"%s/../misc/release_pythonscript.gdnlib" % BASEDIR,
"%s/pythonscript.gdnlib" % dst,
)
shutil.copy("%s/../misc/release_LICENSE.txt" % BASEDIR, "%s/LICENSE.txt" % dst)
with open("%s/../misc/release_README.txt" % BASEDIR) as fd:
readme = fd.read().format(
version=version, date=datetime.utcnow().strftime("%Y-%m-%d")
)
shutil.copy("%s/../misc/release_LICENSE.txt" % BASEDIR, "%s/LICENSE.txt" % dst)
shutil.copy("%s/../misc/release_README.txt" % BASEDIR, "%s/README.txt" % dst)
with open("%s/README.txt" % dst, 'w') as fd:
fd.write(readme)

if buildzip:
print("zipping result...")
Expand All @@ -105,7 +103,7 @@ def main():
try:
shutil.os.mkdir(dst)
shutil.os.mkdir("%s/pythonscript" % dst)
except:
except Exception:
pass
platforms = args.platforms or DEFAULT_PLATFORMS_PER_BACKEND[args.backend]
targets = ["%s-%s" % (p, args.backend) for p in platforms]
Expand Down

0 comments on commit a59de85

Please sign in to comment.