From fc4ae8c221e2bf7605fb5078e6399f18022dc18e Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Sat, 15 Apr 2023 02:39:11 +0200
Subject: [PATCH] testing/ada: new aport

---
 testing/ada/APKBUILD                  | 49 +++++++++++++++++++++++++++
 testing/ada/build-shared-lib.patch    | 13 +++++++
 testing/ada/use-system-simdjson.patch | 15 ++++++++
 3 files changed, 77 insertions(+)
 create mode 100644 testing/ada/APKBUILD
 create mode 100644 testing/ada/build-shared-lib.patch
 create mode 100644 testing/ada/use-system-simdjson.patch

diff --git a/testing/ada/APKBUILD b/testing/ada/APKBUILD
new file mode 100644
index 000000000000..1061b15b37e6
--- /dev/null
+++ b/testing/ada/APKBUILD
@@ -0,0 +1,49 @@
+# Contributor: Jakub Jirutka <jakub@jirutka.cz>
+# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
+pkgname=ada
+pkgver=2.0.0
+pkgrel=0
+pkgdesc="WHATWG-compliant and fast URL parser written in modern C++"
+url="https://ada-url.github.io/ada"
+arch="all"
+license="(Apache-2.0 OR MIT) AND MPL-2.0"
+makedepends="cmake samurai"
+checkdepends="simdjson-dev"
+subpackages="$pkgname-dev"
+source="https://github.com/ada-url/ada/archive/v$pkgver/ada-$pkgver.tar.gz
+	build-shared-lib.patch
+	use-system-simdjson.patch
+	"
+
+build() {
+	local crossopts=
+	[ "$CBUILD" != "$CHOST" ] && crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
+
+	local shared; for shared in OFF ON; do
+		cmake -G Ninja -B build \
+			-DCMAKE_BUILD_TYPE=MinSizeRel \
+			-DCMAKE_INSTALL_PREFIX=/usr \
+			-DCMAKE_INSTALL_LIBDIR=lib \
+			-DBUILD_SHARED_LIBS=$shared \
+			-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
+			-DADA_BENCHMARKS=OFF \
+			$crossopts
+		cmake --build build
+	done
+}
+
+check() {
+	cd build
+	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
+}
+
+package() {
+	DESTDIR="$pkgdir" cmake --install build
+	install -m644 build/src/libada.a -t "$pkgdir"/usr/lib/
+}
+
+sha512sums="
+bc239b1482d2095d4adf3fb9cdbe0b1f544499dbb96a17ba1d02544c8a275abe557e6e991ae27e52ac43c48415be8b9cf42b26d52cc1bc361e1c9bdcb55546ad  ada-2.0.0.tar.gz
+5e22b9d59b1ec8ae012594c49441029a41aae812726da2c7016510f18be72737526267e3192c703b49d948d8e1c4967c7f1272f1425b1f460cb6cf60d676ab6f  build-shared-lib.patch
+de114ce5e9ec20cfdbd56f98ab4fd0347e074c5509ac7550573eafa8b5e89ccf6b4c0c9d8d7f4e39e736d140602cb90e867c69dd2a80196a5c6ed31571e5d055  use-system-simdjson.patch
+"
diff --git a/testing/ada/build-shared-lib.patch b/testing/ada/build-shared-lib.patch
new file mode 100644
index 000000000000..e7909786c3e3
--- /dev/null
+++ b/testing/ada/build-shared-lib.patch
@@ -0,0 +1,13 @@
+Upstream-Issue: https://github.com/ada-url/ada/issues/327
+
+--- a/src/CMakeLists.txt
++++ b/src/CMakeLists.txt
+@@ -7,7 +7,7 @@
+ add_library(ada-source INTERFACE)
+ target_sources(ada-source INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/ada.cpp)
+ target_link_libraries(ada-source INTERFACE ada-include-source)
+-add_library(ada STATIC ada.cpp)
++add_library(ada ada.cpp)
+ target_include_directories(ada PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> )
+ target_include_directories(ada PUBLIC "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>")
+ 
diff --git a/testing/ada/use-system-simdjson.patch b/testing/ada/use-system-simdjson.patch
new file mode 100644
index 000000000000..6c36803f98bf
--- /dev/null
+++ b/testing/ada/use-system-simdjson.patch
@@ -0,0 +1,15 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -24,12 +24,6 @@
+ 
+ option(ADA_BENCHMARKS "Build benchmarks" OFF)
+ 
+-if(BUILD_TESTING OR ADA_BENCHMARKS)
+-  include(${PROJECT_SOURCE_DIR}/cmake/import.cmake)
+-  import_dependency(simdjson simdjson/simdjson 0a3a00c95665cc1fda760e121ba8d442945ede13)
+-  add_dependency(simdjson)
+-endif()
+-
+ if (BUILD_TESTING)
+   message(STATUS "The tests are enabled.")
+   add_subdirectory(tests)
-- 
GitLab