Skip to content
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ if(WEBFRONT_IS_TOP_LEVEL)
endif()
add_library(WebFront_options INTERFACE)
target_compile_features(WebFront_options INTERFACE cxx_std_23)
# The header-only library instantiates enough templates for the examples to exceed MSVC's default
# object-file section limit (error C1128).
target_compile_options(WebFront_options INTERFACE "$<$<CXX_COMPILER_ID:MSVC>:/bigobj>")
# Do not force-define __cpp_lib_format on the command line: unlike a header setting it after
# actually providing <format>, a command-line -D applies from the start of every translation
# unit, so other standard headers (e.g. <vector>) that gate their own <format> integration on
Expand Down
12 changes: 12 additions & 0 deletions cmake/StandardProjectSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
"Release"
"MinSizeRel"
"RelWithDebInfo")
elseif(CMAKE_GENERATOR STREQUAL "Ninja Multi-Config" AND NOT CMAKE_DEFAULT_BUILD_TYPE AND NOT CMAKE_DEFAULT_CONFIGS)
# Only Ninja Multi-Config accepts this variable. Visual Studio and Xcode build Debug unless --config is given.
# The default must belong to CMAKE_CONFIGURATION_TYPES, or generation fails.
foreach(_webfront_candidate RelWithDebInfo Release Debug)
if(_webfront_candidate IN_LIST CMAKE_CONFIGURATION_TYPES)
set(CMAKE_DEFAULT_BUILD_TYPE ${_webfront_candidate})
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
break()
endif()
endforeach()
if(NOT CMAKE_DEFAULT_BUILD_TYPE AND CMAKE_CONFIGURATION_TYPES)
list(GET CMAKE_CONFIGURATION_TYPES 0 CMAKE_DEFAULT_BUILD_TYPE)
endif()
endif()

# Generate compile_commands.json to make it easier to work with clang based tools
Expand Down
14 changes: 12 additions & 2 deletions docs/REACT.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,18 @@ The C++ event computes a generation, updates the island and sets a tuple snapsho
containing the packed grid, generation and population. Each browser owns a separate
simulation, released on disconnect. The original Life starter remains available.

Build the `WebFrontLifeReact` CMake target and run it with a writable copy of
`main.tsx` and `webfront.project.json` from that directory as its project argument.
Build the `WebFrontLifeReact` CMake target. The application only creates an
empty project directory when it is missing (without argument `./life-project`);
it does not copy the example's sources. Use a new directory, so that no existing project is touched: `mkdir` fails if it exists and `cp -n` never overwrites a file. Copy `main.tsx` and
`webfront.project.json` from `examples/life/react/` into that directory first,
then start the application:

```sh
mkdir life-react-project
cp -n examples/life/react/main.tsx examples/life/react/webfront.project.json life-react-project/
./build/examples/WebFrontLifeReact life-react-project
```

In its terminal, run `wf install`, then `wf preview`. The configured registry must
carry `@webfront/react@0.1.0`; this change prepares the archive but does not publish
to npm. The repository's test registry already carries the package. For a local
Expand Down
12 changes: 9 additions & 3 deletions examples/life/react/LifeReact.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
#include "LifeReact.hpp"

#include "../LifeDeveloperOptions.hpp"
#include "../LifeFrontend.hpp"

#include <exception>
#include <filesystem>
#include <iostream>

int main(int argc, char** argv) {
if (argc != 2) {
std::cerr << "Usage: WebFrontLifeReact <project directory>\n";
if (argc > 2 || (argc == 2 && *argv[1] == '\0')) {
std::cerr << "Usage: WebFrontLifeReact [<project directory>]\n"
"Without argument the project is ./"
<< webfront::demo::LifeDeveloperOptions::defaultProject << ", created empty when missing: copy main.tsx and webfront.project.json from examples/life/react/ into it first.\n";
return 2;
}
try {
webfront::demo::LifeApp app{argv[1]};
const std::filesystem::path project = argc == 2 ? argv[1] : webfront::demo::LifeDeveloperOptions::defaultProject;
webfront::demo::prepareLifeProject(project);
webfront::demo::LifeApp app{project};
auto subscription = webfront::demo::installLifeReact(app);
app.bootstrap("developer");
app.show();
Expand Down
Loading