diff --git a/src/Tools/Common.mk b/src/Tools/Common.mk new file mode 100644 index 00000000..f1fb821a --- /dev/null +++ b/src/Tools/Common.mk @@ -0,0 +1,16 @@ +BUILD_PROFILE ?= debug +CARGO_CMD ?= build +WINDOWS_TARGET ?= x86_64-pc-windows-gnu +UNIX_TARGET ?= x86_64-unknown-linux-gnu + +WINDOWS_ARTIFACT = ./target/$(WINDOWS_TARGET)/$(BUILD_PROFILE)/$(ARTIFACT).exe +UNIX_ARTIFACT = ./target/$(UNIX_TARGET)/$(BUILD_PROFILE)/$(ARTIFACT) + +define cp_artifact + $(if $(findstring build,$(CARGO_CMD)), + @mkdir -p $(dir $(1)) + @cp $(1) $(2) + ) +endef + +# Windows build requires "rustup target add x86_64-pc-windows-gnu" and "sudo apt-get install mingw-w64" \ No newline at end of file diff --git a/src/Tools/Makefile b/src/Tools/Makefile new file mode 100644 index 00000000..e69de29b diff --git a/src/Tools/Tools.code-workspace b/src/Tools/Tools.code-workspace index 7f74f1eb..dc2faa8f 100644 --- a/src/Tools/Tools.code-workspace +++ b/src/Tools/Tools.code-workspace @@ -5,10 +5,30 @@ } ], "settings": { + "cargo_task": [ + "wslpath all!Unix: wslpath", + "wslpath all-windows!Windows: wslpath" + ] }, "tasks": { "version": "2.0.0", "tasks": [ + { + "label": "cargo2", + "type": "shell", + "group": { + "kind": "build" + }, + "windows": { + "command": "wsl --shell-type login make -C ./${input:windows_cargo_task} CARGO_CMD=${input:cargo cmd} BUILD_PROFILE=${input:build cfg}" + }, + "linux": { + "command": "make -C ./${input:linux_cargo_task} BUILD_PROFILE=${input:build cfg}" + }, + "problemMatcher": [] + }, + + { "label": "all", "type": "shell", @@ -62,6 +82,28 @@ } ], "inputs": [ + { + "id": "windows_cargo_task", + "type": "command", + "command": "shellCommand.execute", + "args": { + "command": "powershell", + "commandArgs": ["-command", "'${config:cargo_task}'.Replace(',',\"`n\")"], + "fieldSeparator": "!" + } + }, + + + + { + "id": "planschi", + "type": "command", + "command": "shellCommand.execute", + "args": { + "command": "printf A!B\\nB!C", + "fieldSeparator": "!" + } + }, { "id": "build cfg", "type": "pickString", diff --git a/src/Tools/wslpath/Makefile b/src/Tools/wslpath/Makefile new file mode 100644 index 00000000..1cdc3a34 --- /dev/null +++ b/src/Tools/wslpath/Makefile @@ -0,0 +1,15 @@ +include ../Common.mk + +ARTIFACT = wslpath + +.PHONY: $(WINDOWS_ARTIFACT) $(UNIX_ARTIFACT) +$(WINDOWS_ARTIFACT): + cargo $(CARGO_CMD) --$(BUILD_PROFILE) --target=$(WINDOWS_TARGET) + $(call cp_artifact,$(WINDOWS_ARTIFACT), ../../../bin/$(ARTIFACT).exe) + +$(UNIX_ARTIFACT): + cargo $(CARGO_CMD) --$(BUILD_PROFILE) --target=$(UNIX_TARGET) + $(call cp_artifact,$(UNIX_ARTIFACT), ../../../bin/$(ARTIFACT)) + +all-windows: $(WINDOWS_ARTIFACT) +all: $(UNIX_ARTIFACT) \ No newline at end of file