diff options
-rw-r--r-- | Assistant/Pairing.hs | 9 | ||||
-rw-r--r-- | Command/Add.hs | 6 | ||||
-rw-r--r-- | Limit.hs | 12 | ||||
-rw-r--r-- | Makefile | 25 | ||||
-rw-r--r-- | Utility/ThreadScheduler.hs | 8 | ||||
-rw-r--r-- | Utility/libdiskfree.c | 5 | ||||
-rw-r--r-- | Utility/libmounts.h | 5 |
7 files changed, 64 insertions, 6 deletions
diff --git a/Assistant/Pairing.hs b/Assistant/Pairing.hs index 6df54873a..2c1fcf0d0 100644 --- a/Assistant/Pairing.hs +++ b/Assistant/Pairing.hs @@ -5,6 +5,8 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Assistant.Pairing where import Common.Annex @@ -70,7 +72,12 @@ data PairingInProgress = PairingInProgress } deriving (Show) -data SomeAddr = IPv4Addr HostAddress | IPv6Addr HostAddress6 +data SomeAddr = IPv4Addr HostAddress +{- My Android build of the Network library does not currently have IPV6 + - support. -} +#ifndef WITH_ANDROID + | IPv6Addr HostAddress6 +#endif deriving (Ord, Eq, Read, Show) {- This contains the whole secret, just lightly obfuscated to make it not diff --git a/Command/Add.hs b/Command/Add.hs index a68b190de..bfab33099 100644 --- a/Command/Add.hs +++ b/Command/Add.hs @@ -5,6 +5,8 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Command.Add where import Common.Annex @@ -18,7 +20,9 @@ import Logs.Location import Annex.Content import Annex.Content.Direct import Annex.Perms +#ifndef WITH_ANDROID import Utility.Touch +#endif import Utility.FileMode import Config import qualified Git.HashObject @@ -141,12 +145,14 @@ link file key hascontent = handle (undo file key) $ do l <- calcGitLink file key liftIO $ createSymbolicLink l file +#ifndef WITH_ANDROID when hascontent $ do -- touch the symlink to have the same mtime as the -- file it points to liftIO $ do mtime <- modificationTime <$> getFileStatus file touch file (TimeSpec mtime) False +#endif return l @@ -5,13 +5,17 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Limit where -import Text.Regex.PCRE.Light.Char8 -import System.Path.WildMatch import Data.Time.Clock.POSIX import qualified Data.Set as S import qualified Data.Map as M +#ifndef WITH_ANDROID +import Text.Regex.PCRE.Light.Char8 +import System.Path.WildMatch +#endif import Common.Annex import qualified Annex @@ -81,11 +85,15 @@ limitExclude :: MkLimit limitExclude glob = Right $ const $ return . not . matchglob glob matchglob :: String -> Annex.FileInfo -> Bool +#ifdef WITH_ANDROID +matchglob _ _ = error "glob matching not supported" +#else matchglob glob (Annex.FileInfo { Annex.matchFile = f }) = isJust $ match cregex f [] where cregex = compile regex [] regex = '^':wildToRegex glob +#endif {- Adds a limit to skip files not believed to be present - in a specfied repository. -} @@ -14,6 +14,12 @@ sources=Build/SysConfig.hs Utility/Touch.hs Utility/Mounts.hs all=$(bins) $(mans) docs OS:=$(shell uname | sed 's/[-_].*//') +ifeq ($(ANDROID),1) +OPTFLAGS?=-DWITH_INOTIFY -DWITH_ANDROID +clibs=Utility/libdiskfree.o Utility/libmounts.o +CFLAGS:=-Wall -DWITH_ANDROID +THREADFLAGS=-threaded +else ifeq ($(OS),Linux) OPTFLAGS?=-DWITH_INOTIFY -DWITH_DBUS clibs=Utility/libdiskfree.o Utility/libmounts.o @@ -41,6 +47,7 @@ clibs=Utility/libdiskfree.o Utility/libmounts.o Utility/libkqueue.o endif endif endif +endif ALLFLAGS = $(BASEFLAGS) $(FEATURES) $(OPTFLAGS) $(THREADFLAGS) @@ -51,7 +58,8 @@ ifdef PROFILE GHCFLAGS=-prof -auto-all -rtsopts -caf-all -fforce-recomp $(ALLFLAGS) endif -GHCMAKE=ghc $(GHCFLAGS) --make +GHC?=ghc +GHCMAKE=$(GHC) $(GHCFLAGS) --make # Am I typing :make in vim? Do a fast build. ifdef VIM @@ -113,7 +121,7 @@ test: $(sources) $(clibs) testcoverage: rm -f test.tix test - ghc $(GHCFLAGS) -outputdir $(GIT_ANNEX_TMP_BUILD_DIR)/testcoverage --make -fhpc test + $(GHC) $(GHCFLAGS) -outputdir $(GIT_ANNEX_TMP_BUILD_DIR)/testcoverage --make -fhpc test ./test @echo "" @hpc report test --exclude=Main --exclude=QC @@ -216,6 +224,19 @@ osxapp: rm -f tmp/git-annex.dmg.bz2 bzip2 --fast tmp/git-annex.dmg +# Cross compile for Android binary. +# Uses https://github.com/neurocyte/ghc-android +# +# configure is run, probing the local system. +# So the Android should have all the same stuff that configure probes for, +# including the same version of git. +android: + $(MAKE) Build/SysConfig.hs + GHC=$$HOME/.ghc-android-14-arm-linux-androideabi-4.7/bin/arm-unknown-linux-androideabi-ghc \ + CC=$$HOME/.ghc-android-14-arm-linux-androideabi-4.7/bin/arm-linux-androideabi-gcc \ + FEATURES="-DWITH_ANDROID -DWITH_ASSISTANT -DWITH_DNS" \ + ANDROID=1 $(MAKE) fast + # used by ./ghci getflags: @echo $(ALLFLAGS) $(clibs) diff --git a/Utility/ThreadScheduler.hs b/Utility/ThreadScheduler.hs index 96bccbe70..fdf40ab6d 100644 --- a/Utility/ThreadScheduler.hs +++ b/Utility/ThreadScheduler.hs @@ -6,13 +6,17 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Utility.ThreadScheduler where import Common import Control.Concurrent -import System.Posix.Terminal import System.Posix.Signals +#ifndef WITH_ANDROID +import System.Posix.Terminal +#endif newtype Seconds = Seconds { fromSeconds :: Int } deriving (Eq, Ord, Show) @@ -49,8 +53,10 @@ waitForTermination :: IO () waitForTermination = do lock <- newEmptyMVar check softwareTermination lock +#ifndef WITH_ANDROID whenM (queryTerminal stdInput) $ check keyboardSignal lock +#endif takeMVar lock where check sig lock = void $ diff --git a/Utility/libdiskfree.c b/Utility/libdiskfree.c index 5e84d4bde..a9ca90b41 100644 --- a/Utility/libdiskfree.c +++ b/Utility/libdiskfree.c @@ -22,6 +22,10 @@ # define STATCALL statfs /* statfs64 not yet tested on a real FreeBSD machine */ # define STATSTRUCT statfs #else +#if defined WITH_ANDROID +# warning free space checking code not available for Android +# define UNKNOWN +#else #if defined (__linux__) || defined (__FreeBSD_kernel__) /* Linux or Debian kFreeBSD */ /* This is a POSIX standard, so might also work elsewhere too. */ @@ -34,6 +38,7 @@ #endif #endif #endif +#endif #include <errno.h> #include <stdio.h> diff --git a/Utility/libmounts.h b/Utility/libmounts.h index b65978629..76b2484d3 100644 --- a/Utility/libmounts.h +++ b/Utility/libmounts.h @@ -5,6 +5,10 @@ # include <sys/mount.h> # define GETMNTINFO #else +#if defined WITH_ANDROID +# warning mounts listing code not available for Android +# define UNKNOWN +#else #if defined (__linux__) || defined (__FreeBSD_kernel__) /* Linux or Debian kFreeBSD */ #include <mntent.h> @@ -14,6 +18,7 @@ # define UNKNOWN #endif #endif +#endif #include <stdio.h> |