Convert wslpath to makefile

This commit is contained in:
Jaby 2024-10-07 21:58:07 +02:00
parent 327ebc7beb
commit 1c687db308
4 changed files with 73 additions and 0 deletions

16
src/Tools/Common.mk Normal file
View File

@ -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"

0
src/Tools/Makefile Normal file
View File

View File

@ -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",

View File

@ -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)