fltkhs 0.5.1.5 → 0.5.1.6
raw patch · 6 files changed
+359/−72 lines, 6 filessetup-changedPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.md +7/−20
- Setup.hs +97/−28
- fltk-1.3.4-1-source.tar.gz too large to diff
- fltkhs.cabal +6/−1
- src/Graphics/UI/FLTK/LowLevel/FLTKHS.hs +248/−22
- stack.yaml +1/−1
README.md view
@@ -8,37 +8,24 @@ Quick Install ------------- ### Linux, *BSD and OSX-Installing FLTK from source (vs. package mangers) is recommended. Package managers sometimes put headers and libraries in unexpected places-causing `fltkhs` compilation failures. On OSX the `brew` package for the current stable version of FLTK is broken. Furthermore some Linux distributions-only ship the shared libraries which means that executables are less portable. Compiling from source is pretty quick and painless and fixes these problems.--Install FLTK-1.3.4-1 from source:--```- > wget http://fltk.org/pub/fltk/1.3.4/fltk-1.3.4-1-source.tar.gz- > tar -zxf fltk-1.3.4-1-source.tar.gz- > cd fltk-1.3.4-1- > ./configure --enable-gl --enable-shared --enable-localjpeg --enable-localzlib --enable-localpng- > make- > sudo make install- > fltk-config --version- 1.3.4-1-```--Build the FLTKHS skeleton project:+The fastest and easiest way of installing FLTKHS is to use the bundled FLTK library. ``` > brew install autoconf # Only on OSX > git clone http://github.com/deech/fltkhs-hello-world > cd fltkhs-hello-world- > stack install+ > stack install --flag fltkhs:bundled # About 6-8 minutes passes ... > stack exec fltkhs-hello-world ``` +And that's it!++The second fastest way is to compile FLTK from source yourself. For instructions please see the documentation for [Linux](http://hackage.haskell.org/package/fltkhs/docs/Graphics-UI-FLTK-LowLevel-FLTKHS.html#g:10), [OSX](http://hackage.haskell.org/package/fltkhs/docs/Graphics-UI-FLTK-LowLevel-FLTKHS.html#g:11), [Windows](http://hackage.haskell.org/package/fltkhs/docs/Graphics-UI-FLTK-LowLevel-FLTKHS.html#g:12).+ ### Windows -Please see the [detailed Windows installation instructions](http://hackage.haskell.org/package/fltkhs/docs/Graphics-UI-FLTK-LowLevel-FLTKHS.html#g:7)+Please see the [detailed Windows installation instructions](http://hackage.haskell.org/package/fltkhs/docs/Graphics-UI-FLTK-LowLevel-FLTKHS.html#g:8) Screenshots -----------
Setup.hs view
@@ -25,7 +25,7 @@ import qualified Distribution.Simple.Program.Ar as Ar import qualified Distribution.ModuleName as ModuleName import Distribution.Simple.BuildPaths-import System.Directory(getCurrentDirectory, getDirectoryContents, doesDirectoryExist)+import System.Directory(getCurrentDirectory, getDirectoryContents, withCurrentDirectory, doesDirectoryExist) import System.FilePath ( (</>), (<.>), takeExtension, combine, takeBaseName, takeDirectory) import qualified Distribution.Simple.GHC as GHC import qualified Distribution.Simple.JHC as JHC@@ -41,12 +41,69 @@ preConf = myPreConf, buildHook = myBuildHook, cleanHook = myCleanHook,- copyHook = copyCBindings,+ copyHook = copyCBindingsAndBundledExecutables, regHook = registerHook } +fltkSource = "fltk-1.3.4-1"++runMake :: IO ()+runMake =+ case buildOS of+ Windows -> rawSystemExit normal "make" []+ os | os `elem` [FreeBSD, OpenBSD, NetBSD, DragonFly]+ -> rawSystemExit normal "gmake" []+ _ -> rawSystemExit normal "make" []++buildFltk :: IO ()+buildFltk = do+ rawSystemExit normal "tar" ["-zxf", fltkSource ++ "-source.tar.gz"]+ projectRoot <- getCurrentDirectory+ let fltkDir = projectRoot </> fltkSource+ fltkFlags = [ "--enable-gl",+ "--enable-shared",+ "--enable-localjpeg",+ "--enable-localzlib",+ "--enable-localpng"]+ withCurrentDirectory+ fltkDir+ (+ case buildOS of+ OSX -> do+ rawSystemExit normal (fltkDir </> "configure") fltkFlags+ runMake+ updateEnv "DYLD_LIBRARY_PATH" fltkDir+ updateEnv "DYLD_LIBRARY_PATH" (fltkDir </> "lib")+ updateEnv "DYLD_LIBRARY_PATH" (fltkDir </> "src")+ updateEnv "LIBRARY_PATH" (fltkDir </> "lib")+ updateEnv "PATH" (fltkDir </> "fluid")+ updateEnv "PATH" fltkDir+ Windows -> do+ rawSystemExit normal "sh" ([(fltkDir </> "configure")] ++ fltkFlags)+ runMake+ updateEnv "INCLUDE_PATH" fltkDir+ updateEnv "LD_LIBRARY_PATH" (fltkDir </> "lib")+ updateEnv "LD_LIBRARY_PATH" (fltkDir </> "src")+ updateEnv "LIBRARY_PATH" (fltkDir </> "lib")+ updateEnv "PATH" (fltkDir </> "fluid")+ updateEnv "PATH" fltkDir+ _ -> do+ rawSystemExit normal (fltkDir </> "configure") fltkFlags+ runMake+ updateEnv "INCLUDE_PATH" fltkDir+ updateEnv "LD_LIBRARY_PATH" (fltkDir </> "lib")+ updateEnv "LD_LIBRARY_PATH" (fltkDir </> "src")+ updateEnv "LIBRARY_PATH" (fltkDir </> "lib")+ updateEnv "PATH" (fltkDir </> "fluid")+ updateEnv "PATH" fltkDir+ (getEnv "PATH") >>= putStrLn+ )+ myPreConf :: Args -> ConfigFlags -> IO HookedBuildInfo myPreConf args flags = do+ if (flagIsSet (FlagName "bundled") flags)+ then putStrLn "Building bundled FLTK" >> buildFltk+ else return () putStrLn "Running autoconf ..." case buildOS of Windows -> rawSystemExit normal "sh" ["autoconf"]@@ -59,6 +116,8 @@ return (d </> "c-lib") fltkclib = "fltkc" +flagIsSet :: PD.FlagName -> ConfigFlags -> Bool+flagIsSet flag configFlags = maybe False id (lookup flag (configConfigurationsFlags configFlags)) addFltkcDir :: PackageDescription -> PackageDescription addFltkcDir pkg_descr =@@ -73,15 +132,17 @@ (library pkg_descr) } -addToEnvironmentVariable :: String -> String -> IO ()-addToEnvironmentVariable env value = do- currentLdLibraryPath <- tryIOError (getEnv env)- setEnv env ((either (const "")- (\curr -> curr +++updateEnv :: String -> String -> IO ()+updateEnv env value = do+ old <- tryIOError (getEnv env)+ setEnv env ((either (const value)+ (\old' -> value ++ (case buildOS of Windows -> ";"- _ -> ":"))- currentLdLibraryPath) ++ value)+ _ -> ":") +++ old'+ )+ old)) replaceAllInfixes :: String -> String -> String -> String@@ -97,13 +158,10 @@ let removeTrailingNewline = head . lines in removeTrailingNewline<$>(rawSystemStdout normal "cygpath" [o, p]) -replaceMingw =- let mingw = case buildArch of- I386 -> "/mingw32"- _ -> "/mingw64"- fullMingwPath = unsafePerformIO (cygpath "-m" mingw)- in- replaceAllInfixes mingw fullMingwPath+windowsFriendlyPaths s =+ if (isPrefixOf "/" s)+ then (unsafePerformIO (cygpath "-m" "/")) ++ (drop 1 s)+ else s myBuildHook pkg_descr local_bld_info user_hooks bld_flags = do let compileC = do@@ -141,8 +199,8 @@ fmap (\l' -> l' { libBuildInfo = (libBuildInfo l') {- PD.ldOptions = fmap replaceMingw ld,- includeDirs = fmap replaceMingw incDirs,+ PD.ldOptions = fmap windowsFriendlyPaths ld,+ includeDirs = fmap windowsFriendlyPaths incDirs, extraLibDirs = cppGccPthreadPaths ++ (extraLibDirs (libBuildInfo l')), extraLibs = ["stdc++", "gcc", "pthread"] }@@ -155,21 +213,22 @@ fixedPkgDescr <- rewritePaths pkg_descr >>= return . addFltkcDir buildHook autoconfUserHooks fixedPkgDescr local_bld_info user_hooks bld_flags Linux -> do- addToEnvironmentVariable "LD_LIBRARY_PATH" fltkcdir- addToEnvironmentVariable "LIBRARY_PATH" fltkcdir++ updateEnv "LIBRARY_PATH" fltkcdir buildHook autoconfUserHooks pkg_descr local_bld_info user_hooks bld_flags _ -> do- addToEnvironmentVariable "DYLD_LIBRARY_PATH" fltkcdir- addToEnvironmentVariable "LIBRARY_PATH" fltkcdir+ updateEnv "DYLD_LIBRARY_PATH" fltkcdir+ updateEnv "LIBRARY_PATH" fltkcdir buildHook autoconfUserHooks pkg_descr local_bld_info user_hooks bld_flags -copyCBindings :: PackageDescription -> LocalBuildInfo -> UserHooks -> CopyFlags -> IO ()-copyCBindings pkg_descr lbi uhs flags = do+copyCBindingsAndBundledExecutables :: PackageDescription -> LocalBuildInfo -> UserHooks -> CopyFlags -> IO ()+copyCBindingsAndBundledExecutables pkg_descr lbi uhs flags = do (copyHook autoconfUserHooks) pkg_descr lbi uhs flags- let libPref = libdir . absoluteInstallDirs pkg_descr lbi- . fromFlag . copyDest- $ flags+ let installDirs = absoluteInstallDirs pkg_descr lbi+ . fromFlag . copyDest+ $ flags+ libPref = libdir installDirs rawSystemExit (fromFlag $ copyVerbosity flags) "cp" [fltkcdir </> "libfltkc.a" , libPref] case buildOS of@@ -177,6 +236,16 @@ ["c-lib" </> "libfltkc-dyn.dylib", libPref] _ -> rawSystemExit (fromFlag $ copyVerbosity flags) "cp" ["c-lib" </> "libfltkc-dyn.so", libPref]+ if (flagIsSet (FlagName "bundled") (configFlags lbi))+ then do+ projectRoot <- getCurrentDirectory+ let binPref = bindir installDirs+ let fltkDir = projectRoot </> fltkSource+ rawSystemExit (fromFlag $ copyVerbosity flags) "cp"+ [(fltkDir </> "fluid" </> "fluid"), binPref]+ rawSystemExit (fromFlag $ copyVerbosity flags) "cp"+ [(fltkDir </> "fltk-config"), binPref]+ else return () myCleanHook pd x uh cf = do case buildOS of@@ -199,7 +268,7 @@ installedPkgInfoRaw' <- generateRegistrationInfo verbosity pkg lib lbi clbi inplace False distPref packageDb let installedPkgInfoRaw = case buildOS of- Windows -> installedPkgInfoRaw' { Distribution.InstalledPackageInfo.ldOptions = fmap replaceMingw (Distribution.InstalledPackageInfo.ldOptions installedPkgInfoRaw') }+ Windows -> installedPkgInfoRaw' { Distribution.InstalledPackageInfo.ldOptions = fmap windowsFriendlyPaths (Distribution.InstalledPackageInfo.ldOptions installedPkgInfoRaw') } _ -> installedPkgInfoRaw' let installedPkgInfo = installedPkgInfoRaw { libraryDynDirs = (libraryDynDirs installedPkgInfoRaw) ++ (libraryDirs installedPkgInfoRaw),
+ fltk-1.3.4-1-source.tar.gz view
file too large to diff
fltkhs.cabal view
@@ -1,5 +1,5 @@ name : fltkhs-version : 0.5.1.5+version : 0.5.1.6 synopsis : FLTK bindings description: Low level bindings for the FLTK GUI toolkit. For installation and quick start instruction please scroll all the way down to the README.@@ -138,6 +138,11 @@ Cabal < 1.25, filepath, directory++Flag Bundled+ Description: Use the bundled FLTK library.+ Manual: True+ Default: False Executable fltkhs-fluidtohs Main-Is: Main.hs
src/Graphics/UI/FLTK/LowLevel/FLTKHS.hs view
@@ -14,20 +14,35 @@ -- * Installation --- -- ** Linux & *BSD+ -- $InstallationSummary++ -- ** Build With Bundled FLTK++ -- *** Linux & *BSD --+ -- $InstallationLinuxBundled++ -- *** Mac (Yosemite, El Capitan, Sierra)+ --+ -- $InstallationMacBundled++ -- *** Windows(7,8,10)(64-bit)+ --+ -- $InstallationWindowsBundled++ -- ** Compile FLTK Yourself++ -- *** Linux & *BSD+ -- -- $InstallationLinux - -- ** Mac (Yosemite & El Capitan)+ -- *** Mac (Yosemite & El Capitan) -- -- $InstallationMac - -- ** Installation (Windows 64-bit)- --- -- *** Windows 10+ -- *** Windows(7,8,10)(64-bit) -- -- $InstallationWindows10- -- -- * Demos --@@ -391,6 +406,59 @@ -- @ -- +-- $InstallationSummary+-- There are two ways to install FLTKHS, building with the bundled FLTK GUI library, or compiling and installing FLTK from scratch yourself. The bundled way is+-- by far the easiest on all platforms. It is completely self-contained, you don't need any sudo access to your system.+--+-- $InstallationLinuxBundled+-- The steps are:+--+-- - Make sure to have OpenGL installed+-- - Ensure that 'make', 'autoconf' and 'autoheader' are available on your system+-- - Download & install <http://docs.haskellstack.org/en/stable/README/#how-to-install Stack>+-- - Download & install the <https://github.com/deech/fltkhs-hello-world/archive/master.tar.gz FLTKHS hello world skeleton>+-- - Verify the install by running `fltkhs-hello-world`+--+-- == Download & Install Stack+-- Pick the <http://docs.haskellstack.org/en/stable/README/#how-to-install Stack installer> that matches your distribution and install according the instructions.+--+-- == Download & Install the FLTKHS Hello World Skeleton+-- === Downloading Without Git+-- If 'git' is not installed download the latest version of the fltkhs-hello-world application skeleton from <https://github.com/deech/fltkhs-hello-world/archive/master.tar.gz here>+--+--+-- Extract and rename the archive:+--+-- @+-- > tar -zxvf fltkhs-hello-world-master.tar.gz+-- > mv fltkhs-hello-world-master fltkhs-hello-world+-- @+--+-- === Downloading With Git+-- If 'git' is available:+--+-- @+-- > git clone http://github.com/deech/fltkhs-hello-world+-- @+--+-- === Building+-- Build it with Stack:+--+-- @+-- > cd fltkhs-hello-world+-- > stack setup+-- > stack install --flag fltkhs:bundled+-- @+--+-- == Verify The Install+-- Test that the build completed successfully by invoking incredibly unimpressive+--+-- @+-- > stack exec fltkhs-hello-world+-- @+--+--+-- -- $InstallationLinux -- The steps are: --@@ -437,17 +505,11 @@ -- === Downloading Without Git -- If 'git' is not installed download the latest version of the fltkhs-hello-world application skeleton from <https://github.com/deech/fltkhs-hello-world/archive/master.tar.gz here> ----- Rename it:------ @--- > mv fltkhs-hello-world-master.tar.gz fltkhs-hello-world.tar.gz--- @------ -- Extract and enter the archive: -- -- @--- > tar -zxvf fltkhs-hello-world.tar.gz+-- > tar -zxvf fltkhs-hello-world-master.tar.gz+-- > mv fltkhs-hello-world-master fltkhs-hello-world -- @ -- -- === Downloading With Git@@ -480,6 +542,65 @@ -- @ -- +-- $InstallationMacBundled+-- Unfortunately Mac version older than El Capitan and Yosemite are not supported.+--+-- The general steps are:+--+-- - Brew Install Stack+-- - Download & install the <https://github.com/deech/fltkhs-hello-world/archive/master.tar.gz FLTKHS hello world skeleton>+-- - Verify the install by running `fltkhs-hello-world`+--+-- == Brew Install Stack+-- This should be as simple as:+--+-- @+-- > brew install haskell-stack+-- @+--+-- == Brew Install Autoconf+-- @+-- > brew install autoconf+-- @+--+--+-- == Download & Install the FLTKHS Hello World Skeleton+-- === Downloading Without Git+-- If 'git' is not installed download the latest version of the fltkhs-hello-world application skeleton from <https://github.com/deech/fltkhs-hello-world/archive/master.tar.gz here>+--+-- Extract the archive:+--+-- @+-- > cd \/Users\/\<username\>/Downloads\/+-- > tar -zxvf fltkhs-hello-world-master.tar.gz+-- > mv fltkhs-hello-world-master fltkhs-hello-world+-- @+--+-- === Downloading With Git+-- If 'git' is available:+--+-- @+-- > git clone http://github.com/deech/fltkhs-hello-world+-- @+--+-- === Building+-- Build it with Stack:+--+-- @+-- > cd fltkhs-hello-world+-- > stack setup+-- > stack install --flag fltkhs:bundled+-- @+--+-- == Verify The Install+-- Test that the build completed successfully by invoking incredibly unimpressive+--+-- @+-- > stack exec fltkhs-hello-world+-- @+--++ -- $InstallationMac -- Unfortunately Mac version older than El Capitan and Yosemite are not supported. --@@ -521,18 +642,13 @@ -- === Downloading Without Git -- If 'git' is not installed download the latest version of the fltkhs-hello-world application skeleton from <https://github.com/deech/fltkhs-hello-world/archive/master.tar.gz here> ----- Rename it: ----- @--- > cd \/Users\/\<username\>/Downloads\/--- > mv fltkhs-hello-world-master.tar.gz fltkhs-hello-world.tar.gz--- @------ -- Extract the archive: -- -- @--- > tar -zxvf fltkhs-hello-world.tar.gz+-- > cd \/Users\/\<username\>/Downloads\/+-- > tar -zxvf fltkhs-hello-world-master.tar.gz+-- > mv fltkhs-hello-world-master fltkhs-hello-world -- @ -- -- === Downloading With Git@@ -557,6 +673,116 @@ -- @ -- > stack exec fltkhs-hello-world -- @+--++-- $InstallationWindowsBundled+--+-- This install guide has been tested on a Windows 7, 8 and 10.+--+-- == Install Stack+-- Downloading and following the default instructions for the standard <https://www.stackage.org/stack/windows-x86_64-installer Windows installer> should be enough.+-- If the install succeeded 'stack' should on the PATH. To test run 'cmd.exe' and do:+--+-- @+-- > stack --version+-- @+--+-- Now downloading and setup the latest GHC via 'stack':+--+-- @+-- > stack setup+-- @+--+-- From this point on we can live in the MSYS2 shell that comes with Stack. It is a far superior environment to the command prompt. To open the MSYS2 shell do:+--+-- @+-- > stack exec mintty+-- @+--+-- == Install Necessary Utilities via Pacman+-- In the MSYS2 shell prompt update and upgrade the MSYS2 installation:+--+-- @+-- > pacman -Syy+-- > pacmay -Syu+-- @+--+-- ... install packages for download and extracting packages:+--+-- @+-- > pacman -S wget+-- > pacman -S tar+-- > pacman -S unzip+-- > pacman -S zip+-- > pacman -S man+-- @+--+-- ... and building C/C++ programs:+--+-- @+-- > pacman -S autoconf+-- > pacman -S make+-- > pacman -S automake+-- @+--+--+-- == Download And Install The FLTKHS Hello World Skeleton+-- The <https://github.com/deech/fltkhs-hello-world fltkhs-hello-world> skeleton is a simple Hello World GUI which provides the base structure for FLTKHS applications. Please see the 'Demos' section of this document for examples of apps that show off more complex uses of the API.+--+-- @+-- > wget --no-check-certificate https://github.com/deech/fltkhs-hello-world/archive/master.zip+-- > unzip master.zip+-- > mv fltkhs-hello-world-master fltkhs-hello-world+-- > cd fltkhs-hello-world+-- @+--+-- And install with:+--+-- @+-- > stack install --flag fltkhs:bundled+-- @+--+-- To test the installation:+--+-- @+-- > stack exec fltkhs-hello-world+-- @+--+--+-- == Packaging A Windows Executable+--+-- While the 'fltkhs-hello-world' application is mostly stand-alone the MSYS2 environment bundled with 'stack' seems to require 3 runtime DLLs. The DLLs are bundled with 'stack' so it's easy to zip them up with the executable and deploy. The required DLLs are: 'libstdc++-6.dll', 'libgcc_s_seh-1.dll' and 'libwinpthread-1.dll'.+--+--+--+-- First create the directory that will contain the executable and DLLs:+--+-- @+-- > mkdir \/tmp\/fltkhs-hello-world+-- @+--+-- Copy the executable over to that directory:+--+-- @+-- > cp `which fltkhs-hello-world` \/tmp\/fltkhs-hello-world+-- @+--+-- Copy over the DLLs. They are usually located in '../<ghc-version>/mingw/bin' but to make the process slightly less fragile we specify the directory relative to whatever 'ghc' is currently in 'stack' 's context:+--+-- @+-- > cp `dirname $(which ghc)`..\/mingw\/bin\/libstdc++-6.dll \/tmp\/fltkhs-hello-world+-- > cp `dirname $(which ghc)`..\/mingw\/bin\/libgcc_s_seh-1.dll \/tmp\/fltkhs-hello-world+-- > cp `dirname $(which ghc)`..\/mingw\/bin\/libwinpthread-1.dll \/tmp\/fltkhs-hello-world+-- @+--+-- Zip up archive:+--+-- @+-- > cd /tmp+-- > zip fltkhs-hello-world.zip fltkhs-hello-world/*+-- @+--+-- And that's it! Any Windows 10 user should now be able to extract 'fltkhs-hello-world.zip' and run 'fltkhs-hello-world.exe'. -- -- $InstallationWindows10
stack.yaml view
@@ -1,7 +1,7 @@ # For more information, see: http://docs.haskellstack.org/en/stable/yaml_configuration.html # Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)-resolver: lts-7.16+resolver: lts-8.13 # Local packages, usually specified by relative directory name packages: