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.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Assistant.Pairing where
|
module Assistant.Pairing where
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
|
@ -70,7 +72,12 @@ data PairingInProgress = PairingInProgress
|
||||||
}
|
}
|
||||||
deriving (Show)
|
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)
|
deriving (Ord, Eq, Read, Show)
|
||||||
|
|
||||||
{- This contains the whole secret, just lightly obfuscated to make it not
|
{- 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.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Command.Add where
|
module Command.Add where
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
|
@ -18,7 +20,9 @@ import Logs.Location
|
||||||
import Annex.Content
|
import Annex.Content
|
||||||
import Annex.Content.Direct
|
import Annex.Content.Direct
|
||||||
import Annex.Perms
|
import Annex.Perms
|
||||||
|
#ifndef WITH_ANDROID
|
||||||
import Utility.Touch
|
import Utility.Touch
|
||||||
|
#endif
|
||||||
import Utility.FileMode
|
import Utility.FileMode
|
||||||
import Config
|
import Config
|
||||||
import qualified Git.HashObject
|
import qualified Git.HashObject
|
||||||
|
@ -141,12 +145,14 @@ link file key hascontent = handle (undo file key) $ do
|
||||||
l <- calcGitLink file key
|
l <- calcGitLink file key
|
||||||
liftIO $ createSymbolicLink l file
|
liftIO $ createSymbolicLink l file
|
||||||
|
|
||||||
|
#ifndef WITH_ANDROID
|
||||||
when hascontent $ do
|
when hascontent $ do
|
||||||
-- touch the symlink to have the same mtime as the
|
-- touch the symlink to have the same mtime as the
|
||||||
-- file it points to
|
-- file it points to
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
mtime <- modificationTime <$> getFileStatus file
|
mtime <- modificationTime <$> getFileStatus file
|
||||||
touch file (TimeSpec mtime) False
|
touch file (TimeSpec mtime) False
|
||||||
|
#endif
|
||||||
|
|
||||||
return l
|
return l
|
||||||
|
|
||||||
|
|
12
Limit.hs
12
Limit.hs
|
@ -5,13 +5,17 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Limit where
|
module Limit where
|
||||||
|
|
||||||
import Text.Regex.PCRE.Light.Char8
|
|
||||||
import System.Path.WildMatch
|
|
||||||
import Data.Time.Clock.POSIX
|
import Data.Time.Clock.POSIX
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
#ifndef WITH_ANDROID
|
||||||
|
import Text.Regex.PCRE.Light.Char8
|
||||||
|
import System.Path.WildMatch
|
||||||
|
#endif
|
||||||
|
|
||||||
import Common.Annex
|
import Common.Annex
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
|
@ -81,11 +85,15 @@ limitExclude :: MkLimit
|
||||||
limitExclude glob = Right $ const $ return . not . matchglob glob
|
limitExclude glob = Right $ const $ return . not . matchglob glob
|
||||||
|
|
||||||
matchglob :: String -> Annex.FileInfo -> Bool
|
matchglob :: String -> Annex.FileInfo -> Bool
|
||||||
|
#ifdef WITH_ANDROID
|
||||||
|
matchglob _ _ = error "glob matching not supported"
|
||||||
|
#else
|
||||||
matchglob glob (Annex.FileInfo { Annex.matchFile = f }) =
|
matchglob glob (Annex.FileInfo { Annex.matchFile = f }) =
|
||||||
isJust $ match cregex f []
|
isJust $ match cregex f []
|
||||||
where
|
where
|
||||||
cregex = compile regex []
|
cregex = compile regex []
|
||||||
regex = '^':wildToRegex glob
|
regex = '^':wildToRegex glob
|
||||||
|
#endif
|
||||||
|
|
||||||
{- Adds a limit to skip files not believed to be present
|
{- Adds a limit to skip files not believed to be present
|
||||||
- in a specfied repository. -}
|
- 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
|
all=$(bins) $(mans) docs
|
||||||
|
|
||||||
OS:=$(shell uname | sed 's/[-_].*//')
|
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)
|
ifeq ($(OS),Linux)
|
||||||
OPTFLAGS?=-DWITH_INOTIFY -DWITH_DBUS
|
OPTFLAGS?=-DWITH_INOTIFY -DWITH_DBUS
|
||||||
clibs=Utility/libdiskfree.o Utility/libmounts.o
|
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
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
ALLFLAGS = $(BASEFLAGS) $(FEATURES) $(OPTFLAGS) $(THREADFLAGS)
|
ALLFLAGS = $(BASEFLAGS) $(FEATURES) $(OPTFLAGS) $(THREADFLAGS)
|
||||||
|
|
||||||
|
@ -51,7 +58,8 @@ ifdef PROFILE
|
||||||
GHCFLAGS=-prof -auto-all -rtsopts -caf-all -fforce-recomp $(ALLFLAGS)
|
GHCFLAGS=-prof -auto-all -rtsopts -caf-all -fforce-recomp $(ALLFLAGS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
GHCMAKE=ghc $(GHCFLAGS) --make
|
GHC?=ghc
|
||||||
|
GHCMAKE=$(GHC) $(GHCFLAGS) --make
|
||||||
|
|
||||||
# Am I typing :make in vim? Do a fast build.
|
# Am I typing :make in vim? Do a fast build.
|
||||||
ifdef VIM
|
ifdef VIM
|
||||||
|
@ -113,7 +121,7 @@ test: $(sources) $(clibs)
|
||||||
|
|
||||||
testcoverage:
|
testcoverage:
|
||||||
rm -f test.tix test
|
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
|
./test
|
||||||
@echo ""
|
@echo ""
|
||||||
@hpc report test --exclude=Main --exclude=QC
|
@hpc report test --exclude=Main --exclude=QC
|
||||||
|
@ -216,6 +224,19 @@ osxapp:
|
||||||
rm -f tmp/git-annex.dmg.bz2
|
rm -f tmp/git-annex.dmg.bz2
|
||||||
bzip2 --fast tmp/git-annex.dmg
|
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
|
# used by ./ghci
|
||||||
getflags:
|
getflags:
|
||||||
@echo $(ALLFLAGS) $(clibs)
|
@echo $(ALLFLAGS) $(clibs)
|
||||||
|
|
|
@ -6,13 +6,17 @@
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
|
|
||||||
module Utility.ThreadScheduler where
|
module Utility.ThreadScheduler where
|
||||||
|
|
||||||
import Common
|
import Common
|
||||||
|
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
import System.Posix.Terminal
|
|
||||||
import System.Posix.Signals
|
import System.Posix.Signals
|
||||||
|
#ifndef WITH_ANDROID
|
||||||
|
import System.Posix.Terminal
|
||||||
|
#endif
|
||||||
|
|
||||||
newtype Seconds = Seconds { fromSeconds :: Int }
|
newtype Seconds = Seconds { fromSeconds :: Int }
|
||||||
deriving (Eq, Ord, Show)
|
deriving (Eq, Ord, Show)
|
||||||
|
@ -49,8 +53,10 @@ waitForTermination :: IO ()
|
||||||
waitForTermination = do
|
waitForTermination = do
|
||||||
lock <- newEmptyMVar
|
lock <- newEmptyMVar
|
||||||
check softwareTermination lock
|
check softwareTermination lock
|
||||||
|
#ifndef WITH_ANDROID
|
||||||
whenM (queryTerminal stdInput) $
|
whenM (queryTerminal stdInput) $
|
||||||
check keyboardSignal lock
|
check keyboardSignal lock
|
||||||
|
#endif
|
||||||
takeMVar lock
|
takeMVar lock
|
||||||
where
|
where
|
||||||
check sig lock = void $
|
check sig lock = void $
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
# define STATCALL statfs /* statfs64 not yet tested on a real FreeBSD machine */
|
# define STATCALL statfs /* statfs64 not yet tested on a real FreeBSD machine */
|
||||||
# define STATSTRUCT statfs
|
# define STATSTRUCT statfs
|
||||||
#else
|
#else
|
||||||
|
#if defined WITH_ANDROID
|
||||||
|
# warning free space checking code not available for Android
|
||||||
|
# define UNKNOWN
|
||||||
|
#else
|
||||||
#if defined (__linux__) || defined (__FreeBSD_kernel__)
|
#if defined (__linux__) || defined (__FreeBSD_kernel__)
|
||||||
/* Linux or Debian kFreeBSD */
|
/* Linux or Debian kFreeBSD */
|
||||||
/* This is a POSIX standard, so might also work elsewhere too. */
|
/* This is a POSIX standard, so might also work elsewhere too. */
|
||||||
|
@ -34,6 +38,7 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
# include <sys/mount.h>
|
# include <sys/mount.h>
|
||||||
# define GETMNTINFO
|
# define GETMNTINFO
|
||||||
#else
|
#else
|
||||||
|
#if defined WITH_ANDROID
|
||||||
|
# warning mounts listing code not available for Android
|
||||||
|
# define UNKNOWN
|
||||||
|
#else
|
||||||
#if defined (__linux__) || defined (__FreeBSD_kernel__)
|
#if defined (__linux__) || defined (__FreeBSD_kernel__)
|
||||||
/* Linux or Debian kFreeBSD */
|
/* Linux or Debian kFreeBSD */
|
||||||
#include <mntent.h>
|
#include <mntent.h>
|
||||||
|
@ -14,6 +18,7 @@
|
||||||
# define UNKNOWN
|
# define UNKNOWN
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue