Skip to content

Commit

Permalink
Add version API to ECP shared library.
Browse files Browse the repository at this point in the history
  • Loading branch information
clundin25 committed Oct 16, 2023
1 parent bd11497 commit 85b47dc
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
6 changes: 4 additions & 2 deletions build/scripts/darwin_amd64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -eu
set -eux

CURRENT_TAG=$(git tag --sort v:refname | tail -n 1)

# Create a folder to hold the binaries
rm -rf ./build/bin/darwin_amd64
Expand All @@ -26,5 +28,5 @@ mv darwin ./../../../build/bin/darwin_amd64/ecp
cd ./../../..

# Build the signer library
go build -buildmode=c-shared -o build/bin/darwin_amd64/libecp.dylib cshared/main.go
go build -buildmode=c-shared -buildmode=c-shared -ldflags="-X=main.Version=$CURRENT_TAG" -o build/bin/darwin_amd64/libecp.dylib cshared/main.go
rm build/bin/darwin_amd64/libecp.h
6 changes: 4 additions & 2 deletions build/scripts/darwin_arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -eu
set -eux

CURRENT_TAG=$(git tag --sort v:refname | tail -n 1)

# Create a folder to hold the binaries
rm -rf ./build/bin/darwin_arm64
Expand All @@ -26,5 +28,5 @@ mv darwin ./../../../build/bin/darwin_arm64/ecp
cd ./../../..

# Build the signer library
CGO_ENABLED=1 GO111MODULE=on GOARCH=arm64 go build -buildmode=c-shared -o build/bin/darwin_arm64/libecp.dylib cshared/main.go
CGO_ENABLED=1 GO111MODULE=on GOARCH=arm64 go build -buildmode=c-shared -ldflags="-X=main.Version=$CURRENT_TAG" -o build/bin/darwin_arm64/libecp.dylib cshared/main.go
rm build/bin/darwin_arm64/libecp.h
6 changes: 5 additions & 1 deletion build/scripts/linux_amd64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -eux

CURRENT_TAG=$(git tag --sort v:refname | tail -n 1)

# Create a folder to hold the binaries
rm -rf ./build/bin/linux_amd64
mkdir -p ./build/bin/linux_amd64

# Build the signer library
go build -buildmode=c-shared -o build/bin/linux_amd64/libecp.so cshared/main.go
go build -buildmode=c-shared -ldflags="-X=main.Version=$CURRENT_TAG" -o build/bin/linux_amd64/libecp.so cshared/main.go
rm build/bin/linux_amd64/libecp.h

# Build the signer binary
Expand Down
1 change: 1 addition & 0 deletions build/scripts/windows_amd64.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ Move-Item .\windows.exe ..\..\..\build\bin\windows_amd64\ecp.exe
Set-Location ..\..\..\

# Build the signer library
# TODO: Add build version to shared DLL. https://github.com/googleapis/enterprise-certificate-proxy/issues/103
go build -buildmode=c-shared -o .\build\bin\windows_amd64\libecp.dll .\cshared\main.go
Remove-Item .\build\bin\windows_amd64\libecp.h
9 changes: 9 additions & 0 deletions cshared/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import (
"github.com/googleapis/enterprise-certificate-proxy/client"
)

var Version = "dev"

// If ECP Logging is enabled return true
// Otherwise return false
func enableECPLogging() bool {
Expand Down Expand Up @@ -71,6 +73,13 @@ func getCertPem(configFilePath string) []byte {
return certChainPem
}

// Returns ECP's version number.
//
//export ECPVersion
func ECPVersion() *C.char {
return C.CString(Version)
}

// GetCertPemForPython reads the contents of the certificate specified by configFilePath,
// storing the result inside a certHolder byte array of size certHolderLen.
//
Expand Down

0 comments on commit 85b47dc

Please sign in to comment.