diff --git a/mod/project.py b/mod/project.py index 8aa359f..a02bb1e 100644 --- a/mod/project.py +++ b/mod/project.py @@ -7,6 +7,9 @@ from mod import log, util, config, dep, template, settings, android, emsdk, wasisdk from mod.tools import git, cmake, xcrun, ccmake, cmake_gui, vscode, clion, httpserver, wasmtime + +gitignore_entries = ['.fips-*', 'fips-files/build/', 'fips-files/deploy/', '*.pyc', '.vscode/', '.idea/', 'CMakeUserPresets.json'] + #------------------------------------------------------------------------------- def init(fips_dir, proj_name) : """initialize an existing project directory as a fips directory by @@ -24,7 +27,6 @@ def init(fips_dir, proj_name) : for f in ['CMakeLists.txt', 'fips', 'fips.cmd', 'fips.yml'] : template.copy_template_file(fips_dir, proj_dir, f, templ_values) os.chmod(proj_dir + '/fips', 0o744) - gitignore_entries = ['.fips-*', 'fips-files/build/', 'fips-files/deploy/', '*.pyc', '.vscode/', '.idea/', 'CMakeUserPresets.json'] template.write_git_ignore(proj_dir, gitignore_entries) else : log.error("project dir '{}' does not exist".format(proj_dir)) @@ -111,6 +113,7 @@ def gen(fips_dir, proj_dir, cfg_name) : dep.fetch_imports(fips_dir, proj_dir) util.ensure_valid_project_dir(proj_dir) dep.gather_and_write_imports(fips_dir, proj_dir, cfg_name) + template.write_git_ignore(proj_dir, gitignore_entries) # load the config(s) configs = config.load(fips_dir, proj_dir, cfg_name) diff --git a/mod/template.py b/mod/template.py index 705487f..5d69498 100644 --- a/mod/template.py +++ b/mod/template.py @@ -7,40 +7,58 @@ #------------------------------------------------------------------------------- def write_git_ignore(proj_dir, entries) : - """modify or create the .gitignore file with fips-specific + """modify or create the .gitignore or .hgignore file with fips-specific entries. fips entries will go into a special section marked with: #>fips #fips and #fips' in l : - copy_line = False - if copy_line : - out_lines.append(l) - if '#fips\n') - out_lines.append('# this area is managed by fips, do not edit\n') - out_lines.extend('\n'.join(entries) + '\n') - out_lines.append('#fips and #fips" in line: + copy_line = False + if copy_line: + out_lines.append(line) + if "#fips\n") + out_lines.append("# this area is managed by fips, do not edit\n") + + if "hg" == flavour: + # always switch to glob (it's safe because we're at the end!) + out_lines.append("syntax: glob\n") + out_lines.append(".gitignore\n") + else: + out_lines.append(".hgignore\n") + + out_lines.extend("\n".join(entries) + "\n") + out_lines.append("#