Subject: Re: [bug#71897] [PATCH v9 6/8] gnu: Add cpp-ada-url-parser.

From: Liliana Marie Prikler <[email-masked]>
Date: Sun, 22 Sep 2024 23:31:41 +0200

Am Sonntag, dem 22.09.2024 um 19:37 +0800 schrieb dan:
> * gnu/packages/cpp.scm (cpp-ada-url-parser): New variable.
> (cpm-for-cpp-ada-url-parser): New variable.
> 
> Change-Id: I0b61c3b136e2781774c6a5e67eeb6b662e97dd88
> ---
>  gnu/packages/cpp.scm | 58
> ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 58 insertions(+)
> 
> diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
> index c805dae825..29e50d4531 100644
> --- a/gnu/packages/cpp.scm
> +++ b/gnu/packages/cpp.scm
> @@ -3284,3 +3284,61 @@ (define-public tl-optional
>  the std::optional for C++11/14/17, with support for monadic
> operations added in
>  C++23.")
>      (license license:cc0)))
> +
> +(define cpm-for-cpp-ada-url-parser
> +  (let ((version "0.38.6"))
> +    (origin
> +      (method git-fetch)
> +      (uri (git-reference
> +            (url "https://github.com/cpm-cmake/CPM.cmake")
> +            (commit (string-append "v" version))))
> +      (file-name (git-file-name "cpm-for-cpp-ada-url-parser"
> version))
> +      (sha256 (base32
> "1qbbhdq6cz2y7qfyy1k11i98d13s229r3phd5y3n5maq51ky8bgb")))))
> +
> +(define-public cpp-ada-url-parser
> +  (package
> +    (name "cpp-ada-url-parser")
> +    (version "2.9.2")
> +    (source
> +      (origin
> +        (method git-fetch)
> +        (uri (git-reference
> +              (url "https://github.com/ada-url/ada")
> +              (commit (string-append "v" version))))
> +        (file-name (git-file-name name version))
> +        (sha256 (base32
> "0xvvjlia627ajl966gdxzy2b1j0jiimx7zx8ypmffwx0k6x72qam"))))
> +    (build-system cmake-build-system)
> +    (arguments
> +     (list
> +      #:configure-flags #~(list "-DCPM_LOCAL_PACKAGES_ONLY=ON")
> +      #:phases
> +      #~(modify-phases %standard-phases
> +          (add-after 'unpack 'patch-deps
> +            (lambda _
> +              (substitute* "CMakeLists.txt"
> +                (("cmake/CPM.cmake")
> +                 (string-append #$cpm-for-cpp-ada-url-parser
> "/cmake/CPM.cmake"))
> +                ;; We force CPM to find system packages rather than
> using git
Doesn't CMake have a lookup mechanism for those too?  Could we not just
delete the file through a snippet and add this as native input?

> +                ;; to download them.
> +                (("Git_FOUND") "TRUE")
> +                (("3.9.1")
> +                 #$(package-version (this-package-native-input
> "simdjson"))))
You might want to use the package as needle as well, i.e.
(simdjson@)[0-9.]* and then replace the version substring.  This is
more robust in the face of multiple packages having the same versions
by accident of one package getting version-bumped. 
> +              (substitute* "tools/cli/CMakeLists.txt"
> +                (("3.2.0")
> +                 #$(package-version (this-package-native-input
> "cxxopts"))))))
> +          (add-after 'patch-deps 'python-zipfile-disable-strict-
> timestamps
> +            (lambda _
> +              (substitute* "singleheader/amalgamate.py"
> +                (("zipfile.ZIP_DEFLATED")
> +                 "zipfile.ZIP_DEFLATED,
> strict_timestamps=False")))))))
> +    (native-inputs
> +     (list cxxopts
> +           fmt-10
> +           googletest
> +           python
> +           simdjson))
> +    (home-page "https://github.com/ada-url/ada")
> +    (synopsis "URL parser")
> +    (description "Ada is a fast and spec-compliant URL parser
> written in C++.
> +Specification for URL parser can be found from the WHATWG website.")
> +    (license license:gpl3+)))
Cheers