Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

117 lignes
3.4 KiB

  1. # Constants
  2. MK_FILE_PATH = $(lastword $(MAKEFILE_LIST))
  3. PRJ_DIR = $(abspath $(dir $(MK_FILE_PATH))/..)
  4. DEV_DIR = $(PRJ_DIR)/_dev
  5. # Results will be produced in this directory (can be provided by a caller)
  6. BUILD_DIR ?= $(PRJ_DIR)/_dev/GOROOT
  7. # Compiler
  8. GO ?= go
  9. DOCKER ?= docker
  10. # Build environment
  11. OS ?= $(shell $(GO) env GOHOSTOS)
  12. ARCH ?= $(shell $(GO) env GOHOSTARCH)
  13. OS_ARCH := $(OS)_$(ARCH)
  14. VER_OS_ARCH := $(shell $(GO) version | cut -d' ' -f 3)_$(OS)_$(ARCH)
  15. GOROOT_ENV := $(shell $(GO) env GOROOT)
  16. GOROOT_LOCAL = $(BUILD_DIR)/$(OS_ARCH)
  17. # Flag indicates wheter invoke "go install -race std". Supported only on amd64 with CGO enabled
  18. INSTALL_RACE:= $(words $(filter $(ARCH)_$(shell go env CGO_ENABLED), amd64_1))
  19. # Test targets used for compatibility testing
  20. TARGET_TEST_COMPAT=boring picotls tstclnt
  21. # Some target-specific constants
  22. BORINGSSL_REVISION=1530ef3e
  23. BOGO_DOCKER_TRIS_LOCATION=/go/src/github.com/cloudflare/tls-tris
  24. ###############
  25. #
  26. # Build targets
  27. #
  28. ##############################
  29. $(BUILD_DIR)/$(OS_ARCH)/.ok_$(VER_OS_ARCH): clean
  30. # Create clean directory structure
  31. mkdir -p "$(GOROOT_LOCAL)/pkg"
  32. # Copy src/tools from system GOROOT
  33. cp -Hr $(GOROOT_ENV)/src $(GOROOT_LOCAL)/src
  34. cp -Hr $(GOROOT_ENV)/pkg/include $(GOROOT_LOCAL)/pkg/include
  35. cp -Hr $(GOROOT_ENV)/pkg/tool $(GOROOT_LOCAL)/pkg/tool
  36. # Swap TLS implementation
  37. rm -r $(GOROOT_LOCAL)/src/crypto/tls/*
  38. rsync -rltgoD $(PRJ_DIR)/ $(GOROOT_LOCAL)/src/crypto/tls/ --exclude=$(lastword $(subst /, ,$(DEV_DIR)))
  39. # Apply additional patches
  40. for p in $(wildcard $(DEV_DIR)/patches/*); do patch -d "$(GOROOT_LOCAL)" -p1 < "$$p"; done
  41. # Create go package
  42. GOARCH=$(ARCH) GOROOT="$(GOROOT_LOCAL)" $(GO) install -v std
  43. ifeq ($(INSTALL_RACE),1)
  44. GOARCH=$(ARCH) GOROOT="$(GOROOT_LOCAL)" $(GO) install -race -v std
  45. endif
  46. @touch "$@"
  47. build-test-%: $(BUILD_DIR)/$(OS_ARCH)/.ok_$(VER_OS_ARCH)
  48. $(DOCKER) build $(BUILDARG) -t tls-tris:$* $(DEV_DIR)/$*
  49. $(DOCKER) build $(BUILDARG) -t $(*)-localserver $(DEV_DIR)/$*
  50. build-all: \
  51. build-test-tris-client \
  52. build-test-tris-server \
  53. build-test-bogo \
  54. $(addprefix build-test-,$(TARGET_TEST_COMPAT))
  55. # Builds TRIS client
  56. build-test-tris-client: $(BUILD_DIR)/$(OS_ARCH)/.ok_$(VER_OS_ARCH)
  57. cd $(DEV_DIR)/tris-testclient; CGO_ENABLED=0 GOROOT="$(GOROOT_LOCAL)" $(GO) build -v -i .
  58. $(DOCKER) build -t tris-testclient $(DEV_DIR)/tris-testclient
  59. # Builds TRIS server
  60. build-test-tris-server: $(BUILD_DIR)/$(OS_ARCH)/.ok_$(VER_OS_ARCH)
  61. cd $(DEV_DIR)/tris-localserver; CGO_ENABLED=0 GOROOT="$(GOROOT_LOCAL)" $(GO) build -v -i .
  62. $(DOCKER) build -t tris-localserver $(DEV_DIR)/tris-localserver
  63. # BoringSSL specific stuff
  64. build-test-boring: BUILDARG=--build-arg REVISION=$(BORINGSSL_REVISION)
  65. # TODO: This probably doesn't work
  66. build-caddy: $(BUILD_DIR)/$(OS_ARCH)/.ok_$(VER_OS_ARCH)
  67. CGO_ENABLED=0 GOROOT="$(GOROOT_LOCAL)" $(GO) build github.com/mholt/caddy
  68. ###############
  69. #
  70. # Test targets
  71. #
  72. ##############################
  73. test: \
  74. test-unit \
  75. test-bogo \
  76. test-interop
  77. test-unit: $(BUILD_DIR)/$(OS_ARCH)/.ok_$(VER_OS_ARCH)
  78. GOROOT="$(GOROOT_LOCAL)" $(GO) test -race crypto/tls
  79. test-bogo:
  80. $(DOCKER) run --rm -v $(PRJ_DIR):$(BOGO_DOCKER_TRIS_LOCATION) tls-tris:bogo
  81. test-interop:
  82. $(DEV_DIR)/interop_test_runner -v
  83. ###############
  84. #
  85. # Utils
  86. #
  87. ##############################
  88. clean:
  89. rm -rf $(BUILD_DIR)/$(OS_ARCH)
  90. clean-all: clean
  91. rm -rf $(BUILD_DIR)
  92. .PHONY: $(BUILD_DIR) clean build build-test test test-unit test-bogo test-compat