-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (53 loc) · 2.21 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Variables
PYTHON = python3
VENV = ./code-generator/env
REQUIREMENTS = ./code-generator/requirements.txt
CODER_PACKAGE = ./coder
BUILD_SCRIPT = ./code-generator/build.sh
CLI_OUTPUT_PATH = ./plugin/cli
# Default target
all: clean venv install_requirements build copy_cli
# Clean up previous builds and environment
clean:
@echo "Cleaning up previous environment and builds in code-generator..."
cd code-generator && rm -rf $(VENV) build dist
@echo "Cleaning up CLI folder in plugin..."
rm -rf $(CLI_OUTPUT_PATH)
mkdir -p $(CLI_OUTPUT_PATH)
# Create a virtual environment inside code-generator
venv: clean
@echo "Creating virtual environment in code-generator..."
cd code-generator && $(PYTHON) -m venv env
# Install requirements and set up the "coder" folder as a package in code-generator
install_requirements: venv
@echo "Activating virtual environment and installing requirements in code-generator..."
cd code-generator && env/bin/pip install -e .$(CODER_PACKAGE)
cd code-generator && env/bin/pip install -r .$(REQUIREMENTS)
# Build the CLI inside code-generator
build: install_requirements
@echo "Building CLI inside code-generator..."
@cd code-generator && \
source env/bin/activate && \
BINARY_PATH=$$(find env -name 'languages.so' | head -n 1); \
if [ -n "$$BINARY_PATH" ]; then \
echo "Binary path updated: $$BINARY_PATH"; \
chmod +x .$(BUILD_SCRIPT); \
BINARY_PATH=$$BINARY_PATH .$(BUILD_SCRIPT); \
else \
echo "Binary path not found. Skipping build.sh execution."; \
fi
# Copy the CLI to the plugin folder and perform npm install
copy_cli: build
@echo "Copying CLI build to plugin..."
cp -r code-generator/dist/* $(CLI_OUTPUT_PATH)
@echo "Running npm install in plugin..."
cd plugin && npm install
# Help target for guidance
help:
@echo "Available targets:"
@echo " clean - Clean up previous builds and environment"
@echo " venv - Create a new virtual environment inside code-generator"
@echo " install_requirements - Install dependencies in code-generator"
@echo " build - Build the CLI in code-generator"
@echo " copy_cli - Copy the CLI build to plugin/cli and perform npm install"
@echo " all - Run the complete workflow (default)"