Skip to content

Commit 9222c36

Browse files
authored
Update build process to cleanup mutated files. (#94)
1 parent 076f3ff commit 9222c36

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ go.work
2424
.DS_Store
2525

2626
out/**
27-
/dist
27+
/dist
28+
/work

Makefile

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,64 @@ ifndef plugin
77
endif
88

99
build: validate_plugin
10-
go run generate/generator.go templates . $(plugin) $(plugin_github_url)
10+
11+
# Remove existing work dir and create a new directory for the render process
12+
rm -rf work && \
13+
mkdir -p work
14+
15+
# Copy the entire source tree, excluding .git directory, into the new directory
16+
rsync -a --exclude='.git' . work/ >/dev/null 2>&1
17+
18+
# Change to the new directory to perform operations
19+
cd work && \
20+
go run generate/generator.go templates . $(plugin) $(plugin_github_url) && \
21+
go mod tidy && \
22+
$(MAKE) -f out/Makefile build
23+
24+
# Copy the created binary from the work directory
25+
cp work/steampipe_sqlite_$(plugin).so .
26+
27+
# Note: The work directory will contain the full code tree with changes,
28+
# binaries will be copied to the actual root directory.
29+
30+
# render target
31+
render: validate_plugin
32+
@echo "Rendering code for plugin: $(plugin)"
33+
34+
# Remove existing work dir and create a new directory for the render process
35+
rm -rf work && \
36+
mkdir -p work
37+
38+
# Copy the entire source tree, excluding .git directory, into the new directory
39+
rsync -a --exclude='.git' . work/ >/dev/null 2>&1
40+
41+
# Change to the new directory to perform operations
42+
cd work && \
43+
go run generate/generator.go templates . $(plugin) $(plugin_github_url) && \
1144
go mod tidy
45+
46+
# Note: The work directory will contain the full code tree with rendered changes
47+
48+
# build_from_work target
49+
build_from_work: validate_plugin
50+
@if [ ! -d "work" ]; then \
51+
echo "Error: 'work' directory does not exist. Please run the render target first." >&2; \
52+
exit 1; \
53+
fi
54+
@echo "Building from work directory for plugin: $(plugin)"
55+
56+
# Change to the work directory to perform build operations
57+
cd work && \
1258
$(MAKE) -f out/Makefile build
1359

60+
# Copy the created binary from the work directory
61+
cp work/steampipe_sqlite_$(plugin).so .
62+
63+
# Note: This target builds from the 'work' directory and binaries will be copied to the actual root directory.
64+
65+
clean:
66+
rm -rf work
67+
1468
.PHONY: release-dry-run
1569
release-dry-run:
1670
@docker run \

0 commit comments

Comments
 (0)