can now build Android targeted binary
Various things that don't work on Android are just ifdefed out. * the webapp (needs template haskell for arm) * --include and --exclude globbing (needs libpcre, which is not ported; probably I'll make it use the pure haskell glob library instead) * annex.diskreserve checking (missing sys/statvfs.h) * timestamp preservation support (yawn) * S3 * WebDAV * XMPP The resulting 17mb binary has been tested on Android, and it is able to, at least, print its usage message.
This commit is contained in:
parent
f202d997f4
commit
43b4b7d43a
7 changed files with 64 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
12
Limit.hs
12
Limit.hs
|
@ -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. -}
|
||||
|
|
25
Makefile
25
Makefile
|
@ -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)
|
||||
|
|
|
@ -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 $
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue