Map out dependencies between Windows scripts (#6112)
* Map dependencies between Windows scripts * Skip unix-specific command on Windows * Handle missing directory * Explicitly run with PowerShell This makes the scripts with work CMD out-of-the-box.
This commit is contained in:
		
							
								
								
									
										50
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								Makefile
									
									
									
									
									
								
							@ -4,18 +4,38 @@ all: install build check
 | 
			
		||||
###############################################################################
 | 
			
		||||
# INSTALL
 | 
			
		||||
 | 
			
		||||
WASM_PACK ?= ~/.cargo/bin/wasm-pack
 | 
			
		||||
ifeq ($(OS),Windows_NT)
 | 
			
		||||
	CARGO ?= ~/.cargo/bin/cargo.exe
 | 
			
		||||
	WASM_PACK ?= ~/.cargo/bin/wasm-pack.exe
 | 
			
		||||
else
 | 
			
		||||
	CARGO ?= ~/.cargo/bin/cargo
 | 
			
		||||
	WASM_PACK ?= ~/.cargo/bin/wasm-pack
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
.PHONY: install
 | 
			
		||||
install: node_modules/.yarn-integrity $(WASM_PACK) ## Install dependencies
 | 
			
		||||
install: node_modules/.yarn-integrity $(CARGO) $(WASM_PACK) ## Install dependencies
 | 
			
		||||
 | 
			
		||||
node_modules/.yarn-integrity: package.json yarn.lock
 | 
			
		||||
	yarn install
 | 
			
		||||
ifeq ($(OS),Windows_NT)
 | 
			
		||||
	@ type nul > $@
 | 
			
		||||
else
 | 
			
		||||
	@ touch $@
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
$(CARGO):
 | 
			
		||||
ifeq ($(OS),Windows_NT)
 | 
			
		||||
	yarn install:rust:windows
 | 
			
		||||
else
 | 
			
		||||
	yarn install:rust
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
$(WASM_PACK):
 | 
			
		||||
	yarn install:rust
 | 
			
		||||
ifeq ($(OS),Windows_NT)
 | 
			
		||||
	yarn install:wasm-pack:cargo
 | 
			
		||||
else
 | 
			
		||||
	yarn install:wasm-pack:sh
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
###############################################################################
 | 
			
		||||
# BUILD
 | 
			
		||||
@ -31,13 +51,17 @@ VITE_SOURCES := $(wildcard vite.*) $(wildcard vite/**/*.tsx)
 | 
			
		||||
build: build-web build-desktop
 | 
			
		||||
 | 
			
		||||
.PHONY: build-web
 | 
			
		||||
build-web: public/kcl_wasm_lib_bg.wasm build/index.html
 | 
			
		||||
build-web: install public/kcl_wasm_lib_bg.wasm build/index.html
 | 
			
		||||
 | 
			
		||||
.PHONY: build-desktop
 | 
			
		||||
build-desktop: public/kcl_wasm_lib_bg.wasm .vite/build/main.js
 | 
			
		||||
build-desktop: install public/kcl_wasm_lib_bg.wasm .vite/build/main.js
 | 
			
		||||
 | 
			
		||||
public/kcl_wasm_lib_bg.wasm: $(CARGO_SOURCES)$(RUST_SOURCES)
 | 
			
		||||
public/kcl_wasm_lib_bg.wasm: $(CARGO_SOURCES) $(RUST_SOURCES)
 | 
			
		||||
ifeq ($(OS),Windows_NT)
 | 
			
		||||
	yarn build:wasm:dev:windows
 | 
			
		||||
else
 | 
			
		||||
	yarn build:wasm:dev
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
build/index.html: $(REACT_SOURCES) $(TYPESCRIPT_SOURCES) $(VITE_SOURCES)
 | 
			
		||||
	yarn build:local
 | 
			
		||||
@ -63,8 +87,10 @@ lint: install ## Lint the code
 | 
			
		||||
###############################################################################
 | 
			
		||||
# RUN
 | 
			
		||||
 | 
			
		||||
TARGET ?= web
 | 
			
		||||
 | 
			
		||||
.PHONY: run
 | 
			
		||||
run: run-web
 | 
			
		||||
run: run-$(TARGET)
 | 
			
		||||
 | 
			
		||||
.PHONY: run-web
 | 
			
		||||
run-web: install build-web ## Start the web app
 | 
			
		||||
@ -90,7 +116,7 @@ test-unit: install ## Run the unit tests
 | 
			
		||||
	yarn test:unit
 | 
			
		||||
 | 
			
		||||
.PHONY: test-e2e
 | 
			
		||||
test-e2e: test-e2e-desktop
 | 
			
		||||
test-e2e: test-e2e-$(TARGET)
 | 
			
		||||
 | 
			
		||||
.PHONY: test-e2e-web
 | 
			
		||||
test-e2e-web: install build-web ## Run the web e2e tests
 | 
			
		||||
@ -106,15 +132,23 @@ test-e2e-desktop: install build-desktop ## Run the desktop e2e tests
 | 
			
		||||
 | 
			
		||||
.PHONY: clean
 | 
			
		||||
clean: ## Delete all artifacts
 | 
			
		||||
ifeq ($(OS),Windows_NT)
 | 
			
		||||
	git clean --force -d -X
 | 
			
		||||
else
 | 
			
		||||
	rm -rf .vite/ build/
 | 
			
		||||
	rm -rf trace.zip playwright-report/ test-results/
 | 
			
		||||
	rm -rf public/kcl_wasm_lib_bg.wasm
 | 
			
		||||
	rm -rf rust/*/bindings/ rust/*/pkg/ rust/target/
 | 
			
		||||
	rm -rf node_modules/ rust/*/node_modules/
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
.PHONY: help
 | 
			
		||||
help: install
 | 
			
		||||
ifeq ($(OS),Windows_NT)
 | 
			
		||||
	@ powershell -Command "Get-Content $(MAKEFILE_LIST) | Select-String -Pattern '^[^\s]+:.*##\s.*$$' | ForEach-Object { $$line = $$_.Line -split ':.*?##\s+'; Write-Host -NoNewline $$line[0].PadRight(30) -ForegroundColor Cyan; Write-Host $$line[1] }"
 | 
			
		||||
else
 | 
			
		||||
	@ grep -E '^[^[:space:]]+:.*## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
.DEFAULT_GOAL := help
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -92,13 +92,13 @@
 | 
			
		||||
    "fmt:generated": "prettier --write .eslintrc.json *.ts *.json *.js ./rust/kcl-lib/bindings ./rust/kcl-wasm-lib/pkg",
 | 
			
		||||
    "fmt-check": "prettier --check .eslintrc.json ./src *.ts *.json *.js ./e2e ./packages ./rust/kcl-language-server",
 | 
			
		||||
    "fetch:wasm": "./scripts/get-latest-wasm-bundle.sh",
 | 
			
		||||
    "fetch:wasm:windows": "./scripts/get-latest-wasm-bundle.ps1",
 | 
			
		||||
    "fetch:wasm:windows": "powershell -ExecutionPolicy Bypass -File ./scripts/get-latest-wasm-bundle.ps1",
 | 
			
		||||
    "fetch:samples": "rm -rf public/kcl-samples* && curl -L -o public/kcl-samples.zip https://github.com/KittyCAD/kcl-samples/archive/refs/heads/achalmers/kw-args-xylineto.zip && unzip -o public/kcl-samples.zip -d public && mv public/kcl-samples-* public/kcl-samples",
 | 
			
		||||
    "build:wasm": "./scripts/build-wasm.sh",
 | 
			
		||||
    "build:wasm:windows": "./scripts/build-wasm.ps1",
 | 
			
		||||
    "build:wasm:windows": "powershell -ExecutionPolicy Bypass -File ./scripts/build-wasm.ps1",
 | 
			
		||||
    "build:wasm-dev": "yarn build:wasm:dev",
 | 
			
		||||
    "build:wasm:dev": "./scripts/build-wasm-dev.sh",
 | 
			
		||||
    "build:wasm:dev:windows": "./scripts/build-wasm-dev.ps1",
 | 
			
		||||
    "build:wasm:dev:windows": "powershell -ExecutionPolicy Bypass -File ./scripts/build-wasm-dev.ps1",
 | 
			
		||||
    "remove-importmeta": "sed -i 's/import.meta.url/window.location.origin/g' \"./rust/kcl-wasm-lib/pkg/kcl_wasm_lib.js\"; sed -i '' 's/import.meta.url/window.location.origin/g' \"./rust/kcl-wasm-lib/pkg/kcl_wasm_lib.js\" || echo \"sed for both mac and linux\"",
 | 
			
		||||
    "lint-fix": "eslint --fix --ext .ts --ext .tsx src e2e packages/codemirror-lsp-client/src rust/kcl-language-server/client/src",
 | 
			
		||||
    "lint": "eslint --max-warnings 0 --ext .ts --ext .tsx src e2e packages/codemirror-lsp-client/src rust/kcl-language-server/client/src",
 | 
			
		||||
@ -106,7 +106,7 @@
 | 
			
		||||
    "files:set-version": "echo \"$(jq --arg v \"$VERSION\" '.version=$v' package.json --indent 2)\" > package.json",
 | 
			
		||||
    "files:set-notes": "./scripts/set-files-notes.sh",
 | 
			
		||||
    "files:flip-to-nightly": "./scripts/flip-files-to-nightly.sh",
 | 
			
		||||
    "files:flip-to-nightly:windows": "./scripts/flip-files-to-nightly.ps1",
 | 
			
		||||
    "files:flip-to-nightly:windows": "powershell -ExecutionPolicy Bypass -File ./scripts/flip-files-to-nightly.ps1",
 | 
			
		||||
    "files:invalidate-bucket": "./scripts/invalidate-files-bucket.sh",
 | 
			
		||||
    "files:invalidate-bucket:nightly": "./scripts/invalidate-files-bucket.sh --nightly",
 | 
			
		||||
    "postinstall": "yarn --cwd ./rust/kcl-language-server --modules-folder node_modules install && ./node_modules/.bin/electron-rebuild",
 | 
			
		||||
 | 
			
		||||
@ -3,9 +3,13 @@
 | 
			
		||||
$ErrorActionPreference = 'Stop'
 | 
			
		||||
$PSNativeCommandUseErrorActionPreference = $true
 | 
			
		||||
 | 
			
		||||
rm -Recurse -Force rust/kcl-wasm-lib/pkg
 | 
			
		||||
if (Test-Path rust/kcl-wasm-lib/pkg) {
 | 
			
		||||
    rm -Recurse -Force rust/kcl-wasm-lib/pkg
 | 
			
		||||
}
 | 
			
		||||
mkdir -p rust/kcl-wasm-lib/pkg
 | 
			
		||||
rm -Recurse -Force rust/kcl-lib/bindings
 | 
			
		||||
if (Test-Path rust/kcl-lib/bindings) {
 | 
			
		||||
    rm -Recurse -Force rust/kcl-lib/bindings
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cd rust
 | 
			
		||||
$env:RUSTFLAGS='--cfg getrandom_backend="wasm_js"'
 | 
			
		||||
 | 
			
		||||
@ -3,9 +3,13 @@
 | 
			
		||||
$ErrorActionPreference = 'Stop'
 | 
			
		||||
$PSNativeCommandUseErrorActionPreference = $true
 | 
			
		||||
 | 
			
		||||
rm -Recurse -Force rust/kcl-wasm-lib/pkg
 | 
			
		||||
if (Test-Path rust/kcl-wasm-lib/pkg) {
 | 
			
		||||
    rm -Recurse -Force rust/kcl-wasm-lib/pkg
 | 
			
		||||
}
 | 
			
		||||
mkdir -p rust/kcl-wasm-lib/pkg
 | 
			
		||||
rm -Recurse -Force rust/kcl-lib/bindings
 | 
			
		||||
if (Test-Path rust/kcl-lib/bindings) {
 | 
			
		||||
    rm -Recurse -Force rust/kcl-lib/bindings
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cd rust
 | 
			
		||||
$env:RUSTFLAGS='--cfg getrandom_backend="wasm_js"'
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user