new crafter.build structure

This commit is contained in:
Jorijn van der Graaf 2025-11-09 20:11:22 +01:00
commit e35b7302cb
22 changed files with 83 additions and 109 deletions

BIN
Crafter.CppDOM-Bindings.o Normal file

Binary file not shown.

Binary file not shown.

BIN
Crafter.CppDOM.o Normal file

Binary file not shown.

View file

@ -5,7 +5,7 @@
Crafter.CppDOM is a C++ library that exposes the browser DOM api's to C++ WebAssembly. Crafter.CppDOM is a C++ library that exposes the browser DOM api's to C++ WebAssembly.
# How to use # How to use
Please view the samples folder, this is a snippit from the HelloElement sample: Please view the examples folder, this is a snippit from the HelloElement example:
```cpp ```cpp
import Crafter.CppDOM; import Crafter.CppDOM;
@ -18,31 +18,26 @@ int main(){
``` ```
You can also view the wiki for more detailed information. You can also view the wiki for more detailed information.
It is highly recommended to use this with [Crafter.WebBuild](https://github.com/Catcrafts/Crafter.WebBuild), but it is not strictly required if the same way of injecting the env is followed. The following instructions will be for Crafter.WebBuild. It is highly recommended to use this with [Crafter.Build](https://forgejo.catcrafts.net/Catcrafts/Crafter.Build), but it is not strictly required if the same way of injecting the env is followed. The following instructions will be for Crafter.Build.
## Quickstart ## Quickstart
create a ``project.json`` in an empty folder, open it in your preferred text editor. create a ``project.json`` in an empty folder, open it in your preferred text editor.
Create a basic project file, that describes your web project. Create a basic project file, that describes your web project.
```JSON ```JSON
{ {
"name": "sample-project", "name": "main",
"configurations": [ "configurations": [
{ {
"name": "debug", "name": "executable",
"standard": "c++26", "implementations": ["main"],
"source_files": ["main"], "target": "wasm32-wasi",
"module_files": [], "debug" : true,
"build_dir": "./build",
"output_dir": "./bin",
"optimization_level": "0",
"target": "wasm32-unknown-wasi",
"type": "executable",
"dependencies": [ "dependencies": [
{ {
"path":"https://github.com/Catcrafts/Crafter.CppDOM.git", "path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.CppDOM.git",
"configuration":"debug" "configuration":"lib-debug"
} }
] ],
} }
] ]
} }
@ -59,6 +54,6 @@ int main(){
} }
``` ```
Save and close, then run ``crafter-webbuild serve -c debug``. Now you can open the browser at ``http://localhost:8080/`` and ``Hello World!`` will appear in the browser. Save and close, then run ``crafter-build build executable && caddy file-server --listen :8080 --root bin/executable``. if you have caddy installed, if not use your favorite static file server instead. Now you can open the browser at ``http://localhost:8080`` and ``Hello World!`` will appear in the browser.
This sample can also be viewed in the [HelloElement sample](https://github.com/Catcrafts/Crafter.CppDOM/tree/master/samples/HelloElement) This sample can also be viewed in the [HelloElement example](https://forgejo.catcrafts.net/Catcrafts/Crafter.CppDOM/src/branch/master/examples)

View file

@ -43,8 +43,4 @@ let env = {
setInnerHTML:setInnerHTML, setInnerHTML:setInnerHTML,
} }
if(window.crafter_webbuild_env){
window.crafter_webbuild_env = {...crafter_webbuild_env, env};
} else {
window.crafter_webbuild_env = env; window.crafter_webbuild_env = env;
}

View file

@ -0,0 +1,12 @@
![alt text](https://github.com/Catcrafts/Crafter.Web/blob/master/samples/HelloWorld/HelloWorld.png?raw=true)
This sample demonstrates how to use the element class
```bash
crafter-build build executable
run.sh
```
and go to `http://localhost:8080/`
if caddy is not installed you can use your favorite static file server instead

View file

@ -0,0 +1,17 @@
{
"name": "main",
"configurations": [
{
"name": "executable",
"implementations": ["main"],
"target": "wasm32-wasi",
"debug" : true,
"dependencies": [
{
"path":"../../project.json",
"configuration":"lib-debug"
}
]
}
]
}

1
examples/HelloElement/run.sh Executable file
View file

@ -0,0 +1 @@
caddy file-server --listen :8080 --root bin/executable

View file

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Before After
Before After

View file

@ -0,0 +1,12 @@
![alt text](https://github.com/Catcrafts/Crafter.Web/blob/master/samples/HelloWorld/HelloWorld.png?raw=true)
This sample demonstrates a simple hello world.
```bash
crafter-build build executable
run.sh
```
and go to `http://localhost:8080/`
if caddy is not installed you can use your favorite static file server instead

View file

@ -0,0 +1,17 @@
{
"name": "main",
"configurations": [
{
"name": "example",
"implementations": ["main"],
"target": "wasm32-wasi",
"debug" : true,
"dependencies": [
{
"path":"../../project.json",
"configuration":"lib-debug"
}
]
}
]
}

View file

@ -0,0 +1 @@
caddy file-server --listen :8080 --root bin/executable

View file

@ -18,9 +18,8 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
module;
#include <string>
export module Crafter.CppDOM:Bindings; export module Crafter.CppDOM:Bindings;
import std;
export namespace Crafter::CppDOM::Bindings { export namespace Crafter::CppDOM::Bindings {
__attribute__((import_module("env"), import_name("freeJs"))) void FreeJs(void* ptr); __attribute__((import_module("env"), import_name("freeJs"))) void FreeJs(void* ptr);

View file

@ -18,9 +18,8 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
module;
#include <string>
export module Crafter.CppDOM:HtmlElement; export module Crafter.CppDOM:HtmlElement;
import std;
import :Bindings; import :Bindings;
namespace Crafter::CppDOM { namespace Crafter::CppDOM {

View file

@ -21,13 +21,3 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
export module Crafter.CppDOM; export module Crafter.CppDOM;
export import :Bindings; export import :Bindings;
export import :HtmlElement; export import :HtmlElement;
extern "C" {
void __cxa_allocate_exception() {
}
void __cxa_throw(int, int, int) {
}
}

View file

@ -2,25 +2,16 @@
"name": "crafter-cppdom", "name": "crafter-cppdom",
"configurations": [ "configurations": [
{ {
"name": "base", "name": "lib",
"standard": "c++26", "interfaces": ["interfaces/Crafter.CppDOM-HtmlElement", "interfaces/Crafter.CppDOM", "interfaces/Crafter.CppDOM-Bindings"],
"source_files": [], "additional_files": ["additional/env.js"],
"module_files": ["Crafter.CppDOM-HtmlElement", "Crafter.CppDOM", "Crafter.CppDOM-Bindings"],
"additional_files": ["Crafter.CppDOM.js"],
"build_dir": "./build",
"output_dir": "./bin",
"type":"library", "type":"library",
"target":"wasm32-unknown-wasi" "target":"wasm32-wasi"
}, },
{ {
"name": "debug", "name": "lib-debug",
"extends": ["base"], "extends": ["lib"],
"optimization_level": "0" "debug": true
},
{
"name": "release",
"extends": ["base"],
"optimization_level": "3"
} }
] ]
} }

View file

@ -1,5 +0,0 @@
![alt text](https://github.com/Catcrafts/Crafter.Web/blob/master/samples/HelloWorld/HelloWorld.png?raw=true)
This sample demonstrates the use of the ``HtmlElement`` class.
Run ``crafter-webbuild serve -c debug`` and go to ``localhost:8080`` to view it.

View file

@ -1,23 +0,0 @@
{
"name": "hello-element",
"configurations": [
{
"name": "debug",
"standard": "c++26",
"source_files": ["main"],
"module_files": [],
"additional_files": [],
"build_dir": "./build",
"output_dir": "./bin",
"optimization_level": "0",
"target": "wasm32-unknown-wasi",
"type": "executable",
"dependencies": [
{
"path":"../../project.json",
"configuration":"debug"
}
]
}
]
}

View file

@ -1,5 +0,0 @@
![alt text](https://github.com/Catcrafts/Crafter.Web/blob/master/samples/HelloWorld/HelloWorld.png?raw=true)
This sample demonstrates a simple hello world.
Run ``crafter-webbuild serve -c debug`` and go to ``localhost:8080`` to view it.

View file

@ -1,23 +0,0 @@
{
"name": "hello-world",
"configurations": [
{
"name": "debug",
"standard": "c++26",
"source_files": ["main"],
"module_files": [],
"additional_files": [],
"build_dir": "./build",
"output_dir": "./bin",
"optimization_level": "0",
"target": "wasm32-unknown-wasi",
"type": "executable",
"dependencies": [
{
"path":"../../project.json",
"configuration":"debug"
}
]
}
]
}