quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

meson.build (6025B)


      1 project('quickjs-tart', 'c',
      2   version : '0.0.1',
      3   meson_version: '>=0.55.0',
      4   default_options : [
      5     'warning_level=1',
      6     'optimization=2',
      7   ],
      8 )
      9 
     10 flags = [
     11   '-D_GNU_SOURCE',
     12   '-D_LARGEFILE_SOURCE',
     13   '-D_FILE_OFFSET_BITS=64',
     14   '-DCONFIG_VERSION="0.0.1"',
     15   '-DCONFIG_BIGNUM',
     16   '-fno-omit-frame-pointer',
     17 ]
     18 
     19 add_project_arguments(flags, language : 'c')
     20 add_project_arguments(flags, language : 'c', native : true)
     21 
     22 if host_machine.system() == 'android'
     23   add_project_link_arguments('-Wl,--hash-style=both', language : 'c')
     24 endif
     25 
     26 
     27 cc = meson.get_compiler('c')
     28 
     29 m_dep = cc.find_library('m', required : false)
     30 dl_dep = cc.find_library('dl', required : true)
     31 thread_dep = dependency('threads')
     32 
     33 cmake = import('cmake')
     34 cmake_opts = cmake.subproject_options()
     35 cmake_opts.add_cmake_defines({
     36   'CMAKE_POSITION_INDEPENDENT_CODE' : true,
     37   'ENABLE_TESTING' : false,
     38   'ENABLE_PROGRAMS' : false})
     39 
     40 # TLS library
     41 mbedtls_proj = cmake.subproject('mbedtls', required : true, options : cmake_opts)
     42 mbedcrypto_dep = mbedtls_proj.dependency('mbedcrypto')
     43 mbedtls_dep = mbedtls_proj.dependency('mbedtls')
     44 mbedx509_dep = mbedtls_proj.dependency('mbedx509')
     45 
     46 # Library for HTTP requests
     47 curl_proj = subproject('curl', required : true)
     48 curl_dep = curl_proj.get_variable('curl_dep')
     49 
     50 # Crypto library
     51 sodium_proj = subproject('libsodium', required : true)
     52 sodium_dep = sodium_proj.get_variable('sodium_dep')
     53 
     54 # quickjs math library (big float)
     55 libbf = static_library('bf', 'quickjs/libbf.c')
     56 # regular expression library
     57 libregexp = static_library('regexp', 'quickjs/libregexp.c')
     58 # unicode
     59 libunicode = static_library('unicode', 'quickjs/libunicode.c')
     60 # general utilities
     61 cutils = static_library('cutils', 'quickjs/cutils.c')
     62 # standard library for quickjs (std and os modules)
     63 quickjs_libc = static_library('quickjs-libc', ['quickjs/quickjs-libc.c', 'quickjs/quickjs-http.c'], dependencies : curl_dep )
     64 # base JS interpreter
     65 quickjs = static_library('quickjs', 'quickjs/quickjs.c')
     66 sqlite3 = static_library('sqlite3', 'sqlite3/sqlite3.c')
     67 
     68 # avoid warning but compile more slowly on non-cross builds
     69 avoid_cross_warning = true
     70 
     71 # native version of quickjs used by the qjsc (.js -> .c compiler),
     72 # compiled for the build platform.
     73 if avoid_cross_warning or meson.is_cross_build()
     74   libbf_native = static_library('bf_native', 'quickjs/libbf.c', native : true)
     75   libregexp_native = static_library('regexp_native', 'quickjs/libregexp.c', native : true)
     76   libunicode_native = static_library('unicode_native', 'quickjs/libunicode.c', native : true)
     77   cutils_native = static_library('cutils_native', 'quickjs/cutils.c', native : true)
     78   quickjs_native = static_library('quickjs_native', 'quickjs/quickjs.c', native : true)
     79 else
     80   libbf_native = libbf
     81   libregexp_native = libregexp
     82   libunicode_native = libunicode
     83   cutils_native = cutils
     84   quickjs_libc_native = quickjs_libc
     85   quickjs_native = quickjs
     86 endif
     87 
     88 # QuickJS compiler (.js -> C)
     89 qjsc_exe = executable('qjsc', [
     90   'quickjs/qjsc.c',
     91   'quickjs/quickjs-libc.c',
     92   ],
     93   # Just the compiler, no HTTP support required
     94   c_args : ['-DNO_HTTP'],
     95   link_with: [
     96     libbf_native, 
     97     libregexp_native, 
     98     libunicode_native,
     99     cutils_native,
    100     quickjs_native,
    101   ],
    102   dependencies: [
    103     m_dep,
    104     dl_dep,
    105     thread_dep,
    106   ],
    107   native : true)
    108 
    109 # JS implementation of the read-eval-print loop,
    110 # just used for interactive testing
    111 repl_c = custom_target('repl_c',
    112   input : ['quickjs/repl.js'],
    113   output : ['repl.c'],
    114   command : [qjsc_exe, '-c', '-m',
    115     '-o', '@OUTPUT@',
    116     '@INPUT@'])
    117 
    118 # Helper functions used by the wallet-core JS,
    119 # compiled to C.
    120 prelude_c = custom_target('prelude_c',
    121   input : ['prelude.js'],
    122   output : ['prelude.c'],
    123   command : [qjsc_exe, '-c', '-m', '-M', 'tart',
    124     '-o', '@OUTPUT@',
    125     '@INPUT@'])
    126 
    127 # Wallet core JS file,
    128 # compiled to C.
    129 wallet_core_c = custom_target('wallet_core_c',
    130   input : ['taler-wallet-core-qjs.mjs'],
    131   output : ['wallet_core.c'],
    132   command : [qjsc_exe, '-c', '-m', '-M', 'tart', '-N', 'qjsc_wallet_core',
    133     '-o', '@OUTPUT@',
    134     '@INPUT@'])
    135 
    136 # Static libraries from the generated C files
    137 repl = static_library('repl', repl_c)
    138 prelude = static_library('prelude', prelude_c)
    139 wallet_core = static_library('wallet_core', wallet_core_c)
    140 
    141 # Taler runtime ("tart") loadable JavaScript module
    142 tart = static_library('tart', 'tart_module.c',
    143   link_with : [sqlite3],
    144   dependencies : [
    145     m_dep,
    146     mbedcrypto_dep,
    147     mbedtls_dep,
    148     mbedx509_dep,
    149     sodium_dep
    150   ])
    151 
    152 # Interactive JS interpreter with Taler-specific
    153 # functions (crypto etc.)
    154 if not meson.is_cross_build()
    155   qtart_exe = executable('qtart', [
    156     'qtart.c',
    157   ],
    158   link_with: [
    159     libbf, 
    160     libregexp, 
    161     libunicode ,
    162     cutils,
    163     quickjs_libc,
    164     quickjs,
    165     repl,
    166     wallet_core,
    167     prelude,
    168     tart,
    169   ],
    170   dependencies: [
    171     m_dep,
    172     mbedcrypto_dep,
    173     mbedtls_dep,
    174     mbedx509_dep,
    175     curl_dep,
    176     sodium_dep
    177   ])
    178 endif
    179 
    180 # Library that implements wallet-core, typically
    181 # the only build output directly used by the UI layer.
    182 if host_machine.system() == 'ios'
    183   talerwalletcore_lib = static_library('talerwalletcore', 'taler_wallet_core_lib.c',
    184     link_with : [
    185       libbf,
    186       libregexp,
    187       libunicode,
    188       cutils,
    189       quickjs_libc,
    190       quickjs,
    191       tart,
    192       wallet_core,
    193       prelude,
    194     ],
    195     dependencies: [
    196       m_dep,
    197       mbedcrypto_dep,
    198       mbedtls_dep,
    199       mbedx509_dep,
    200       sodium_dep,
    201     ])
    202 else
    203   talerwalletcore_lib = shared_library('talerwalletcore', 'taler_wallet_core_lib.c',
    204     link_with : [
    205       libbf,
    206       libregexp,
    207       libunicode,
    208       cutils,
    209       quickjs_libc,
    210       quickjs,
    211       tart,
    212       wallet_core,
    213       prelude,
    214     ],
    215     dependencies: [
    216       m_dep,
    217       mbedcrypto_dep,
    218       mbedtls_dep,
    219       mbedx509_dep,
    220       sodium_dep,
    221     ])
    222 endif
    223 
    224 # Example for using libtalerwalletcore.so
    225 if not meson.is_cross_build()
    226   wallet_client_example_exe = executable('wallet-client-example',
    227     'wallet-client-example.c',
    228     link_with : [talerwalletcore_lib])
    229 endif