Skip to content

Commit

Permalink
chore: fix platform specific build options
Browse files Browse the repository at this point in the history
  • Loading branch information
pnck committed May 2, 2024
1 parent 643df72 commit 0b0c5a3
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
env:
scheme: foo_input_ncm-${{ matrix.config }}
run: |
xcodebuild clean build -workspace ${{ matrix.workspace }} -scheme "$scheme" -configuration ${{ matrix.config }}
xcodebuild clean build -workspace ${{ matrix.workspace }} -scheme "$scheme" -configuration ${{ matrix.config }} -sdk macosx -mmacosx-version-min=13.3
if: matrix.os == 'macos-14'

- name: (MSBuild) Setup MSBuild
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ jobs:
working-directory: ${{ github.workspace }}/vendor/googletest
run: |
mkdir build
cd build && cmake -G Xcode ..
cd build && cmake -G Xcode cmake -DCMAKE_BUILD_TYPE=${{ matrix.config }} ..
- name: Build Tests
working-directory: ${{ github.workspace }}
run: |
xcodebuild clean build -workspace foo_input_ncm.xcworkspace -scheme foo_input_ncm_tests -configuration ${{ matrix.config }} -derivedDataPath .
xcodebuild clean build -workspace foo_input_ncm.xcworkspace -scheme foo_input_ncm_tests -configuration ${{ matrix.config }} -derivedDataPath .
- name: Run Tests
working-directory: ${{ github.workspace }}/Build/Products/${{ matrix.config }}
run: |
./foo_input_ncm_tests --gtest_repeat=10 --gtest_shuffle
./foo_input_ncm_tests --gtest_repeat=10 --gtest_shuffle
matrix-build:
name: Matrix Build
Expand Down Expand Up @@ -120,8 +120,8 @@ jobs:

- name: Versioning
run: |
TAG=$(git describe --tags)
VERSION=${TAG:1}
TAG=$(git describe --long --all)
VERSION=${TAG:6}
echo "#define CURRENT_VERSION $VERSION" >> src/stdafx.h
echo "----------------------------"
cat src/stdafx.h
Expand Down Expand Up @@ -150,7 +150,7 @@ jobs:
env:
scheme: foo_input_ncm-${{ matrix.config }}
run: |
xcodebuild clean build -workspace ${{ matrix.workspace }} -scheme "$scheme" -configuration ${{ matrix.config }}
xcodebuild clean build -workspace ${{ matrix.workspace }} -scheme "$scheme" -configuration ${{ matrix.config }} -sdk macosx -mmacosx-version-min=13.3
if: matrix.os == 'macos-14'

- name: (MSBuild) Setup MSBuild
Expand Down
8 changes: 4 additions & 4 deletions foo_input_ncm.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<AdditionalIncludeDirectories>src; vendor; vendor/sdk</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>src;vendor/spdlog/include;vendor/rapidjson/include;vendor/sdk;vendor/sdk/foobar2000</AdditionalIncludeDirectories>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
Expand All @@ -116,7 +116,7 @@
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<AdditionalIncludeDirectories>src; vendor; vendor/sdk</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>src;vendor/spdlog/include;vendor/rapidjson/include;vendor/sdk;vendor/sdk/foobar2000</AdditionalIncludeDirectories>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
Expand All @@ -140,7 +140,7 @@
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<AdditionalIncludeDirectories>src;vendor/spdlog/include;vendor/rapidjson/include;vendor/sdk</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>src;vendor/spdlog/include;vendor/rapidjson/include;vendor/sdk;vendor/sdk/foobar2000</AdditionalIncludeDirectories>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
Expand Down Expand Up @@ -168,7 +168,7 @@ copy $(TargetPath) $(ProjectDir)dist\$(Platform)\</Command>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<AdditionalIncludeDirectories>src; vendor; vendor/sdk</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>src;vendor/spdlog/include;vendor/rapidjson/include;vendor/sdk;vendor/sdk/foobar2000</AdditionalIncludeDirectories>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
Expand Down
2 changes: 1 addition & 1 deletion src/cipher/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace fb2k_ncm::cipher
explicit cipher_error(std::string reason, STATUS status) : std::runtime_error(""), status_(status), reason_(std::move(reason)) {
last_error_ = GetLastError();
std::stringstream err_ss;
msg_ = fmt::format("cipher runtime error because of [{}] \n Last Error: 0x{:08X}\n STATUS: 0x{:08X}",
msg_ = fmtlib::format("cipher runtime error because of [{}] \n Last Error: 0x{:08X}\n STATUS: 0x{:08X}",
reason_,
last_error_,
static_cast<uint32_t>(status_));
Expand Down
12 changes: 8 additions & 4 deletions src/common/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ typedef DWORD DWORD;
#define KEYSIZE_ERROR STATUS_INVALID_PARAMETER
#define COMMON_ERROR STATUS_UNSUCCESSFUL

#include <format>
namespace fmtlib = std;

#elif defined __APPLE__
#include <CommonCrypto/CommonCryptoError.h>
#include <cerrno>

// since we are using spdlog, we can use fmt::format instead of std::format,
// which is still unavailable (as of libc++15, within macos-14 github action runner)
#include "spdlog/fmt/fmt.h"
namespace fmtlib = fmt;

#if 0
namespace std
{
Expand All @@ -48,7 +56,3 @@ inline auto GetLastError() {
#define COMMON_ERROR kCCUnspecifiedError

#endif

// since we are using spdlog, we can use fmt::format instead of std::format,
// which is still unavailable (as of libc++15, within macos-14 github action runner)
#include "spdlog/fmt/bundled/format.h"
2 changes: 1 addition & 1 deletion src/ncm_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void ncm_file::parse(uint16_t to_parse /* = 0xff*/) {
uint64_t magic = 0;
source_->read(&magic, sizeof(uint64_t), p_abort);
if (magic != parsed_file_.magic) [[unlikely]] {
throw_format_error(fmt::format("magic number mismatch: {}", magic));
throw_format_error(fmtlib::format("magic number mismatch: {}", magic));
}

// skip gap
Expand Down
42 changes: 36 additions & 6 deletions test/unit/macos/foo_input_ncm_tests.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

/* Begin PBXBuildFile section */
A35F94992BE17E7100ABAABA /* test_crypto_functionality.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A35F94972BE17E7100ABAABA /* test_crypto_functionality.cpp */; };
A35F94BA2BE17F0B00ABAABA /* libgtest_main.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A35F94B82BE17F0300ABAABA /* libgtest_main.a */; };
A35F94BB2BE17F0B00ABAABA /* libgtest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A35F94B62BE17F0300ABAABA /* libgtest.a */; };
A35F94C32BE1813800ABAABA /* aes_common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A35F94C12BE1813800ABAABA /* aes_common.cpp */; };
A35F94C42BE1813800ABAABA /* aes_macos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A35F94C22BE1813800ABAABA /* aes_macos.cpp */; };
A35F94CE2BE31FBE00ABAABA /* libgtest_main.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A35F94B82BE17F0300ABAABA /* libgtest_main.a */; settings = {ATTRIBUTES = (Required, ); }; };
A35F94CF2BE31FBE00ABAABA /* libgtest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A35F94B62BE17F0300ABAABA /* libgtest.a */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -29,6 +29,20 @@
remoteGlobalIDString = 0687E84752724FAFBE8BF815;
remoteInfo = gtest_main;
};
A35F94D02BE3286000ABAABA /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A35F94AC2BE17F0300ABAABA /* googletest-distribution.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = BE4A6BB60264456AB04086C8;
remoteInfo = gtest;
};
A35F94D22BE3286000ABAABA /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A35F94AC2BE17F0300ABAABA /* googletest-distribution.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 4001D1E151AD4D3DB34BE895;
remoteInfo = gtest_main;
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -57,8 +71,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
A35F94BA2BE17F0B00ABAABA /* libgtest_main.a in Frameworks */,
A35F94BB2BE17F0B00ABAABA /* libgtest.a in Frameworks */,
A35F94CE2BE31FBE00ABAABA /* libgtest_main.a in Frameworks */,
A35F94CF2BE31FBE00ABAABA /* libgtest.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -116,6 +130,8 @@
buildRules = (
);
dependencies = (
A35F94D12BE3286000ABAABA /* PBXTargetDependency */,
A35F94D32BE3286000ABAABA /* PBXTargetDependency */,
);
name = foo_input_ncm_tests;
productName = foo_input_ncm_tests;
Expand Down Expand Up @@ -190,6 +206,19 @@
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
A35F94D12BE3286000ABAABA /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = gtest;
targetProxy = A35F94D02BE3286000ABAABA /* PBXContainerItemProxy */;
};
A35F94D32BE3286000ABAABA /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = gtest_main;
targetProxy = A35F94D22BE3286000ABAABA /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
A35F94862BE17DF500ABAABA /* Debug */ = {
isa = XCBuildConfiguration;
Expand Down Expand Up @@ -244,7 +273,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 13.3;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -299,9 +328,10 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 13.3;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand Down
2 changes: 1 addition & 1 deletion test/unit/macos/test_crypto_functionality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AESFuncitoalityTest : public ::testing::Test {

// random plain text
auto len = arc4random_uniform(128);
len = (len + 10) % 128;
len = (len % 128) + 10;
random_plain_.resize(len);
arc4random_buf(random_plain_.data(), random_plain_.size());
decltype(random_plain_) _end = {'E', 'N', 'D', 'O', 'F', 'P', 'L', 'A', 'I', 'N'};
Expand Down
12 changes: 6 additions & 6 deletions test/unit/win32/foo_input_ncm_tests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)src;$(SolutionDir)vendor/spdlog/include;$(SolutionDir)vendor/rapidjson/include;$(SolutionDir)vendor/sdk;$(SolutionDir)vendor/sdk/foobar2000;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
Expand All @@ -106,7 +106,7 @@
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)src;$(SolutionDir)vendor/spdlog/include;$(SolutionDir)vendor/rapidjson/include;$(SolutionDir)vendor/sdk;$(SolutionDir)vendor/sdk/foobar2000;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
Expand All @@ -129,7 +129,7 @@
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)src;$(SolutionDir)vendor/spdlog/include;$(SolutionDir)vendor/rapidjson/include;$(SolutionDir)vendor/sdk;$(SolutionDir)vendor/sdk/foobar2000;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
Expand All @@ -151,7 +151,7 @@
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)src;$(SolutionDir)vendor/spdlog/include;$(SolutionDir)vendor/rapidjson/include;$(SolutionDir)vendor/sdk;$(SolutionDir)vendor/sdk/foobar2000;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<LanguageStandard_C>stdc11</LanguageStandard_C>
Expand All @@ -174,7 +174,7 @@
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)src;$(SolutionDir)vendor/spdlog/include;$(SolutionDir)vendor/rapidjson/include;$(SolutionDir)vendor/sdk;$(SolutionDir)vendor/sdk/foobar2000;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<LanguageStandard_C>stdc11</LanguageStandard_C>
Expand All @@ -197,7 +197,7 @@
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>$(SolutionDir)src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)src;$(SolutionDir)vendor/spdlog/include;$(SolutionDir)vendor/rapidjson/include;$(SolutionDir)vendor/sdk;$(SolutionDir)vendor/sdk/foobar2000;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalOptions>/Zc:__cplusplus %(AdditionalOptions)</AdditionalOptions>
<LanguageStandard_C>stdc11</LanguageStandard_C>
Expand Down

0 comments on commit 0b0c5a3

Please sign in to comment.