more project tidying

This commit is contained in:
Eric Froemling 2019-10-11 16:56:18 -07:00
parent 33b9f8a5ec
commit ce1763f9c0
6 changed files with 91 additions and 3 deletions

View File

@ -1,6 +1,8 @@
<component name="ProjectDictionaryState">
<dictionary name="ericf">
<words>
<w>maxdepth</w>
<w>efrocache</w>
<w>packagedir</w>
<w>priv</w>
<w>aaaa</w>

View File

@ -1,3 +1,24 @@
# Copyright (c) 2011-2019 Eric Froemling
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# ------------------------------------------------------------------------------
# This Makefile encompasses most high level functionality you should need when
# working with Ballistica. These build rules are also handy as reference or a
# starting point if you need specific funtionality beyond that exposed here.
@ -13,6 +34,11 @@ all: help
# Tell make which of these targets don't represent files.
.PHONY: all
# EFROCACHE_TARGET
build/testfile:
mkdir -p $(dir $@)
echo foobar > $@
################################################################################
# #

View File

@ -90,7 +90,7 @@ def set_config(projroot: Path, config: Dict[str, Any]) -> None:
def get_public_license(style: str) -> str:
"""Return the MIT license as used for our public facing stuff.
'style' arg can be 'python', 'c++', or 'raw'.
'style' arg can be 'python', 'c++', or 'makefile, or 'raw'.
"""
raw = MIT_LICENSE
if style == 'raw':
@ -98,6 +98,11 @@ def get_public_license(style: str) -> str:
if style == 'python':
return ('\n'.join('#' + (' ' if l else '') + l
for l in raw.splitlines()) + '\n' + '# ' + '-' * 77)
if style == 'makefile':
# Basically same as python except one char wider
# (Pep8 specifies 79 char lines vs more standard 80)
return ('\n'.join('#' + (' ' if l else '') + l
for l in raw.splitlines()) + '\n' + '# ' + '-' * 78)
if style == 'c++':
return '\n'.join('//' + (' ' if l else '') + l
for l in raw.splitlines())

View File

@ -0,0 +1,23 @@
# Copyright (c) 2011-2019 Eric Froemling
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# -----------------------------------------------------------------------------
"""A simple cloud caching system for making built binaries/assets available."""
from __future__ import annotations

View File

@ -511,7 +511,7 @@ def python_gather() -> None:
def clean_orphaned_assets() -> None:
"""Remove assets that are no longer part of the build."""
"""Remove asset files that are no longer part of the build."""
import json
# Operate from dist root..
@ -523,7 +523,7 @@ def clean_orphaned_assets() -> None:
fpath = os.path.join(root, fname)
fpathrel = fpath[13:] # paths are relative to assets/build
if fpathrel not in manifest:
print(f"Removing orphaned asset: {fpath}")
print(f"Removing orphaned asset file: {fpath}")
os.unlink(fpath)
# Lastly, clear empty dirs.
@ -597,5 +597,15 @@ def capitalize() -> None:
print(' '.join(w.capitalize() for w in sys.argv[2:]))
def efrocache_update() -> None:
"""Build & push files to efrocache for public access."""
print('WOULD UPDATE EFROCACHE')
def efrocache_get() -> None:
"""Get a file from efrocache."""
print('WOULD GET FROM EFROCACHE')
if __name__ == '__main__':
snippets_main(globals())

View File

@ -39,6 +39,7 @@ from __future__ import annotations
import os
import sys
import subprocess
from dataclasses import dataclass
from typing import TYPE_CHECKING
@ -95,6 +96,7 @@ class App:
self._update_generated_code_makefile()
self._update_assets_makefile()
self._check_makefiles()
self._check_python_files()
self._check_sync_states()
@ -307,6 +309,26 @@ class App:
expected=line,
can_auto_update=allow_auto)
def _check_makefiles(self) -> None:
from efrotools import get_public_license
# Run a few sanity checks on whatever makefiles we come across.
fnames = subprocess.run('find . -maxdepth 3 -name Makefile',
shell=True,
capture_output=True,
check=True).stdout.decode().split()
fnames = [n for n in fnames if '/build/' not in n]
for fname in fnames:
with open(fname) as infile:
makefile = infile.read()
if LEGAL_NOTICE_PRIVATE not in makefile:
raise RuntimeError(f'Priv legal not found in {fname}')
if self._public:
public_license = get_public_license('makefile')
if public_license not in makefile:
raise RuntimeError(f'Pub license not found in {fname}')
def _check_python_file(self, fname: str) -> None:
from efrotools import get_public_license
with open(fname) as infile: