-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
695 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,173 @@ | ||
"""Conan recipe for CODA-oss | ||
Note: building packages on Windows usually requires enabling Conan's short_path | ||
workaround due to issues handling paths longer than 260 characters on Windows. | ||
To do so, set use_always_short_paths = True in ~/.conan/conan.conf, or set the | ||
environment variable CONAN_USE_ALWAYS_SHORT_PATHS=1. To control where the build | ||
directories are placed, set user_home_short in ~/.conan/conan.conf, or set the | ||
environment variable CONAN_USER_HOME_SHORT. For further information see | ||
https://docs.conan.io/en/latest/reference/conanfile/attributes.html#short-paths | ||
""" | ||
|
||
from conans import ConanFile, CMake, tools | ||
from conans.client.conan_api import ConanAPIV1 | ||
import os | ||
import sys | ||
|
||
class CodaOssConan(ConanFile): | ||
name = "coda-oss" | ||
url = "https://github.com/mdaus/coda-oss" | ||
description = "Common Open Development Archive - OSS" | ||
scm = { | ||
"type": "git", | ||
"url": url + ".git", | ||
"revision": "auto", | ||
} | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = {"shared": [True, False], | ||
"BOOST_HOME": "ANY", | ||
"PYTHON_HOME": "ANY", | ||
"PYTHON_VERSION": "ANY", | ||
"ENABLE_BOOST": [True, False], | ||
"ENABLE_PYTHON": [True, False], | ||
"ENABLE_SWIG": [True, False], | ||
"ENABLE_J2K": [True, False], | ||
"ENABLE_JARS": [True, False], | ||
"ENABLE_JPEG": [True, False], | ||
"ENABLE_PCRE": [True, False], | ||
"ENABLE_XML": [True, False], | ||
"ENABLE_ZIP": [True, False], | ||
"RE_ENABLE_STD_REGEX": [True, False], | ||
"CMAKE_DISABLE_FIND_PACKAGE_OpenSSL": [True, False], | ||
"CMAKE_DISABLE_FIND_PACKAGE_CURL": [True, False], | ||
"MT_DEFAULT_PINNING": [True, False], | ||
"CODA_BUILD_TESTS": [True, False], | ||
"CODA_INSTALL_TESTS": [True, False], | ||
} | ||
default_options = {"shared": False, | ||
"BOOST_HOME": "", | ||
"PYTHON_HOME": "", | ||
"PYTHON_VERSION": "", | ||
"ENABLE_BOOST": False, | ||
"ENABLE_PYTHON": True, | ||
"ENABLE_SWIG": False, | ||
"ENABLE_J2K": True, | ||
"ENABLE_JARS": True, | ||
"ENABLE_JPEG": True, | ||
"ENABLE_PCRE": True, | ||
"ENABLE_XML": True, | ||
"ENABLE_ZIP": True, | ||
"RE_ENABLE_STD_REGEX": False, | ||
"CMAKE_DISABLE_FIND_PACKAGE_OpenSSL": False, | ||
"CMAKE_DISABLE_FIND_PACKAGE_CURL": False, | ||
"MT_DEFAULT_PINNING": False, | ||
"CODA_BUILD_TESTS": True, | ||
"CODA_INSTALL_TESTS": False, | ||
} | ||
license = "GNU LESSER GENERAL PUBLIC LICENSE Version 3" | ||
generators = ("cmake", "cmake_paths") | ||
|
||
# default to short_paths mode (Windows only) | ||
short_paths = True | ||
# default the short_paths home to ~/.conan_short | ||
# this may be overridden by setting the environment variable | ||
# CONAN_USER_HOME_SHORT or setting user_home_short in ~/.conan/conan.conf | ||
if sys.platform.startswith('win32') and os.getenv("CONAN_USER_HOME_SHORT") is None: | ||
os.environ["CONAN_USER_HOME_SHORT"] = os.path.join( | ||
os.path.expanduser("~"), ".conan_short") | ||
|
||
def set_version(self): | ||
git = tools.Git(folder=self.recipe_folder) | ||
self.version = git.get_revision()[:16] | ||
|
||
def _get_in_tree_dependencies(self): | ||
# The in-tree dependencies ("drivers"). | ||
# To automatically compile them when a package is not already built, | ||
# add the "--build outdated" option to the conan "create" or "install" | ||
# command line (otherwise it will fail). | ||
in_tree_dependencies = { | ||
"openjpeg": dict( | ||
version="2.3.1", | ||
user="coda", | ||
channel="driver", | ||
path=os.path.join("modules", "drivers", "j2k", "openjpeg"), | ||
enable_option="ENABLE_J2K", | ||
), | ||
"libjpeg": dict( | ||
version="9d", | ||
user="coda", | ||
channel="driver", | ||
path=os.path.join("modules", "drivers", "jpeg"), | ||
enable_option="ENABLE_JPEG", | ||
), | ||
"pcre2": dict( | ||
version="10.22", | ||
user="coda", | ||
channel="driver", | ||
path=os.path.join("modules", "drivers", "pcre"), | ||
enable_option="ENABLE_PCRE", | ||
), | ||
"xerces-c": dict( | ||
version="3.2.3", | ||
user="coda", | ||
channel="driver", | ||
path=os.path.join("modules", "drivers", "xml", "xerces"), | ||
enable_option="ENABLE_XML", | ||
), | ||
"zlib": dict( | ||
version="1.2.13", | ||
user="coda", | ||
channel="driver", | ||
path=os.path.join("modules", "drivers", "zlib"), | ||
enable_option="ENABLE_ZIP", | ||
), | ||
} | ||
return in_tree_dependencies | ||
|
||
def export(self): | ||
# Export the driver dependency recipes when the coda-oss recipe is | ||
# exported. | ||
(cpm, _, _) = ConanAPIV1.factory() | ||
for dep_name, dep_info in self._get_in_tree_dependencies().items(): | ||
cpm.export(os.path.join(self.recipe_folder, dep_info["path"]), | ||
dep_name, dep_info["version"], | ||
dep_info["user"], dep_info["channel"]) | ||
|
||
def requirements(self): | ||
for dep_name, dep_info in self._get_in_tree_dependencies().items(): | ||
if self.options.__getattr__(dep_info["enable_option"]): | ||
self.requires(f'{dep_name}/{dep_info["version"]}@{dep_info["user"]}/{dep_info["channel"]}') | ||
|
||
def _configure_cmake(self): | ||
cmake = CMake(self) | ||
# automatically foward all uppercase arguments to CMake | ||
for name, val in self.options.iteritems(): | ||
if name.isupper() and val is not None: | ||
cmake.definitions[name] = val | ||
cmake.configure() | ||
return cmake | ||
|
||
def build(self): | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def package(self): | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
|
||
def package_id(self): | ||
# Make any change in our dependencies' version require a new binary | ||
self.info.requires.full_version_mode() | ||
|
||
if len(self.info.options.BOOST_HOME) > 0: | ||
self.info.options.ENABLE_BOOST = True | ||
if len(self.info.options.PYTHON_HOME) > 0: | ||
self.info.options.ENABLE_PYTHON = True | ||
|
||
# make ABI independent of specific paths | ||
for name, val in self.info.options.as_list(): | ||
if name.endswith("_HOME"): | ||
self.info.options.remove(name) | ||
|
||
def package_info(self): | ||
self.cpp_info.builddirs = ["lib/cmake"] |
24 changes: 24 additions & 0 deletions
24
externals/nitro/externals/coda-oss/modules/c++/zip/CMakeLists.txt
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,24 @@ | ||
if (ENABLE_ZIP AND CONAN_PACKAGE_NAME) | ||
# import targets from zlib conan package | ||
find_package(coda-oss_zlib REQUIRED) | ||
endif() | ||
|
||
if (TARGET z AND TARGET minizip) | ||
set(MODULE_NAME zip) | ||
|
||
coda_add_module( | ||
${MODULE_NAME} | ||
VERSION 1.0 | ||
DEPS io-c++ coda_oss-c++ z minizip) | ||
|
||
coda_add_tests( | ||
MODULE_NAME ${MODULE_NAME} | ||
DIRECTORY "tests") | ||
|
||
coda_add_tests( | ||
MODULE_NAME ${MODULE_NAME} | ||
DIRECTORY "unittests" | ||
UNITTEST) | ||
else() | ||
message("zip will not be build since zlib + minizip were not enabled") | ||
endif() |
Binary file added
BIN
+41 Bytes
externals/nitro/externals/coda-oss/modules/c++/zip/unittests/test.gz
Binary file not shown.
Binary file added
BIN
+126 Bytes
externals/nitro/externals/coda-oss/modules/c++/zip/unittests/test.zip
Binary file not shown.
1 change: 1 addition & 0 deletions
1
externals/nitro/externals/coda-oss/modules/c++/zip/unittests/text.txt
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 @@ | ||
Hello World! |
103 changes: 103 additions & 0 deletions
103
externals/nitro/externals/coda-oss/modules/c++/zip/unittests/unittest_GZip.cpp
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,103 @@ | ||
/* ========================================================================= | ||
* This file is part of zip-c++ | ||
* ========================================================================= | ||
* | ||
* (C) Copyright 2004 - 2016, MDA Information Systems LLC | ||
* | ||
* zip-c++ is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this program; If not, | ||
* see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include <std/filesystem> | ||
|
||
#include <import/sys.h> | ||
#include <import/io.h> | ||
#include <import/zip.h> | ||
#include <io/ReadUtils.h> | ||
|
||
#include <TestCase.h> | ||
|
||
static std::filesystem::path find_unittest_file(const std::filesystem::path& name) | ||
{ | ||
static const auto unittests = std::filesystem::path("modules") / "c++" / "zip" / "unittests"; | ||
return sys::test::findGITModuleFile("coda-oss", unittests, name); | ||
} | ||
|
||
static std::string txt_to_gz(const std::filesystem::path& txt_path) | ||
{ | ||
const auto pid = sys::OS().getSpecialEnv("PID"); | ||
return txt_path.stem().string() + pid + txt_path.extension().string() + ".gz"; | ||
} | ||
|
||
static std::string gz_to_txt(const std::filesystem::path& gz_path) | ||
{ | ||
const auto pid = sys::OS().getSpecialEnv("PID"); | ||
return gz_path.stem().string() + pid + gz_path.extension().string() + ".txt"; | ||
} | ||
|
||
TEST_CASE(gzip) | ||
{ | ||
const auto inputPath = find_unittest_file("text.txt"); | ||
|
||
const std::filesystem::path argv0 = sys::OS().getSpecialEnv("0"); | ||
auto outputPath = argv0.parent_path() / txt_to_gz(inputPath); | ||
{ | ||
io::FileInputStream input(inputPath.string()); | ||
zip::GZipOutputStream output(outputPath.string()); | ||
|
||
input.streamTo(output); | ||
input.close(); | ||
output.close(); | ||
} | ||
|
||
std::vector<coda_oss::byte> buffer; | ||
io::readFileContents(outputPath, buffer); | ||
TEST_ASSERT_EQ(32, buffer.size()); | ||
{ | ||
zip::GZipInputStream input(outputPath.string()); | ||
outputPath = argv0.parent_path() / gz_to_txt(outputPath); | ||
io::FileOutputStream output(outputPath.string()); | ||
while (input.streamTo(output, 8192)) ; | ||
|
||
input.close(); | ||
output.close(); | ||
|
||
const auto str = io::readFileContents(outputPath.string()); | ||
TEST_ASSERT_EQ("Hello World!", str); | ||
} | ||
} | ||
|
||
TEST_CASE(gunzip) | ||
{ | ||
const auto inputPath = find_unittest_file("test.gz"); | ||
|
||
const std::filesystem::path argv0 = sys::OS().getSpecialEnv("0"); | ||
const auto outputPath = argv0.parent_path() / gz_to_txt(inputPath); | ||
|
||
zip::GZipInputStream input(inputPath.string()); | ||
io::FileOutputStream output(outputPath.string()); | ||
while ( input.streamTo(output, 8192) ); | ||
|
||
input.close(); | ||
output.close(); | ||
|
||
const auto str = io::readFileContents(outputPath.string()); | ||
TEST_ASSERT_EQ("Hello World!", str); | ||
} | ||
|
||
TEST_MAIN( | ||
TEST_CHECK(gzip); | ||
TEST_CHECK(gunzip); | ||
) |
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,9 @@ | ||
NAME = 'zip' | ||
VERSION = '1.0' | ||
MODULE_DEPS = 'io' | ||
USELIB_CHECK = 'MINIZIP ZIP' | ||
|
||
options = configure = distclean = lambda p: None | ||
|
||
def build(bld): | ||
bld.module(**globals()) |
Oops, something went wrong.