From 671a372d87ff8311956f9158e8885ffc254fe1bc Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 29 Jun 2021 13:14:14 +0200 Subject: compiler: add "portable" target This adds a build flag for generating a portable version of the compiler binary which make it look in its own runtime directory for its assets. This is useful in particular for the portable release tarballs which contain the web viewer at the same location instead of a pre-defined one in the FHS. GitHub: closes #286 --- compiler/app/ViewerDist.hs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 compiler/app/ViewerDist.hs (limited to 'compiler/app/ViewerDist.hs') diff --git a/compiler/app/ViewerDist.hs b/compiler/app/ViewerDist.hs new file mode 100644 index 0000000..2b80ffc --- /dev/null +++ b/compiler/app/ViewerDist.hs @@ -0,0 +1,39 @@ +-- ldgallery - A static generator which turns a collection of tagged +-- pictures into a searchable web gallery. +-- +-- Copyright (C) 2021 Pacien TRAN-GIRARD +-- +-- This program is free software: you can redistribute it and/or modify +-- it under the terms of the GNU Affero General Public License as +-- published by the Free Software Foundation, either version 3 of the +-- License, or (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU Affero General Public License for more details. +-- +-- You should have received a copy of the GNU Affero General Public License +-- along with this program. If not, see . + +{-# LANGUAGE CPP #-} + +module ViewerDist where + +#ifndef FLAG_PORTABLE + +import Paths_ldgallery_compiler (getDataFileName) + +viewerDistPath = getDataFileName "viewer" + +#else + +import Data.Functor ((<&>)) +import System.FilePath (takeDirectory, ()) +import System.Environment (getExecutablePath) + +viewerDistPath = fmap takeDirectory getExecutablePath <&> ( "viewer") + +#endif + +viewerDistPath :: IO FilePath -- cgit v1.2.3