diff --git a/build2/kram.xcodeproj/project.pbxproj b/build2/kram.xcodeproj/project.pbxproj index d86559b..2b30d68 100644 --- a/build2/kram.xcodeproj/project.pbxproj +++ b/build2/kram.xcodeproj/project.pbxproj @@ -659,7 +659,6 @@ 706EEE1A26D1583F001C950E /* KramTimer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = KramTimer.cpp; sourceTree = ""; }; 706EEE1B26D1583F001C950E /* KTXImage.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = KTXImage.cpp; sourceTree = ""; }; 706EEE1C26D1583F001C950E /* KramMipper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = KramMipper.cpp; sourceTree = ""; }; - 706EEE1D26D1583F001C950E /* _clang-format */ = {isa = PBXFileReference; lastKnownFileType = text; path = "_clang-format"; sourceTree = ""; }; 706EEE1E26D1583F001C950E /* KramZipHelper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = KramZipHelper.cpp; sourceTree = ""; }; 706EEE1F26D1583F001C950E /* TaskSystem.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TaskSystem.cpp; sourceTree = ""; }; 706EEE2026D1583F001C950E /* KramSDFMipper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KramSDFMipper.h; sourceTree = ""; }; @@ -1219,7 +1218,6 @@ 70D222DC2AD2132300B9EA23 /* ImmutableString.cpp */, 706EEE3826D1583F001C950E /* TaskSystem.h */, 706EEE1F26D1583F001C950E /* TaskSystem.cpp */, - 706EEE1D26D1583F001C950E /* _clang-format */, ); path = kram; sourceTree = ""; diff --git a/kram-preview/kram_preview.entitlements b/kram-preview/kram_preview.entitlements index f2ef3ae..311b32b 100644 --- a/kram-preview/kram_preview.entitlements +++ b/kram-preview/kram_preview.entitlements @@ -2,9 +2,9 @@ - com.apple.security.app-sandbox - - com.apple.security.files.user-selected.read-only - + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + diff --git a/kram-thumb/kram_thumb.entitlements b/kram-thumb/kram_thumb.entitlements index f2ef3ae..311b32b 100644 --- a/kram-thumb/kram_thumb.entitlements +++ b/kram-thumb/kram_thumb.entitlements @@ -2,9 +2,9 @@ - com.apple.security.app-sandbox - - com.apple.security.files.user-selected.read-only - + com.apple.security.app-sandbox + + com.apple.security.files.user-selected.read-only + diff --git a/libkram/kram/KTXImage.cpp b/libkram/kram/KTXImage.cpp index d263984..c1ddb1a 100644 --- a/libkram/kram/KTXImage.cpp +++ b/libkram/kram/KTXImage.cpp @@ -17,7 +17,7 @@ #include "zstd.h" #ifndef USE_LIBCOMPRESSION -#define USE_LIBCOMPRESSION 0 // (KRAM_MAC || KRAM_IOS || KRAM_VISION) +#define USE_LIBCOMPRESSION 0 // KRAM_APPLE #endif #if USE_LIBCOMPRESSION diff --git a/libkram/kram/Kram.cpp b/libkram/kram/Kram.cpp index 5630915..9b02f33 100644 --- a/libkram/kram/Kram.cpp +++ b/libkram/kram/Kram.cpp @@ -28,7 +28,7 @@ #include "miniz.h" #ifndef USE_LIBCOMPRESSION -#define USE_LIBCOMPRESSION 0 // (KRAM_MAC || KRAM_IOS || KRAM_VISION) +#define USE_LIBCOMPRESSION 0 // KRAM_APPLE #endif #if USE_LIBCOMPRESSION diff --git a/libkram/kram/KramConfig.h b/libkram/kram/KramConfig.h index 1a12e39..3077183 100644 --- a/libkram/kram/KramConfig.h +++ b/libkram/kram/KramConfig.h @@ -46,6 +46,10 @@ #define KRAM_DEBUG 1 #endif +// Don't really need 3 libs. This means can build one +// but can't use availability or platforms specifics then. +#define KRAM_APPLE (KRAM_MAC || KRAM_IOS || KRAM_VISION) + //------------------------ #if KRAM_WIN @@ -80,7 +84,7 @@ // SIMD_WORKSPACE is set // can't have ATE defined to 1 on other platforms -#if !(KRAM_MAC || KRAM_IOS) // || KRAM_VISION +#if !KRAM_APPLE #undef COMPILE_ATE #endif @@ -192,7 +196,7 @@ //------------------------- // simd -#if KRAM_MAC || KRAM_IOS || KRAM_VISION +#if KRAM_APPLE // can use old or new #define USE_SIMDLIB 1 diff --git a/libkram/kram/KramFileHelper.cpp b/libkram/kram/KramFileHelper.cpp index 4896e47..b6d4373 100644 --- a/libkram/kram/KramFileHelper.cpp +++ b/libkram/kram/KramFileHelper.cpp @@ -15,7 +15,7 @@ #include "tmpfileplus.h" -#if KRAM_MAC || KRAM_IOS || KRAM_VISION || KRAM_LINUX +#if KRAM_APPLE || KRAM_LINUX #include // for getpagesize() #endif @@ -124,7 +124,7 @@ size_t FileHelper::pagesize() { static size_t pagesize = 0; if (pagesize == 0) { -#if KRAM_MAC || KRAM_IOS || KRAM_VISION || KRAM_LINUX +#if KRAM_APPLE || KRAM_LINUX pagesize = getpagesize(); #elif KRAM_WIN // win has mostly 4k, then 1MB/2MB large page size diff --git a/libkram/kram/KramFmt.h b/libkram/kram/KramFmt.h index 7ca16df..a43f5ca 100644 --- a/libkram/kram/KramFmt.h +++ b/libkram/kram/KramFmt.h @@ -2,7 +2,7 @@ // The license and copyright notice shall be included // in all copies or substantial portions of the Software. -#if !KRAM_VISION // this is breaking link on visionOS +#if 1 // !KRAM_VISION // this is breaking link on visionOS #pragma once diff --git a/libkram/kram/KramLog.cpp b/libkram/kram/KramLog.cpp index bcb56c6..2f688df 100644 --- a/libkram/kram/KramLog.cpp +++ b/libkram/kram/KramLog.cpp @@ -6,7 +6,7 @@ //#include -#if KRAM_MAC || KRAM_IOS || KRAM_VISION +#if KRAM_APPLE #define KRAM_LOG_STACKTRACE KRAM_DEBUG #elif KRAM_WIN // TODO: need to debug code before enabling @@ -33,7 +33,7 @@ #elif KRAM_ANDROID #include -#elif KRAM_MAC || KRAM_IOS || KRAM_VISION +#elif KRAM_APPLE #include // demangle #include // address to symbol #include @@ -44,9 +44,9 @@ #include "KramTimer.h" #include "TaskSystem.h" -#if !KRAM_VISION // this is breaking link on visionOS +//#if !KRAM_VISION // this is breaking link on visionOS #include "format.h" // really fmt/format.h -#endif +//#endif namespace kram { @@ -442,7 +442,7 @@ string format(const char* format, ...) //---------------------------------- -#if !KRAM_VISION // this is breaking link on visionOS +#if 1 // !KRAM_VISION // this is breaking link on visionOS static size_t my_formatted_size(fmt::string_view format, fmt::format_args args) { @@ -929,7 +929,7 @@ static int32_t logMessageImpl(const LogMessage& msg) __android_log_write_log_message(msg); #else -#if KRAM_MAC || KRAM_IOS || KRAM_VISION +#if KRAM_APPLE // test os_log static bool useOSLog = true; @@ -990,7 +990,7 @@ int32_t logMessage(const char* group, int32_t logLevel, void* dso = nullptr; void* logAddress = nullptr; -#if KRAM_MAC || KRAM_IOS || KRAM_VISION +#if KRAM_APPLE dso = &__dso_handle; // may need to come from call site for the mach_header of .o logAddress = __builtin_return_address(0); // or __builtin_frame_address(0)) #elif KRAM_WIN @@ -1050,7 +1050,7 @@ int32_t logMessage(const char* group, int32_t logLevel, // to have full source to impl to fix things in fmt. // https://fmt.dev/latest/api.html#_CPPv4IDpEN3fmt14formatted_sizeE6size_t13format_stringIDp1TEDpRR1T -#if !KRAM_VISION // exceptions causing this not to link +#if 1 // !KRAM_VISION // exceptions causing this not to link // TODO: can this use STL_NAMESPACE::string_view instead ? int32_t logMessage(const char* group, int32_t logLevel, @@ -1060,7 +1060,7 @@ int32_t logMessage(const char* group, int32_t logLevel, // TODO: size_t size = std::formatted_size(format, args); // and then reserve that space in str. Use that for impl of append_format. // can then append to existing string (see vsprintf) -#if KRAM_MAC || KRAM_IOS || KRAM_VISION +#if KRAM_APPLE void* dso = &__dso_handle; void* logAddress = __builtin_return_address(0); // or __builtin_frame_address(0)) #else diff --git a/libkram/kram/KramMmapHelper.cpp b/libkram/kram/KramMmapHelper.cpp index 5805925..b32ad5f 100644 --- a/libkram/kram/KramMmapHelper.cpp +++ b/libkram/kram/KramMmapHelper.cpp @@ -10,7 +10,7 @@ #include #include -#if KRAM_MAC || KRAM_IOS || KRAM_VISION || KRAM_LINUX +#if KRAM_APPLE || KRAM_LINUX #include #include #elif KRAM_WIN @@ -56,7 +56,7 @@ bool MmapHelper::open(const char *filename) // need Windows equilvent of getpagesize() call before putting this back. This was to use // with MTLBuffer no copy which has a strict page alignment requirement on start and size. // - //#if KRAM_MAC || KRAM_LINUX || KRAM_IOS + //#if KRAM_APPLE || KRAM_LINUX // // pad it out to the page size (this can be 4k or 16k) // // need this alignment, or it can't be converted to a MTLBuffer // size_t pageSize = FileHelper::pagesize(); diff --git a/libkram/kram/KramTimer.cpp b/libkram/kram/KramTimer.cpp index f91103e..f8e5f96 100644 --- a/libkram/kram/KramTimer.cpp +++ b/libkram/kram/KramTimer.cpp @@ -8,7 +8,7 @@ #if KRAM_WIN #include -#elif KRAM_MAC || KRAM_IOS || KRAM_VISION +#elif KRAM_APPLE #include #elif KRAM_ANDROID #include @@ -38,7 +38,7 @@ static uint64_t queryCounter() return counter.QuadPart; }; -#elif KRAM_MAC || KRAM_IOS || KRAM_VISION +#elif KRAM_APPLE static double queryPeriod() { diff --git a/libkram/kram/KramZipHelper.cpp b/libkram/kram/KramZipHelper.cpp index d986476..d614f1c 100644 --- a/libkram/kram/KramZipHelper.cpp +++ b/libkram/kram/KramZipHelper.cpp @@ -11,7 +11,7 @@ // libcompress can only encode lvl 5, but here it's only decompress. // This is failing on various ktx2 files in the mac archive #ifndef USE_LIBCOMPRESSION -#define USE_LIBCOMPRESSION 0 // (KRAM_MAC || KRAM_IOS || KRAM_VISION) +#define USE_LIBCOMPRESSION 0 // KRAM_APPLE #endif #if USE_LIBCOMPRESSION diff --git a/libkram/kram/TaskSystem.cpp b/libkram/kram/TaskSystem.cpp index 3ebd7f9..c783dbd 100644 --- a/libkram/kram/TaskSystem.cpp +++ b/libkram/kram/TaskSystem.cpp @@ -1,17 +1,18 @@ #include "TaskSystem.h" -#if KRAM_MAC +// Stop using this, so can have unified kram lib +//#if KRAM_MAC // affinity -#include -#include +//#include +//#include +//#endif + +#if KRAM_APPLE #include #include #include -#elif KRAM_IOS || KRAM_VISION -#include -#include #elif KRAM_WIN -// annoying thata windows.h has to be ordered first +// annoying that windows.h has to be ordered first // clang-format off #include // clang-format off @@ -86,7 +87,7 @@ static const CoreInfo& GetCoreInfo() coreInfo.logicalCoreCount = std::thread::hardware_concurrency(); coreInfo.physicalCoreCount = coreInfo.logicalCoreCount; -#if KRAM_MAC || KRAM_IOS || KRAM_VISION +#if KRAM_APPLE // get big/little core counts // use sysctl -a from command line to see all size_t size = sizeof(coreInfo.bigCoreCount); @@ -319,7 +320,7 @@ void getThreadName(std::thread::native_handle_type threadHandle, char name[kMaxT void setCurrentThreadName(const char* threadName) { -#if KRAM_MAC || KRAM_IOS || KRAM_VISION +#if KRAM_APPLE // can only set thread from thread on macOS, sucks int val = pthread_setname_np(threadName); #else @@ -350,7 +351,7 @@ void getCurrentThreadName(char name[kMaxThreadName]) //------------------ -#if KRAM_MAC || KRAM_IOS || KRAM_VISION +#if KRAM_APPLE static void setThreadPriority(std::thread::native_handle_type handle, ThreadPriority priority) { @@ -487,7 +488,7 @@ static void setThreadAffinity(std::thread::native_handle_type handle, uint32_t t bool success = false; -#if KRAM_MAC || KRAM_IOS || KRAM_VISION +#if KRAM_APPLE // no support, don't use thread_policy_set it's not on M1 and just a hint success = true; @@ -622,7 +623,7 @@ static ThreadPriority getThreadPriority(std::thread::native_handle_type handle) { ThreadPriority priority = ThreadPriority::Default; -#if KRAM_MAC || KRAM_IOS || KRAM_VISION || KRAM_ANDROID +#if KRAM_APPLE || KRAM_ANDROID // Note: this doesn't handle qOS, and returns default priority // on those threads. diff --git a/scripts/cibuild.sh b/scripts/cibuild.sh index 0b89a4f..e9ea14f 100755 --- a/scripts/cibuild.sh +++ b/scripts/cibuild.sh @@ -75,14 +75,24 @@ if [[ $buildType == macos ]]; then xcodebuild build -workspace kram.xcworkspace -list echo "::endgroup::" + # vectormath + echo "::group::vectormath-vos" + xcodebuild build -sdk xros2.0 -workspace kram.xcworkspace -scheme vectormath-vos -configuration Release ${xargs} -destination generic/platform=visionOS CONFIGURATION_BUILD_DIR=${binPath} BUILD_LIBRARY_FOR_DISTRIBUTION=YES + echo "::endgroup::" + echo "::group::vectormath-ios" xcodebuild build -sdk iphoneos -workspace kram.xcworkspace -scheme vectormath-ios -configuration Release ${xargs} -destination generic/platform=iOS CONFIGURATION_BUILD_DIR=${binPath} BUILD_LIBRARY_FOR_DISTRIBUTION=YES echo "::endgroup::" echo "::group::vectormath" - xcodebuild build -sdk iphoneos -workspace kram.xcworkspace -scheme vectormath -configuration Release ${xargs} -destination generic/platform=macOS CONFIGURATION_BUILD_DIR=${binPath} BUILD_LIBRARY_FOR_DISTRIBUTION=YES + xcodebuild build -sdk macosx -workspace kram.xcworkspace -scheme vectormath -configuration Release ${xargs} -destination generic/platform=macOS CONFIGURATION_BUILD_DIR=${binPath} BUILD_LIBRARY_FOR_DISTRIBUTION=YES echo "::endgroup::" + # libkram + echo "::group::kram-vos" + xcodebuild build -sdk xros2.0 -workspace kram.xcworkspace -scheme kram-vos -configuration Release ${xargs} -destination generic/platform=visionOS CONFIGURATION_BUILD_DIR=${binPath} BUILD_LIBRARY_FOR_DISTRIBUTION=YES + echo "::endgroup::" + echo "::group::kram-ios" xcodebuild build -sdk iphoneos -workspace kram.xcworkspace -scheme kram-ios -configuration Release ${xargs} -destination generic/platform=iOS CONFIGURATION_BUILD_DIR=${binPath} BUILD_LIBRARY_FOR_DISTRIBUTION=YES echo "::endgroup::" @@ -93,24 +103,27 @@ if [[ $buildType == macos ]]; then # install apps so they are signed # can't specify empty INSTALL_PATH, or xcodebuild succeeds but copies nothing to bin + + # kramc cli echo "::group::kramc" xcodebuild install -sdk macosx -workspace kram.xcworkspace -scheme kramc -configuration Release ${xargs} -destination generic/platform=macOS DSTROOT=${binHolderPath} INSTALL_PATH=bin echo "::endgroup::" + # kramv viewer echo "::group::kramv" xcodebuild install -sdk macosx -workspace kram.xcworkspace -scheme kramv -configuration Release ${xargs} -destination generic/platform=macOS DSTROOT=${binHolderPath} INSTALL_PATH=bin echo "::endgroup::" popd - # build hlslparser to bin directory + # hlslparser pushd hlslparser echo "::group::hlsl-parser" xcodebuild install -sdk macosx -project hlslparser.xcodeproj -configuration Release ${xargs} -destination generic/platform=macOS DSTROOT=${binHolderPath} INSTALL_PATH=bin echo "::endgroup::" popd - # build kram-profile to bin directory + # kram-profile pushd kram-profile echo "::group::kram-profiler" xcodebuild install -sdk macosx -project kram-profile.xcodeproj -configuration Release ${xargs} -destination generic/platform=macOS DSTROOT=${binHolderPath} INSTALL_PATH=bin