Skip to content

Commit

Permalink
kram - builds - cleanup platform tests with KRAM_APPLE, add vos libs,…
Browse files Browse the repository at this point in the history
… turn off sandbox on preview/thumbnails

May be able to get away with just mac/ios libs.
The appex may poison files with sandbox enabled, and no signing.  So leave it off.  Will need to set that in signed builds only.
  • Loading branch information
alecazam committed Oct 17, 2024
1 parent db208e0 commit 8781eab
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 46 deletions.
2 changes: 0 additions & 2 deletions build2/kram.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,6 @@
706EEE1A26D1583F001C950E /* KramTimer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = KramTimer.cpp; sourceTree = "<group>"; };
706EEE1B26D1583F001C950E /* KTXImage.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = KTXImage.cpp; sourceTree = "<group>"; };
706EEE1C26D1583F001C950E /* KramMipper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = KramMipper.cpp; sourceTree = "<group>"; };
706EEE1D26D1583F001C950E /* _clang-format */ = {isa = PBXFileReference; lastKnownFileType = text; path = "_clang-format"; sourceTree = "<group>"; };
706EEE1E26D1583F001C950E /* KramZipHelper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = KramZipHelper.cpp; sourceTree = "<group>"; };
706EEE1F26D1583F001C950E /* TaskSystem.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TaskSystem.cpp; sourceTree = "<group>"; };
706EEE2026D1583F001C950E /* KramSDFMipper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KramSDFMipper.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1219,7 +1218,6 @@
70D222DC2AD2132300B9EA23 /* ImmutableString.cpp */,
706EEE3826D1583F001C950E /* TaskSystem.h */,
706EEE1F26D1583F001C950E /* TaskSystem.cpp */,
706EEE1D26D1583F001C950E /* _clang-format */,
);
path = kram;
sourceTree = "<group>";
Expand Down
8 changes: 4 additions & 4 deletions kram-preview/kram_preview.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<false/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
8 changes: 4 additions & 4 deletions kram-thumb/kram_thumb.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<false/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion libkram/kram/KTXImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libkram/kram/Kram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions libkram/kram/KramConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -192,7 +196,7 @@
//-------------------------
// simd

#if KRAM_MAC || KRAM_IOS || KRAM_VISION
#if KRAM_APPLE
// can use old or new
#define USE_SIMDLIB 1

Expand Down
4 changes: 2 additions & 2 deletions libkram/kram/KramFileHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "tmpfileplus.h"

#if KRAM_MAC || KRAM_IOS || KRAM_VISION || KRAM_LINUX
#if KRAM_APPLE || KRAM_LINUX
#include <unistd.h> // for getpagesize()
#endif

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libkram/kram/KramFmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions libkram/kram/KramLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

//#include <string>

#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
Expand All @@ -33,7 +33,7 @@
#elif KRAM_ANDROID
#include <log.h>

#elif KRAM_MAC || KRAM_IOS || KRAM_VISION
#elif KRAM_APPLE
#include <cxxabi.h> // demangle
#include <dlfcn.h> // address to symbol
#include <execinfo.h>
Expand All @@ -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 {

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libkram/kram/KramMmapHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <stdio.h>
#include <sys/stat.h>

#if KRAM_MAC || KRAM_IOS || KRAM_VISION || KRAM_LINUX
#if KRAM_APPLE || KRAM_LINUX
#include <sys/mman.h>
#include <unistd.h>
#elif KRAM_WIN
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions libkram/kram/KramTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#if KRAM_WIN
#include <windows.h>
#elif KRAM_MAC || KRAM_IOS || KRAM_VISION
#elif KRAM_APPLE
#include <mach/mach_time.h>
#elif KRAM_ANDROID
#include <trace.h>
Expand Down Expand Up @@ -38,7 +38,7 @@ static uint64_t queryCounter()
return counter.QuadPart;
};

#elif KRAM_MAC || KRAM_IOS || KRAM_VISION
#elif KRAM_APPLE

static double queryPeriod()
{
Expand Down
2 changes: 1 addition & 1 deletion libkram/kram/KramZipHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 13 additions & 12 deletions libkram/kram/TaskSystem.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#include "TaskSystem.h"

#if KRAM_MAC
// Stop using this, so can have unified kram lib
//#if KRAM_MAC
// affinity
#include <mach/thread_act.h>
#include <mach/thread_policy.h>
//#include <mach/thread_act.h>
//#include <mach/thread_policy.h>
//#endif

#if KRAM_APPLE
#include <pthread/pthread.h>
#include <pthread/qos.h>
#include <sys/sysctl.h>
#elif KRAM_IOS || KRAM_VISION
#include <pthread/qos.h>
#include <sys/sysctl.h>
#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 <windows.h>
// clang-format off
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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.

Expand Down
19 changes: 16 additions & 3 deletions scripts/cibuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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::"
Expand All @@ -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
Expand Down

0 comments on commit 8781eab

Please sign in to comment.