Giter Club home page Giter Club logo

pombredanne / ruby-packer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pmq20/ruby-packer

0.0 2.0 0.0 39.95 MB

Packing your Ruby application into a single executable.

Home Page: http://enclose.io

License: MIT License

Shell 0.57% Ruby 40.22% Batchfile 0.02% GDB 0.05% Makefile 0.53% M4 0.35% C 49.05% Perl 0.01% Python 0.02% Scheme 0.01% Perl 6 0.01% Objective-C 1.22% Roff 5.32% C++ 0.27% HTML 0.03% Assembly 0.86% TeX 0.51% Ragel 0.04% Yacc 0.91% CSS 0.02%

ruby-packer's Introduction

Ruby Packer

Packing your Ruby application into a single executable.

Status Status GitHub version

Features

  • Works on Linux, Mac and Windows
  • Creates a binary distribution of your application
  • Supports natively any form of require and load, including dynamic ones (e.g. load(my_path + 'x.rb')
  • Features zero-config auto-update capabilities to make your compiled project to stay updated
  • Native C extensions are fully supported
  • Rails applications are fully supported
  • Open Source, MIT Licensed

Get Started

It takes less than 5 minutes to compile any project with Ruby Compiler.

You won't need to modify a single line of code in your application, no matter how you developed it as long as it works in plain Ruby!

Architecture Latest Stable
macOS x86-64 http://enclose.io/rubyc/rubyc-darwin-x64.gz
Linux x86-64 http://enclose.io/rubyc/rubyc-linux-x64.gz
Windows x86-64 http://enclose.io/rubyc/rubyc-x64.zip

For previous releases, cf. http://enclose.io/rubyc

Install on macOS

First install the prerequisites:

  • SquashFS Tools 4.3: brew install squashfs
  • Xcode
    • You also need to install the Command Line Tools via Xcode. You can find this under the menu Xcode -> Preferences -> Downloads
    • This step will install gcc and the related toolchain containing make
  • Ruby

Then,

curl -L http://enclose.io/rubyc/rubyc-darwin-x64.gz | gunzip > rubyc
chmod +x rubyc
./rubyc --help

Install on Linux

First install the prerequisites:

  • SquashFS Tools 4.3
    • sudo yum install squashfs-tools
    • sudo apt-get install squashfs-tools
  • gcc or clang
  • GNU Make
  • Ruby

Then,

curl -L http://enclose.io/rubyc/rubyc-linux-x64.gz | gunzip > rubyc
chmod +x rubyc
./rubyc --help

Install on Windows

First install the prerequisites:

Then download rubyc-x64.zip, and this zip file contains only one executable. Unzip it. Optionally, rename it to rubyc.exe and put it under C:\Windows (or any other directory that is part of PATH). Execute rubyc --help from the command line.

Usage

If ENTRANCE was not provided, then a single Ruby interpreter executable will be produced. ENTRANCE can be either a file path, or a "x" string as in bundle exec "x".

rubyc [OPTION]... [ENTRANCE]
  -r, --root=DIR                   The path to the root of the application
  -o, --output=FILE                The path of the output file
  -d, --tmpdir=DIR                 The directory for temporary files
  -c, --clean-tmpdir               Cleans temporary files before compiling
      --keep-tmpdir                Keeps all temporary files that were generated last time
      --make-args=ARGS             Extra arguments to be passed to make
      --nmake-args=ARGS            Extra arguments to be passed to nmake
      --auto-update-url=URL        Enables auto-update and specifies the URL to get the latest version
      --auto-update-base=STRING    Enables auto-update and specifies the base version string
      --debug                      Enable debug mode
  -v, --version                    Prints the version of rubyc and exit
      --ruby-version               Prints the version of the Ruby runtime and exit
      --ruby-api-version           Prints the version of the Ruby API and exit
  -h, --help                       Prints this help and exit

Examples

Producing a single Ruby interpreter executable

rubyc
./a.out (or a.exe on Windows)

Compiling a CLI tool

git clone --depth 1 https://github.com/pmq20/ruby-compiler
cd ruby-compiler
rubyc bin/rubyc
./a.out (or a.exe on Windows)

Compiling a Rails application

rails new yours
cd yours
rubyc bin/rails
./a.out server (or a.exe server on Windows)

Note that some gems that use C extensions that use libc IO to load files from your Rails application will not work with rubyc. Notably, bootsnap will not work with rubyc.

Compiling a Gem

rubyc --gem=bundler --gem-version=1.15.4 bundle
./a.out (or a.exe on Windows)

Building rubyc yourself

To build rubyc you must have a C compiler and the necessary toolchain to build ruby and the libraries stuffed inside rubyc which include at least:

  • gdbm
  • libffi
  • ncurses
  • openssl
  • readline
  • yaml
  • zlib

If you are unsure if your toolchain is complete then trying to build rubyc will let you know you are missing something. Unfortunately it may tell you with some unfamiliar message. Please file an issue here if this occurs.

Once your toolchain is set up run bundle. To compile your own rubyc run:

bundle exec rake rubyc

Or:

rm rubyc; ruby -Ilib bin/rubyc bin/rubyc -o rubyc

Remember that rubyc includes all the files from the current directory in the built executable. You must delete the prior rubyc or your squashfs will continually grow larger and the embedded squashfs compile time will be very, very long.

If you make changes to the stuffed libraries or the compiler you may need to add the --clean-tmpdir argument to rubyc for a clean rebuild.

See Also

  • Libsquash: portable, user-land SquashFS that can be easily linked and embedded within your application.
  • Libautoupdate: cross-platform C library to enable your application to auto-update itself in place.

ruby-packer's People

Contributors

drbrain avatar jakolehm avatar nilsding avatar pmq20 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.