diff --git a/.gitignore b/.gitignore index 475a8b5..6c2375d 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ *.app build/ +CMakeUserPresets.json # CLion stuff cmake-build-* diff --git a/CMakeLists.txt b/CMakeLists.txt index 1222d90..a4768ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,8 @@ cmake_minimum_required(VERSION 3.10) + +# Include the Conan provider to automatically handle dependencies +set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/conan_provider.cmake") + project(asm-parser) set(CMAKE_CXX_STANDARD 20) diff --git a/README.md b/README.md index f2ac4d9..a472ec8 100644 --- a/README.md +++ b/README.md @@ -24,22 +24,25 @@ Other parameters: Feeding an objdump via stdin into asm-parser: -`objdump --d a.out -l --insn-width=16 | asm-parser -stdin -binary` +`objdump -d a.out -l --insn-width=16 | asm-parser -stdin -binary` -### Building locally +### Building locally (debug build) -You'll need: -- conan 2 - see `https://github.com/compiler-explorer/asm-parser/blob/main/setup.sh#L1` on how to install and configure -- fmt needs to be build explicitly like so https://github.com/compiler-explorer/asm-parser/blob/main/setup.sh#L12 (don't ask why, no idea) -- `gcc` 12 or similar or later (or hack your settings to support your compiler) +You'll need `gcc` 12 or later (or hack your settings to support your compiler). -Then you can +1. `setup.sh` sets up a venv, installs conan2 in it and uses that to install packages (fmt needs to be explicitly built for some reason): +``` +$ ./setup.sh +``` + +2. Then you can: ``` -$ mkdir build $ cd build -$ cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER= +$ cmake .. -DCMAKE_BUILD_TYPE=Debug $ make -j$(nproc) $ make test ``` (see https://github.com/compiler-explorer/asm-parser/blob/main/build.sh for an example, you might need to configure PATH first before doing so) + +The built executable should be found in the path `./build/src/asm-parser` . \ No newline at end of file diff --git a/build.sh b/build.sh index 431c9c0..aca21cd 100755 --- a/build.sh +++ b/build.sh @@ -4,7 +4,7 @@ PATH=/opt/compiler-explorer/cmake/bin:/opt/compiler-explorer/ninja:$PWD/.venv/bi rm -Rf build mkdir build -cmake -B build -G Ninja -S . -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./conan_provider.cmake -DCMAKE_BUILD_TYPE=Debug +cmake -B build -G Ninja -S . -DCMAKE_BUILD_TYPE=Debug cmake --build build --config Debug CURDIR=$PWD diff --git a/conanfile.txt b/conanfile.txt index b5e2fea..6c12642 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -9,3 +9,4 @@ cmake_layout [generators] CMakeDeps +CMakeToolchain diff --git a/setup.sh b/setup.sh index fb456c3..843797f 100755 --- a/setup.sh +++ b/setup.sh @@ -7,6 +7,7 @@ python3 -m venv .venv .venv/bin/conan profile detect +# Modify the Conan configuration file to retrieve packages with standard C++20 sed -i 's/compiler\.cppstd=.*/compiler.cppstd=20/g' ~/.conan2/profiles/default .venv/bin/conan install --build=fmt/11.0.0 . diff --git a/src/main.cpp b/src/main.cpp index e8219d4..508a4c9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -70,8 +70,16 @@ AsmParserConfiguration getConfigurationFromCommandline(const int argc, const cha int main(int argc, const char **argv) { - std::locale loc("en_US.UTF-8"); - std::locale::global(loc); + try { + std::locale loc("en_US.UTF-8"); + std::locale::global(loc); + } catch (const std::runtime_error& e) { + std::cerr << "Failed to set locale: " << e.what() << std::endl; + std::cerr << "Please make sure that the locale is installed on your system:" << std::endl; + std::cerr << "$ sudo apt-get install locales" << std::endl; + std::cerr << "$ locale-gen en_US.UTF-8" << std::endl; + return 1; + } AsmParser::global_start_timer();