diff --git a/README.md b/README.md index cfc1bc7..ad21dbb 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,23 @@ Converts asm to pseudo-C code. Requires [rizin](https://github.com/rizinorg/rizin). -# Install +# Install system wide Follow the following steps to install jsdec - clone this repository - Run `cd p` - - Run `meson -Djsc_folder=".." build` to create the build folder + - Run `meson -Djsc_folder=".." --prefix=/usr build` to create the build folder - Run `ninja -C build install` to build the shared library and to install it + +# Install in home folder (or in other paths) + +If you want to install in the HOME folder or in other non standard paths, just +set the `prefix` to a different value + - Run `cd p` + - Run ``meson -Djsc_folder=".." --prefix=~/.local build`` + - Run `ninja -C build install` + # Usage * Open your file with rizin diff --git a/p/meson.build b/p/meson.build index e73fcc7..41cd643 100644 --- a/p/meson.build +++ b/p/meson.build @@ -1,46 +1,28 @@ -project('jsdec', 'c', meson_version: '>=0.46.0') +project('jsdec', 'c', meson_version: '>=0.51.0') pyth = import('python').find_installation() -rizin = find_program('rizin', required: false) cc = meson.get_compiler('c') -incs = ['.'] +incs = ['.', 'duktape'] deps = [] c_args = [] -rizin_incdir = get_option('rizin_incdir') -if rizin_incdir == '' and rizin.found() - rizin_incdir = run_command(rizin, '-H', 'RZ_INCDIR').stdout().strip() -endif - -rizin_libdir = get_option('rizin_libdir') -if rizin_libdir == '' and rizin.found() - rizin_libdir = run_command(rizin, '-H', 'RZ_LIBDIR').stdout().strip() -endif - -rizin_plugdir = get_option('rizin_plugdir') -if rizin_plugdir == '' and rizin.found() - rizin_plugdir = run_command(rizin, '-H', 'RZ_USER_PLUGINS').stdout().strip() - if rizin_plugdir == '' - rizin_plugdir = get_option('libdir') - endif -endif - -plugin_jsdec_dir = join_paths(rizin_plugdir, 'jsdec') - -libs = ['rz_core', 'rz_util', 'rz_cons', 'rz_config', 'rz_io'] -foreach lib : libs - deps += cc.find_library(lib, dirs: rizin_libdir) -endforeach - +rz_core_dep = dependency('rz_core') +deps += rz_core_dep +deps += dependency('rz_util') +deps += dependency('rz_cons') +deps += dependency('rz_config') +deps += dependency('rz_io') deps += cc.find_library('m', required: false) -if rizin_incdir != '' - incs += rizin_incdir - incs += rizin_incdir + '/sdb' +rizin_plugdir = get_option('rizin_plugdir') +if rizin_plugdir == '' + rizin_plugdir = rz_core_dep.get_variable(pkgconfig: 'plugindir', cmake: 'rz_core_PLUGINDIR') + plugin_jsdec_dir = join_paths(get_option('prefix'), rizin_plugdir, 'jsdec') +else + plugin_jsdec_dir = join_paths(rizin_plugdir, 'jsdec') endif -incs += 'duktape' files = [ 'core_pdd.c', @@ -67,9 +49,7 @@ if jsc_folder != '' ) endif -message('Rizin Include Dir: ' + rizin_incdir) -message('Rizin Library Dir: ' + rizin_libdir) -message('Rizin Plugin Dir: ' + rizin_plugdir) +message('Rizin Plugin Dir: ' + plugin_jsdec_dir) if jsc_folder != '' message('JS to C Folder: ' + jsc_folder) endif @@ -88,4 +68,4 @@ if jsc_folder == '' install_subdir(join_paths('..', 'themes'), install_dir: plugin_jsdec_dir) install_data(join_paths('..', 'jsdec-duk.js'), install_dir: plugin_jsdec_dir) install_data(join_paths('..', 'require.js'), install_dir: plugin_jsdec_dir) -endif \ No newline at end of file +endif diff --git a/p/meson_options.txt b/p/meson_options.txt index 0a96876..e5e3a6b 100644 --- a/p/meson_options.txt +++ b/p/meson_options.txt @@ -1,4 +1,2 @@ -option('rizin_libdir', type: 'string', value: '', description: 'rizin library directory') -option('rizin_incdir', type: 'string', value: '', description: 'rizin include directory') option('rizin_plugdir', type: 'string', value: '', description: 'rizin install directory') option('jsc_folder', type: 'string', value: '', description: 'When a path is defined, the js code, found in its subfolders, is embedded into the C code.') \ No newline at end of file