This commit updates the README.md file to include a new 'Building from Source' section. This section provides step-by-step instructions for compiling Picocrypt on Linux, macOS, and Windows, including prerequisites, dependency management, and platform-specific build commands. For macOS and Windows, optional instructions are also included for creating application bundles/installers and embedding resources to match the official release builds more closely.
4.9 KiB
Building Picocrypt on macOS
This guide provides instructions on how to build Picocrypt from source on a macOS system.
Prerequisites
-
Xcode Command Line Tools: If you haven't already, install the Xcode Command Line Tools. Open Terminal and run:
xcode-select --install
Follow the on-screen prompts.
-
Homebrew: Homebrew is a package manager for macOS. If you don't have it, install it by following the instructions at brew.sh.
-
Go Programming Language:
- Installation: It's recommended to install the latest stable version of Go. You can download it from the official Go website or install it via Homebrew:
brew install go
- Environment Setup (if not using Homebrew's Go): Ensure your
GOPATH
andGOROOT
environment variables are set up correctly, and that$GOPATH/bin
and$GOROOT/bin
are in yourPATH
. If you installed Go via Homebrew, this is usually handled automatically. You can check your Go environment withgo env
.
- Installation: It's recommended to install the latest stable version of Go. You can download it from the official Go website or install it via Homebrew:
-
Git: If not already installed (usually comes with Xcode Command Line Tools), install Git:
brew install git
-
Required Libraries (GLFW & GLEW): Picocrypt's GUI depends on GLFW and GLEW. Install them using Homebrew:
brew install glfw glew
Build Steps
-
Clone the Repository: Open Terminal and navigate to the directory where you want to store the Picocrypt source code. Then clone the repository:
git clone https://github.com/Picocrypt/Picocrypt.git cd Picocrypt
-
Navigate to the Source Directory: The main Go source code is located in the
src
directory.cd src
-
Download Dependencies: Picocrypt uses Go modules to manage its dependencies. Download them using:
go mod download
This command inspects the
go.mod
file and downloads all necessary libraries. -
Compile the Application: Build the Picocrypt application. The
-ldflags="-s -w"
flags help reduce the binary size by stripping debug symbols.CGO_ENABLED=1
is necessary as Picocrypt uses Cgo for its GUI components.CGO_ENABLED=1 go build -v -ldflags="-s -w" -o Picocrypt Picocrypt.go
The
-v
flag enables verbose output, showing the packages as they are compiled. The-o Picocrypt
flag specifies the output file name.Upon successful compilation, you will find an executable file named
Picocrypt
in thesrc
directory.
Packaging (Optional - Creating a .app Bundle and .dmg)
The following steps replicate the process used in the GitHub Actions workflow to create a standard macOS application bundle (.app
) and a disk image (.dmg
).
-
Prepare the .app Bundle Structure: The Picocrypt repository includes a template for the
.app
bundle.- Go back to the root directory of the cloned repository:
cd ..
- The template
Picocrypt.app.zip
is usually located indist/macos/
. For a manual build, you might need to ensure this path is correct or download/copy this template if it's not present directly. Assuming it's indist/macos/
:
This creates acp dist/macos/Picocrypt.app.zip . unzip -d Picocrypt.app Picocrypt.app.zip rm Picocrypt.app.zip
Picocrypt.app
directory with the necessary bundle structure.
- Go back to the root directory of the cloned repository:
-
Move the Compiled Binary: Move the
Picocrypt
executable you compiled in thesrc
directory into the.app
bundle:mv src/Picocrypt Picocrypt.app/Contents/MacOS/Picocrypt
-
Create the .dmg Disk Image:
-
Create a temporary directory to hold the
.app
bundle for DMG creation:mkdir out cp -R Picocrypt.app out/
-
Use
hdiutil
to create the DMG:hdiutil create Picocrypt.dmg -volname Picocrypt -fs APFS -format UDZO -srcfolder out
This will create
Picocrypt.dmg
in the root of the repository. -
Clean up the temporary directory:
rm -rf out rm -rf Picocrypt.app
-
You should now have a Picocrypt.dmg
file ready for distribution or installation. The standalone Picocrypt
executable (from src/Picocrypt
) can also be run directly if you don't need the .app
bundle.
Running Picocrypt
- Directly: You can run the compiled binary from the
src
directory:./src/Picocrypt
- From .app Bundle: If you created the
.app
bundle, you can run it by double-clickingPicocrypt.app
in Finder, or from Terminal:open Picocrypt.app
- From .dmg: Open
Picocrypt.dmg
, and then dragPicocrypt.app
to your Applications folder. Run it from there.
This completes the build process for Picocrypt on macOS.