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

Refactor Makefile, update build and install targets, and fix Node.js conflict #4847

Merged
merged 3 commits into from
Apr 11, 2023

Conversation

niccoloraspa
Copy link
Member

@niccoloraspa niccoloraspa commented Apr 6, 2023

Closes: #3125

What is the purpose of the change

This PR refactors the Makefile to simplify the build and install process, as well as address an issue where the make install command may cause a conflict with Node.js's node command.

Now the make build (make install) command builds (installs) only the osmosisd binary while a new target make build-all builds all the binaries in the repo (chain, node, osmosisd, querygen).

Brief Changelog

The changes include:

  • Remove unnecessary targets and simplify the structure of the Makefile
  • Introduce GO_MODULE variable to automatically extract the module path from the go.mod file
  • Update build target to use GO_MODULE variable and build the osmosisd package alone
  • Add a new build-all target to build all packages in the current directory and its subdirectories, similar to the original build target
  • Update install target to use GO_MODULE variable and install the osmosisd package alone, avoiding conflicts with Node.js's node command

These changes make the Makefile more concise, improve maintainability, simplify the build and install process, and resolve the conflict with Node.js's node command.

Testing and Verifying

New build target:

❯  make build

mkdir -/github.com/osmosis-labs/osmosis-build/build/

GOWORK=off go build -mod=readonly  -tags "netgo ledger" \
-ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=osmosis \
-X github.com/cosmos/cosmos-sdk/version.AppName=osmosisd \
-X github.com/cosmos/cosmos-sdk/version.Version=crosschain-swaps-v1.0.0-210-g95bb54e84 \
-X github.com/cosmos/cosmos-sdk/version.Commit=95bb54e8490a4961ea57987f613028b49632ba39 \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger" \
-w -s' -trimpath -o /github.com/osmosis-labs/osmosis-build/build/ github.com/osmosis-labs/osmosis/v15/cmd/osmosisd

New build-all target:

❯ make build-all

mkdir -p /github.com/osmosis-labs/osmosis-build/build/

GOWORK=off go build -mod=readonly -tags "netgo ledger" \
-ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=osmosis \
-X github.com/cosmos/cosmos-sdk/version.AppName=osmosisd \
-X github.com/cosmos/cosmos-sdk/version.Version=crosschain-swaps-v1.0.0-210-g95bb54e84 \
-X github.com/cosmos/cosmos-sdk/version.Commit=95bb54e8490a4961ea57987f613028b49632ba39 \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger" \
-w -s' -trimpath -o /github.com/osmosis-labs/osmosis-build/build/ ./...

Old make build (same as the new make build-all) command:

# Old version
❯ make build 

GOWORK=off go build -mod=readonly -tags "netgo ledger" \
-ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=osmosis \
-X github.com/cosmos/cosmos-sdk/version.AppName=osmosisd \
-X github.com/cosmos/cosmos-sdk/version.Version=15.0.0 \
-X github.com/cosmos/cosmos-sdk/version.Commit=ff18d8244fcda7313ec951fb1b3bee8369b8316b \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger" \
-w -s' -trimpath -o /github.com/osmosis-labs/osmosis/build/ ./...

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? no
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? no
  • How is the feature or change documented? not applicable

@niccoloraspa
Copy link
Member Author

cc: @mikedotexe

@niccoloraspa niccoloraspa added V:state/compatible/backport State machine compatible PR, should be backported A:backport/v15.x backport patches to v15.x branch labels Apr 6, 2023
@niccoloraspa
Copy link
Member Author

Was the old make build command used in e2e anywhere @p0mvn ?

@p0mvn
Copy link
Member

p0mvn commented Apr 9, 2023

Was the old make build command used in e2e anywhere @p0mvn ?

No, I don't think so. There are separate Docker-image-building-related makefile steps that are used by e2e

@niccoloraspa
Copy link
Member Author

Then we are good to merge :)

Comment on lines +102 to +104
build-all: check_version go.sum
mkdir -p $(BUILDDIR)/
GOWORK=off go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/ ./...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have binaries that aren't just osmosisd?

Copy link
Member Author

@niccoloraspa niccoloraspa Apr 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah! This was the cause of the issue.
The following binaries get created:

osmosisd
chain (e2e)
node (e2e)
querygen

@ValarDragon
Copy link
Member

Can we get a changelog entry for the bugfix for node users?

@niccoloraspa niccoloraspa requested a review from a team as a code owner April 11, 2023 13:27
@niccoloraspa
Copy link
Member Author

Added CHANGELOG entry!

@niccoloraspa
Copy link
Member Author

niccoloraspa commented Apr 11, 2023

BTW

CODEOWNER feature works :)
image

@niccoloraspa niccoloraspa merged commit 353933a into main Apr 11, 2023
@niccoloraspa niccoloraspa deleted the nicco/fix-make-install-conflicts branch April 11, 2023 14:12
mergify bot pushed a commit that referenced this pull request Apr 11, 2023
…conflict (#4847)

* Update targets in Makefile

* Restore go 1.20

* Update CHANGELOG.md

(cherry picked from commit 353933a)

# Conflicts:
#	CHANGELOG.md
#	Makefile
niccoloraspa added a commit that referenced this pull request Apr 11, 2023
…conflict (backport #4847) (#4890)

* Refactor Makefile, update build and install targets, and fix Node.js conflict (#4847)

* Update targets in Makefile

* Restore go 1.20

* Update CHANGELOG.md

(cherry picked from commit 353933a)

# Conflicts:
#	CHANGELOG.md
#	Makefile

* Update CHANGELOG.md

* Update Makefile

---------

Co-authored-by: Niccolo Raspa <6024049+niccoloraspa@users.noreply.github.com>
@mikedotexe
Copy link

cc: @mikedotexe

Thank you, and thanks Osmosis team!

@daniel-farina
Copy link
Contributor

Friendly reminder to remove node and reinstall node in order to fix this issue.

which node
rm /root/go/bin/node

Then reinstall your preferred node version. Simply reinstalling node w/o removing the old one did not work on my end.

@github-actions github-actions bot mentioned this pull request Feb 15, 2024
@github-actions github-actions bot mentioned this pull request Mar 15, 2024
@github-actions github-actions bot mentioned this pull request Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v15.x backport patches to v15.x branch T:build V:state/compatible/backport State machine compatible PR, should be backported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make install may cause conflict with NodeJS's node
5 participants