work towards getting spinoff working in public repos

This commit is contained in:
Eric Froemling 2023-05-16 16:59:07 -07:00
parent 58d3b2f6e3
commit 2a411f875b
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
5 changed files with 41 additions and 16 deletions

View File

@ -163,6 +163,7 @@ ctx.filter_file_names = {
'flycheck-dir-locals.el', 'flycheck-dir-locals.el',
'.projectile', '.projectile',
'.editorconfig', '.editorconfig',
'ci.yml',
'LICENSE', 'LICENSE',
'cloudtool', 'cloudtool',
'bacloud', 'bacloud',
@ -187,6 +188,7 @@ ctx.no_filter_file_names = {
'.pylintrc', '.pylintrc',
'CPPLINT.cfg', 'CPPLINT.cfg',
'.mypy.ini', '.mypy.ini',
'.efrocachemap',
'._ba_sources_hash', '._ba_sources_hash',
'._baplus_sources_hash', '._baplus_sources_hash',
'._bascenev1_sources_hash', '._bascenev1_sources_hash',

View File

@ -532,10 +532,11 @@ def generate_assets_makefile(
out_files['src/assets/.asset_manifest_public.json'] = _gen_manifest( out_files['src/assets/.asset_manifest_public.json'] = _gen_manifest(
all_targets_public all_targets_public
) )
# Only *generate* the private manifest in the private repo. In public
# we just give what's already on disk.
manprivpath = 'src/assets/.asset_manifest_private.json'
if not public: if not public:
out_files['src/assets/.asset_manifest_private.json'] = _gen_manifest( out_files[manprivpath] = _gen_manifest(all_targets_private)
all_targets_private
)
return out_files return out_files

View File

@ -380,15 +380,27 @@ class ProjectUpdater:
self._generate_top_level_makefile(path, existing_data) self._generate_top_level_makefile(path, existing_data)
elif path == 'src/assets/Makefile': elif path == 'src/assets/Makefile':
self._generate_assets_makefile(path, existing_data) self._generate_assets_makefile(path, existing_data)
elif path.startswith('src/assets/.asset_manifest_'): elif path.startswith('src/assets/.asset_manifest_public'):
# These are generated as a side-effect of the assets makefile. # These are always generated as a side-effect of the
# assets Makefile.
self.generate_file('src/assets/Makefile') self.generate_file('src/assets/Makefile')
elif path.startswith('src/assets/.asset_manifest_private'):
if self.public:
# In public repos these are just pulled through as-is
# from the source project.
self._generate_passthrough_file(path, existing_data)
else:
# In private repos, these are generated as a side-effect
# of the assets Makefile.
self.generate_file('src/assets/Makefile')
elif path == 'src/resources/Makefile': elif path == 'src/resources/Makefile':
self._generate_resources_makefile(path, existing_data) self._generate_resources_makefile(path, existing_data)
elif path == 'src/meta/Makefile': elif path == 'src/meta/Makefile':
self._generate_meta_makefile(existing_data) self._generate_meta_makefile(existing_data)
elif path.startswith('src/meta/.meta_manifest_'): elif path.startswith('src/meta/.meta_manifest_'):
# These are generated as a side-effect of the meta makefile. # These are always generated as a side-effect of the
# meta Makefile.
self.generate_file('src/meta/Makefile') self.generate_file('src/meta/Makefile')
assert path in self._generated_files assert path in self._generated_files
else: else:
@ -649,6 +661,7 @@ class ProjectUpdater:
outfiles = generate_assets_makefile( outfiles = generate_assets_makefile(
self.projroot, path, existing_data, meta_manifests self.projroot, path, existing_data, meta_manifests
) )
for out_path, out_contents in outfiles.items(): for out_path, out_contents in outfiles.items():
self._generated_files[out_path] = out_contents self._generated_files[out_path] = out_contents
@ -667,6 +680,9 @@ class ProjectUpdater:
def _update_meta_makefile(self) -> None: def _update_meta_makefile(self) -> None:
self.enqueue_update('src/meta/Makefile') self.enqueue_update('src/meta/Makefile')
def _generate_passthrough_file(self, path: str, existing_data: str) -> None:
self._generated_files[path] = existing_data
def _generate_meta_makefile(self, existing_data: str) -> None: def _generate_meta_makefile(self, existing_data: str) -> None:
from batools.metamakefile import generate_meta_makefile from batools.metamakefile import generate_meta_makefile

View File

@ -59,6 +59,7 @@ class SpinoffContext:
dst_root: str, dst_root: str,
mode: Mode, mode: Mode,
force: bool = False, force: bool = False,
verbose: bool = False,
print_full_lists: bool = False, print_full_lists: bool = False,
override_paths: list[str] | None = None, override_paths: list[str] | None = None,
backport_file: str | None = None, backport_file: str | None = None,
@ -74,6 +75,7 @@ class SpinoffContext:
self._mode = mode self._mode = mode
self._force = force self._force = force
self._verbose = verbose
self._print_full_lists = print_full_lists self._print_full_lists = print_full_lists
self._override_paths = override_paths self._override_paths = override_paths
self._backport_file = backport_file self._backport_file = backport_file
@ -128,6 +130,7 @@ class SpinoffContext:
'.asset_manifest_public.json', '.asset_manifest_public.json',
'.asset_manifest_private.json', '.asset_manifest_private.json',
} }
self._project_file_suffixes = { self._project_file_suffixes = {
'.vcxproj', '.vcxproj',
'.vcxproj.filters', '.vcxproj.filters',
@ -438,11 +441,12 @@ class SpinoffContext:
else: else:
assert_never(self._mode) assert_never(self._mode)
# Bail at this point if anything went wrong. We don't store state # Always write state at this point. Even if there have been
# or update the .gitignore or anything in that case. # errors, we want to keep track of the latest states we have for
# Note: perhaps we should? If we wrote a bit of stuff and then # anything wrote/etc.
# failed we'll get a bunch of complaints about mod times changing self._write_state()
# under us next time we run, right?
# Bail at this point if anything went wrong.
if ( if (
self._src_error_entities self._src_error_entities
or self._dst_error_entities or self._dst_error_entities
@ -462,10 +466,6 @@ class SpinoffContext:
if self._mode is self.Mode.UPDATE or self._mode is self.Mode.OVERRIDE: if self._mode is self.Mode.UPDATE or self._mode is self.Mode.OVERRIDE:
self._write_gitignore() self._write_gitignore()
# Only writing updated state in case of success. Is there a reason
# we would want to write it on errors also?
self._write_state()
def _apply_project_configs(self) -> None: def _apply_project_configs(self) -> None:
# pylint: disable=exec-used # pylint: disable=exec-used
try: try:
@ -1418,9 +1418,14 @@ class SpinoffContext:
self._execution_error = True self._execution_error = True
print( print(
f'{Clr.RED}Error copying/filtering file:' f'{Clr.RED}Error copying/filtering file:'
f" '{src_path_full}'{Clr.RST}: {exc}.", f" '{src_path_full}'{Clr.RST}: {exc}"
' (use --verbose for full traceback)',
file=sys.stderr, file=sys.stderr,
) )
if self._verbose:
import traceback
traceback.print_exc(file=sys.stderr)
def _handle_src_copy_file( def _handle_src_copy_file(
self, self,

View File

@ -124,6 +124,7 @@ def _main() -> None:
dst_root, dst_root,
single_run_mode, single_run_mode,
force='--force' in sys.argv, force='--force' in sys.argv,
verbose='--verbose' in sys.argv,
print_full_lists='--full' in sys.argv, print_full_lists='--full' in sys.argv,
).run() ).run()