Skip to content

Guus/fix hot reload refs #1143

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

Merged
merged 14 commits into from
May 23, 2025
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
11 changes: 11 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@ inherits = "release"

[profile.debug-tracy]
inherits = "dev"

[profile.small]
inherits = "release"
opt-level = "z"
codegen-units = 1
# This saves like 2MB (from 52 to 50MB on formabble)
lto = true

[profile.extra-small]
inherits = "small"
panic = "abort"
34 changes: 27 additions & 7 deletions cmake/Platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ if(APPLE)
if(CMAKE_Swift_FLAGS)
string(REGEX REPLACE "-target [^ ]+" "" CMAKE_Swift_FLAGS "${CMAKE_Swift_FLAGS}")
endif()

# Add the deployment target flag to Swift compiler options
set(CMAKE_Swift_FLAGS "${CMAKE_Swift_FLAGS} ${deployment_target_flag}" CACHE STRING "Swift compiler flags" FORCE)

# Find Swift compiler instead of hardcoding the Xcode path
find_program(CMAKE_Swift_COMPILER swiftc REQUIRED)
enable_language(Swift)
Expand All @@ -44,10 +44,12 @@ if(APPLE)

if(XCODE_SDK)
string(REGEX MATCH "simulator" IS_SIMULATOR ${XCODE_SDK})

if(IS_SIMULATOR)
message(STATUS "Building for simulator: ${XCODE_SDK}")

# Generic simulator settings here

# Optionally detect specific simulator type
if(XCODE_SDK MATCHES "iphonesimulator")
message(STATUS "iOS Simulator detected")
Expand Down Expand Up @@ -121,6 +123,7 @@ endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(SH_DEBUG=1)
endif()

if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
# define SH_RELWITHDEBINFO to enable some extra debug asserts
add_compile_definitions(SH_RELWITHDEBINFO=1)
Expand Down Expand Up @@ -205,12 +208,20 @@ endif()
if(MSVC OR CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
set(WINDOWS_ABI "msvc")

# We can not keep iterators in memory without freeing with iterator debugging
# See SHTable/Set iterator internals
set(ITERATOR_DEBUG_LEVEL 0)

if(CMAKE_BUILD_TYPE MATCHES "Debug")
add_compile_definitions(_ITERATOR_DEBUG_LEVEL=1)
list(APPEND EXTERNAL_CMAKE_ARGS -DCMAKE_CXX_FLAGS="-D_ITERATOR_DEBUG_LEVEL=1")
set(ITERATOR_DEBUG_LEVEL 1)
endif()

# This is required for ASAN to work correctly under LLVM/MSVC
if(USE_ASAN)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
set(ITERATOR_DEBUG_LEVEL 0) # Needed to match clang_rt.asan lib
endif()

add_compile_definitions(_ITERATOR_DEBUG_LEVEL=${ITERATOR_DEBUG_LEVEL})
list(APPEND EXTERNAL_CMAKE_ARGS -DCMAKE_CXX_FLAGS="-D_ITERATOR_DEBUG_LEVEL=${ITERATOR_DEBUG_LEVEL}")
else()
set(WINDOWS_ABI "gnu")
endif()
Expand Down Expand Up @@ -322,6 +333,7 @@ if(USE_ASAN)
$<$<COMPILE_LANGUAGE:CXX,C>:-fno-omit-frame-pointer>
$<$<COMPILE_LANGUAGE:CXX,C>:-g>
)

if(CMAKE_GENERATOR STREQUAL "Xcode")
add_link_options(
-DBOOST_USE_ASAN
Expand Down Expand Up @@ -364,6 +376,7 @@ if(USE_TSAN)
$<$<COMPILE_LANGUAGE:CXX,C>:-fsanitize=thread>
$<$<COMPILE_LANGUAGE:CXX,C>:-g>
)

if(CMAKE_GENERATOR STREQUAL "Xcode")
add_link_options(
-fsanitize=thread
Expand All @@ -375,6 +388,7 @@ if(USE_TSAN)
$<$<COMPILE_LANGUAGE:CXX,C>:-g>
)
endif()

if(USE_TSAN GREATER 1)
add_compile_options(
$<$<COMPILE_LANGUAGE:CXX,C>:-O1>
Expand All @@ -383,6 +397,7 @@ if(USE_TSAN)
$<$<COMPILE_LANGUAGE:CXX,C>:-O1>
)
endif()

add_compile_definitions($<$<COMPILE_LANGUAGE:CXX,C>:SH_USE_TSAN>)
endif()

Expand Down Expand Up @@ -431,3 +446,8 @@ else()
set(LIB_PREFIX "lib")
set(LIB_SUFFIX ".a")
endif()

if(MSVC OR CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
# Workaround for tbb sometimes linking #pragma comment(lib, "tbb12.lib")
add_compile_definitions(__TBB_SOURCE_DIRECTLY_INCLUDED=1)
endif()
16 changes: 16 additions & 0 deletions cmake/Rust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ if(RUST_BUILD_TYPE STREQUAL "Debug")
elseif(RUST_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(RUST_CARGO_FLAGS_INT --profile rel-with-deb-info)
set(RUST_BUILD_SUBDIR_CONFIGURATION rel-with-deb-info)
elseif(RUST_BUILD_TYPE STREQUAL "Small")
set(RUST_CARGO_FLAGS_INT --profile small)
set(RUST_BUILD_SUBDIR_CONFIGURATION small)
list(APPEND RUST_FLAGS -Zlocation-detail=none)
list(APPEND RUSTC_FLAGS
-Zbuild-std=std
-Zbuild-std-features=optimize_for_size
)
elseif(RUST_BUILD_TYPE STREQUAL "ExtraSmall")
set(RUST_CARGO_FLAGS_INT --profile extra-small)
set(RUST_BUILD_SUBDIR_CONFIGURATION extra-small)
list(APPEND RUST_FLAGS -Zlocation-detail=none)
list(APPEND RUSTC_FLAGS
-Zbuild-std=std,panic_abort
-Zbuild-std-features=optimize_for_size,panic_immediate_abort
)
else()
set(RUST_CARGO_FLAGS_INT --release)
set(RUST_BUILD_SUBDIR_CONFIGURATION release)
Expand Down
2 changes: 1 addition & 1 deletion deps/JoltPhysics
Submodule JoltPhysics updated 1 files
+1 −2 Jolt/Jolt.cmake
3 changes: 2 additions & 1 deletion lib/hot-reload.shs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[base-path script-path] | FS.Join = script-path-abs
script-path-abs | Regex.Replace("\\\\" "\\\\\\\\") = script-path-escaped

script-path-abs | Log("Setting up hot reload for script")
[script-path-abs namespace] | Log("Setting up hot reload for script")

[
"\"seq\":["
Expand Down Expand Up @@ -81,6 +81,7 @@
} Pure: true)
) = loader-ast
Regex.Replace("""\{"id":\{"name":"loader"\}\}""" wrapper-name-id-json)
Regex.Replace("""\{"id":\{"name":"namespace"\}\}""" (["{\"str\": \"" namespace "\"}"] | String.Format))
Regex.Replace("""\{"id":\{"name":"script-path"\}\}""" (["{\"str\": \"" script-path-escaped "\"}"] | String.Format))
Regex.Replace(""""id":\{"name":"include-dirs"\}""" include-dirs-json)

Expand Down
1 change: 1 addition & 0 deletions shards/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(core_SOURCES
taskflow.cpp
pmr/shared_temp_allocator.cpp
log_api.cpp
wires.cpp
)

if(EMSCRIPTEN)
Expand Down
5 changes: 3 additions & 2 deletions shards/core/brancher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ struct Brancher {
BranchFailureBehavior failureBehavior = BranchFailureBehavior::Everything;

private:
std::unordered_map<std::string_view, SHExposedTypeInfo> _collectedRequirements;
decltype(SHWire::requirements) _collectedRequirements;
std::unordered_set<std::string_view> _copyBySerialize;
ExposedInfo _mergedRequirements;
ExposedInfo _shared;
mutable std::vector<SHTypeInfo> _cachedObjectTypes;

public:
Brancher() { mesh->inheritLogContext = true; }
Brancher() { mesh->inheritLogContext = true; }
~Brancher() { cleanup(nullptr); }

// Adds a single wire or sequence of shards as a looped wire
Expand Down Expand Up @@ -86,6 +86,7 @@ struct Brancher {
_collectedRequirements.clear();
_copyBySerialize.clear();

decltype(SHWire::requirements) required;
SHInstanceData tmpData = data;
tmpData.privateContext = nullptr; // null this, in order to create a new context!
ExposedInfo shared{shared_};
Expand Down
Loading
Loading