Updated new_source tool to respect a modules set C++ namespace. Fixed generation of modules with templates without config.json.
This commit is contained in:
@@ -8,7 +8,7 @@ from typing import Optional, Literal
|
||||
|
||||
sys.path.append(os.path.dirname(__file__))
|
||||
|
||||
from common import prompt_choices, prompt_path, prompt_yesno, run_script
|
||||
from common import find_module_folder, get_module_config, prompt_choices, prompt_path, prompt_yesno, run_script
|
||||
from common.jinja import is_jinja_installed, generate_file
|
||||
|
||||
|
||||
@@ -44,12 +44,31 @@ def _make_source_path(base_path: Path) -> Path:
|
||||
def _apply_params(header_folder: Path, do_create_source: bool, base_path: Path) -> None:
|
||||
global _header_path, _source_path, _namespace
|
||||
|
||||
_namespace = base_path.parts[0]
|
||||
source_path = _make_source_path(base_path)
|
||||
module_folder = find_module_folder(source_path)
|
||||
|
||||
namespace = None
|
||||
if module_folder is not None:
|
||||
module_subfolder = module_folder.relative_to(_PRIVATE_PATH)
|
||||
module_key = str(module_subfolder)
|
||||
if os.path.sep != '/':
|
||||
module_key = module_key.replace(os.pathsep, '/')
|
||||
|
||||
all_module_conf = get_module_config()
|
||||
module_conf = all_module_conf.get(module_key)
|
||||
if module_conf is not None:
|
||||
namespace = module_conf.get('cxx_namespace')
|
||||
if namespace is None:
|
||||
namespace = module_key.replace('/', '_')
|
||||
|
||||
if namespace is None:
|
||||
namespace = base_path.parts[0]
|
||||
_namespace = namespace
|
||||
|
||||
if header_folder is not None:
|
||||
_header_path = _make_header_path(header_folder, base_path)
|
||||
if do_create_source:
|
||||
_source_path = _make_source_path(base_path)
|
||||
_source_path = source_path
|
||||
|
||||
def query_params() -> None:
|
||||
header_folder = prompt_choices('Create Header?', _HEADER_CHOICES)
|
||||
|
||||
Reference in New Issue
Block a user