From 5857c910d10e9ee5ef5bde1beec0632bf47a0d03 Mon Sep 17 00:00:00 2001 From: ehutchllew Date: Sat, 11 May 2024 23:03:57 -0400 Subject: [PATCH] Core/multiplatform binaries (#21) * Saving progress: making a Makefile to handle building and publishing * Adding some platform specific builds and publishing commands to the Makefile; Adding directories for platform binary output * Changing package json bin location and adding a default bin created by makefile * Typo in Makefile * Adding a postinstall script to swap default bin with os viable bin * Fixing a couple typos * Got Makefile mostly working * Finished with Makefile * Adding a clean action to Makefile * Tweaking publish checks in Makefile * Adjusting optionalDeps versions * Forgot to include the postinstall script inthe pacakge json files * Adding windows support * Adding the windows builds to the publish-all make target/action --- Makefile | 56 +++++++++++++++++++++----- npm/@tmplts/darwin-arm64/package.json | 2 +- npm/@tmplts/darwin-x64/package.json | 2 +- npm/@tmplts/linux-x64/package.json | 2 +- npm/@tmplts/windows-arm64/package.json | 20 +++++++++ npm/@tmplts/windows-ia32/package.json | 20 +++++++++ npm/@tmplts/windows-x64/package.json | 20 +++++++++ npm/package.json | 11 +++-- 8 files changed, 115 insertions(+), 18 deletions(-) create mode 100644 npm/@tmplts/windows-arm64/package.json create mode 100644 npm/@tmplts/windows-ia32/package.json create mode 100644 npm/@tmplts/windows-x64/package.json diff --git a/Makefile b/Makefile index 7058e06..b1697fc 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,7 @@ +# TODO: Look into way for `sub-makes` to maintain +# variable references to the root make. For now I've +# used `TGOOS`, `TGOARCH`, and `TNPMDIR` in the +# `platform-unixlike` target to solve this issue VERSION := $(shell go run scripts/version.go) # Strip debug info (symbol table and DWARF) # Also add version info to binary @@ -19,13 +23,19 @@ clean: rm -rf \ darwin-arm64/bin \ darwin-x64/bin \ - linux-x64/bin + linux-x64/bin \ + windows-arm64/bin \ + windows-ia32/bin \ + windows-x64/bin cd npm/@tmplts && \ rm -f\ darwin-arm64/README.md darwin-arm64/LICENSE \ darwin-x64/README.md darwin-x64/LICENSE \ - linux-x64/README.md linux-x64/LICENSE + linux-x64/README.md linux-x64/LICENSE \ + windows-arm64/README.md windows-arm64/LICENSE \ + windows-ia32/README.md windows-ia32/LICENSE \ + windows-x64/README.md windows-x64/LICENSE .PHONY copy-files: copy-files: @@ -33,6 +43,9 @@ copy-files: cp README.md LICENSE npm/@tmplts/darwin-arm64/ cp README.md LICENSE npm/@tmplts/darwin-x64/ cp README.md LICENSE npm/@tmplts/linux-x64/ + cp README.md LICENSE npm/@tmplts/windows-arm64/ + cp README.md LICENSE npm/@tmplts/windows-ia32/ + cp README.md LICENSE npm/@tmplts/windows-x64/ ############## # Publishing # @@ -53,7 +66,10 @@ publish-all: copy-files publish-default \ publish-darwin-arm64 \ publish-darwin-x64 \ - publish-linux-x64 + publish-linux-x64 \ + publish-windows-arm64 \ + publish-windows-ia32 \ + publish-windows-x64 publish-default: platform-default cd npm && npm publish @@ -67,24 +83,42 @@ publish-darwin-x64: platform-darwin-x64 publish-linux-x64: platform-linux-x64 cd npm/@tmplts/linux-x64 && npm publish +publish-windows-arm64: platform-windows-arm64 + cd npm/@tmplts/windows-arm64 && npm publish + +publish-windows-ia32: platform-windows-ia32 + cd npm/@tmplts/windows-ia32 && npm publish + +publish-windows-x64: platform-windows-x64 + cd npm/@tmplts/windows-x64 && npm publish + ################## # Platform Build # ################## platform-unixlike: - @test -n "$(GOOS)" || (echo "The environment variable GOOS must be provided" && false) - @test -n "$(GOARCH)" || (echo "The environment variable GOARCH must be provided" && false) - @test -n "$(NPMDIR)" || (echo "The environment variable NPMDIR must be provided" && false) - CGO_ENABLED=0 GOOS="$(GOOS)" GOARCH="$(GOARCH)" go build $(GO_FLAGS) -o "$(NPMDIR)/bin/tmplts" + @test -n "$(TGOOS)" || (echo "The environment variable GOOS must be provided" && false) + @test -n "$(TGOARCH)" || (echo "The environment variable GOARCH must be provided" && false) + @test -n "$(TNPMDIR)" || (echo "The environment variable NPMDIR must be provided" && false) + CGO_ENABLED=0 GOOS="$(TGOOS)" GOARCH="$(TGOARCH)" go build $(GO_FLAGS) -o "$(TNPMDIR)/bin/tmplts" platform-default: - @$(MAKE) --no-print-directory GOOS=darwin GOARCH=arm64 NPMDIR=npm platform-unixlike + @$(MAKE) --no-print-directory TGOOS=darwin TGOARCH=arm64 TNPMDIR=npm platform-unixlike platform-darwin-arm64: - @$(MAKE) --no-print-directory GOOS=darwin GOARCH=arm64 NPMDIR=npm/@tmplts/darwin-arm64 platform-unixlike + @$(MAKE) --no-print-directory TGOOS=darwin TGOARCH=arm64 TNPMDIR=npm/@tmplts/darwin-arm64 platform-unixlike platform-darwin-x64: - @$(MAKE) --no-print-directory GOOS=darwin GOARCH=amd64 NPMDIR=npm/@tmplts/darwin-x64 platform-unixlike + @$(MAKE) --no-print-directory TGOOS=darwin TGOARCH=amd64 TNPMDIR=npm/@tmplts/darwin-x64 platform-unixlike platform-linux-x64: - @$(MAKE) --no-print-directory GOOS=linux GOARCH=amd64 NPMDIR=npm/@tmplts/linux-x64 platform-unixlike + @$(MAKE) --no-print-directory TGOOS=linux TGOARCH=amd64 TNPMDIR=npm/@tmplts/linux-x64 platform-unixlike + +platform-windows-arm64: + CGO_ENABLED=0 GOOS="windows" GOARCH="arm64" go build $(GO_FLAGS) -o "npm/@tmplts/windows-arm64/bin/tmplts.exe" + +platform-windows-ia32: + CGO_ENABLED=0 GOOS="windows" GOARCH="386" go build $(GO_FLAGS) -o "npm/@tmplts/windows-ia32/bin/tmplts.exe" + +platform-windows-x64: + CGO_ENABLED=0 GOOS="windows" GOARCH="amd64" go build $(GO_FLAGS) -o "npm/@tmplts/windows-x64/bin/tmplts.exe" diff --git a/npm/@tmplts/darwin-arm64/package.json b/npm/@tmplts/darwin-arm64/package.json index 97b2fdb..a00f484 100644 --- a/npm/@tmplts/darwin-arm64/package.json +++ b/npm/@tmplts/darwin-arm64/package.json @@ -1,7 +1,7 @@ { "name": "@tmplts/darwin-arm64", "author": "ev-the-dev", - "version": "0.1.2", + "version": "0.1.3", "description": "MacOS ARM 64-bit (Mac Silicon) binary for TmplTS", "license": "Apache-2.0", "repository": { diff --git a/npm/@tmplts/darwin-x64/package.json b/npm/@tmplts/darwin-x64/package.json index 5a8a365..98baf00 100644 --- a/npm/@tmplts/darwin-x64/package.json +++ b/npm/@tmplts/darwin-x64/package.json @@ -1,7 +1,7 @@ { "name": "@tmplts/darwin-x64", "author": "ev-the-dev", - "version": "0.1.2", + "version": "0.1.3", "description": "MacOS AMD 64-bit (Intel) binary for TmplTS", "license": "Apache-2.0", "repository": { diff --git a/npm/@tmplts/linux-x64/package.json b/npm/@tmplts/linux-x64/package.json index b0b67ad..b0050a8 100644 --- a/npm/@tmplts/linux-x64/package.json +++ b/npm/@tmplts/linux-x64/package.json @@ -1,7 +1,7 @@ { "name": "@tmplts/linux-x64", "author": "ev-the-dev", - "version": "0.1.2", + "version": "0.1.3", "description": "Linux 64-bit (Intel) binary for TmplTS", "license": "Apache-2.0", "repository": { diff --git a/npm/@tmplts/windows-arm64/package.json b/npm/@tmplts/windows-arm64/package.json new file mode 100644 index 0000000..fb0adc9 --- /dev/null +++ b/npm/@tmplts/windows-arm64/package.json @@ -0,0 +1,20 @@ +{ + "name": "@tmplts/windows-arm64", + "author": "ev-the-dev", + "version": "0.1.3", + "description": "Windows ARM 64-bit binary for TmplTS", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "git+https://github.com/ev-the-dev/tmplts.git" + }, + "publishConfig": { + "access": "public" + }, + "os": [ + "win32" + ], + "cpu": [ + "arm64" + ] +} diff --git a/npm/@tmplts/windows-ia32/package.json b/npm/@tmplts/windows-ia32/package.json new file mode 100644 index 0000000..26f5cee --- /dev/null +++ b/npm/@tmplts/windows-ia32/package.json @@ -0,0 +1,20 @@ +{ + "name": "@tmplts/windows-ia32", + "author": "ev-the-dev", + "version": "0.1.3", + "description": "Windows 32-bit binary for TmplTS", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "git+https://github.com/ev-the-dev/tmplts.git" + }, + "publishConfig": { + "access": "public" + }, + "os": [ + "win32" + ], + "cpu": [ + "ia32" + ] +} diff --git a/npm/@tmplts/windows-x64/package.json b/npm/@tmplts/windows-x64/package.json new file mode 100644 index 0000000..6309726 --- /dev/null +++ b/npm/@tmplts/windows-x64/package.json @@ -0,0 +1,20 @@ +{ + "name": "@tmplts/windows-x64", + "author": "ev-the-dev", + "version": "0.1.3", + "description": "Windows 64-bit binary for TmplTS", + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "git+https://github.com/ev-the-dev/tmplts.git" + }, + "publishConfig": { + "access": "public" + }, + "os": [ + "win32" + ], + "cpu": [ + "x64" + ] +} diff --git a/npm/package.json b/npm/package.json index a5b5fd6..1ae4865 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,7 +1,7 @@ { "name": "@ev-the-dev/tmplts", "author": "ev-the-dev", - "version": "0.1.2", + "version": "0.1.3", "description": "TypeScript Project Configuration Bootstrapper", "license": "Apache-2.0", "bin": { @@ -29,9 +29,12 @@ "url": "https://github.com/ev-the-dev/tmplts/issues" }, "optionalDependencies": { - "@tmplts/darwin-arm64": "0.1.2", - "@tmplts/darwin-x64": "0.1.2", - "@tmplts/linux-x64": "0.1.2" + "@tmplts/darwin-arm64": "0.1.3", + "@tmplts/darwin-x64": "0.1.3", + "@tmplts/linux-x64": "0.1.3", + "@tmplts/win32-arm64": "0.1.3", + "@tmplts/win32-ia32": "0.1.3", + "@tmplts/win32-x64": "0.1.3" }, "keywords": [ "typescript",