latest cloudtool work

This commit is contained in:
Eric Froemling 2020-01-08 17:16:01 -08:00
parent 83f60675f4
commit 59b48f03c6
3 changed files with 72 additions and 22 deletions

View File

@ -58,6 +58,8 @@
<w>apichanges</w> <w>apichanges</w>
<w>apis</w> <w>apis</w>
<w>apks</w> <w>apks</w>
<w>appath</w>
<w>appathout</w>
<w>appcfg</w> <w>appcfg</w>
<w>appconfig</w> <w>appconfig</w>
<w>appdelegate</w> <w>appdelegate</w>
@ -109,6 +111,7 @@
<w>autodesk</w> <w>autodesk</w>
<w>autogenerate</w> <w>autogenerate</w>
<w>autonoassets</w> <w>autonoassets</w>
<w>autopoint</w>
<w>autoremove</w> <w>autoremove</w>
<w>autoretain</w> <w>autoretain</w>
<w>autoselect</w> <w>autoselect</w>
@ -193,6 +196,7 @@
<w>buttondown</w> <w>buttondown</w>
<w>buttonwidget</w> <w>buttonwidget</w>
<w>bval</w> <w>bval</w>
<w>bytecount</w>
<w>byteswap</w> <w>byteswap</w>
<w>cachable</w> <w>cachable</w>
<w>cachebasename</w> <w>cachebasename</w>
@ -647,6 +651,7 @@
<w>gametype</w> <w>gametype</w>
<w>gametypes</w> <w>gametypes</w>
<w>gameutils</w> <w>gameutils</w>
<w>gbytecount</w>
<w>gearvr</w> <w>gearvr</w>
<w>gendocs</w> <w>gendocs</w>
<w>gendummymodule</w> <w>gendummymodule</w>
@ -660,6 +665,7 @@
<w>getconf</w> <w>getconf</w>
<w>getconfig</w> <w>getconfig</w>
<w>getcurrency</w> <w>getcurrency</w>
<w>getcwd</w>
<w>getdata</w> <w>getdata</w>
<w>getlevelname</w> <w>getlevelname</w>
<w>getmaps</w> <w>getmaps</w>
@ -832,6 +838,7 @@
<w>jsonstrbase</w> <w>jsonstrbase</w>
<w>jsontools</w> <w>jsontools</w>
<w>jsonutils</w> <w>jsonutils</w>
<w>kbytecount</w>
<w>keepaway</w> <w>keepaway</w>
<w>keeprefs</w> <w>keeprefs</w>
<w>keylayout</w> <w>keylayout</w>
@ -964,6 +971,7 @@
<w>maxval</w> <w>maxval</w>
<w>maxw</w> <w>maxw</w>
<w>maxwidth</w> <w>maxwidth</w>
<w>mbytecount</w>
<w>mdiv</w> <w>mdiv</w>
<w>mdocs</w> <w>mdocs</w>
<w>mdocslines</w> <w>mdocslines</w>

View File

@ -94,6 +94,14 @@ class AssetType(Enum):
"""Types for asset files.""" """Types for asset files."""
TEXTURE = 'texture' TEXTURE = 'texture'
SOUND = 'sound' SOUND = 'sound'
DATA = 'data'
ASSET_SOURCE_FILE_EXTS = {
AssetType.TEXTURE: 'png',
AssetType.SOUND: 'wav',
AssetType.DATA: 'yaml',
}
class Asset: class Asset:
@ -103,8 +111,8 @@ class Asset:
path: str) -> None: path: str) -> None:
self.assettype = assettype self.assettype = assettype
self.path = path self.path = path
exts = {AssetType.TEXTURE: '.png', AssetType.SOUND: '.wav'} self.filepath = os.path.join(
self.filepath = os.path.join(package.path, path + exts[assettype]) package.path, path + '.' + ASSET_SOURCE_FILE_EXTS[assettype])
def get_tz_offset_seconds() -> float: def get_tz_offset_seconds() -> float:
@ -158,6 +166,7 @@ class AssetPackage:
self.assets: Dict[str, Asset] = {} self.assets: Dict[str, Asset] = {}
self.path = Path('') self.path = Path('')
self.name = 'untitled' self.name = 'untitled'
self.index = ''
@classmethod @classmethod
def load_from_disk(cls, path: Path) -> AssetPackage: def load_from_disk(cls, path: Path) -> AssetPackage:
@ -170,14 +179,20 @@ class AssetPackage:
package.path = path package.path = path
with open(Path(path, indexfilename)) as infile: with open(Path(path, indexfilename)) as infile:
index = yaml.safe_load(infile) package.index = infile.read()
index = yaml.safe_load(package.index)
if not isinstance(index, dict): if not isinstance(index, dict):
raise CleanError(f'Root dict not found in {indexfilename}') raise CleanError(f'Root dict not found in {indexfilename}')
# Pull our name from the index file.
# (NOTE: can probably just let the server do this)
name = index.get('name') name = index.get('name')
if not isinstance(name, str): if not isinstance(name, str):
raise CleanError(f'No "name" str found in {indexfilename}') raise CleanError(f'No "name" str found in {indexfilename}')
validate_asset_package_name(name) validate_asset_package_name(name)
package.name = name package.name = name
# Build our list of Asset objs from the index.
assets = index.get('assets') assets = index.get('assets')
if not isinstance(assets, dict): if not isinstance(assets, dict):
raise CleanError(f'No "assets" dict found in {indexfilename}') raise CleanError(f'No "assets" dict found in {indexfilename}')
@ -191,8 +206,6 @@ class AssetPackage:
raise CleanError( raise CleanError(
f'Invalid asset type for {assetpath} in {indexfilename}') f'Invalid asset type for {assetpath} in {indexfilename}')
assettype = AssetType(assettypestr) assettype = AssetType(assettypestr)
# print('Looking at asset:', assetpath, assetdata)
package.assets[assetpath] = Asset(package, assettype, assetpath) package.assets[assetpath] = Asset(package, assettype, assetpath)
return package return package
@ -203,7 +216,7 @@ class AssetPackage:
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from multiprocessing import cpu_count from multiprocessing import cpu_count
manifest: Dict = {'name': self.name, 'files': {}} manifest: Dict = {'name': self.name, 'files': {}, 'index': self.index}
def _get_asset_info(iasset: Asset) -> Tuple[Asset, Dict]: def _get_asset_info(iasset: Asset) -> Tuple[Asset, Dict]:
sha = hashlib.sha256() sha = hashlib.sha256()
@ -213,7 +226,11 @@ class AssetPackage:
sha.update(filebytes) sha.update(filebytes)
if not os.path.isfile(iasset.filepath): if not os.path.isfile(iasset.filepath):
raise Exception(f'Asset file not found: "{iasset.filepath}"') raise Exception(f'Asset file not found: "{iasset.filepath}"')
info_out: Dict = {'hash': sha.hexdigest(), 'size': filesize} info_out: Dict = {
'hash': sha.hexdigest(),
'size': filesize,
'ext': ASSET_SOURCE_FILE_EXTS[iasset.assettype]
}
return iasset, info_out return iasset, info_out
# Use all procs to hash files for extra speedy goodness. # Use all procs to hash files for extra speedy goodness.
@ -250,8 +267,9 @@ class App:
self._load_cache() self._load_cache()
if len(sys.argv) < 2: if len(sys.argv) < 2:
raise CleanError( print(f'{CLRRED}You must provide one or more arguments.{CLREND}')
f'Invalid args. Run "cloudtool help" for usage info.') self.do_misc_command(['help'])
raise CleanError()
cmd = sys.argv[1] cmd = sys.argv[1]
if cmd == CMD_LOGIN: if cmd == CMD_LOGIN:
@ -263,7 +281,7 @@ class App:
self.do_assetpack_put() self.do_assetpack_put()
else: else:
# For all other commands, simply pass them to the server verbatim. # For all other commands, simply pass them to the server verbatim.
self.do_misc_command() self.do_misc_command(sys.argv[1:])
self._save_cache() self._save_cache()
@ -373,7 +391,6 @@ class App:
_response = self._servercmd('assetpackputfinish', { _response = self._servercmd('assetpackputfinish', {
'packageversion': version, 'packageversion': version,
}) })
# print(f'{CLRGRN}Created asset package: {version}{CLREND}')
def _assetpack_put_upload(self, package: AssetPackage, version: str, def _assetpack_put_upload(self, package: AssetPackage, version: str,
files: List[str]) -> None: files: List[str]) -> None:
@ -383,7 +400,7 @@ class App:
for fnum, fname in enumerate(files): for fnum, fname in enumerate(files):
print( print(
f'{CLRBLU}Uploading file {fnum+1} of {len(files)}: ' f'{CLRBLU}Uploading file {fnum+1} of {len(files)}: '
f'"{fname}"...{CLREND}', f'{fname}{CLREND}',
flush=True) flush=True)
with tempfile.TemporaryDirectory() as tempdir: with tempfile.TemporaryDirectory() as tempdir:
asset = package.assets[fname] asset = package.assets[fname]
@ -403,12 +420,12 @@ class App:
files=putfiles, files=putfiles,
) )
def do_misc_command(self) -> None: def do_misc_command(self, args: List[str]) -> None:
"""Run a miscellaneous command.""" """Run a miscellaneous command."""
# We don't do anything special with the response here; the normal # We don't do anything special with the response here; the normal
# error-handling/message-printing is all that happens. # error-handling/message-printing is all that happens.
self._servercmd('misc', {'a': sys.argv[1:]}) self._servercmd('misc', {'a': args})
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -215,6 +215,20 @@ def build_android(rootdir: str, arch: str, debug: bool = False) -> None:
'"') '"')
os.chdir(builddir) os.chdir(builddir)
# It seems we now need 'autopoint' as part of this build, but on mac it
# is not available on the normal path, but only as part of the keg-only
# gettext homebrew formula.
if (subprocess.run('which autopoint', shell=True, check=False).returncode
!= 0):
print("Updating path for mac autopoint...")
appath = subprocess.run('brew ls gettext | grep bin/autopoint',
shell=True,
check=True,
capture_output=True)
appathout = os.path.dirname(appath.stdout.decode().strip())
os.environ['PATH'] += (':' + appathout)
print(f'ADDED "{appathout}" TO SYS PATH...')
# Commit from Dec 6th, 2018. Looks like right after this one the repo # Commit from Dec 6th, 2018. Looks like right after this one the repo
# switched to ndk r19 beta 2 and now seems to require r19, so we can # switched to ndk r19 beta 2 and now seems to require r19, so we can
# try switching back to master one r19 comes down the pipe. # try switching back to master one r19 comes down the pipe.
@ -265,8 +279,8 @@ def build_android(rootdir: str, arch: str, debug: bool = False) -> None:
"'./configure', '--with-pydebug',") "'./configure', '--with-pydebug',")
# We don't use this stuff so lets strip it out to simplify. # We don't use this stuff so lets strip it out to simplify.
ftxt = efrotools.replace_one(ftxt, "'--with-system-ffi',", "") # ftxt = efrotools.replace_one(ftxt, "'--with-system-ffi',", "")
ftxt = efrotools.replace_one(ftxt, "'--with-system-expat',", "") # ftxt = efrotools.replace_one(ftxt, "'--with-system-expat',", "")
ftxt = efrotools.replace_one(ftxt, "'--without-ensurepip',", "") ftxt = efrotools.replace_one(ftxt, "'--without-ensurepip',", "")
# This builds all modules as dynamic libs, but we want to be consistent # This builds all modules as dynamic libs, but we want to be consistent
@ -274,11 +288,17 @@ def build_android(rootdir: str, arch: str, debug: bool = False) -> None:
# need... so to change that we'll need to add a hook for ourself after # need... so to change that we'll need to add a hook for ourself after
# python is downloaded but before it is built so we can muck with it. # python is downloaded but before it is built so we can muck with it.
ftxt = efrotools.replace_one( ftxt = efrotools.replace_one(
ftxt, ' def prepare(self):', ftxt, ' def build(self):',
' def prepare(self):\n import os\n' ' def build(self):\n import os\n'
' if os.system(\'"' + rootdir + ' if os.system(\'"' + rootdir +
'/tools/snippets" python_android_patch "' + os.getcwd() + '/tools/snippets" python_android_patch "' + os.getcwd() +
'"\') != 0: raise Exception("patch apply failed")') '"\') != 0: raise Exception("patch apply failed")')
# ftxt = efrotools.replace_one(
# ftxt, ' def prepare(self):',
# ' def prepare(self):\n import os\n'
# ' if os.system(\'"' + rootdir +
# '/tools/snippets" python_android_patch "' + os.getcwd() +
# '"\') != 0: raise Exception("patch apply failed")')
efrotools.writefile('pybuild/packages/python.py', ftxt) efrotools.writefile('pybuild/packages/python.py', ftxt)
@ -291,10 +311,15 @@ def build_android(rootdir: str, arch: str, debug: bool = False) -> None:
# Check out a particular commit right after the clone. # Check out a particular commit right after the clone.
ftxt = efrotools.replace_one( ftxt = efrotools.replace_one(
ftxt, ftxt, "'git', 'clone', '--single-branch', '-b',"
"'git', 'clone', '-b', self.branch, self.source_url, self.dest])", " self.branch, self.source_url, self.dest])",
"'git', 'clone', '-b', self.branch, self.source_url, self.dest])\n" "'git', 'clone', '-b',"
" run_in_dir(['git', 'checkout', '" + commit + " self.branch, self.source_url, self.dest])\n"
" # efro: hack to get the python we want.\n"
" print('DOING URL', self.source_url)\n"
" if self.source_url == "
"'https://github.com/python/cpython/':\n"
" run_in_dir(['git', 'checkout', '" + commit +
"'], self.source_dir)") "'], self.source_dir)")
efrotools.writefile('pybuild/source.py', ftxt) efrotools.writefile('pybuild/source.py', ftxt)
ftxt = efrotools.readfile('pybuild/util.py') ftxt = efrotools.readfile('pybuild/util.py')