rust-libnghttp2-unbundle.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. From a11e85e9de2d16b1aa0a0d1265d4d01dee8a2f70 Mon Sep 17 00:00:00 2001
  2. From: Maxime Devos <maximedevos@telenet.be>
  3. Date: Sat, 4 Jun 2022 19:00:54 +0000
  4. Subject: [PATCH] Support using the system's libnghttp2 instead of the bundled
  5. copy.
  6. - Cargo.toml: Add pkg-config build dependency, make cc optional,
  7. add "vendored" feature, for backwards compatibility default to
  8. enabling the "vendored" feature. Add modification information
  9. as seems to be required by the Apache license.
  10. - README.md: add information on how to unbundle.
  11. - build.rs: Implement using the system copy instead of the local
  12. copy, while keeping support for vendoring intact.
  13. - LICENSE-MIT: Update copyright information.
  14. Modified in Guix to backport to version packaged in Guix
  15. and because of crates.io's rewriting of Cargo.toml.
  16. Submitted upstream at <https://github.com/alexcrichton/nghttp2-rs/pull/5>.
  17. ---
  18. Cargo.toml | 8 +++++++-
  19. LICENSE-MIT | 1 +
  20. README.md | 5 ++++-
  21. build.rs | 24 +++++++++++++++++++++++-
  22. 4 files changed, 35 insertions(+), 3 deletions(-)
  23. diff --git a/Cargo.toml.orig b/Cargo.toml.orig
  24. index 6a42a7f..bb096b5 100644
  25. --- a/Cargo.toml.orig
  26. +++ b/Cargo.toml.orig
  27. @@ -1,3 +1,4 @@
  28. +# modified by Maxime Devos (2022) (see 4(b) in LICENSE-APACHE)
  29. [package]
  30. name = "libnghttp2-sys"
  31. version = "0.1.7+1.45.0"
  32. @@ -21,4 +22,9 @@ members = ['systest']
  33. libc = '0.2'
  34. [build-dependencies]
  35. -cc = "1.0.24"
  36. +cc = { version = "1.0.24", optional = true }
  37. +pkg-config = { version = "0.3.19" }
  38. +
  39. +[features]
  40. +vendored = ["cc"]
  41. +default = ["vendored"] # for backwards compatibility
  42. \ No newline at end of file
  43. diff --git a/LICENSE-MIT b/LICENSE-MIT
  44. index 39e0ed6..d46b385 100644
  45. --- a/LICENSE-MIT
  46. +++ b/LICENSE-MIT
  47. @@ -1,4 +1,5 @@
  48. Copyright (c) 2014 Alex Crichton
  49. +Copyright (c) 2022 Maxime Devos
  50. Permission is hereby granted, free of charge, to any
  51. person obtaining a copy of this software and associated
  52. diff --git a/README.md b/README.md
  53. index 6bc558a..01a0013 100644
  54. --- a/README.md
  55. +++ b/README.md
  56. @@ -1,7 +1,9 @@
  57. # nghttp2-sys
  58. A common library for linking `nghttp2` to rust programs (also known as
  59. -libnghttp2).
  60. +libnghttp2). By default, it uses a bundled copy of `libnghttp2`. If that
  61. +is not desired, you can use the system's `libnghttp2` instead by not enabling
  62. +the default `vendored` feature.
  63. ## Generating bindings
  64. @@ -42,6 +44,7 @@ This project is licensed under either of
  65. at your option.
  66. +Modified by Maxime Devos (2022) (see 4(b) in LICENSE-APACHE) (TODO: is there a less intrusive way to do this?)
  67. ### Contribution
  68. Unless you explicitly state otherwise, any contribution intentionally submitted
  69. diff --git a/build.rs b/build.rs
  70. index 3b20efc..8018ebe 100644
  71. --- a/build.rs
  72. +++ b/build.rs
  73. @@ -1,12 +1,26 @@
  74. +// modified by Maxime Devos (2022) (see 4(b) in LICENSE-APACHE)
  75. +
  76. +#[cfg(feature = "vendored")]
  77. extern crate cc;
  78. use std::env;
  79. use std::fs;
  80. use std::path::PathBuf;
  81. const VERSION: &str = "1.33.90";
  82. -fn main() {
  83. +#[cfg(not(feature = "vendored"))]
  84. +extern crate pkg_config;
  85. +
  86. +// use system copy of nghttp2
  87. +#[cfg(not(feature = "vendored"))]
  88. +fn main_system() {
  89. + pkg_config::Config::new().atleast_version("1.44.0").probe("libnghttp2").unwrap();
  90. +}
  91. +
  92. +// use bundled copy of nghttp2
  93. +#[cfg(feature = "vendored")]
  94. +fn main_vendored() {
  95. let target = env::var("TARGET").unwrap();
  96. let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
  97. let lib_version = env::var("CARGO_PKG_VERSION")
  98. @@ -112,3 +126,11 @@ fn main() {
  99. )
  100. .unwrap();
  101. }
  102. +
  103. +fn main() {
  104. + #[cfg(not(feature = "vendored"))]
  105. + main_system();
  106. +
  107. + #[cfg(feature = "vendored")]
  108. + main_vendored();
  109. +}
  110. --
  111. 2.36.0