Skip to content

Commit 1473607

Browse files
authored
Merge pull request #1143 from fragcolor-xyz/guus/fix-hot-reload-refs
Guus/fix hot reload refs
2 parents bfcb818 + 6cccd8a commit 1473607

30 files changed

+735
-509
lines changed

.cargo/config.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,14 @@ inherits = "release"
1111

1212
[profile.debug-tracy]
1313
inherits = "dev"
14+
15+
[profile.small]
16+
inherits = "release"
17+
opt-level = "z"
18+
codegen-units = 1
19+
# This saves like 2MB (from 52 to 50MB on formabble)
20+
lto = true
21+
22+
[profile.extra-small]
23+
inherits = "small"
24+
panic = "abort"

cmake/Platform.cmake

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ if(APPLE)
2424
if(CMAKE_Swift_FLAGS)
2525
string(REGEX REPLACE "-target [^ ]+" "" CMAKE_Swift_FLAGS "${CMAKE_Swift_FLAGS}")
2626
endif()
27-
27+
2828
# Add the deployment target flag to Swift compiler options
2929
set(CMAKE_Swift_FLAGS "${CMAKE_Swift_FLAGS} ${deployment_target_flag}" CACHE STRING "Swift compiler flags" FORCE)
30-
30+
3131
# Find Swift compiler instead of hardcoding the Xcode path
3232
find_program(CMAKE_Swift_COMPILER swiftc REQUIRED)
3333
enable_language(Swift)
@@ -44,10 +44,12 @@ if(APPLE)
4444

4545
if(XCODE_SDK)
4646
string(REGEX MATCH "simulator" IS_SIMULATOR ${XCODE_SDK})
47+
4748
if(IS_SIMULATOR)
4849
message(STATUS "Building for simulator: ${XCODE_SDK}")
50+
4951
# Generic simulator settings here
50-
52+
5153
# Optionally detect specific simulator type
5254
if(XCODE_SDK MATCHES "iphonesimulator")
5355
message(STATUS "iOS Simulator detected")
@@ -121,6 +123,7 @@ endif()
121123
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
122124
add_compile_definitions(SH_DEBUG=1)
123125
endif()
126+
124127
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
125128
# define SH_RELWITHDEBINFO to enable some extra debug asserts
126129
add_compile_definitions(SH_RELWITHDEBINFO=1)
@@ -205,12 +208,20 @@ endif()
205208
if(MSVC OR CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
206209
set(WINDOWS_ABI "msvc")
207210

208-
# We can not keep iterators in memory without freeing with iterator debugging
209-
# See SHTable/Set iterator internals
211+
set(ITERATOR_DEBUG_LEVEL 0)
212+
210213
if(CMAKE_BUILD_TYPE MATCHES "Debug")
211-
add_compile_definitions(_ITERATOR_DEBUG_LEVEL=1)
212-
list(APPEND EXTERNAL_CMAKE_ARGS -DCMAKE_CXX_FLAGS="-D_ITERATOR_DEBUG_LEVEL=1")
214+
set(ITERATOR_DEBUG_LEVEL 1)
215+
endif()
216+
217+
# This is required for ASAN to work correctly under LLVM/MSVC
218+
if(USE_ASAN)
219+
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
220+
set(ITERATOR_DEBUG_LEVEL 0) # Needed to match clang_rt.asan lib
213221
endif()
222+
223+
add_compile_definitions(_ITERATOR_DEBUG_LEVEL=${ITERATOR_DEBUG_LEVEL})
224+
list(APPEND EXTERNAL_CMAKE_ARGS -DCMAKE_CXX_FLAGS="-D_ITERATOR_DEBUG_LEVEL=${ITERATOR_DEBUG_LEVEL}")
214225
else()
215226
set(WINDOWS_ABI "gnu")
216227
endif()
@@ -322,6 +333,7 @@ if(USE_ASAN)
322333
$<$<COMPILE_LANGUAGE:CXX,C>:-fno-omit-frame-pointer>
323334
$<$<COMPILE_LANGUAGE:CXX,C>:-g>
324335
)
336+
325337
if(CMAKE_GENERATOR STREQUAL "Xcode")
326338
add_link_options(
327339
-DBOOST_USE_ASAN
@@ -364,6 +376,7 @@ if(USE_TSAN)
364376
$<$<COMPILE_LANGUAGE:CXX,C>:-fsanitize=thread>
365377
$<$<COMPILE_LANGUAGE:CXX,C>:-g>
366378
)
379+
367380
if(CMAKE_GENERATOR STREQUAL "Xcode")
368381
add_link_options(
369382
-fsanitize=thread
@@ -375,6 +388,7 @@ if(USE_TSAN)
375388
$<$<COMPILE_LANGUAGE:CXX,C>:-g>
376389
)
377390
endif()
391+
378392
if(USE_TSAN GREATER 1)
379393
add_compile_options(
380394
$<$<COMPILE_LANGUAGE:CXX,C>:-O1>
@@ -383,6 +397,7 @@ if(USE_TSAN)
383397
$<$<COMPILE_LANGUAGE:CXX,C>:-O1>
384398
)
385399
endif()
400+
386401
add_compile_definitions($<$<COMPILE_LANGUAGE:CXX,C>:SH_USE_TSAN>)
387402
endif()
388403

@@ -431,3 +446,8 @@ else()
431446
set(LIB_PREFIX "lib")
432447
set(LIB_SUFFIX ".a")
433448
endif()
449+
450+
if(MSVC OR CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
451+
# Workaround for tbb sometimes linking #pragma comment(lib, "tbb12.lib")
452+
add_compile_definitions(__TBB_SOURCE_DIRECTLY_INCLUDED=1)
453+
endif()

cmake/Rust.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,22 @@ if(RUST_BUILD_TYPE STREQUAL "Debug")
7878
elseif(RUST_BUILD_TYPE STREQUAL "RelWithDebInfo")
7979
set(RUST_CARGO_FLAGS_INT --profile rel-with-deb-info)
8080
set(RUST_BUILD_SUBDIR_CONFIGURATION rel-with-deb-info)
81+
elseif(RUST_BUILD_TYPE STREQUAL "Small")
82+
set(RUST_CARGO_FLAGS_INT --profile small)
83+
set(RUST_BUILD_SUBDIR_CONFIGURATION small)
84+
list(APPEND RUST_FLAGS -Zlocation-detail=none)
85+
list(APPEND RUSTC_FLAGS
86+
-Zbuild-std=std
87+
-Zbuild-std-features=optimize_for_size
88+
)
89+
elseif(RUST_BUILD_TYPE STREQUAL "ExtraSmall")
90+
set(RUST_CARGO_FLAGS_INT --profile extra-small)
91+
set(RUST_BUILD_SUBDIR_CONFIGURATION extra-small)
92+
list(APPEND RUST_FLAGS -Zlocation-detail=none)
93+
list(APPEND RUSTC_FLAGS
94+
-Zbuild-std=std,panic_abort
95+
-Zbuild-std-features=optimize_for_size,panic_immediate_abort
96+
)
8197
else()
8298
set(RUST_CARGO_FLAGS_INT --release)
8399
set(RUST_BUILD_SUBDIR_CONFIGURATION release)

deps/JoltPhysics

lib/hot-reload.shs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
[base-path script-path] | FS.Join = script-path-abs
1616
script-path-abs | Regex.Replace("\\\\" "\\\\\\\\") = script-path-escaped
1717

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

2020
[
2121
"\"seq\":["
@@ -81,6 +81,7 @@
8181
} Pure: true)
8282
) = loader-ast
8383
Regex.Replace("""\{"id":\{"name":"loader"\}\}""" wrapper-name-id-json)
84+
Regex.Replace("""\{"id":\{"name":"namespace"\}\}""" (["{\"str\": \"" namespace "\"}"] | String.Format))
8485
Regex.Replace("""\{"id":\{"name":"script-path"\}\}""" (["{\"str\": \"" script-path-escaped "\"}"] | String.Format))
8586
Regex.Replace(""""id":\{"name":"include-dirs"\}""" include-dirs-json)
8687

shards/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ set(core_SOURCES
1111
taskflow.cpp
1212
pmr/shared_temp_allocator.cpp
1313
log_api.cpp
14+
wires.cpp
1415
)
1516

1617
if(EMSCRIPTEN)

shards/core/brancher.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ struct Brancher {
2929
BranchFailureBehavior failureBehavior = BranchFailureBehavior::Everything;
3030

3131
private:
32-
std::unordered_map<std::string_view, SHExposedTypeInfo> _collectedRequirements;
32+
decltype(SHWire::requirements) _collectedRequirements;
3333
std::unordered_set<std::string_view> _copyBySerialize;
3434
ExposedInfo _mergedRequirements;
3535
ExposedInfo _shared;
3636
mutable std::vector<SHTypeInfo> _cachedObjectTypes;
3737

3838
public:
39-
Brancher() { mesh->inheritLogContext = true; }
39+
Brancher() { mesh->inheritLogContext = true; }
4040
~Brancher() { cleanup(nullptr); }
4141

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

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

0 commit comments

Comments
 (0)