Improved build.config output detection + relative paattern support

This commit is contained in:
MaXFeeD
2026-08-08 11:31:24 +03:00
parent 956a05db38
commit 6a61ef6f34
2 changed files with 18 additions and 3 deletions
+2 -1
View File
@@ -84,7 +84,8 @@ class BuildConfig(MakeDataConfig):
script_path = self.get_relative_path(relative_path) script_path = self.get_relative_path(relative_path)
output_path = basename(script_path) output_path = basename(script_path)
if isfile(script_path): if isfile(script_path):
output_path = splitext(output_path)[0] + ".js" output_path = splitext(output_path)[0]
output_path += ".js"
return MakeScriptData( return MakeScriptData(
relative_path=relative_path, relative_path=relative_path,
+16 -2
View File
@@ -1,6 +1,6 @@
from dataclasses import dataclass from dataclasses import dataclass
from itertools import chain from itertools import chain
from os.path import basename, exists, isdir, isfile, join, relpath from os.path import basename, exists, isdir, isfile, join, relpath, splitext
from time import time from time import time
from typing import Any, List, MutableMapping, Optional, Tuple from typing import Any, List, MutableMapping, Optional, Tuple
@@ -90,6 +90,7 @@ def compute_and_capture_changed_scripts() -> Tuple[List[FileSource], List[FileSo
for source in GLOBALS.MAKE_CONFIG.iterate_scripts(): for source in GLOBALS.MAKE_CONFIG.iterate_scripts():
includes_path = ensure_not_whitespace(source.includes_path, ".includes") includes_path = ensure_not_whitespace(source.includes_path, ".includes")
is_pattern_path = source.relative_path.endswith("*")
for source_path in expand_paths(GLOBALS.MAKE_CONFIG.get_relative_path(source.relative_path)): for source_path in expand_paths(GLOBALS.MAKE_CONFIG.get_relative_path(source.relative_path)):
if not exists(source_path): if not exists(source_path):
@@ -110,8 +111,15 @@ def compute_and_capture_changed_scripts() -> Tuple[List[FileSource], List[FileSo
attention(f"Source {GLOBALS.MAKE_CONFIG.get_path_to_config(source_path)!r} specifies target language as TypeScript, so this script probably uses ESNext capabilities. Building as normal JavaScript files, since `denyTypeScript` property of your 'toolchain.json' is active.") attention(f"Source {GLOBALS.MAKE_CONFIG.get_path_to_config(source_path)!r} specifies target language as TypeScript, so this script probably uses ESNext capabilities. Building as normal JavaScript files, since `denyTypeScript` property of your 'toolchain.json' is active.")
language = "javascript" language = "javascript"
# Preserve output target duplication if not is_pattern_path:
prefixed_path = source.output_path prefixed_path = source.output_path
else:
script_name = basename(source_path)
if isfile(source_path):
script_name = splitext(script_name)[0]
prefixed_path = join(source.output_path, script_name + ".js")
# Preserve output target duplication
try: try:
dot_index = prefixed_path.rindex(".") dot_index = prefixed_path.rindex(".")
prefixed_path = prefixed_path[:dot_index] + "{}" + prefixed_path[dot_index:] prefixed_path = prefixed_path[:dot_index] + "{}" + prefixed_path[dot_index:]
@@ -133,6 +141,12 @@ def compute_and_capture_changed_scripts() -> Tuple[List[FileSource], List[FileSo
changed_files.append(FileSource(source_path, destination_path, language)) changed_files.append(FileSource(source_path, destination_path, language))
files.append(FileSource(source_path, destination_path, language)) files.append(FileSource(source_path, destination_path, language))
if PROPERTIES.get_value("debug"):
debug(f"Files ({len(files)}): {', '.join([str(file) for file in files])}")
debug(f"Changed Files ({len(changed_files)}): {', '.join([str(file) for file in changed_files])}")
debug(f"Directories ({len(directories)}): {', '.join([str(directory) for directory in directories])}")
debug(f"Changed Directories ({len(changed_directories)}): {', '.join([str(directory) for directory in changed_directories])}")
return changed_files, files, changed_directories, directories return changed_files, files, changed_directories, directories
def copy_build_targets(files: List[FileSource], directories: List[DirectorySource]) -> None: def copy_build_targets(files: List[FileSource], directories: List[DirectorySource]) -> None: