Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
Copy the prototype to the project, if needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
renpytom committed Aug 25, 2018
1 parent b95802e commit 1641239
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
43 changes: 43 additions & 0 deletions buildlib/rapt/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,45 @@ def split_renpy(directory):
]


def copy_project(update_always=False):
"""
This updates the project, if necessary.
"""

def snarf(fn):
fn = plat.path(fn)

if os.path.exists(fn):
return open(fn, "r").read().strip()
else:
return None

project = plat.path("project")
prototype = plat.path("prototype")

update = False

if not os.path.exists(project):
update = True
elif update_always:
if snarf("project/build.txt") != snarf("prototype/build.txt"):
update = True

if not update:
return

lp = snarf("project/local.properties")

if os.path.exists(project):
shutil.rmtree(project)

shutil.copytree(prototype, project)

if lp is not None:
with open(plat.path("project/local.properties"), "w") as f:
f.write(lp + "\n")


def build(iface, directory, commands, launch=False, finished=None):

# Are we doing a Ren'Py build?
Expand Down Expand Up @@ -401,6 +440,10 @@ def build(iface, directory, commands, launch=False, finished=None):
if config.store not in [ "play", "none" ]:
config.expansion = False

iface.info(__("Updating project."))

copy_project(config.update_always)

iface.info(__("Creating assets directory."))

assets = plat.path("project/app/src/main/assets")
Expand Down
7 changes: 7 additions & 0 deletions buildlib/rapt/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self, directory):
self.google_play_salt = None
self.store = "none"
self.update_icons = True
self.update_always = True

try:
with file(os.path.join(directory, ".android.json"), "r") as f:
Expand Down Expand Up @@ -185,6 +186,12 @@ def configure(interface, directory, default_name=None, default_version=None):

config.permissions = permissions

config.update_always = interface.choice(
__("Do you want to automatically update the generated project?"), [
(True, __("Yes. This is the best choice for most projects.")),
(False, __("No. This may require manual updates when Ren'Py or the project configuration changes."))
], config.update_always)

config.save(directory)


Expand Down
5 changes: 5 additions & 0 deletions buildlib/rapt/install_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ def generate_keys(interface):


def install_sdk(interface):

# Create the project directory.
import rapt.build
rapt.build.copy_project(False)

check_java(interface)

unpack_sdk(interface)
Expand Down
1 change: 1 addition & 0 deletions test_renpy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cd "$ROOT"
"$ROOT/build_renpy.sh"

ln -s "$ROOT/Sdk" "$ROOT/dist/Sdk"
mkdir "$ROOT/dist/project"
cp -a local.properties "$ROOT/dist/project"

cd "$ROOT/dist"
Expand Down

0 comments on commit 1641239

Please sign in to comment.