Skip to content

Commit

Permalink
Massive cleanup in the meson build. Regular vs_use defines. Added lib…
Browse files Browse the repository at this point in the history
…riscv
  • Loading branch information
karurochari committed Dec 19, 2024
1 parent c3bc5f2 commit 02bfc2e
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 60 deletions.
4 changes: 3 additions & 1 deletion include/cache/memory-storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ class mem_storage_t{
entry_it fetch_from_buffer(const mem_key_t& path, std::span<uint8_t const> str, entry_t::format_t format);
entry_it fetch_from_cstring(const mem_key_t& path, std::string_view str, entry_t::format_t format);
entry_it fetch_from_fs(const mem_key_t& path, entry_t::format_t format);
# ifdef HAS_CURL
# if defined VS_USE_NETWORKING_CURL || defined VS_USE_NETWORKING_SIMPLE
entry_it fetch_from_http(const mem_key_t& path, entry_t::format_t format);
# endif
# ifdef VS_USE_NETWORKING_CURL
entry_it fetch_from_https(const mem_key_t& path, entry_t::format_t format);
entry_it fetch_from_gemini(const mem_key_t& path, entry_t::format_t format);
# endif
Expand Down
19 changes: 0 additions & 19 deletions include/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,6 @@

namespace vs{


/*
extern app_env_t env; //Computed basic environment based on user config & shell env
extern path_env_t path_env; //Computed paths
//extern policies_t policy;
extern js_rt_t js_rt;
extern cache::mem_storage_t mem_storage;
//extern cache::kv_storage_t kv_storage;
//extern cache::res_storage_t res_storage;
//extern cache::secrets_t secrets;
extern vs_test_debug_t debug;
extern field_models_t value_models;
*/


/**
* @brief Global context structure
*
Expand Down
2 changes: 1 addition & 1 deletion include/ui-tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct ui_tree {
frame_mode_t mode = frame_mode_t::AUTO;

//Book-keeping. Duplicated info on nested structures, but they are short lived, and it is better compared to unrolling the stack each time.
global_ctx_t* globals;
global_ctx_t* globals = nullptr;
//Book-keeping. Duplicated info on nested structures, but they are short lived, and it is better compared to unrolling the stack each time.
pipelines::link_with_t link_with = {nullptr, nullptr};

Expand Down
79 changes: 49 additions & 30 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,60 @@ cmake = import('cmake')
cc = meson.get_compiler('c')
cxx = meson.get_compiler('cpp')

vs_fltk_flags = ['-Wno-c23-extensions', '-Wno-vla-cxx-extension', '-Wno-unused-variable']
vs_fltk_deps = []

need_pugixml = false
need_fltk = false

# Full dependency list for vs_fltk

vs_fltk_deps = []

# Process options

add_global_arguments(
[
'-DVS_COMMONS_DIR="'
+ join_paths(get_option('prefix'), get_option('datadir'), 'vs-fltk')
+ '/"',
],
language: ['cpp', 'c'],
)
vs_fltk_flags += '-DVS_COMMONS_DIR="' + join_paths(get_option('prefix'), get_option('datadir'), 'vs-fltk') + '/"'

if get_option('use_tcc')
add_global_arguments(['-DVS_USE_TCC'], language: ['cpp', 'c'])
vs_fltk_flags += '-DVS_USE_TCC'
endif

if get_option('use_quickjs')
add_global_arguments(['-DVS_USE_QJS'], language: ['cpp', 'c'])
vs_fltk_flags += '-DVS_USE_QJS'
endif

if get_option('use_wamr')
add_global_arguments(['-DVS_USE_WAMR'], language: ['cpp', 'c'])
vs_fltk_flags += '-DVS_USE_WAMR'
endif

if get_option('use_lua') and get_option('use_luajit')
if get_option('use_vm_riscv')
vs_fltk_flags += '-DVS_USE_VS_RISCV'
endif

if get_option('use_lua_base') and get_option('use_lua_jit')
error(
'Only lua or luajit can be used. At least one must be disabled from the options',
)
endif

if get_option('use_lua')
add_global_arguments(['-DVS_USE_LUA'], language: ['cpp', 'c'])
if get_option('use_lua_base')
vs_fltk_flags += '-DVS_USE_LUA'
endif

if get_option('use_lua_jit')
vs_fltk_flags += '-DVS_USE_LUAJIT'
endif

if get_option('use_networking_curl') and get_option('use_networking_simple')
error(
'Only curl or simple can be used for networking. At least one must be disabled from the options',
)
endif

if get_option('use_networking_curl')
vs_fltk_flags += '-DVS_USE_NETWORKING_CURL'
endif

if get_option('use_luajit')
add_global_arguments(['-DVS_USE_LUAJIT'], language: ['cpp', 'c'])
if get_option('use_networking_simple')
vs_fltk_flags += '-DVS_USE_NETWORKING_SIMPLE'
endif

if get_option('use_system_pugixml')
Expand All @@ -65,7 +77,7 @@ endif
if need_pugixml or get_option('use_system_pugixml') == false
#Used by pugi to enable compact mode. I might want to disable execptions too.
add_global_arguments(['-DPUGIXML_COMPACT'], language: ['cpp', 'c'])
pugixml_proj = subproject('pugixml')
pugixml_proj = subproject('pugixml', default_options: ['compact=true'])
pugixml_dep = pugixml_proj.get_variable('pugixml_dep')
endif

Expand Down Expand Up @@ -127,6 +139,21 @@ if get_option('use_wamr')

endif

if get_option('use_vm_riscv')
opt_riscv = cmake.subproject_options()
opt_riscv.add_cmake_defines(
{
'CMAKE_POSITION_INDEPENDENT_CODE': true,
'CMAKE_INSTALL_LIBDIR': get_option('libdir'),
},
)
riscv_proj = cmake.subproject('libriscv', options: opt_riscv)
riscv_dep = riscv_proj.dependency('riscv')

vs_fltk_deps += riscv_dep

endif

if get_option('use_quickjs')
opt_quickjs = cmake.subproject_options()
opt_quickjs.add_cmake_defines(
Expand Down Expand Up @@ -208,13 +235,13 @@ if get_option('use_networking_curl') and get_option('use_networking_simple')
endif

if get_option('use_networking_curl')
curl = dependency('libcurl', required: false)
curl = dependency('libcurl', required: true)
vs_fltk_deps += curl
endif

#TODO: support networking_simple
if get_option('use_networking_simple')
libhttp_proj = subproject('libhttp')
libhttp_dep = libhttp_proj.get_variable('libhttp_dep')
libhttp_dep = libhttp_proj.get_variable('http_dep')

vs_fltk_deps += libhttp_dep
endif
Expand All @@ -241,14 +268,6 @@ vs_fltk_deps += [
treesitter_dep,
]

vs_fltk_flags = ['-Wno-c23-extensions', '-Wno-vla-cxx-extension', '-Wno-unused-variable']

if curl.found()
vs_fltk_deps += [curl]
vs_fltk_flags += '-DHAS_CURL'
else
endif

#vs_fltk_flags += '-DPUGIXML_COMPACT'

subdir('./src/components')
Expand Down
7 changes: 4 additions & 3 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ option('use_networking_simple', type: 'boolean', value: false)

option('use_tcc', type: 'boolean', value: true)
option('use_quickjs', type: 'boolean', value: true)
option('use_wamr', type: 'boolean', value: true)
option('use_wamr', type: 'boolean', value: false)
option('use_vm_riscv', type: 'boolean', value: true)

# Only one between lua and luajit should be enabled
option('use_lua', type: 'boolean', value: true)
option('use_luajit', type: 'boolean', value: false)
option('use_lua_base', type: 'boolean', value: true)
option('use_lua_jit', type: 'boolean', value: false)

# If present, else build it manually
option('use_system_fltk', type: 'boolean', value: true)
Expand Down
2 changes: 1 addition & 1 deletion src/cache/memory-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <cstdio>

#ifdef HAS_CURL
#ifdef VS_USE_NETWORKING_CURL
#include <curl/curl.h>
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/loader.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <iostream>

#ifdef HAS_CURL
#ifdef VS_USE_NETWORKING_CURL
#include <curl/curl.h>
#endif

Expand All @@ -14,7 +14,7 @@
namespace vs {
app_loader::app_loader(global_ctx_t& globals, const char *profile, const char *path) {

#ifdef HAS_CURL
#ifdef VS_USE_NETWORKING_CURL
curl_global_init(CURL_GLOBAL_ALL);
#endif
pugi::xml_document doc;
Expand Down Expand Up @@ -68,7 +68,7 @@ int app_loader::run() {
}

app_loader::~app_loader() {
#ifdef HAS_CURL
#ifdef VS_USE_NETWORKING_CURL
curl_global_cleanup();
#endif
if (root != nullptr)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#endif

//#include <uv.h>
#ifdef HAS_CURL
#ifdef VS_USE_NETWORKING_CURL
#include <curl/curl.h>
#endif

Expand Down Expand Up @@ -151,7 +151,7 @@ void prepare_db(){
versions_t get_versions(){
versions_t tmp;
tmp.vs=vs_version();
# ifdef HAS_CURL
# ifdef VS_USE_NETWORKING_CURL
tmp.curl = curl_version();
# else
tmp.curl = "Not installed";
Expand Down
7 changes: 7 additions & 0 deletions subprojects/libriscv.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[wrap-git]
url = https://github.com/libriscv/libriscv.git
revision = HEAD
depth = 1
method = cmake
[provide]
riscv = riscv_dep

0 comments on commit 02bfc2e

Please sign in to comment.