-
Notifications
You must be signed in to change notification settings - Fork 9
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
write build_go_mac.sh file to set up go package so it can be installed more seamlessly #79
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
764784f
adjust make_go.sh file to do black magic
ramfox 537cb23
point to the right location...
ramfox 3734978
build go for release
ramfox 32c4f6d
adjust module name
ramfox 1b1c3e1
adjust module path again
ramfox 20dda4a
rename module
ramfox b6d9d08
adjust ci
ramfox a7b4a8a
fix test imports
ramfox 669da58
adjust scripts, make sure we only keep needed files for go build
ramfox 4b54c9b
make build scripts for linux and mac
ramfox e8310af
make the data dir if it doesnt already exist
ramfox c83b8e3
adjust go build/run instructions
ramfox 285d55d
adjust ci
ramfox f2d1b88
remove release-assets.yml
ramfox d64e45f
adjust linux build script again
ramfox 0794feb
remove unneeded make files
ramfox 5047599
fix gitignore
ramfox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
set -eu | ||
|
||
MODE="" | ||
DIR_NAME="debug" | ||
if [ "$#" -eq 1 ]; then | ||
if [[ $1 == "release" ]]; then | ||
MODE="--release" | ||
DIR_NAME="release" | ||
elif [[ $1 != "debug" ]]; then | ||
echo "Unknown mode '$1'. Options are 'release' and 'debug'. Defaults to 'debug'" | ||
exit | ||
fi | ||
fi | ||
|
||
# the path to the new folder we are including | ||
GO_DIR="./iroh-go" | ||
INCLUDE_PATH="${GO_DIR}/iroh/ffi" | ||
IROH_GO_PATH="${GO_DIR}/iroh/*" | ||
UDL_PATH="./src/iroh.udl" | ||
IROH_GO_FILE="${GO_DIR}/iroh/iroh.go" | ||
|
||
rm -rf $IROH_GO_PATH | ||
|
||
# build iroh-ffi and save the assets to ./go/iroh/include | ||
cargo build $MODE | ||
|
||
uniffi-bindgen-go $UDL_PATH --out-dir $GO_DIR | ||
|
||
# TODO why does this needs to exist twice? once in the path and the other in | ||
# the "deps" directory? | ||
# move needed files over | ||
mkdir ${INCLUDE_PATH} | ||
cp "target/${DIR_NAME}/libiroh.so" "${INCLUDE_PATH}/libiroh.so" | ||
mkdir "${INCLUDE_PATH}/deps" | ||
cp "${INCLUDE_PATH}/libiroh.so" "${INCLUDE_PATH}/deps/libiroh.so" | ||
|
||
sed -i "s/\/\/ #include <iroh.h>/\/\*\n#cgo CFLAGS: -I.\/ffi\n#cgo LDFLAGS: -liroh -L.\/ffi\n#include <iroh.h>\n\*\//" $IROH_GO_FILE | ||
|
||
# to run you need to let the linker know where the linked library files are: | ||
# LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}:./iroh/ffi" \ | ||
# CGO_LDFLAGS="-liroh -L ./iroh/ffi" \ | ||
# go <actual go command to build or run> | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
set -eu | ||
|
||
MODE="" | ||
DIR_NAME="debug" | ||
if [ "$#" -eq 1 ]; then | ||
if [[ $1 == "release" ]]; then | ||
MODE="--release" | ||
DIR_NAME="release" | ||
elif [[ $1 != "debug" ]]; then | ||
echo "Unknown mode '$1'. Options are 'release' and 'debug'. Defaults to 'debug'" | ||
exit | ||
fi | ||
fi | ||
|
||
# the path to the new folder we are including | ||
GO_DIR="./iroh-go" | ||
INCLUDE_PATH="${GO_DIR}/iroh/ffi" | ||
IROH_GO_PATH="${GO_DIR}/iroh/*" | ||
UDL_PATH="./src/iroh.udl" | ||
IROH_GO_FILE="${GO_DIR}/iroh/iroh.go" | ||
|
||
rm -rf $IROH_GO_PATH | ||
|
||
# build iroh-ffi and save the assets to ./go/iroh/include | ||
cargo build $MODE | ||
|
||
# TODO why does this needs to exist twice? once in the path and the other in | ||
# the "deps" directory? | ||
# move needed files over | ||
mkdir ${INCLUDE_PATH} | ||
cp "target/${DIR_NAME}/libiroh.dylib" "${INCLUDE_PATH}/libiroh.dylib" | ||
mkdir "${INCLUDE_PATH}/deps" | ||
cp "${INCLUDE_PATH}/libiroh.dylib" "${INCLUDE_PATH}/deps/libiroh.dylib" | ||
|
||
uniffi-bindgen-go $UDL_PATH --out-dir $GO_DIR | ||
|
||
sed -i '' "s/\/\/ #include <iroh.h>/\/\*\n#cgo CFLAGS: -I.\/ffi\n#cgo LDFLAGS: -liroh -L.\/ffi\n#include <iroh.h>\n\*\//" $IROH_GO_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
module github.com/n0-computer/iroh-ffi | ||
module github.com/n0-computer/iroh-ffi/iroh-go | ||
|
||
go 1.19 | ||
|
||
require github.com/stretchr/testify v1.8.4 | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/stretchr/testify v1.8.4 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this stay here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, unfortunately from my linux experimentation, it won't recognize the linked files, no matter where I put
libiroh.so
. Either the box I was using was ignoring it, or maybe something was wrong with how it was set up for dynamic linking, but I couldn't get it to recognize the cgo flag. I needed to still add the LD_LIBRARY_PATH manually. So until that's confirmed to work I want to leave these instructions in.