From cffcf65433adfc669256a438435ce772822236bf Mon Sep 17 00:00:00 2001 From: Vinicius Fortuna Date: Fri, 19 Apr 2024 12:50:43 -0400 Subject: [PATCH] Remove Makefile (#1540) --- .gitignore | 1 + Taskfile.yml | 4 +++ src/shadowbox/Taskfile.yml | 15 +++------- third_party/Taskfile.yml | 50 +++++++++++++++++++++++++++++++++ third_party/prometheus/Makefile | 32 --------------------- 5 files changed, 59 insertions(+), 43 deletions(-) create mode 100644 third_party/Taskfile.yml delete mode 100644 third_party/prometheus/Makefile diff --git a/.gitignore b/.gitignore index 5cd442a34..b0b6e5184 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store .idea/ +.task/ .vscode/ /build/ /src/server_manager/install_scripts/do_install_script.ts diff --git a/Taskfile.yml b/Taskfile.yml index afc5efd9f..89ae5829b 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -22,6 +22,10 @@ includes: taskfile: ./src/shadowbox/Taskfile.yml vars: {OUTPUT_BASE: '{{joinPath .BUILD_ROOT "shadowbox"}}'} + third_party: + taskfile: ./third_party/Taskfile.yml + vars: {OUTPUT_BASE: '{{joinPath .BUILD_ROOT "third_party"}}'} + tasks: clean: desc: Clean output files diff --git a/src/shadowbox/Taskfile.yml b/src/shadowbox/Taskfile.yml index 09b478358..a7a7daf9a 100644 --- a/src/shadowbox/Taskfile.yml +++ b/src/shadowbox/Taskfile.yml @@ -9,7 +9,6 @@ tasks: vars: TARGET_OS: '{{.TARGET_OS | default "linux"}}' TARGET_ARCH: '{{.TARGET_ARCH | default "x86_64"}}' - GOOS: '{{get (dict "macos" "darwin") .TARGET_OS | default .TARGET_OS}}' GOARCH: '{{get (dict "x86_64" "amd64") .TARGET_ARCH | default .TARGET_ARCH}}' TARGET_DIR: '{{.TARGET_DIR | default (joinPath .OUTPUT_BASE .TARGET_OS .TARGET_ARCH)}}' NODE_DIR: '{{joinPath .TARGET_DIR "app"}}' @@ -22,22 +21,16 @@ tasks: # Build Node.js app - npx webpack --config='{{joinPath .TASKFILE_DIR "webpack.config.js"}}' --output-path='{{.NODE_DIR}}' ${BUILD_ENV:+--mode="${BUILD_ENV}"} # Copy third_party dependencies - - mkdir -p '{{.BIN_DIR}}' - - | - { - cd '{{joinPath .USER_WORKING_DIR "third_party" "prometheus"}}' - make 'bin/{{.TARGET_OS}}-{{.TARGET_ARCH}}/prometheus' - cp 'bin/{{.TARGET_OS}}-{{.TARGET_ARCH}}/prometheus' '{{.BIN_DIR}}/' - } + - task: ':third_party:prometheus:copy-{{.TARGET_OS}}-{{.GOARCH}}' + vars: {TARGET_DIR: '{{.BIN_DIR}}'} # Set CGO_ENABLED=0 to force static linkage. See https://mt165.co.uk/blog/static-link-go/. - - GOOS={{.GOOS}} GOARCH={{.GOARCH}} CGO_ENABLED=0 go build -ldflags='-s -w -X main.version=embedded' -o '{{.BIN_DIR}}/' github.com/Jigsaw-Code/outline-ss-server/cmd/outline-ss-server + - GOOS={{.TARGET_OS}} GOARCH={{.GOARCH}} CGO_ENABLED=0 go build -ldflags='-s -w -X main.version=embedded' -o '{{.BIN_DIR}}/' github.com/Jigsaw-Code/outline-ss-server/cmd/outline-ss-server start: desc: Run the Outline server locally deps: [{task: build, vars: {TARGET_OS: '{{.TARGET_OS}}', TARGET_ARCH: '{{.TARGET_ARCH}}'}}] vars: - UNAME_OS: {sh: 'uname -s'} - TARGET_OS: '{{get (dict "Linux" "linux" "Darwin" "macos") .UNAME_OS}}' + TARGET_OS: {sh: "uname -s | tr '[:upper:]' '[:lower:]'"} TARGET_ARCH: {sh: 'uname -m'} RUN_ID: '{{.RUN_ID | default (now | date "2006-01-02-150405")}}' RUN_DIR: '{{joinPath "/tmp/outline" .RUN_ID}}' diff --git a/third_party/Taskfile.yml b/third_party/Taskfile.yml new file mode 100644 index 000000000..a27495450 --- /dev/null +++ b/third_party/Taskfile.yml @@ -0,0 +1,50 @@ +version: '3' + +requires: + vars: [OUTPUT_BASE] + +tasks: + prometheus:debug: + cmds: + - echo {{.GOOS}} + + prometheus:download-*-*: + desc: Download and extract prometheus binary + vars: + VERSION: '2.37.1' + GOOS: '{{index .MATCH 0}}' + GOARCH: '{{index .MATCH 1}}' + TEMPFILE: {sh: mktemp} + SHA256: '{{printf "%v/%v" .GOOS .GOARCH | get + (dict + "linux/amd64" "753f66437597cf52ada98c2f459aa8c03745475c249c9f2b40ac7b3919131ba6" + "linux/arm64" "b59a66fb5c7ec5acf6bf426793528a5789a1478a0dad8c64edc2843caf31b1b8" + "darwin/amd64" "e03a43d98955ac3500f57353ea74b5df829074205f195ea6b3b88f55c4575c79" + "darwin/arm64" "eb8a174c82a0fb6c84e81d9a73214318fb4a605115ad61505d7883d02e5a6f52" + ) + }}' + TARGET_DIR: '{{joinPath .OUTPUT_BASE "prometheus" .GOOS .GOARCH}}' + TARGET: '{{joinPath .TARGET_DIR "prometheus"}}' + generates: ['{{.TARGET}}'] + sources: ['Taskfile.yml'] + preconditions: + - {sh: "[[ '{{.GOOS}}' =~ 'linux|darwin' ]]", msg: "invalid GOOS {{.GOOS}}"} + - {sh: "[[ '{{.GOARCH}}' =~ 'amd64|arm64' ]]", msg: "invalid GOARCH {{.GOARCH}}"} + cmds: + - node '{{joinPath .ROOT_DIR "src/build/download_file.mjs"}}' --url='https://github.com/prometheus/prometheus/releases/download/v{{.VERSION}}/prometheus-{{.VERSION}}.{{.GOOS}}-{{.GOARCH}}.tar.gz' --out='{{.TEMPFILE}}' --sha256='{{.SHA256}}' + - defer: rm -f '{{.TEMPFILE}}' + - mkdir -p '{{.TARGET_DIR}}' + - tar -zx -f '{{.TEMPFILE}}' --strip-components=1 -C '{{.TARGET_DIR}}' 'prometheus-{{.VERSION}}.{{.GOOS}}-{{.GOARCH}}/prometheus' + - chmod +x '{{.TARGET}}' + + prometheus:copy-*-*: + desc: Copy prometheus binary to target directory + requires: + vars: [TARGET_DIR] + vars: + GOOS: '{{index .MATCH 0}}' + GOARCH: '{{index .MATCH 1}}' + cmds: + - task: prometheus:download-{{.GOOS}}-{{.GOARCH}} + - mkdir -p '{{.TARGET_DIR}}' + - cp -R '{{joinPath .OUTPUT_BASE "prometheus" .GOOS .GOARCH}}'/* '{{.TARGET_DIR}}/' diff --git a/third_party/prometheus/Makefile b/third_party/prometheus/Makefile deleted file mode 100644 index 89cf4a4a0..000000000 --- a/third_party/prometheus/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -VERSION=2.37.1 - -.PHONY: all -all: bin/linux-x86_64/prometheus bin/linux-arm64/prometheus bin/macos-x86_64/prometheus bin/macos-arm64/prometheus - -bin/linux-x86_64/prometheus: OS=linux -bin/linux-x86_64/prometheus: GOARCH=amd64 -bin/linux-x86_64/prometheus: SHA256=753f66437597cf52ada98c2f459aa8c03745475c249c9f2b40ac7b3919131ba6 - -bin/linux-arm64/prometheus: OS=linux -bin/linux-arm64/prometheus: GOARCH=arm64 -bin/linux-arm64/prometheus: SHA256=b59a66fb5c7ec5acf6bf426793528a5789a1478a0dad8c64edc2843caf31b1b8 - -bin/macos-x86_64/prometheus: OS=darwin -bin/macos-x86_64/prometheus: GOARCH=amd64 -bin/macos-x86_64/prometheus: SHA256=e03a43d98955ac3500f57353ea74b5df829074205f195ea6b3b88f55c4575c79 - -bin/macos-arm64/prometheus: OS=darwin -bin/macos-arm64/prometheus: GOARCH=arm64 -bin/macos-arm64/prometheus: SHA256=eb8a174c82a0fb6c84e81d9a73214318fb4a605115ad61505d7883d02e5a6f52 - -bin/%/prometheus: TEMPFILE := $(shell mktemp) -bin/%/prometheus: - node ../../src/build/download_file.mjs --url="https://github.com/prometheus/prometheus/releases/download/v$(VERSION)/prometheus-$(VERSION).$(OS)-$(GOARCH).tar.gz" --out="$(TEMPFILE)" --sha256=$(SHA256) - mkdir -p "$(dir $@)" - tar -zx -f "$(TEMPFILE)" --strip-components=1 -C "$(dir $@)" prometheus-$(VERSION).$(OS)-$(GOARCH)/prometheus - chmod +x "$@" - rm -f $(TEMPFILE) - -.PHONY: clean -clean: - rm -rf bin