build(wasm): libconstants can now compile to wasm and run as a wasm module
This commit is contained in:
19
cross/macos_arm64.ini
Normal file
19
cross/macos_arm64.ini
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
[binaries]
|
||||||
|
c = 'arm64-apple-darwin25-clang'
|
||||||
|
cpp = 'arm64-apple-darwin25-clang++'
|
||||||
|
ar = 'arm64-apple-darwin25-ar'
|
||||||
|
strip = 'arm64-apple-darwin25-strip'
|
||||||
|
pkg-config = 'pkg-config'
|
||||||
|
ranlib = '/usr/bin/true'
|
||||||
|
|
||||||
|
[host_machine]
|
||||||
|
system = 'darwin'
|
||||||
|
cpu_family = 'aarch64'
|
||||||
|
cpu = 'arm64'
|
||||||
|
endian = 'little'
|
||||||
|
|
||||||
|
[built-in options]
|
||||||
|
c_args = ['-mmacosx-version-min=15.0']
|
||||||
|
cpp_args = ['-mmacos-version-min=15.0']
|
||||||
|
c_link_args = ['-mmacosx-version-min=15.0']
|
||||||
|
cpp_link_args = ['-mmacos-version-min=15.0']
|
||||||
19
cross/wasm.ini
Normal file
19
cross/wasm.ini
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
[binaries]
|
||||||
|
cpp = 'em++'
|
||||||
|
ar = 'emar'
|
||||||
|
strip = 'emstrip'
|
||||||
|
|
||||||
|
exec_wrapper = 'node'
|
||||||
|
|
||||||
|
[built-in options]
|
||||||
|
cpp_args = ['-Dpkg_config=false', '-Dbuild_tests=false', '-Dbuild_examples=true', '-fwasm-exceptions', '-s', 'MEMORY64=1']
|
||||||
|
cpp_link_args = ['-s', 'WASM=1', '-s', 'ALLOW_MEMORY_GROWTH=1', '-s', 'MEMORY64=1', '-fwasm-exceptions']
|
||||||
|
|
||||||
|
[host_machine]
|
||||||
|
system = 'emscripten'
|
||||||
|
cpu_family = 'wasm64'
|
||||||
|
cpu = 'wasm64'
|
||||||
|
endian = 'little'
|
||||||
|
|
||||||
|
[properties]
|
||||||
|
cmake_toolchain_file = '/home/tboudreaux/Programming/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake'
|
||||||
1
examples/meson.build
Normal file
1
examples/meson.build
Normal file
@@ -0,0 +1 @@
|
|||||||
|
executable('simple_constant_usage', 'simple.cpp', dependencies: [const_dep])
|
||||||
13
examples/simple.cpp
Normal file
13
examples/simple.cpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#include "fourdst/constants/const.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
fourdst::constant::Constants& C = fourdst::constant::Constants::getInstance();
|
||||||
|
|
||||||
|
std::cout << "Speed of light is " << C.get("c") << std::endl;
|
||||||
|
std::cout << "All avalible constants are: ";
|
||||||
|
|
||||||
|
for (const auto& key : C.keys()) {
|
||||||
|
std::cout << "\t " << key << ": " << C[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
11
meson.build
11
meson.build
@@ -28,9 +28,16 @@ cpp = meson.get_compiler('cpp')
|
|||||||
subdir('assets/static')
|
subdir('assets/static')
|
||||||
|
|
||||||
subdir('src')
|
subdir('src')
|
||||||
subdir('tests')
|
|
||||||
|
|
||||||
if get_option('pkg-config')
|
if get_option('build_tests')
|
||||||
|
subdir('tests')
|
||||||
|
endif
|
||||||
|
|
||||||
|
if get_option('build_examples')
|
||||||
|
subdir('examples')
|
||||||
|
endif
|
||||||
|
|
||||||
|
if get_option('pkg_config')
|
||||||
message('Generating pkg-config file for libconstants...')
|
message('Generating pkg-config file for libconstants...')
|
||||||
pkg = import('pkgconfig')
|
pkg = import('pkgconfig')
|
||||||
pkg.generate(
|
pkg.generate(
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
option('pkg-config', type: 'boolean', value: true, description: 'generate pkg-config file for libconstants (fourdst_constants.pc)')
|
option('pkg_config', type: 'boolean', value: true, description: 'generate pkg-config file for libconstants (fourdst_constants.pc)')
|
||||||
|
option('build_tests', type: 'boolean', value: true, description: 'control if tests are built or not')
|
||||||
|
option('build_examples', type: 'boolean', value: true, description: 'control if examples is built or not')
|
||||||
|
|||||||
@@ -20,11 +20,10 @@
|
|||||||
// *********************************************************************** */
|
// *********************************************************************** */
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
|
||||||
#include "fourdst/constants/const.h"
|
#include "fourdst/constants/const.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user