Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ __pycache__/
*.egg-info
build/
dist/
.python-version
3 changes: 3 additions & 0 deletions makelove/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"love_binaries": val.Path(),
"shared_libraries": val.List(val.Path()),
"artifacts": val.ValueOrList(val.Choice("directory", "archive")),
"archive_files": val.Dict(val.Path(), val.Path()),
}
),
"linux": val.Section(
Expand All @@ -87,13 +88,15 @@
"source_appimage": val.Path(),
"shared_libraries": val.List(val.Path()),
"artifacts": val.ValueOrList(val.Choice("appdir", "appimage")),
"archive_files": val.Dict(val.Path(), val.Path()),
}
),
"macos": val.Section(
{
"love_binaries": val.Path(),
"icon_file": val.Path(),
"app_metadata": val.Dict(val.String(), val.String()),
"artifacts": val.ValueOrList(val.Choice("directory", "archive")),
"archive_files": val.Dict(val.Path(), val.Path()),
}
),
Expand Down
11 changes: 11 additions & 0 deletions makelove/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,14 @@ def execute_hook(command, config, version, targets, build_directory):
new_config = get_config(tmp_config_path)
os.remove(tmp_config_path)
return new_config

def execute_target_hook(command, target):
env = os.environ.copy()
env.update({
"MAKELOVE_TARGET": target,
})

try:
subprocess.run(command, shell=True, check=True, env=env)
except Exception as e:
sys.exit("Build target hook '{}' failed: {}".format(command, e))
30 changes: 30 additions & 0 deletions makelove/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from .util import fuse_files, tmpfile, parse_love_version, ask_yes_no
from .config import all_love_versions, should_build_artifact
from .hooks import execute_target_hook


def get_appimagetool_path():
Expand Down Expand Up @@ -143,6 +144,8 @@ def build_linux(config, version, target, target_directory, love_file_path):

appdir_path = os.path.join(target_directory, "squashfs-root")
appdir = lambda x: os.path.join(appdir_path, x)
appdirbin_path = os.path.join(appdir_path, "bin")
appdirbin = lambda x: os.path.join(appdirbin_path, x)

game_name = config["name"]
if " " in game_name:
Expand Down Expand Up @@ -174,6 +177,12 @@ def build_linux(config, version, target, target_directory, love_file_path):
fuse_files(fused_exe_path, appdir("bin/love"), love_file_path)
os.chmod(fused_exe_path, 0o755)
os.remove(appdir("bin/love"))

# rename back to bin/love so love.sh can pick it up
parsed_version = parse_love_version(config["love_version"])
if (parsed_version[0], parsed_version[1]) >= (11, 4):
os.rename(fused_exe_path, appdir("bin/love"))

desktop_exec = f"{game_name} %f"
else:
sys.exit(
Expand Down Expand Up @@ -226,6 +235,24 @@ def build_linux(config, version, target, target_directory, love_file_path):
for k, v in desktop_file_fields.items():
f.write("{}={}\n".format(k, v))

# archive files
archive_files = {}
if "archive_files" in config:
archive_files.update(config["archive_files"])
if target in config and "archive_files" in config[target]:
archive_files.update(config[target]["archive_files"])

for k, v in archive_files.items():
path = appdirbin(v)
os.makedirs(os.path.dirname(path), exist_ok=True)
if os.path.isfile(k):
shutil.copyfile(k, path)
elif os.path.isdir(k):
shutil.copytree(k, path)
else:
sys.exit("Cannot copy archive file '{}'".format(k))


# Shared libraries
if target in config and "shared_libraries" in config[target]:
if os.path.isfile(appdir("usr/lib/liblove.so")):
Expand All @@ -234,6 +261,9 @@ def build_linux(config, version, target, target_directory, love_file_path):
elif os.path.isfile(appdir("lib/liblove.so")):
# Official AppImages (since 11.4)
so_target_dir = appdir("lib/")
elif os.path.isfile(appdir("lib/liblove-{}.so".format(config["love_version"]))):
# Support for >= 11.5
so_target_dir = appdir("lib/")
else:
sys.exit(
"Could not find liblove.so in AppDir. The AppImage has an unknown format."
Expand Down
9 changes: 9 additions & 0 deletions makelove/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from PIL import Image

from .util import eprint, get_default_love_binary_dir, get_download_url
from .hooks import execute_target_hook


def download_love(version, platform):
Expand Down Expand Up @@ -243,3 +244,11 @@ def build_macos(config, version, target, target_directory, love_file_path):

loveZipKey = f"{config['name']}.app/Contents/Resources/{config['name']}.love"
app_zip.writestr(loveZipKey, love_zip.read())

# default behavior is to create an archive
if target in config and "artifacts" in config[target] and "directory" in config[target]["artifacts"]:
unzip_dst = os.path.join(target_directory, f"{config['name']}-{target}")
with ZipFile(dst, "r") as zip_ref:
zip_ref.extractall(unzip_dst)
os.remove(dst)

4 changes: 4 additions & 0 deletions makelove/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from .util import get_default_love_binary_dir, get_download_url, tmpfile, eprint
from .config import should_build_artifact
from .hooks import execute_target_hook


def common_prefix(l):
Expand Down Expand Up @@ -233,6 +234,9 @@ def build_windows(config, version, target, target_directory, love_file_path):
archive_files.update(config["archive_files"])
if "windows" in config and "archive_files" in config["windows"]:
archive_files.update(config["windows"]["archive_files"])
# also add win32/win64 files
if target in config and "archive_files" in config[target]:
archive_files.update(config[target]["archive_files"])

for k, v in archive_files.items():
path = dest(v)
Expand Down