How set up rapidjson without git - linux

I need to use rapidjson as a third party library to replace libjson. I'm trying to figure out how to build it so I can use it's build files in my project (dependency list).
I downloaded rapidjson from github, and I'm trying to get a buildable project. I'm looking at the instructions at rapidjson website, and it's showing that I need to do the following, below (Installation).
We don't use git, so what would I need to do instead of the git submodule update --init step?
Why would I need a build dir in the include/rapidjson directory with nothing in it?
When I cd to build and type cmake, it seems to be missing parameters. What is the full cmake command? Thanks!
Installation
RapidJSON is a header-only C++ library. Just copy the include/rapidjson folder to system or project's include path.
RapidJSON uses following software as its dependencies:
•CMake as a general build tool
•(optional)Doxygen to build documentation
•(optional)googletest for unit and performance testing
To generate user documentation and run tests please proceed with the steps below:
1.Execute git submodule update --init to get the files of thirdparty submodules (google test).
2.Create directory called build in rapidjson source directory.
3.Change to build directory and run cmake .. command to configure your build. Windows users can do the same with cmake-gui application.
4.On Windows, build the solution found in the build directory. On Linux, run make from the build directory.
On successfull build you will find compiled test and example binaries in bin directory. The generated documentation will be available in doc/html directory of the build tree. To run tests after finished build please run make test or ctest from your build tree. You can get detailed output using ctest -V command.
It is possible to install library system-wide by running make install command from the build tree with administrative privileges. This will install all files according to system preferences. Once RapidJSON is installed, it is possible to use it from other CMake projects by adding find_package(RapidJSON) line to your CMakeLists.txt.

It is header-only library. So if you just want to integrate it into your project, just copy the /include folder to your project, and it should works.
All other instructions are for building unit tests, performance tests and documentation.

Related

How can I create a Rust Clippy binary to use as part of a separate standalone application?

I am trying to build a standalone application through which I can run Rust Clippy without needing to install it locally. Essentially, I want to run a command like cargo-clippy -- --message-format=json through my application when a Rust project is uploaded to it.
What I've tried:
I installed cargo locally using the instructions here
I forked the Clippy repo locally into a folder called clippy_local
I ran cargo build on the repo which created some exe binary files including cargo-clippy under clippy_local/target/debug/ (contents of the target folder attached in screenshot below)
I copied this cargo-clippy exe into the tool binaries folder for my application
After this, the project compiles, but when I try to run Clippy through my tool, I get an error like below:
dyld[14510]: Library not loaded: '#rpath/librustc_driver-6ca1b5240144bf0b.dylib'
Referenced from: '/Users/<redacted>/repos/<redacted>/target/webapp/WEB-INF/classes/tools/clippy/cargo-clippy'
Reason: tried: '/usr/local/lib/librustc_driver-6ca1b5240144bf0b.dylib' (no such file), '/usr/lib/librustc_driver-6ca1b5240144bf0b.dylib' (no such file)
My app is running the following command internally to invoke Clippy:
/Users/<redacted>/repos/<redacted>/target/webapp/WEB-INF/classes/tools/clippy/cargo-clippy -- --message-format=json
I was guessing from the error that it has something to do with missing libraries/dependencies (apart from the cargo-clippy exe). I have tried to copy all the contents of the target/debug folder into my app as well, but the same error still persists.
So, I want to know what's going wrong and how I can build a Rust Clippy binary which I can then use to run Clippy from other applications?

Create directory for configuration when running cargo install

I built a tool that requires configuration by means of a config.yaml. I'd like to provide a basic version of that file along with the installation. Is it possible to have customizable task carried out (such as creating a directory under /etc/mytool/ and creating a file herein) when running cargo install --path .?
Build Scripts are your friend.
The Rust file designated by the build command (relative to the package root) will be compiled and invoked before anything else is compiled in the package, allowing your Rust code to depend on the built or generated artifacts. By default Cargo looks up for "build.rs" file in a package root (even if you do not specify a value for build).
Use build = "custom_build_name.rs" to specify a custom build name, e.g. add in Cargo.toml:
[package]
# ...
build = "custom_build_name.rs"

How to set up googletest wtih meson?

I have a git repository with some test code in C++ and I want to use Googletest to write some tests. I used git submodule to get it as part of the above repository. I want to use meson as the build engine. So far, so good.
However, I cannot fathom how to get meson to build and link my tests with the googletest submodule… Should I use a wrap? An external dependency? what?
Note that meson supports dependencies on packaged versions of gtest/gmock but this is not what I want since the developers of gtest/gmock recommend against it. Plus, I want bleeding edge 'cause I am crazy⸮
Furthermore, I do not think ninja plays a role here but I mentioned that I use it just in case.
I tried using the wrap for gtest with
gtest_proj = subproject('gtest')
gtest_dep = gtest_proj.get_variable('gtest_dep')
gmock_dep = gtest_proj.get_variable('gmock_dep')
in meson.build. This builds a local copies of googletest which can then be used like so:
tests_src = [
'tests/gtest-all.cpp',
'tests/test_MyClass.cpp',
]
e = executable(
'gtest-all',
tests_src,
dependencies : [
gtest_dep,
gmock_dep],
link_with : libshield,
)
test('gtest tests', e)
Note that libshield is a shared library created from my (toy) code so I can link to it.
If you would like to use a project that is not meson project you need to find that project in wrapDB:
meson wrap search gtest
If that command gives you name of the wrap then you need to install it to your project:
mkdir -p subprojects
meson wrap install gtest
Then you should reconfigure your project and meson will download that project for you:
meson --reconfigure path/to/build/dir
Additional information you can find in documentation of wrap tool.
--reconfigure - supported since 0.49.0

How do you debug a Node.js addon built with CMake.js?

I want to be able to step though my C++ code for a Node.js addon that I am making. I understand that CMake.js has the --debug option, but there is no documentation about it.
I am using the node-addon-api module, in CLion.
After months of blind debugging though the use of Errors to print variables, I have finally figured out how to attach the CLion debugger to a Node.js addon.
Create a new CMake Application configuration.
Fill in these fields:
Target: Your project
Executable: The Node binary (On Unix do which node or where.exe node on Windows)
Program arguments: Path to your JS file
Working directory: The directory where the JS file is located
Before launch: Build
Start this configuration in debug mode.
I recently stumbled on the same problem and had success creating a custom toolchain in CLion 2020.3 with CMake.js on a Linux system.
Reproducible steps:
Install cmake-js via npm install -g cmake-js. Make sure to install the package globally, so that your toolchain becomes available across multiple projects.
Create a npm project, e.g mkdir my-project && cd my-project && npm init.
Run npm install bindings && npm install node-addon-api (For the C++ wrapper).
Create a CMakeLists.txt in the root directory and paste this. Make sure to replace file(GLOB SOURCE_FILES hello.cpp) with your addon-specific cpp and header files.
Open my-project in CLion.
Go to Settings / Preferences | Build, Execution, Deployment | Custom Build Targets and click + to add a new target.
Go to Build | Tool Settings | Program and set it to the cmake-js binary that you downloaded in the npm directory where you keep your global packages.
Set the arguments to compile -D and set the working directory to the root directory of my-project.
Go to Clean | Tool Settings | Program and set it to the directory where you keep your cmake-js binary. Set the arguments to clean and set the working directory to your project's root directory.
Add a new Run Configuration and specify the Toolchain you just created in the Target field. Point the Executable to your node executable and add the .js file where you import your native addons to. Set the working directory to the current directory as well. Now, you can build the target, and also debug the N-API layer of your native code, too!

Build binary to generate configuration with Cabal

I need to build an executable to test the environment and generate configuration for the following steps of building process. How can I tell Cabal to build such an executable during the configuration stage and not to install it as a part of the distribution?
Modern cabal now has a setup-depends field that lets you specify custom dependencies to your setup script (see: http://cabal.readthedocs.io/en/latest/developing-packages.html?highlight=setup-depends#custom-setup-scripts)
As such, your setup script can now use whatever libraries you want to import.

Resources