-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* minmea: add recipe * drop support msvc * remove trailing newlines * fix typo * require pkgconf only on tools.gnu:pkg_config is false Co-authored-by: Abril Rincón Blanco <[email protected]> * simplify test_package.c * support MSVC * define MINMEA_INCLUDE_COMPAT in MSVC * follow version policy Co-authored-by: Martin Valgur <[email protected]> * follow version policy part 2 * Simplify minmea recipe Signed-off-by: Uilian Ries <[email protected]> * Build on Windows Signed-off-by: Uilian Ries <[email protected]> * Remove ununsed import Signed-off-by: Uilian Ries <[email protected]> --------- Signed-off-by: Uilian Ries <[email protected]> Co-authored-by: Abril Rincón Blanco <[email protected]> Co-authored-by: Martin Valgur <[email protected]> Co-authored-by: Uilian Ries <[email protected]>
- Loading branch information
1 parent
1266024
commit 168c942
Showing
8 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
sources: | ||
"0.3.0.cci.20230620": | ||
url: "https://github.com/kosma/minmea/archive/e368d847d75abd891c651f7d30ce5efb6681adb7.tar.gz" | ||
sha256: "9b845dfc7f4475c17710a0ac0823b11a6946df7b20dfacd02b03921826eeab3a" | ||
patches: | ||
"0.3.0.cci.20230620": | ||
- patch_file: "patches/001-disable-pkgconfig-libcheck.patch" | ||
patch_description: "Do not search for libcheck - Exclusive for testing" | ||
patch_type: "conan" | ||
- patch_file: "patches/002-windows-support.patch" | ||
patch_description: "Manage compat header file for Windows" | ||
patch_type: "portability" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
from conan import ConanFile | ||
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout | ||
from conan.tools.files import copy, get, apply_conandata_patches, export_conandata_patches | ||
from conan.tools.microsoft import is_msvc | ||
from conan.errors import ConanInvalidConfiguration | ||
import os | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
class MinmeaConan(ConanFile): | ||
name = "minmea" | ||
description = "a lightweight GPS NMEA 0183 parser library in pure C" | ||
license = ("WTFPL", "MIT", "LGPL-3.0-or-later") | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/kosma/minmea" | ||
topics = ("gps", "NMEA", "parser") | ||
package_type = "library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
} | ||
|
||
def export_sources(self): | ||
export_conandata_patches(self) | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
self.settings.rm_safe("compiler.cppstd") | ||
self.settings.rm_safe("compiler.libcxx") | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def validate(self): | ||
# INFO: Windows mingw supported: https://github.com/kosma/minmea?tab=readme-ov-file#compatibility | ||
# INFO: MSVC fails with error C2011: 'timespec': 'struct' type redefinition | ||
if is_msvc(self): | ||
raise ConanInvalidConfiguration(f"{self.ref} can not be built on Visual Studio and msvc. Use mingw instead or similar.") | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
if self.settings.os == "Windows": | ||
tc.preprocessor_definitions["MINMEA_INCLUDE_COMPAT"] = "1" | ||
tc.generate() | ||
|
||
def build(self): | ||
apply_conandata_patches(self) | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build(target="minmea") | ||
|
||
def package(self): | ||
copy(self, "COPYING", self.source_folder, os.path.join(self.package_folder, "licenses")) | ||
copy(self, "LICENSE.*", self.source_folder, os.path.join(self.package_folder, "licenses")) | ||
copy(self, "minmea.h", self.source_folder, os.path.join(self.package_folder, "include")) | ||
copy(self, "libminmea.a", self.build_folder, os.path.join(self.package_folder, "lib")) | ||
copy(self, "libminmea.so", self.build_folder, os.path.join(self.package_folder, "lib")) | ||
copy(self, "libminmea.dylib", self.build_folder, os.path.join(self.package_folder, "lib")) | ||
if self.settings.os == "Windows": | ||
copy(self, "libminmea.dll.a", self.build_folder, os.path.join(self.package_folder, "lib")) | ||
copy(self, "libminmea.dll", self.build_folder, os.path.join(self.package_folder, "bin")) | ||
copy(self, "minmea_compat.h", self.source_folder, os.path.join(self.package_folder, "include")) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["minmea"] | ||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs = ["m"] | ||
if self.settings.os == "Windows": | ||
self.cpp_info.defines = ["MINMEA_INCLUDE_COMPAT=1"] |
12 changes: 12 additions & 0 deletions
12
recipes/minmea/all/patches/001-disable-pkgconfig-libcheck.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index b96e1d7..4674f49 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -6,7 +6,6 @@ project(minmea) | ||
|
||
find_package(Threads REQUIRED) # Workaround for https://github.com/libcheck/check/issues/48#issuecomment-322965461 | ||
find_package(PkgConfig) | ||
-pkg_check_modules(CHECK REQUIRED check) | ||
link_directories(${CHECK_LIBRARY_DIRS}) | ||
|
||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -Wextra -Werror -std=c99") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 4674f49..895b835 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -13,6 +13,11 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -D_D | ||
|
||
set(minmea_SRCS minmea.c minmea.h) | ||
add_library(minmea ${minmea_SRCS}) | ||
+target_include_directories(minmea PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) | ||
+if (WIN32) | ||
+ configure_file(compat/minmea_compat_windows.h ${CMAKE_CURRENT_SOURCE_DIR}/minmea_compat.h COPYONLY) | ||
+ target_compile_definitions(minmea PRIVATE MINMEA_INCLUDE_COMPAT) | ||
+endif() | ||
|
||
add_executable(example example.c) | ||
target_link_libraries(example minmea) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(test_package LANGUAGES C) | ||
|
||
find_package(minmea REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.c) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE minmea::minmea) | ||
target_compile_features(${PROJECT_NAME} PRIVATE c_std_99) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindir, "test_package") | ||
self.run(bin_path, env="conanrun") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <stdio.h> | ||
#include "minmea.h" | ||
|
||
|
||
int main(void) { | ||
char* nmea_data = "$GPGGA,155246.585,5231.171,N,01321.830,E,1,12,1.0,0.0,M,0.0,M,,*6F"; | ||
|
||
if (minmea_sentence_id(nmea_data, false) == MINMEA_SENTENCE_GGA) { | ||
struct minmea_sentence_gga frame; | ||
if (minmea_parse_gga(&frame, nmea_data)) { | ||
printf("$GGA: fix quality: %d\n", frame.fix_quality); | ||
} | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"0.3.0.cci.20230620": | ||
folder: all |