Commit 11286f51 authored by Armin Bernstetter's avatar Armin Bernstetter Committed by Kristof Korwisi

Fixed sed split in build script (now splits at :SPACE instead of SPACE), fixed...

Fixed sed split in build script (now splits at :SPACE instead of SPACE), fixed text to add decker to Env:Path
parent e1334748
......@@ -61,7 +61,6 @@ build:win:
artifacts:
paths:
- decker.exe
- resource.zip
- version.txt
cache:
key: build-win
......
......@@ -4,42 +4,79 @@
.DESCRIPTION
Build script to build Decker for windows. Allows to set the build
mode via parameters for custom builds in the CI pipeline.
.PARAMETER buildtype
Defaults to assume preextracted resources for the build.
If set to any other value will include the resources in the executable.
#>
Param(
[string] $buildtype = "preextracted",
[switch] $skiptemplates,
[switch] $preparepackage
[switch] $preparepackage,
[switch] $local
)
Write-Output "Building Windows Decker"
if(-Not $skiptemplates) {
Write-Output "Copying resources to resource directory is not available at the moment. See the Makefile for assistance."
<# Check if running as Administrator #>
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$admin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-Not $admin -And $local) {
Write-Error "You are not running as admin but using the -local parameter. Decker will not be copied to ${Env:ProgramFiles(x86)}"
}
if($buildtype -eq "preextracted"){
Write-Output "Building for preextracted resources"
& stack build -j4 --flag decker:preextractedresources
} else {
Write-Output "Building standalone binary"
<# TODO: Here we need to copy resources from `third-party` to
`resource/support/vendor` as done in `third-party/symlinks.mk`. Once that
works, pre-extraction is obsolete because everything is read directly from
the embedded ZIP archive. #>
& stack build -j4
$deckerdir = Split-Path $PSScriptRoot -Parent
Write-Host "Building Windows Decker" -ForegroundColor Green
if (-Not $skiptemplates) {
Write-Output "Copying resources to resource directory is not available at the moment. See the Makefile for assistance."
}
if($preparepackage) {
$binpath=(Join-Path ($(stack path | Select-String -Pattern "local-install-root") -split " ")[1] "bin\decker.exe")
<# Cleanup of old files #>
Write-Host "Cleaning before new build" -ForegroundColor Green
& stack clean
Remove-Item "$deckerdir\resource\support\vendor" -Recurse -Force
Remove-Item "$deckerdir\public" -Recurse -Force
Write-Host "Starting build of standalone binary" -ForegroundColor Green
& git submodule update --init
& .\third-party\vendor.ps1
# Return to the decker root directory
Set-Location (Split-Path $PSScriptRoot -Parent)
Write-Host "Compiling the Haskell source code" -ForegroundColor Green
& stack build -j4
if ($preparepackage) {
$binpath = (Join-Path ($(stack path | Select-String -Pattern "local-install-root") -split " ")[1] "bin\decker.exe")
Copy-Item $binpath .
$version = Get-Content .\package.yaml | Select-String -Pattern "version: "
$version = $version -replace "\s+", " "
$version = ($version -split " ")[1]
Write-Output $version > version.txt
}
# If it's a local install, copy the program Decker to C:\ProgramFiles (x86)\Decker
# C:\ProgramFiles (x86)\Decker\bin needs to be on PATH to execute decker from anywhere
# needs Admin Rights
if ($local) {
$exepath = (Join-Path ($(stack path | Select-String -Pattern "local-install-root") -split ": ")[1] "bin\decker.exe")
$deckerpath = "${Env:ProgramFiles(x86)}\Decker"
Write-Host "Copying the decker executable to $deckerpath\bin" -ForegroundColor Green
New-Item -Path "$deckerpath\bin" -Force -ItemType "directory"
Copy-Item "$exepath" "$deckerpath\bin\decker.exe"
$version = Get-Content .\package.yaml | Select-String -Pattern "version: "
$version = $version -replace "\s+", " "
$version = ($version -split " ")[1]
Write-Output $version > "$deckerpath\version.txt"
$docs = [Environment]::GetFolderPath("MyDocuments")
if($buildtype -eq "preextracted"){
Compress-Archive -Force -Path .\resource -CompressionLevel Fastest -DestinationPath resource
}
Write-Host "To then call decker from anywhere on the PowerShell command line create a PowerShell profile file, add the following line, and restart your PowerShell session!" -ForegroundColor Green
Write-Host '$Env:Path += ";${Env:ProgramFiles(x86)}\Decker\bin"' -ForegroundColor Green
}
\ No newline at end of file
project-name: Decker
publish-annotations: True
provisioning: SymLink
exclude-directories:
- app
- bin
- code
- dist
- log
- node_modules
- public
- resource/support/fonts
- resource/support/vendor
- src
- src-unix
- src-win
- third-party
static-resource-dirs:
- test/static
# Sane defaults for reval.js
menu: true
center: true
controls: true
keyboard: true
progress: true
hash: true
overview: true
touch: true
fragments: true
fragmentInURL: true
help: true
hideInactiveCursor: true
hideCursorTime: 2000
transition: "none"
backgroundTransition: "none"
......@@ -34,9 +34,6 @@ profile: build-profile
stack exec -- decker clean
stack exec --work-dir .stack-work-profile -- decker +RTS -p
preextracted: resources
stack build --flag decker:preextractedresources
dist: install
rm -rf dist
mkdir -p dist
......@@ -55,4 +52,4 @@ clean:
rm -rf dist public
rm -rf resource/support/vendor
.PHONY: build clean test install dist docs resources preextracted
.PHONY: build clean test install dist docs
\ No newline at end of file
......@@ -114,8 +114,6 @@ library:
else:
source-dirs: src-unix
exposed-modules: "System.Decker.OS"
- condition: flag(preextractedresources)
cpp-options: "-DPREEXTRACTEDRESOURCES"
executables:
decker:
......@@ -158,9 +156,3 @@ default-extensions:
- ScopedTypeVariables
- TemplateHaskell
- TupleSections
flags:
preextractedresources:
description: Assumes that the resources are already preextracted and will not extract them again or delete them
manual: true
default: false
......@@ -16,12 +16,26 @@ chmod a+x decker
## Installation from source
1. Install [stack](https://docs.haskellstack.org/en/stable/README/).
1. Install [stack](https://docs.haskellstack.org/en/stable/README/) and [Node.js](https://www.npmjs.com/get-npm) (for `npm`)
2. Clone this repo.
3. `cd decker`
4. `git submodule update --init --recursive`
5. `make install`
## Installation from source on Windows
Instead of a `makefile` we use a PowerShell script on Windows to install decker from source
1. `cd decker`
2. `.\bin\build.ps1`
If you want to copy `decker` to `C:\Program Files (x86)` you can call `.\bin\build.ps1 -local`. This needs a PowerShell session with administrator rights.
To then call decker from anywhere on the PowerShell command line create a PowerShell profile file, add the following line, and restart your PowerShell session!
```$Env:Path += ";${Env:ProgramFiles(x86)}\Decker\bin"```
## Development
### Haskell
......@@ -53,7 +67,7 @@ Decker uses a few external tools that need to be installed on the system:
- [*pdf2svg*](https://github.com/dawbarton/pdf2svg) to generate SVG files from
PDF documents
- *libbzip2-dev*
- [*NodeJS*](https://nodejs.org/) as a prerequisite for Yarn
- [*NodeJS*](https://nodejs.org/) to install JavaScript dependencies
- [*coreutils*](https://www.gnu.org/software/coreutils/) the GNU coreutils
### Installation of external tools on macOS
......@@ -197,12 +211,3 @@ Haskell soure code readability depends heavily on consistent formatting
conventions. With decker, formatting is automated using the excellent
[hindent]() tool. Formatting is checked for each commit that is uploaded to the
GitLab repository.
## Compile Flags
The Decker executable contains per default all necessary supporting files and
extracts them on the first run. Some packaging solutions prefer to already
extract the files during the installation. To support this, a compile flag
`preextractedresources` is available which instructs Decker to work with the
already extracted resource files. Invoke
`stack --flag decker:preextractedresources` to compile such a version.
\ No newline at end of file
......@@ -52,7 +52,7 @@ $endif$
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? '$decker-support-dir$/vendor/reveal/css/print/pdf.css' : '$decker-support-dir$/vendor/reveal/css/print/paper.css';
link.href = window.location.search.match( /print-pdf/gi ) ? String.raw`$decker-support-dir$/vendor/reveal/css/print/pdf.css` : String.raw`$decker-support-dir$/vendor/reveal/css/print/paper.css`;
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
......@@ -356,7 +356,7 @@ $if(thebelab.enable)$
$endif$
$if(mathjax)$
math: {
mathjax: "$decker-support-dir$/vendor/mathjax/MathJax.js",
mathjax: String.raw`$decker-support-dir$/vendor/mathjax/MathJax.js`,
TeX: {
Macros: {
R: "{\\mathrm{{I}\\kern-.15em{R}}}",
......@@ -405,34 +405,34 @@ $endif$
// Optional reveal.js plugins
dependencies: [
{ src: '$decker-support-dir$/vendor/reveal/lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: '$decker-support-dir$/vendor/reveal/plugin/zoom-js/zoom.js', async: true },
{ src: String.raw`$decker-support-dir$/vendor/reveal/lib/js/classList.js`, condition: function() { return !document.body.classList; } },
{ src: String.raw`$decker-support-dir$/vendor/reveal/plugin/zoom-js/zoom.js`, async: true },
$if(notes-server)$
{ src: '$decker-support-dir$/vendor/reveal/socket.io/socket.io.js', async: true },
{ src: '$decker-support-dir$/vendor/reveal/plugin/notes-server/client.js', async: true },
{ src: String.raw`$decker-support-dir$/vendor/reveal/socket.io/socket.io.js`, async: true },
{ src: String.raw`$decker-support-dir$/vendor/reveal/plugin/notes-server/client.js`, async: true },
$endif$
$if(chart)$
{ src: '$decker-support-dir$/vendor/charts/Chart.js'},
{ src: '$decker-support-dir$/vendor/charts/plugin-errorbars.js'},
{ src: '$decker-support-dir$/vendor/charts/plugin-colorschemes.js'},
{ src: '$decker-support-dir$/vendor/charts/csv2chart.js'},
{ src: String.raw`$decker-support-dir$/vendor/charts/Chart.js`},
{ src: String.raw`$decker-support-dir$/vendor/charts/plugin-errorbars.js`},
{ src: String.raw`$decker-support-dir$/vendor/charts/plugin-colorschemes.js`},
{ src: String.raw`$decker-support-dir$/vendor/charts/csv2chart.js`},
$endif$
$if(chalkboard)$
{ src: '$decker-support-dir$/vendor/whiteboard/whiteboard.js'},
{ src: String.raw`$decker-support-dir$/vendor/whiteboard/whiteboard.js`},
$endif$
$if(menu)$
{ src: '$decker-support-dir$/vendor/reveal.js-menu/menu.js', async: true },
{ src: String.raw`$decker-support-dir$/vendor/reveal.js-menu/menu.js`, async: true },
$endif$
$if(highlightjs)$
{ src: '$decker-support-dir$/vendor/highlight/highlight.js' },
{ src: String.raw`$decker-support-dir$/vendor/highlight/highlight.js` },
$endif$
$if(mathjax)$
{ src: '$decker-support-dir$/vendor/math/math.js' },
{ src: String.raw`$decker-support-dir$/vendor/math/math.js` },
$endif$
$if(thebelab.enable)$
{ src: '$decker-support-dir$/js/thebelab.js', async: true },
{ src: String.raw`$decker-support-dir$/js/thebelab.js`, async: true },
$endif$
{ src: '$decker-support-dir$/vendor/reveal/plugin/notes/notes.js', async: true }
{ src: String.raw`$decker-support-dir$/vendor/reveal/plugin/notes/notes.js`, async: true }
]
});
</script>
......
......@@ -2,7 +2,6 @@
module System.Decker.OS
( defaultProvisioning
, urlPath
, preextractedResourceFolder
, chrome
) where
......@@ -17,11 +16,6 @@ defaultProvisioning = SymLink
urlPath :: FilePath -> FilePath
urlPath path = path
preextractedResourceFolder :: IO FilePath
preextractedResourceFolder = do
exep <- getExecutablePath
return $ joinPath [(takeDirectory exep), "..", "Resources", "resource"]
-- Look for chrome executable on $PATH
chromeExecutable :: IO (Either String String)
chromeExecutable = do
......
......@@ -2,7 +2,6 @@
module System.Decker.OS
( defaultProvisioning
, urlPath
, preextractedResourceFolder
, chrome
) where
......@@ -17,11 +16,6 @@ defaultProvisioning = Copy
urlPath :: FilePath -> FilePath
urlPath path = intercalate "/" (splitDirectories path)
preextractedResourceFolder :: IO FilePath
preextractedResourceFolder = do
exep <- getExecutablePath
return $ joinPath [(takeDirectory exep), "..", "resource"]
-- start chrome from cmd
chrome :: IO (Either String String)
chrome = return $ Right "start chrome"
{-- Author: Jan-Philipp Stauffert <jan-philipp.stauffert@uni-wuerzburg.de.de> --}
{-# LANGUAGE CPP #-}
module Text.Decker.Internal.Flags
( hasPreextractedResources
) where
hasPreextractedResources :: Bool
#ifdef PREEXTRACTEDRESOURCES
hasPreextractedResources = True
#else
hasPreextractedResources = False
#endif
......@@ -42,7 +42,7 @@ module Text.Decker.Project.Project
import System.Decker.OS
import Text.Decker.Internal.Common
import Text.Decker.Internal.Flags
-- import Text.Decker.Internal.Flags
import Text.Decker.Internal.Helper
import Text.Decker.Internal.Meta
import Text.Decker.Project.Glob
......@@ -161,10 +161,7 @@ projectDirectories = do
(ProjectDirs projectDir publicDir cacheDir supportDir appDataDir logDir)
deckerResourceDir :: IO FilePath
deckerResourceDir =
if hasPreextractedResources
then preextractedResourceFolder
else D.getXdgDirectory
deckerResourceDir = D.getXdgDirectory
D.XdgData
("decker" ++
"-" ++
......
<#
.SYNOPSIS
Builds and copies vendor libraries to the support folder
.DESCRIPTION
Counterpart to symlinks.mk for Windows. As symlinks are not properly
supported, all required files are copied.
#>
$third = Split-Path -parent $PSCommandPath
$decker = Split-Path $third -parent
$support = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$decker\resource\support\vendor")
Write-Host "Building third party dependencies" -ForegroundColor Green
# Build jquery
Set-Location "$third\jquery"
& npm run build
# Build thebelab
Set-Location "$third\thebelab"
& npm install
& npm run build
# Build Chart.js
Set-Location "$third\Chart.js"
& npm install
& npx rollup -c rollup.config.js
Write-Host ("Copy third party dependencies to " + $support) -ForegroundColor Green
New-Item -Path $support -Force -ItemType "directory"
Set-Location $third
# Copy jquery
Copy-Item "$third\jquery\dist\jquery.min.js" "$support\jquery.js -Force"
# Copy thebelab
New-Item -Path "$support\thebelab" -Force -ItemType "directory"
Copy-Item $third\thebelab\lib\*.js "$support\thebelab" -Force
Copy-Item $third\thebelab\lib\*.map "$support\thebelab" -Force
# Copy mathjax
New-Item -Path "$support\mathjax\jax\input" -Force -ItemType "directory"
New-Item -Path "$support\mathjax\jax\output" -Force -ItemType "directory"
Foreach ($i in ("MathJax.js", "config", "jax\input\TeX", "jax\output\SVG", "jax\element", "extensions")) {
Copy-Item -Recurse "$third\MathJax\$i" "$support\mathjax\$i" -Force
}
# Copy reveal.js
New-Item "$support\reveal\plugin" -Force -ItemType "directory"
New-Item "$support\reveal\plugin\markdown" -Force -ItemType "directory"
New-Item "$support\reveal\plugin\markdown" -Force -ItemType "directory"
Copy-Item "$third\reveal.js\plugin\markdown\marked.js" "$support\reveal\plugin\markdown\marked.js" -Force
Foreach ($i in ("js", "css", "lib", "plugin\math", "plugin\zoom-js", "plugin\notes")) {
Copy-Item -r "$third\reveal.js\$i" "$support\reveal\$i" -Force
}
# Copy Reveal.js-menu
New-Item "$support\reveal.js-menu" -Force -ItemType "directory"
Foreach ($i in ("menu.css", "menu.js")) {
Copy-Item -r "$third\reveal.js-menu\$i" "$support\reveal.js-menu\$i" -Force
}
# Copy bootstrap
New-Item "$support\bootstrap" -Force -ItemType "directory"
Copy-Item -Recurse "$third\bootstrap\dist\css" "$support\bootstrap\css" -Force
# Copy piklor.js
Copy-Item -Recurse "$third\piklor.js\src\piklor.min.js" "$support\piklor.js" -Force
# Copy whiteboard
Copy-Item -Recurse "$third\mb-reveal-plugins\whiteboard" "$support\whiteboard" -Force
# Copy Charts
Copy-Item -Recurse "$third\mb-reveal-plugins\charts" "$support\charts" -Force
# Copy math
Copy-Item -Recurse "$third\mb-reveal-plugins\math" "$support\math" -Force
# Copy highlight
Copy-Item -Recurse "$third\mb-reveal-plugins\highlight" "$support\highlight" -Force
# Copy fontawesome
New-Item "$support\fontawesome" -Force -ItemType "directory"
Foreach ($i in ( "js", "css", "webfonts", "svgs", "sprites")) {
Copy-Item -Recurse "$third\Font-Awesome\js-packages\@fortawesome\fontawesome-free\$i" "$support\fontawesome\$i" -Force
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment