diff --git a/README.md b/README.md index 9bf1ba3..ed3a512 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ a port written against the module, with every outcome equal to upstream's. ## Getting started ```sh -mcpp new pictures --template mcpplibs.mwrap.libpng@1.6.43 +mcpp new pictures --template mcpplibs.mwrap.libpng@1.6.43.1 cd pictures mcpp run ``` @@ -37,7 +37,7 @@ it back pixel for pixel, and describes it with the low-level reader; ```toml [dependencies] -"mcpplibs.mwrap.libpng" = "1.6.43" +mcpplibs.mwrap.libpng = "1.6.43.1" ``` ```cpp diff --git a/README.zh.md b/README.zh.md index 2626c9a..cabcf05 100644 --- a/README.zh.md +++ b/README.zh.md @@ -25,7 +25,7 @@ constexpr 函数,把构建选项映射成 `constexpr bool`。每次 CI 都会 ## 快速开始 ```sh -mcpp new pictures --template mcpplibs.mwrap.libpng@1.6.43 +mcpp new pictures --template mcpplibs.mwrap.libpng@1.6.43.1 cd pictures mcpp run ``` @@ -35,7 +35,7 @@ mcpp run ```toml [dependencies] -"mcpplibs.mwrap.libpng" = "1.6.43" +mcpplibs.mwrap.libpng = "1.6.43.1" ``` ```cpp diff --git a/mcpp.toml b/mcpp.toml index a51354b..9a5586f 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -2,7 +2,7 @@ [package] namespace = "mcpplibs.mwrap" name = "libpng" -version = "1.6.43" +version = "1.6.43.1" description = "libpng 1.6.43 C++ modules for mcpp (import mcpplibs.mwrap.libpng;): the API of png.h over compat.libpng, its macros as constants and constexpr functions, its build options as constexpr bool" license = "Apache-2.0" authors = ["mcpp-community"] diff --git a/templates/image/mcpp.toml.in b/templates/image/mcpp.toml.in index a637560..43c2cea 100644 --- a/templates/image/mcpp.toml.in +++ b/templates/image/mcpp.toml.in @@ -7,4 +7,4 @@ kind = "bin" main = "src/main.cpp" [dependencies] -"{{self.name}}" = "{{self.version}}" +{{self.name}} = "{{self.version}}" diff --git a/tools/test_template.py b/tools/test_template.py index 81ea805..07f1ca6 100644 --- a/tools/test_template.py +++ b/tools/test_template.py @@ -48,7 +48,10 @@ def main(): project = temporary / "quickstart" manifest = project / "mcpp.toml" text = manifest.read_text() - dependency = tomllib.loads(text)["dependencies"][identity] + # The key is unquoted, so TOML reads it as one table per segment. + dependency = tomllib.loads(text)["dependencies"] + for segment in identity.split("."): + dependency = dependency[segment] options = {"version": dependency} if isinstance(dependency, str) else dependency assert options["version"] == version, options replacement = '{ path = ' + json.dumps(package.as_posix()) @@ -56,9 +59,9 @@ def main(): replacement += ', features = ' + json.dumps(options["features"]) replacement += ' }' lines = text.splitlines() - matches = [i for i, line in enumerate(lines) if line.startswith(json.dumps(identity) + " =")] - assert len(matches) == 1, "Expected exactly one qualified dependency from self.name" - lines[matches[0]] = json.dumps(identity) + " = " + replacement + matches = [i for i, line in enumerate(lines) if line.startswith(identity + " =")] + assert len(matches) == 1, "Expected exactly one unquoted qualified dependency from self.name" + lines[matches[0]] = identity + " = " + replacement manifest.write_text("\n".join(lines) + "\n") if args.index: candidate_index = args.index.resolve()