Skip to content

Commit

Permalink
Add CUnit package (#15)
Browse files Browse the repository at this point in the history
The official installation instructions indicate that Conan be used to
install CUnit, so this package is necessary to avoid installing an
additional package manager on Windows.

Note that CUnit's versioning isn't supported in Nuget, so I changed
2.1-3 to 2.1.3 to make it work.

Signed-off-by: Scott K Logan <[email protected]>
  • Loading branch information
cottsay authored Oct 24, 2019
1 parent 6e8399a commit 620f9e3
Show file tree
Hide file tree
Showing 13 changed files with 753 additions and 0 deletions.
17 changes: 17 additions & 0 deletions package/cunit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Chocolatey package for CUnit

This package is beta quality and designed for a specific application.
At this time it is not recommended to distribute this package outside of the
tutorial application which requires it.

To build the package, follow these steps.

You need Git, Visual Studio 2019 Command line tools and CMake.

- Download and extract CUnit from https://svwh.dl.sourceforge.net/project/cunit/CUnit/2.1-3/CUnit-2.1-3.tar.bz2
- Copy the contents of the `build/` subdirectory into the root of the CUnit sources
- Apply the patch using your favorite patching application: `git apply snprintf.patch`
- Create a CMake build directory and run `cmake -G "NMake Makefiles" -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=PATH_TO_THIS_DIRECTORY PATH_TO_CUNIT_SOURCES`.
- Run `nmake install`.
- Run `choco pack`.
- Test the package and if it's good upload it somewhere your end users can reach it.
85 changes: 85 additions & 0 deletions package/cunit/build/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
cmake_minimum_required(VERSION 3.0.2)
project(CUnit LANGUAGES C)

# Export all symbols when building a DLL on MSVC
if(WIN32 AND MSVC AND BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()

# Build target
set(SOURCES_DIR "CUnit/Sources")
set(HEADERS_DIR "CUnit/Headers")

set(VERSION "${MAJOR}.${MINOR}")
set(RELEASE "${PATCH}")
configure_file("${HEADERS_DIR}/CUnit.h.in" "CUnit.h" @ONLY)

set(BASIC_HEADERS "${HEADERS_DIR}/Basic.h")
set(BASIC_SOURCES "${SOURCES_DIR}/Basic/Basic.c")
set(AUTOMATED_HEADERS "${HEADERS_DIR}/Automated.h")
set(AUTOMATED_SOURCES "${SOURCES_DIR}/Automated/Automated.c")
set(CONSOLE_HEADERS "${HEADERS_DIR}/Console.h")
set(CONSOLE_SOURCES "${SOURCES_DIR}/Console/Console.c")

set(FRAMEWORK_DIR "${SOURCES_DIR}/Framework")
set(FRAMEWORK_HEADERS "${HEADERS_DIR}/CUError.h"
"${HEADERS_DIR}/MyMem.h"
"${HEADERS_DIR}/TestDB.h"
"${HEADERS_DIR}/TestRun.h"
"${HEADERS_DIR}/Util.h"
"${HEADERS_DIR}/CUnit_intl.h"
"${CMAKE_CURRENT_BINARY_DIR}/CUnit.h")
set(FRAMEWORK_SOURCES "${FRAMEWORK_DIR}/CUError.c"
"${FRAMEWORK_DIR}/MyMem.c"
"${FRAMEWORK_DIR}/TestDB.c"
"${FRAMEWORK_DIR}/TestRun.c"
"${FRAMEWORK_DIR}/Util.c")

add_library(
cunit
${BASIC_HEADERS}
${BASIC_SOURCES}
${AUTOMATED_HEADERS}
${AUTOMATED_SOURCES}
${CONSOLE_HEADERS}
${CONSOLE_SOURCES}
${FRAMEWORK_HEADERS}
${FRAMEWORK_SOURCES})

target_include_directories(
cunit
PRIVATE
"${HEADERS_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}")

# Install target
install(
TARGETS
cunit
ARCHIVE DESTINATION
lib
LIBRARY DESTINATION
lib
RUNTIME DESTINATION
lib
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ GROUP_WRITE
WORLD_READ)

install(
FILES
$<TARGET_PDB_FILE:cunit>
DESTINATION
bin
OPTIONAL)

install(
FILES
${BASIC_HEADERS}
${AUTOMATED_HEADERS}
${CONSOLE_HEADERS}
${FRAMEWORK_HEADERS}
DESTINATION
include/CUnit)

19 changes: 19 additions & 0 deletions package/cunit/build/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2017 - 2018 ADLINK Technology Limited

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
13 changes: 13 additions & 0 deletions package/cunit/build/snprintf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- source_subfolder/CUnit/Headers/CUnit.h.in 2014-04-24 02:54:45.000000000 +0200
+++ source_subfolder/CUnit/Headers/CUnit.h.in.patched 2018-06-22 18:21:11.755600964 +0200
@@ -102,7 +102,9 @@
# define CU_EXPORT
# endif
# ifdef _MSC_VER
-# define snprintf _snprintf
+# if _MSC_VER < 1900
+# define snprintf _snprintf
+# endif
# endif
#else
# define CU_EXPORT
60 changes: 60 additions & 0 deletions package/cunit/cunit.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Read this before creating packages: https://chocolatey.org/docs/create-packages -->
<!-- It is especially important to read the above link to understand additional requirements when publishing packages to the community feed aka dot org (https://chocolatey.org/packages). -->

<!-- Test your packages in a test environment: https://github.com/chocolatey/chocolatey-test-environment -->

<!--
This is a nuspec. It mostly adheres to https://docs.nuget.org/create/Nuspec-Reference. Chocolatey uses a special version of NuGet.Core that allows us to do more than was initially possible. As such there are certain things to be aware of:
* the package xmlns schema url may cause issues with nuget.exe
* Any of the following elements can ONLY be used by choco tools - projectSourceUrl, docsUrl, mailingListUrl, bugTrackerUrl, packageSourceUrl, provides, conflicts, replaces
* nuget.exe can still install packages with those elements but they are ignored. Any authoring tools or commands will error on those elements
-->

<!-- You can embed software files directly into packages, as long as you are not bound by distribution rights. -->
<!-- * If you are an organization making private packages, you probably have no issues here -->
<!-- * If you are releasing to the community feed, you need to consider distribution rights. -->
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<!-- == PACKAGE SPECIFIC SECTION == -->
<!-- This section is about this package, although id and version have ties back to the software -->
<!-- id is lowercase and if you want a good separator for words, use '-', not '.'. Dots are only acceptable as suffixes for certain types of packages, e.g. .install, .portable, .extension, .template -->
<!-- If the software is cross-platform, attempt to use the same id as the debian/rpm package(s) if possible. -->
<id>cunit</id>
<!-- version should MATCH as closely as possible with the underlying software -->
<!-- Is the version a prerelease of a version? https://docs.nuget.org/create/versioning#creating-prerelease-packages -->
<!-- Note that unstable versions like 0.0.1 can be considered a released version, but it's possible that one can release a 0.0.1-beta before you release a 0.0.1 version. If the version number is final, that is considered a released version and not a prerelease. -->
<version>2.1.3</version>
<packageSourceUrl>https://github.com/ros2/choco-packages/tree/latest/package/cunit</packageSourceUrl>
<owners>Scott K Logan</owners>
<!-- ============================== -->

<!-- == SOFTWARE SPECIFIC SECTION == -->
<!-- This section is about the software itself -->
<title>CUnit</title>
<authors>anilsaharan, jdpipe, tlh2000</authors>
<!-- projectUrl is required for the community feed -->
<projectUrl>https://sourceforge.net/projects/cunit/</projectUrl>
<!-- If there is a license Url available, it is is required for the community feed -->
<licenseUrl>https://sourceforge.net/p/cunit/code/HEAD/tree/trunk/COPYING</licenseUrl>
<tags>cunit</tags>
<summary>Automated testing framework for 'C'.</summary>
<description>
The basic framework is platform/version independent and should be
portable to all platforms. CUnit provides various interfaces to
the framework, some of which are platform dependent (e.g. curses on
*nix). Building other interfaces should be straightforward with
the facilities provided in the framework.
</description>
</metadata>
<files>
<!-- this section controls what actually gets packaged into the Chocolatey package -->
<file src="tools\**" target="tools" />
<file src="include\**" target="include" />
<file src="lib\**" target="lib" />
<file src="share\**" target="share" />
<!--Building from Linux? You may need this instead: <file src="tools/**" target="tools" />-->
</files>
</package>
Empty file added package/cunit/include/.gitkeep
Empty file.
Empty file added package/cunit/lib/.gitkeep
Empty file.
11 changes: 11 additions & 0 deletions package/cunit/share/cmake/CUnitConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
get_filename_component(_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE)
set(CUnit_INCLUDE_DIRS "${_PREFIX}/include")
set(CUnit_LIBRARIES "${_PREFIX}/lib/cunit.lib")

# Compatibility with nonstandard and legacy package variable expectations.
set(CUnit_INCLUDE_DIR "${CUnit_INCLUDE_DIRS}")
set(CUNIT_INCLUDE_DIRS "${CUnit_INCLUDE_DIRS}")
set(CUNIT_INCLUDE_DIR "${CUnit_INCLUDE_DIRS}")
set(CUnit_LIBRARY "${CUnit_LIBRARIES}")
set(CUNIT_LIBRARIES "${CUnit_LIBRARIES}")
set(CUNIT_LIBRARY "${CUnit_LIBRARIES}")
9 changes: 9 additions & 0 deletions package/cunit/share/cmake/CUnitConfigVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(PACKAGE_VERSION "2.1")
set(PACKAGE_VERSION_MAJOR 2)
set(PACKAGE_VERSION_MINOR 1)

if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
endif()
Loading

0 comments on commit 620f9e3

Please sign in to comment.