Unverified Commit 7c87ea18 authored by Ulysses Zhan's avatar Ulysses Zhan
Browse files

megacmd: add darwin support

parent 4211063d
Loading
Loading
Loading
Loading
+49 −0
Original line number Diff line number Diff line
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,6 +25,11 @@ AM_CPPFLAGS = \
 
 AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/sdk/include
 
+if DARWIN
+AM_LIBTOOLFLAGS="--tag=CXX"
+AM_CPPFLAGS+=-I$(top_srcdir)/include/mega/osx -I$(top_srcdir)/sdk/include/mega/osx
+endif
+
 if WIN32
 AM_CPPFLAGS+=-I$(top_srcdir)/sdk/include/mega/win32
 else
--- a/src/megacmdshell/megacmdshellcommunications.cpp
+++ b/src/megacmdshell/megacmdshellcommunications.cpp
@@ -306,10 +306,6 @@ SOCKET MegaCmdShellCommunications::createSocket(int number, bool initializeserve
         #endif
                     const char executable2[] = "./mega-cmd-server";
     #else
-        #ifdef __MACH__
-                    const char executable[] = "/Applications/MEGAcmd.app/Contents/MacOS/mega-cmd";
-                    const char executable2[] = "./mega-cmd";
-        #else
                     const char executable[] = "mega-cmd-server";
             #ifdef __linux__
                     char executable2[PATH_MAX];
@@ -317,7 +313,6 @@ SOCKET MegaCmdShellCommunications::createSocket(int number, bool initializeserve
             #else
                     const char executable2[] = "./mega-cmd-server";
             #endif
-        #endif
     #endif
 
                     std::vector<char*> argsVector{
--- a/sdk/Makefile.am
+++ b/sdk/Makefile.am
@@ -27,6 +27,11 @@ AM_CPPFLAGS = \
 
 include m4/aminclude.am
 
+if DARWIN
+AM_LIBTOOLFLAGS="--tag=CXX"
+AM_CPPFLAGS+=-I$(top_srcdir)/include/mega/osx
+endif
+
 if WIN32
 AM_CPPFLAGS+=-I$(top_srcdir)/include/mega/win32
 else
+44 −28
Original line number Diff line number Diff line
@@ -25,17 +25,29 @@
let
  pname = "megacmd";
  version = "1.7.0";
  srcOptions =
    if stdenv.isLinux then
      {
        tag = "${version}_Linux";
        hash = "sha256-UlSqwM8GQKeG8/K0t5DbM034NQOeBg+ujNi/MMsVCuM=";
      }
    else
      {
        tag = "${version}_macOS";
        hash = "sha256-UlSqwM8GQKeG8/K0t5DbM034NQOeBg+ujNi/MMsVCuM=";
      };
in
stdenv.mkDerivation {
  inherit pname version;

  src = fetchFromGitHub {
  src = fetchFromGitHub (
    srcOptions
    // {
      owner = "meganz";
      repo = "MEGAcmd";
    rev = "${version}_Linux";
    hash = "sha256-UlSqwM8GQKeG8/K0t5DbM034NQOeBg+ujNi/MMsVCuM=";
      fetchSubmodules = true;
  };
    }
  );

  enableParallelBuilding = true;
  nativeBuildInputs = [
@@ -43,13 +55,14 @@ stdenv.mkDerivation {
    pkg-config
  ];

  buildInputs = [
  buildInputs =
    lib.optionals stdenv.isLinux [ gcc-unwrapped ] # fix: ld: cannot find lib64/libstdc++fs.a
    ++ [
      c-ares
      cryptopp
      curl
      ffmpeg
      icu
    gcc-unwrapped
      libmediainfo
      libraw
      libsodium
@@ -58,10 +71,10 @@ stdenv.mkDerivation {
      pcre-cpp
      readline
      sqlite
  ] ++ lib.optionals withFreeImage [ freeimage ];
    ]
    ++ lib.optionals withFreeImage [ freeimage ];

  configureFlags = [
    "--disable-curl-checks"
    "--disable-examples"
    "--with-cares"
    "--with-cryptopp"
@@ -77,8 +90,14 @@ stdenv.mkDerivation {
    "--with-termcap"
  ] ++ (if withFreeImage then [ "--with-freeimage" ] else [ "--without-freeimage" ]);

  # On darwin, some macros defined in AssertMacros.h (from apple-sdk) are conflicting.
  postConfigure = ''
    echo '#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0' >> sdk/include/mega/config.h
  '';

  patches = [
    ./fix-ffmpeg.patch # https://github.com/meganz/sdk/issues/2635#issuecomment-1495405085
    ./fix-darwin.patch # fix: libtool tag not found; MacFileSystemAccess not declared; server cannot init
  ];

  meta = {
@@ -88,10 +107,7 @@ stdenv.mkDerivation {
      bsd2
      gpl3Only
    ];
    platforms = [
      "i686-linux"
      "x86_64-linux"
    ];
    platforms = lib.platforms.linux ++ lib.platforms.darwin;
    maintainers = with lib.maintainers; [
      lunik1
      ulysseszhan