phryniszak / strtt

Segger RTT console using ST-link
GNU General Public License v3.0
41 stars 7 forks source link

fix compile issue under mac os #4

Closed hitsmaxft closed 3 months ago

hitsmaxft commented 4 months ago
  1. fix makefile compile error under darwin ; and move build target to root compile dir
  2. add a nix shell.nix for compile and developing strtt
phryniszak commented 4 months ago

Thanks, looks good to me. I have no way to verify mac build by I try to merge it anyway.

Could you please tell me what is the purpose of shell.nix with some references to nrf?

{ pkgs ? import <nixpkgs> {} }:

pkgs.mkShell {
  name = "nrf51-dev-environment";

  buildInputs = with pkgs; [
    inetutils
    openocd
    cmake
    ninja
    python3 # The nRF tools often require Python
    gcc-arm-embedded
  ];
  nativeBuildInputs = [
      pkgs.libusb1
  ];

  # Set the required environment variables
  shellHook = ''
  '';
}
hitsmaxft commented 3 months ago

Thanks, looks good to me. I have no way to verify mac build by I try to merge it anyway.

Could you please tell me what is the purpose of shell.nix with some references to nrf?

{ pkgs ? import <nixpkgs> {} }:

pkgs.mkShell {
  name = "nrf51-dev-environment";

  buildInputs = with pkgs; [
    inetutils
    openocd
    cmake
    ninja
    python3 # The nRF tools often require Python
    gcc-arm-embedded
  ];
  nativeBuildInputs = [
      pkgs.libusb1
  ];

  # Set the required environment variables
  shellHook = ''
  '';
}

I've forgot to remove my testing configurations.

After make some code cleanup , shell.nix provides a clean build shell for strtt in nix

strtt on  mac_support via △
❯ nix-shell
[WARN] - (starship::utils): Executing command "/nix/store/bin32lqag7lx38994xpf9jvhk1xbd64c-cmake-3.28.2/bin/cmake" timed out.
[WARN] - (starship::utils): You can set command_timeout in your config to a higher value to allow longer-running commands to keep executing.

strtt on  mac_support via △ v3.28.2 in ❄️  impure
✗  cmake .
CMake Deprecation Warning at CMakeLists.txt:3 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- The C compiler identification is Clang 16.0.6
-- The CXX compiler identification is Clang 16.0.6
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /nix/store/6kpjydf9x7zqa1xq2qipnwr32ki3fs2n-clang-wrapper-16.0.6/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /nix/store/6kpjydf9x7zqa1xq2qipnwr32ki3fs2n-clang-wrapper-16.0.6/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- LIBUSB_INCLUDE_DIR="/nix/store/0r2bbar77ag3ngr21pdv2dg0x6g87r7f-libusb-1.0.27-dev/include/libusb-1.0"
-- LIBUSB_LIBRARY="/nix/store/zg05db67jhdcfg96kmj4w59jb6ccncs8-libusb-1.0.27/lib/libusb-1.0.dylib"
-- CMAKE_VERSION="3.28.2"
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- CMAKE_USE_PTHREADS_INIT="1"
-- Configuring done (18.1s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/hitsmaxft/Projects/rust/strtt

strtt on  mac_support [?] via △ v3.28.2 in ❄️  impure took 18s
❯ make
[ 11%] Building C object src/openocd/CMakeFiles/stlink.dir/log.c.o
[ 22%] Building C object src/openocd/CMakeFiles/stlink.dir/stlink.c.o
[ 33%] Building C object src/openocd/CMakeFiles/stlink.dir/helper_time_support.c.o
[ 44%] Building C object src/openocd/CMakeFiles/stlink.dir/adapter.c.o
[ 55%] Building C object src/openocd/CMakeFiles/stlink.dir/libusb_helper.c.o
[ 66%] Building C object src/openocd/CMakeFiles/stlink.dir/helper_replacement.c.o
[ 66%] Built target stlink
[ 77%] Building CXX object src/rtt/CMakeFiles/strtt.dir/strtt.cpp.o
[ 88%] Building CXX object src/rtt/CMakeFiles/strtt.dir/strttapp.cpp.o
In file included from /Users/hitsmaxft/Projects/rust/strtt/src/rtt/strttapp.cpp:23:
/Users/hitsmaxft/Projects/rust/strtt/src/rtt/kbhit.h:7:9: warning: 'FIONREAD' macro redefined [-Wmacro-redefined]
#define FIONREAD 0x541B
        ^
/nix/store/2cgdzzb6wy0jnnzsqrq93lw7bzxr9w8h-libSystem-11.0.0/include/sys/filio.h:77:9: note: previous definition is here
#define FIONREAD        _IOR('f', 127, int)     /* get # bytes to read */
        ^
1 warning generated.
[100%] Linking CXX executable strtt
[100%] Built target strtt