Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new builders #336

Merged
merged 6 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,10 @@ jobs:
uses: ./.github/actions/quick_cmake
with:
cmake-version: "3.27"
if: success() || failure()

- name: Check CMake 3.28
uses: ./.github/actions/quick_cmake
with:
cmake-version: "3.28"
if: success() || failure()
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
# SPDX-License-Identifier: BSD-3-Clause
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cmake_minimum_required(VERSION 3.0)

# Make sure users don't get warnings on a tested (3.0 to 3.27) version of CMake. For
# most of the policies, the new version is better (hence the change). We don't use the
# 3.0...3.17 syntax because of a bug in an older MSVC's built-in and modified CMake 3.11
if(${CMAKE_VERSION} VERSION_LESS 3.27)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
if(${CMAKE_VERSION} VERSION_GREATER 3.20)
cmake_minimum_required(VERSION 3.20...3.28)
else()
cmake_policy(VERSION 3.27)
cmake_minimum_required(VERSION 3.0)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()

if(NOT UNITS_CMAKE_PROJECT_NAME)
Expand Down
11 changes: 11 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ jobs:
gcc12:
containerImage: gcc:12
units.std: 20
gcc13:
containerImage: gcc:13
units.std: 20
container: $[ variables['containerImage'] ]
steps:
- template: .ci/azure-cmake.yml
Expand Down Expand Up @@ -132,6 +135,14 @@ jobs:
containerImage: helics/buildenv:clang14-builder
units.std: 20
units.options: -DUNITS_FORCE_LIBCXX=ON -DCMAKE_CXX_FLAGS=-std=c++20
clang16_20:
containerImage: helics/buildenv:clang16-builder
units.std: 20
units.options: -DUNITS_FORCE_LIBCXX=ON -DCMAKE_CXX_FLAGS=-std=c++20
clang18_23:
containerImage: helics/buildenv:clang18-builder
units.std: 23
units.options: -DUNITS_FORCE_LIBCXX=ON -DCMAKE_CXX_FLAGS=-std=c++23
container: $[ variables['containerImage'] ]
steps:
- template: .ci/azure-build.yml
Expand Down
14 changes: 10 additions & 4 deletions units/commodity_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace commodities {
template<size_t N>
constexpr std::uint32_t generateStringCode(const char (&code)[N])
{
static_assert(N == 6, "invalid string code");
static_assert(N == 6, "invalid string code, must be 5 characters");
return 0x60000000U +
((static_cast<std::uint32_t>(code[0] - '_') & 0X1FU) << 20U) +
((static_cast<std::uint32_t>(code[1] - '_') & 0X1FU) << 15U) +
Expand All @@ -54,7 +54,7 @@ namespace commodities {
template<size_t N>
constexpr std::uint32_t generateStringCodeUpper(const char (&code)[N])
{
static_assert(N == 6, "invalid string code");
static_assert(N == 6, "invalid string code, must be 5 characters");
return 0x70000000U +
((static_cast<std::uint32_t>(code[0] - '@') & 0X1FU) << 20U) +
((static_cast<std::uint32_t>(code[1] - '@') & 0X1FU) << 15U) +
Expand Down Expand Up @@ -91,7 +91,7 @@ namespace commodities {
template<size_t N>
constexpr std::uint32_t generateCurrencyCode(const char (&code)[N])
{
static_assert(N == 4, "invalid string code");
static_assert(N == 4, "invalid currency code, must be 3 characters");
return 0x46000000U + (static_cast<std::uint32_t>(code[0]) << 16U) +
(static_cast<std::uint32_t>(code[1]) << 8U) +
static_cast<std::uint32_t>(code[2]);
Expand All @@ -100,7 +100,7 @@ namespace commodities {
template<size_t N>
constexpr std::uint32_t generateChemCode(const char (&code)[N])
{
static_assert(N == 5, "invalid string code");
static_assert(N == 5, "invalid chem code must be 4 characters");
return 0x4D000000U +
((static_cast<std::uint32_t>(code[0] - ' ') & 0X3FU) << 18U) +
((static_cast<std::uint32_t>(code[1] - ' ') & 0X3FU) << 12U) +
Expand Down Expand Up @@ -516,6 +516,12 @@ namespace commodities {
alcohol = generateHarmonizedCode(22, 07, 10),
choline_chloride = generateHarmonizedCode(29, 23, 10),
};

constexpr std::uint32_t
package(std::uint32_t packaging, std::uint32_t commodity)
{
return packaging | commodity;
}
} // namespace commodities

} // namespace UNITS_NAMESPACE
40 changes: 30 additions & 10 deletions units/r20_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,11 @@ namespace precise {
unitD{
"KLK",
"lactic dry material percentage",
{1.0, percent, commodities::packaging::dry + commodities::milk}},
{1.0,
percent,
commodities::package(
commodities::packaging::dry,
commodities::milk)}},
unitD{"KLX", "kilolux", kilo* lux},
unitD{
"KMA",
Expand All @@ -1991,7 +1995,9 @@ namespace precise {
"milliequivalence caustic potash per gram of product",
{1.0,
milli / g,
commodities::packaging::equivalent + commodities::chemicals::KOH}},
commodities::package(
commodities::packaging::equivalent,
commodities::chemicals::KOH)}},
unitD{"KPA", "kilopascal", kilo* Pa},
unitD{
"KPH",
Expand Down Expand Up @@ -2146,7 +2152,9 @@ namespace precise {
"lactose excess percentage",
{1.0,
percent,
commodities::packaging::excess + commodities::lactose}},
commodities::package(
commodities::packaging::excess,
commodities::lactose)}},
unitD{"LBR", "pound", lb},
unitD{"LBT", "troy pound (US)", troy::pound},
unitD{
Expand Down Expand Up @@ -2764,16 +2772,18 @@ namespace precise {
"proof litre",
{1.0,
L,
commodities::packaging::equivalent +
commodities::chemicals::alcohol}},
commodities::package(
commodities::packaging::equivalent,
commodities::chemicals::alcohol)}},
unitD{"PG", "plate", {1.0, count, commodities::packaging::plate}},
unitD{
"PGL",
"proof gallon",
{1.0,
gal,
commodities::packaging::equivalent +
commodities::chemicals::alcohol}},
commodities::package(
commodities::packaging::equivalent,
commodities::chemicals::alcohol)}},
unitD{"PI", "pitch", {1.0, count / in, commodities::character}},
unitD{"PK", "pack", {1.0, count, commodities::packaging::pack}},
unitD{"PL", "pail", {1.0, count, commodities::packaging::pail}},
Expand Down Expand Up @@ -2836,14 +2846,22 @@ namespace precise {
unitD{
"QB",
"page - hardcopy",
{1.0, count, commodities::packaging::page + commodities::paper}},
{1.0,
count,
commodities::package(
commodities::packaging::page,
commodities::paper)}},
unitD{"QD", "quarter dozen", {3, one}},
unitD{"QH", "quarter hour", {0.25, hr}},
unitD{"QK", "quarter kilogram", {0.25, kg}},
unitD{
"QR",
"quire",
{25.0, count, commodities::packaging::sheet + commodities::paper}},
{25.0,
count,
commodities::package(
commodities::packaging::sheet,
commodities::paper)}},
unitD{"QT", "quart (US)", us::quart},
unitD{"QTD", "dry quart (US)", us::dry::quart},
unitD{"QTI", "quart (UK)", imp::quart},
Expand Down Expand Up @@ -2934,7 +2952,9 @@ namespace precise {
"stick, cigarette",
{1.0,
count,
commodities::packaging::stick + commodities::cigarette}},
commodities::package(
commodities::packaging::stick,
commodities::cigarette)}},
unitD{"STL", "standard litre", L},
unitD{"STN", "ton (US)", av::ton},
unitD{"STW", "straw", {1.0, count, commodities::packaging::straw}},
Expand Down
Loading