/tools/ -> /bin/, to have it in more common schema
This commit is contained in:
7
bin/build.sh
Executable file
7
bin/build.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/env sh
|
||||
|
||||
if [ "$1" = "web" ]; then
|
||||
emcmake cmake -B .build-web "${@:2}" && cmake --build .build-web
|
||||
else
|
||||
cmake -B .build "$@" && cmake --build .build
|
||||
fi
|
4
bin/gen_api_header.sh
Executable file
4
bin/gen_api_header.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/env sh
|
||||
# single header api generator with clang
|
||||
|
||||
clang -I./ -P -E -nostdinc -nobuiltininc -DTWN_NOT_C $TWNROOT/include/twn_game_api.h | clang-format
|
51
bin/gitea-lfs-pull.py
Executable file
51
bin/gitea-lfs-pull.py
Executable file
@ -0,0 +1,51 @@
|
||||
#!/bin/env python3
|
||||
# curl based lfs link fetcher, for systems that don't have git-lfs easily available (haiku, for example)
|
||||
|
||||
from subprocess import getoutput
|
||||
from urllib.parse import urlsplit
|
||||
from getpass import getpass
|
||||
from os import walk
|
||||
import random, string, json, mimetypes
|
||||
|
||||
def randomword(length):
|
||||
letters = string.ascii_lowercase
|
||||
return ''.join(random.choice(letters) for i in range(length))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
origin = getoutput(["git remote get-url origin"])
|
||||
print("Origin:", origin)
|
||||
parts = urlsplit(origin)
|
||||
location = parts.netloc
|
||||
|
||||
name = input("Username: ")
|
||||
passw = getpass("Password: ")
|
||||
|
||||
query_data = '{"name": "%s"}' % (randomword(6),)
|
||||
query = f"curl -s -H 'Content-Type: application/json' -d '{query_data}' -u '{name}:{passw}' https://{location}/api/v1/users/{name}/tokens"
|
||||
token_response = getoutput(query)
|
||||
token = json.loads(token_response)["sha1"]
|
||||
|
||||
for root, dirs, files in walk("."):
|
||||
for file in files:
|
||||
path = root + '/' + file
|
||||
with open(path, 'r') as f:
|
||||
file_result = getoutput(f"file -b {path}")
|
||||
if file_result != "ASCII text":
|
||||
continue
|
||||
header = f.readline()
|
||||
if header != "version https://git-lfs.github.com/spec/v1\n":
|
||||
continue
|
||||
sha = f.readline().split(':')[1].strip()
|
||||
size = f.readline().split(' ')[1].strip()
|
||||
|
||||
query_data = '{"operation": "download", "transfer": ["basic"], "objects": [{"oid": "%s", "size": %s}]}' % (sha, size)
|
||||
query = f"curl -s -X POST -H 'Authorization: token {token}' -H 'Accept: application/vnd.git-lfs+json' -H 'Content-type: application/json' -d '{query_data}' {origin}.git/info/lfs/objects/batch"
|
||||
response = getoutput(query)
|
||||
|
||||
href = json.loads(response)["objects"][0]["actions"]["download"]["href"]
|
||||
query = f"curl -s -X GET -H 'Authorization: token {token}' {href} > {path}"
|
||||
response = getoutput(query)
|
||||
|
||||
print("Processed", path)
|
||||
|
33
bin/package_data.py
Normal file
33
bin/package_data.py
Normal file
@ -0,0 +1,33 @@
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import argparse
|
||||
import pathlib
|
||||
|
||||
# cli arguments
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='package_data',
|
||||
description='Creates a data package for the engine.',
|
||||
epilog='Note that the engine will, by default, only read .btw packages.')
|
||||
parser.add_argument('-d', '--datadir',
|
||||
default='./data',
|
||||
type=pathlib.Path,
|
||||
help='directory containing the source data')
|
||||
parser.add_argument('-o', '--outdir',
|
||||
default='./',
|
||||
type=pathlib.Path,
|
||||
help='target directory of the resulting package file')
|
||||
parser.add_argument('-n', '--name',
|
||||
default='data',
|
||||
help='name to be used for the package file')
|
||||
parser.add_argument('-e', '--extension',
|
||||
default='btw',
|
||||
help='extension to be used for the package file')
|
||||
args = parser.parse_args()
|
||||
|
||||
shutil.make_archive(f"{args.outdir}/{args.name}", 'zip', args.datadir)
|
||||
shutil.move(f"{args.outdir}/{args.name}.zip",
|
||||
f"{args.outdir}/{args.name}.{args.extension.removeprefix('.')}")
|
||||
|
||||
print('All done!')
|
||||
input('Press Return to exit...')
|
Reference in New Issue
Block a user