Skip to content

Commit

Permalink
Initial work to handle components not in XML format
Browse files Browse the repository at this point in the history
  • Loading branch information
karurochari committed Nov 28, 2024
1 parent 763ec86 commit 4fdb809
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 3 deletions.
3 changes: 1 addition & 2 deletions docs/for-developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Start by installing all the `bun` dependencies needed:
bun install
```

Then run the following npm scripts:
Then run the following NPM scripts:

```bash
bun run codegen #Initial codegen from schemas
Expand Down Expand Up @@ -169,7 +169,6 @@ They can also be useful for the developer while testing new functionality, so th
- Runtime tests/benchmarks on `vs`in headless mode with automatic actions, with optional memory profiling.
- Runtime tests on `vs` with a headless x11 server to obtain screenshot to highlight possible visual regressions.


### Testing features of the vs-fltk library

### Memory profile of vs
Expand Down
19 changes: 19 additions & 0 deletions docs/ideas/path-finding.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
Order of search for component when the direct `fullname` is not found. `name` is `fullname` reduced of its last extension.

First attempt is to look for the exact name:

- `fullname`

If it fails, check for any the following in such order:

- `name.vs`
- `name.xml`
- `name.wasm`
- `name.so` | `name.dll` | `name.dylib`
- `name.c`

If it fails and the folder `name` exists, check for these ones:

- `name/main.vs`
- `name/main.xml`
- `name/main.wasm`
- `name/main.so` | `name/main.dll` | `name/main.dylib`
- `name/main.c`

## Loading pipelines

- `.vs` & `.xml` files are either loaded directly, or after being compiled from `vs.templ`.
- `.wasm` files are handled as wasm components by wamr
- `.so` & al. are loaded as native components
- `.c` are compiled by tcc into native components and loaded as such
8 changes: 8 additions & 0 deletions include/cbindings/vs.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ enum vs_frame_access_t{
};
typedef enum vs_frame_access_t vs_frame_access_t;

enum struct vs_component_t{
VS_COMPONENT_NONE,
VS_COMPONENT_XML,
VS_COMPONENT_WASM,
VS_COMPONENT_LIB,
VS_COMPONENT_CNATIVE,
};
typedef enum vs_component_t vs_component_t;

typedef vs_symbol_mode_t vs_frame_mode_t;

Expand Down
13 changes: 13 additions & 0 deletions include/fetcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@

namespace vs{


enum struct component_t{
NONE,
XML,
WASM,
LIB,
CNATIVE,
};
component_t component_t_i(const char* t);
constexpr const char* component_t_s(component_t t);

std::tuple<resolve_path::reason_t::t, scoped_rpath_t, component_t> fetch_component();

/**
* @brief Fetch resource using its path and some contextual information (or get it if already on cache)
*
Expand Down
1 change: 1 addition & 0 deletions include/utils/paths.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ struct resolve_path{

///Try to resolve the path described by src based on the policies, env, and current path.
std::pair<reason_t::t,scoped_rpath_t> operator()(from_t from,const char* src);

};

#undef tnk
Expand Down
37 changes: 37 additions & 0 deletions src/fetcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,43 @@

namespace vs{

component_t component_t_i(const char* t){
if(false);
else if(strcmp(t,".vs")==1)return component_t::XML;
else if(strcmp(t,".xml")==1)return component_t::XML;
else if(strcmp(t,".wasm")==1)return component_t::WASM;
# if defined(__linux__)
else if(strcmp(t,".so")==1)return component_t::LIB;
# elif defined(_WIN32) || defined(_WIN64)
else if(strcmp(t,".dll")==1)return component_t::LIB;
# elif defined(__APPLE__)
else if(strcmp(t,".dylib")==1)return component_t::LIB;
# endif
else if(strcmp(t,".c")==1)return component_t::CNATIVE;
else return component_t::NONE;
}

constexpr const char* component_t_s(component_t t){
if(t==component_t::NONE)return nullptr;
else if(t==component_t::XML)return ".vs";
else if(t==component_t::WASM)return ".wasm";
else if(t==component_t::LIB){
# if defined(__linux__)
return ".so";
# elif defined(_WIN32) || defined(_WIN64)
return ".dll";
# elif defined(__APPLE__)
return ".dylib";
# endif
}
else if(t==component_t::CNATIVE)return ".c";
else return nullptr;
}

std::tuple<resolve_path::reason_t::t, scoped_rpath_t, component_t> fetch_component(){
//TODO:
}

std::tuple<resolve_path::reason_t::t,cache::buffer_t, scoped_rpath_t> fetcher(resolve_path& base, resolve_path::from_t from,const char* src, bool promote, bool preserve){
auto ret = base(from,src);
if(ret.first==resolve_path::reason_t::OK){
Expand Down
1 change: 0 additions & 1 deletion src/utils/paths.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <iostream>
#include <utils/paths.hpp>

namespace vs{
Expand Down

0 comments on commit 4fdb809

Please sign in to comment.