new crafter.build structure
This commit is contained in:
parent
ad69ebeac8
commit
e35b7302cb
22 changed files with 83 additions and 109 deletions
BIN
Crafter.CppDOM-Bindings.o
Normal file
BIN
Crafter.CppDOM-Bindings.o
Normal file
Binary file not shown.
BIN
Crafter.CppDOM-HtmlElement.o
Normal file
BIN
Crafter.CppDOM-HtmlElement.o
Normal file
Binary file not shown.
BIN
Crafter.CppDOM.o
Normal file
BIN
Crafter.CppDOM.o
Normal file
Binary file not shown.
29
README.md
29
README.md
|
|
@ -5,7 +5,7 @@
|
|||
Crafter.CppDOM is a C++ library that exposes the browser DOM api's to C++ WebAssembly.
|
||||
|
||||
# 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
|
||||
import Crafter.CppDOM;
|
||||
|
|
@ -18,31 +18,26 @@ int main(){
|
|||
```
|
||||
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
|
||||
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.
|
||||
```JSON
|
||||
{
|
||||
"name": "sample-project",
|
||||
"name": "main",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "debug",
|
||||
"standard": "c++26",
|
||||
"source_files": ["main"],
|
||||
"module_files": [],
|
||||
"build_dir": "./build",
|
||||
"output_dir": "./bin",
|
||||
"optimization_level": "0",
|
||||
"target": "wasm32-unknown-wasi",
|
||||
"type": "executable",
|
||||
"name": "executable",
|
||||
"implementations": ["main"],
|
||||
"target": "wasm32-wasi",
|
||||
"debug" : true,
|
||||
"dependencies": [
|
||||
{
|
||||
"path":"https://github.com/Catcrafts/Crafter.CppDOM.git",
|
||||
"configuration":"debug"
|
||||
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.CppDOM.git",
|
||||
"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)
|
||||
|
|
|
|||
|
|
@ -43,8 +43,4 @@ let env = {
|
|||
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;
|
||||
12
examples/HelloElement/README.md
Normal file
12
examples/HelloElement/README.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||

|
||||
|
||||
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
|
||||
17
examples/HelloElement/project.json
Normal file
17
examples/HelloElement/project.json
Normal 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
1
examples/HelloElement/run.sh
Executable file
|
|
@ -0,0 +1 @@
|
|||
caddy file-server --listen :8080 --root bin/executable
|
||||
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
12
examples/HelloWorld/README.md
Normal file
12
examples/HelloWorld/README.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||

|
||||
|
||||
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
|
||||
17
examples/HelloWorld/project.json
Normal file
17
examples/HelloWorld/project.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "main",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "example",
|
||||
"implementations": ["main"],
|
||||
"target": "wasm32-wasi",
|
||||
"debug" : true,
|
||||
"dependencies": [
|
||||
{
|
||||
"path":"../../project.json",
|
||||
"configuration":"lib-debug"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
1
examples/HelloWorld/run.sh
Normal file
1
examples/HelloWorld/run.sh
Normal file
|
|
@ -0,0 +1 @@
|
|||
caddy file-server --listen :8080 --root bin/executable
|
||||
|
|
@ -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
|
||||
*/
|
||||
|
||||
module;
|
||||
#include <string>
|
||||
export module Crafter.CppDOM:Bindings;
|
||||
import std;
|
||||
|
||||
export namespace Crafter::CppDOM::Bindings {
|
||||
__attribute__((import_module("env"), import_name("freeJs"))) void FreeJs(void* ptr);
|
||||
|
|
@ -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
|
||||
*/
|
||||
|
||||
module;
|
||||
#include <string>
|
||||
export module Crafter.CppDOM:HtmlElement;
|
||||
import std;
|
||||
import :Bindings;
|
||||
|
||||
namespace Crafter::CppDOM {
|
||||
|
|
@ -20,14 +20,4 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
export module Crafter.CppDOM;
|
||||
export import :Bindings;
|
||||
export import :HtmlElement;
|
||||
|
||||
extern "C" {
|
||||
void __cxa_allocate_exception() {
|
||||
|
||||
}
|
||||
|
||||
void __cxa_throw(int, int, int) {
|
||||
|
||||
}
|
||||
}
|
||||
export import :HtmlElement;
|
||||
23
project.json
23
project.json
|
|
@ -2,25 +2,16 @@
|
|||
"name": "crafter-cppdom",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "base",
|
||||
"standard": "c++26",
|
||||
"source_files": [],
|
||||
"module_files": ["Crafter.CppDOM-HtmlElement", "Crafter.CppDOM", "Crafter.CppDOM-Bindings"],
|
||||
"additional_files": ["Crafter.CppDOM.js"],
|
||||
"build_dir": "./build",
|
||||
"output_dir": "./bin",
|
||||
"name": "lib",
|
||||
"interfaces": ["interfaces/Crafter.CppDOM-HtmlElement", "interfaces/Crafter.CppDOM", "interfaces/Crafter.CppDOM-Bindings"],
|
||||
"additional_files": ["additional/env.js"],
|
||||
"type":"library",
|
||||
"target":"wasm32-unknown-wasi"
|
||||
"target":"wasm32-wasi"
|
||||
},
|
||||
{
|
||||
"name": "debug",
|
||||
"extends": ["base"],
|
||||
"optimization_level": "0"
|
||||
},
|
||||
{
|
||||
"name": "release",
|
||||
"extends": ["base"],
|
||||
"optimization_level": "3"
|
||||
"name": "lib-debug",
|
||||
"extends": ["lib"],
|
||||
"debug": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||

|
||||
|
||||
This sample demonstrates the use of the ``HtmlElement`` class.
|
||||
|
||||
Run ``crafter-webbuild serve -c debug`` and go to ``localhost:8080`` to view it.
|
||||
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||

|
||||
|
||||
This sample demonstrates a simple hello world.
|
||||
|
||||
Run ``crafter-webbuild serve -c debug`` and go to ``localhost:8080`` to view it.
|
||||
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue