aboutsummaryrefslogtreecommitdiff
path: root/lib/Utils.Cryptography/monocypher/Taskfile.yaml
blob: 6eabe5461cc304164b846e979e36bb9a044f6a6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# https://taskfile.dev

#Called by the vnbuild system to produce builds for my website
#https://www.vaughnnugent.com/resources/software

#This taskfile is called in this directory and is specific to the vnlib_monocypher project
#that handles the MSBuild outside of the solution file

version: '3'

vars:
  MS_ARGS: '/p:Platform=x64 /p:RunAnalyzersDuringBuild=false /p:BuildInParallel=true /p:MultiProcessorCompilation=true'
  PROJECT_NAME: 'vnlib_monocypher'
  MODULE_NAME: 'vnlib.core'
  BUILD_DIR: 'build/{{ OS }}'
  BUILD_TYPE: '{{ .BUILD_TYPE | default "Release" }}'

tasks:

  default:
    desc: "Builds the entire project from source code without using the VNBuild build system for target machines"
    cmds:
      #build with defaults
      - task: build
      - cmd: echo "Your {{ .PROJECT_NAME }} dll file can be found in '{{ .USER_WORKING_DIR }}/{{ .BUILD_DIR }}'"
        silent: true
  
  build:
    cmds:
     - cmd: echo Building {{ .PROJECT_NAME }} in {{ .BUILD_TYPE }} mode
       silent: true

     - cmake {{ .CLI_ARGS }}
       -B./{{ .BUILD_DIR }} 
       -DCMAKE_BUILD_TYPE={{ .BUILD_TYPE }}       

     #compile     
     - cmd: cmake --build {{ .BUILD_DIR }}/ --config Debug
       platforms: [ windows ]   #debug builds only work on Windows 

     - cmake --build {{ .BUILD_DIR }}/ --config Release 
 
  postbuild_success:
    vars:
      #required files to include in tar
      TAR_FILES: "license.txt readme.txt"
    
    cmds:
      #make bin dir
    - cmd: powershell -Command "New-Item -Type Directory -Force -Path './bin'"
      ignore_error: true

    #get licenses for debug
    - task: licenses
      vars: 
        TARGET: '{{ .BUILD_DIR }}/Debug'

    - task: licenses
      vars:
        TARGET: './{{ .BUILD_DIR }}/Release'
   

    #static debug lib
    - cd {{ .BUILD_DIR }}/Debug && tar -czf '../../bin/msvc-x64-debug-{{.PROJECT_NAME}}-static.tgz' {{.PROJECT_NAME}}_static.lib {{.TAR_FILES}} {{.PROJECT_NAME}}_static.pdb
    #dynamic debug lib
    - cd {{ .BUILD_DIR }}/Debug && tar -czf '../../bin/msvc-x64-debug-{{.PROJECT_NAME}}.tgz' {{.PROJECT_NAME}}.dll {{.TAR_FILES}} {{.PROJECT_NAME}}.pdb
    
    #release static lib
    - cd {{ .BUILD_DIR }}/Release && tar -czf '../../bin/msvc-x64-release-{{.PROJECT_NAME}}-static.tgz' {{.PROJECT_NAME}}_static.lib {{.TAR_FILES}}
    #release dll
    - cd {{ .BUILD_DIR }}/Release && tar -czf '../../bin/msvc-x64-release-{{.PROJECT_NAME}}.tgz' {{.PROJECT_NAME}}.dll {{.TAR_FILES}}

    #source code
    - task: pack_source

  licenses:
    cmds:
     #add monocypher license to binary output (wrong on purpose see source code)
     - powershell -Command "Copy-Item -Path vendor/LICENCE.md -Destination '{{.TARGET}}/license.md'"
     #add my license file
     - powershell -Command "Copy-Item -Path license -Destination '{{.TARGET}}/license.txt'"
     #add readme file
     - powershell -Command "Copy-Item -Path build.readme.txt -Destination '{{.TARGET}}/readme.txt'"
  
  pack_source:
    dir: '{{.USER_WORKING_DIR}}'
    cmds:
     #pack monocypher source code and create the archive
     - powershell -Command "tar --exclude build/* --exclude bin/* --exclude .git/* -czf 'bin/src.tgz' ."

  dev-init:
    desc: 'Configures the project for local development'
    cmds:
     - task: build
       vars: { BUILD_TYPE: Debug }

     - cmd: echo "dev init complete"
       silent: true

  clean:
    ignore_error: true
    cmds:
     - for: [ bin/, build/ ]
       cmd: powershell rm -Recurse -Force '{{ .ITEM }}'