##  Copyright (c) MediaArea.net SARL. All Rights Reserved.
##
##  Use of this source code is governed by a BSD-style license that can
##  be found in the License.html file in the root of the source tree.
##

Param([parameter(Mandatory=$true)][String]$arch)

$ErrorActionPreference = "Stop"

#-----------------------------------------------------------------------
# Setup
$release_directory = $PSScriptRoot
$version = (Get-Content "${release_directory}\..\Project\version.txt" -Raw).Trim()
$arch_c2pa="${arch}"
if ("${arch}" -eq "Win32" ) {
    $arch_c2pa="i686"
}
#-----------------------------------------------------------------------
# Build c2pa-rs
Push-Location -Path "${release_directory}\..\Source\ThirdParty\c2pa-rs"
    cargo build --release -p c2pa -p c2pa-c-ffi --target "${arch_c2pa}-pc-windows-msvc"
Pop-Location

#-----------------------------------------------------------------------
# Build
Push-Location -Path "${release_directory}\..\Project\QtCreator"
    New-Item -Force -ItemType Directory "${arch}"
    Push-Location -Path "${arch}"
        qmake ENABLE_C2PA=1 ..
        nmake
    Pop-Location
Pop-Location
