Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update standalone build process to not mutate source code #465

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,37 @@ install: build
if test -d ~/.steampipe/db/14.2.0; then \
cp ./build-$(PLATFORM)/steampipe_postgres_fdw--1.0.sql $(STEAMPIPE_INSTALL_DIR)/db/14.2.0/postgres/share/postgresql/extension/; \
cp ./build-$(PLATFORM)/steampipe_postgres_fdw.control $(STEAMPIPE_INSTALL_DIR)/db/14.2.0/postgres/share/postgresql/extension/; \
fi

if test -f ./build-$(PLATFORM)/steampipe_postgres_fdw.so; then \
cp ./build-$(PLATFORM)/steampipe_postgres_fdw.so $(STEAMPIPE_INSTALL_DIR)/db/14.2.0/postgres/lib/postgresql/; \
fi
if test -f ./build-$(PLATFORM)/steampipe_postgres_fdw.dylib; then \
cp ./build-$(PLATFORM)/steampipe_postgres_fdw.dylib $(STEAMPIPE_INSTALL_DIR)/db/14.2.0/postgres/lib/postgresql/; \
fi

# build standalone
standalone: validate_plugin prebuild.go
@echo "Building standalone FDW for plugin: $(plugin)"
go run generate/generator.go templates . $(plugin) $(plugin_github_url)
go mod tidy
$(MAKE) -C ./fdw clean
$(MAKE) -C ./fdw go
$(MAKE) -C ./fdw

# Remove existing work dir and create a new directory for the render process
rm -rf work && \
mkdir -p work

# Copy the entire source tree, excluding .git directory, into the new directory
rsync -a --exclude='.git' . work/ >/dev/null 2>&1

# Change to the new directory to perform operations
cd work && \
go run generate/generator.go templates . $(plugin) $(plugin_github_url) && \
go mod tidy && \
$(MAKE) -C ./fdw clean && \
$(MAKE) -C ./fdw go && \
$(MAKE) -C ./fdw && \
$(MAKE) -C ./fdw standalone

rm -f prebuild.go

# Delete existing build-${PLATFORM} and copy the binaries to the actual
# build-${PLATFORM} folder
rm -rf build-${PLATFORM} && \
mkdir -p build-${PLATFORM} && \
cp -a work/build-${PLATFORM}/* build-${PLATFORM}/

# Note: The work directory will contain the full code tree with changes,
# binaries will be copied to build-${PLATFORM} folder

# render target
render: validate_plugin prebuild.go
Expand Down Expand Up @@ -113,4 +124,3 @@ clean:
# Usage: make release input="v1.7.2"
release:
./scripts/upload_arm_asset.sh $(input)

Loading