From 90563bd4e3643e8c758257b248af8aef762efa22 Mon Sep 17 00:00:00 2001 From: Philip Top Date: Sat, 4 May 2024 15:35:31 -0700 Subject: [PATCH 1/5] Add some additional builders with newer compilers --- azure-pipelines.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f81b83e3..3903e9c0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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 @@ -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 From d95f4f6bb3a003f6ff6852a67124974219349162 Mon Sep 17 00:00:00 2001 From: Philip Top Date: Sun, 5 May 2024 05:49:19 -0700 Subject: [PATCH 2/5] clean up some compiler warnings --- units/commodity_definitions.hpp | 13 +++++++++---- units/r20_conv.cpp | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/units/commodity_definitions.hpp b/units/commodity_definitions.hpp index 8e3d1cc4..5c17220e 100644 --- a/units/commodity_definitions.hpp +++ b/units/commodity_definitions.hpp @@ -42,7 +42,7 @@ namespace commodities { template 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(code[0] - '_') & 0X1FU) << 20U) + ((static_cast(code[1] - '_') & 0X1FU) << 15U) + @@ -54,7 +54,7 @@ namespace commodities { template 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(code[0] - '@') & 0X1FU) << 20U) + ((static_cast(code[1] - '@') & 0X1FU) << 15U) + @@ -91,7 +91,7 @@ namespace commodities { template 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(code[0]) << 16U) + (static_cast(code[1]) << 8U) + static_cast(code[2]); @@ -100,7 +100,7 @@ namespace commodities { template 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(code[0] - ' ') & 0X3FU) << 18U) + ((static_cast(code[1] - ' ') & 0X3FU) << 12U) + @@ -516,6 +516,11 @@ 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 diff --git a/units/r20_conv.cpp b/units/r20_conv.cpp index fde2991a..4b05c5f7 100644 --- a/units/r20_conv.cpp +++ b/units/r20_conv.cpp @@ -1973,7 +1973,7 @@ 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", @@ -1991,7 +1991,7 @@ 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", @@ -2146,7 +2146,7 @@ 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{ @@ -2764,16 +2764,16 @@ 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}}, @@ -2836,14 +2836,14 @@ 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}, @@ -2934,7 +2934,7 @@ 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}}, From 65d4a2309e0f786b3bbd2d79cdf332766b3e8f23 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 5 May 2024 12:49:45 +0000 Subject: [PATCH 3/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- units/commodity_definitions.hpp | 5 +++-- units/r20_conv.cpp | 36 +++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/units/commodity_definitions.hpp b/units/commodity_definitions.hpp index 5c17220e..3662b97c 100644 --- a/units/commodity_definitions.hpp +++ b/units/commodity_definitions.hpp @@ -517,9 +517,10 @@ namespace commodities { choline_chloride = generateHarmonizedCode(29, 23, 10), }; - constexpr std::uint32_t package(std::uint32_t packaging, std::uint32_t commodity) + constexpr std::uint32_t + package(std::uint32_t packaging, std::uint32_t commodity) { - return packaging|commodity; + return packaging | commodity; } } // namespace commodities diff --git a/units/r20_conv.cpp b/units/r20_conv.cpp index 4b05c5f7..e0eb1da9 100644 --- a/units/r20_conv.cpp +++ b/units/r20_conv.cpp @@ -1973,7 +1973,11 @@ namespace precise { unitD{ "KLK", "lactic dry material percentage", - {1.0, percent, commodities::package(commodities::packaging::dry,commodities::milk)}}, + {1.0, + percent, + commodities::package( + commodities::packaging::dry, + commodities::milk)}}, unitD{"KLX", "kilolux", kilo* lux}, unitD{ "KMA", @@ -1991,7 +1995,9 @@ namespace precise { "milliequivalence caustic potash per gram of product", {1.0, milli / g, - commodities::package(commodities::packaging::equivalent,commodities::chemicals::KOH)}}, + commodities::package( + commodities::packaging::equivalent, + commodities::chemicals::KOH)}}, unitD{"KPA", "kilopascal", kilo* Pa}, unitD{ "KPH", @@ -2146,7 +2152,9 @@ namespace precise { "lactose excess percentage", {1.0, percent, - commodities::package(commodities::packaging::excess,commodities::lactose)}}, + commodities::package( + commodities::packaging::excess, + commodities::lactose)}}, unitD{"LBR", "pound", lb}, unitD{"LBT", "troy pound (US)", troy::pound}, unitD{ @@ -2764,7 +2772,8 @@ namespace precise { "proof litre", {1.0, L, - commodities::package(commodities::packaging::equivalent, + commodities::package( + commodities::packaging::equivalent, commodities::chemicals::alcohol)}}, unitD{"PG", "plate", {1.0, count, commodities::packaging::plate}}, unitD{ @@ -2772,7 +2781,8 @@ namespace precise { "proof gallon", {1.0, gal, - commodities::package(commodities::packaging::equivalent, + 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}}, @@ -2836,14 +2846,22 @@ namespace precise { unitD{ "QB", "page - hardcopy", - {1.0, count, commodities::package(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::package(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}, @@ -2934,7 +2952,9 @@ namespace precise { "stick, cigarette", {1.0, count, - commodities::package(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}}, From 02156a44c0ee2a44f20cfccb875e74ba5135e416 Mon Sep 17 00:00:00 2001 From: Philip Top Date: Tue, 7 May 2024 06:58:49 -0700 Subject: [PATCH 4/5] update cmake builds --- .github/workflows/tests.yml | 6 ++++++ CMakeLists.txt | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8c4088b5..4830bcbb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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() \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d3334bd..83238388 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,15 +5,16 @@ # 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) From bc594e84134cc77536654ad8b244c2e6b1d8c1b1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 May 2024 13:59:38 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 83238388..b02de677 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,12 +5,10 @@ # SPDX-License-Identifier: BSD-3-Clause # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - # 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_GREATER 3.20) +if(${CMAKE_VERSION} VERSION_GREATER 3.20) cmake_minimum_required(VERSION 3.20...3.28) else() cmake_minimum_required(VERSION 3.0)