### Inno Setup Script for Ocran Installer Source: https://github.com/largo/ocran/blob/master/README.md An example Inno Setup script (`.iss` file) used with Ocran's `--innosetup` option. Key sections like `[Setup]` define application details, and `[Icons]` create shortcuts. Do not include `[Files]` or `[Dirs]` sections as Ocran manages them. ```ini [Setup] AppName=SomeApp AppVersion=0.1 DefaultDirName={pf}\\SomeApp DefaultGroupName=SomeApp OutputBaseFilename=SomeAppInstaller [Icons] Name: "{group}\\SomeApp"; Filename: "{app}\\someapp.bat"; IconFilename: "{app}\\someapp.ico"; Flags: runminimized; Name: "{group}\\Uninstall SomeApp"; Filename: "{uninstallexe}" ``` -------------------------------- ### Build Inno Setup Installer with OCRAN Source: https://context7.com/largo/ocran/llms.txt Creates a professional Windows installer using Inno Setup, which installs the application to Program Files for faster startup and persistence. Requires Inno Setup to be installed and `ISCC.exe` in the PATH. ```bash # First create an Inno Setup script (myapp.iss): cat > myapp.iss << 'EOF' [Setup] AppName=MyApplication AppVersion=1.0 DefaultDirName={pf}\MyApplication DefaultGroupName=MyApplication OutputBaseFilename=MyAppInstaller [Icons] Name: "{group}\MyApplication"; Filename: "{app}\launcher.bat"; IconFilename: "{app}\myapp.ico" Name: "{group}\Uninstall MyApplication"; Filename: "{uninstallexe}" EOF # Build installer with custom icon ocran myapp.rb --output myapp.exe --innosetup myapp.iss \ --icon myapp.ico --no-lzma --chdir-first # This creates MyAppInstaller.exe in the Output directory # User runs installer which copies files to Program Files # Subsequent launches are much faster (no extraction needed) # Requirements: # - Inno Setup 5+ must be installed # - ISCC.exe must be in PATH # - Must use --no-lzma with Inno Setup # - Must use --chdir-first with Inno Setup ``` -------------------------------- ### Generate Inno Setup Installer with Ocran Source: https://github.com/largo/ocran/blob/master/README.md This snippet demonstrates how to use Ocran with the `--innosetup` option to generate a Windows installer for your application using Inno Setup. Ensure Inno Setup is installed and its directory is in your PATH. Ocran automatically handles the [Files] and [Dirs] sections of the script. ```bash ocran someapp/script/rails someapp --output someapp.exe --add-all-core \ --gemfile someapp/Gemfile --no-dep-run --gem-full --chdir-first --no-lzma \ --icon someapp.ico --innosetup someapp.iss -- server ``` -------------------------------- ### Maximalist Ocran Example with Innosetup, OpenSSL, tzinfo-data Source: https://github.com/largo/ocran/blob/master/Workarounds.md A comprehensive Ocran command for creating a Windows executable with advanced options. This includes using Innosetup for installation, enabling LZMA compression, and including specific gems like OpenSSL and tzinfo-data, along with numerous core DLLs. ```shell ocra test.rb --chdir-first --no-lzma --innosetup setup.iss --gem-full --add-all-core --icon iconfile.ico --output test.exe --dll ruby_builtin_dlls/libgmp-10.dll --dll ruby_builtin_dlls/libffi-7.dll --dll ruby_builtin_dlls/zlib1.dll --dll ruby_builtin_dlls/libssp-0.dll --dll ruby_builtin_dlls/libssl-1_1-x64.dll --dll ruby_builtin_dlls/libcrypto-1_1-x64.dll --dll ruby_builtin_dlls/libyaml-0-2.dll --dll ruby_builtin_dlls/libwinpthread-1.dll --dll libiconv-2.dll --dll libsqlite3-0.dll --dll ruby_builtin_dlls/libgcc_s_seh-1.dll --gem-full=openssl --gem-full=tzinfo-data ``` -------------------------------- ### Install FreeTDS and TinyTDS for Ocran Source: https://github.com/largo/ocran/blob/master/Workarounds.md Installs the FreeTDS library and the TinyTDS gem, required for connecting to SQL Server. This process involves using pacman to install FreeTDS and then installing the gem with specific include paths. ```shell ridk exec pacman -S mingw-w64-ucrt-x86_64-freetds --noconfirm gem install tiny_tds --with-freetds-include=C:\Ruby31-x64\msys64\ucrt64\include\freetds copy C:\Ruby31-x64\msys64\ucrt64\bin\libsybdb-5.dll C:\Ruby31-x64\bin ``` -------------------------------- ### Install SQLite3 and Ruby Dependencies for Ocran (Ruby 3.1) Source: https://github.com/largo/ocran/blob/master/Workarounds.md Installs the necessary SQLite3 and Ruby dependencies for Ocran on Ruby 3.1. This involves using pacman to install the sqlite3 package and copying specific DLLs to the Ruby bin directory. It also includes updating the Ruby installation with a specific version. ```shell ridk exec pacman -S mingw-w64-x86_64-sqlite3 --noconfirm copy C:\Ruby31-x64\msys64\mingw64\bin\libiconv-2.dll C:\Ruby31-x64\bin copy C:\Ruby31-x64\msys64\mingw64\bin\libsqlite3-0.dll C:\Ruby31-x64\bin ridk.cmd exec pacman -S mingw-w64-x86_64-ruby3.0.3-2 --noconfirm copy C:\Ruby31-x64\msys64\mingw64\lib\ruby\3.0.0\x64-mingw32\fiber.so C:\Ruby31-x64\lib\ruby\3.1.0\x64-mingw-ucrt ``` -------------------------------- ### Install Dependencies for Ruby 3.0 Workarounds Source: https://github.com/largo/ocran/blob/master/Workarounds.md Installs essential development dependencies for Ruby 3.0, including SQLite3, FreeTDS, and Ruby itself. This script prepares the environment for Ruby 3.0 based projects that might require these packages. ```shell call ridk exec pacman -S mingw-w64-x86_64-sqlite3 --noconfirm call ridk exec pacman -S mingw-w64-x86_64-freetds --noconfirm call ridk exec pacman -S mingw-w64-ucrt-x86_64-freetds --noconfirm call copy C:\Ruby32-x64\msys64\mingw64\bin\libiconv-2.dll C:\Ruby32-x64\bin call copy C:\Ruby32-x64\msys64\mingw64\bin\libsqlite3-0.dll C:\Ruby32-x64\bin call ridk exec pacman -S mingw-w64-x86_64-ruby --noconfirm call copy C:\Ruby32-x64\msys64\mingw64\lib\ruby\3.0.0\x64-mingw32\fiber.so C:\Ruby32-x64\lib\ruby\3.1.0\x64-mingw-ucrt ``` -------------------------------- ### Ruby Compilation with OCRAN Source: https://github.com/largo/ocran/blob/master/README.md OCRAN compiles Ruby code by loading the script and detecting dependencies. It automatically includes DLLs from the Ruby installation and distinguishes between console (.rb) and windowed (.rbw) applications, or can be explicitly set with flags. ```ruby # Example: Your script should require all necessary files. # OCRAN will detect dependencies automatically. require 'some_gem' puts "Hello from OCRAN!" ``` -------------------------------- ### Install TinyTDS with FreeTDS for Ruby 3.0 Source: https://github.com/largo/ocran/blob/master/Workarounds.md Installs the TinyTDS gem with specific FreeTDS include paths for Ruby 3.0 projects. This ensures that TinyTDS can correctly locate and utilize the FreeTDS library for database connections. ```shell call gem install tiny_tds -- --with-freetds-include=C:\Ruby32-x64\msys64\ucrt64\include\freetds call bundle config build.tiny_tds --with-freetds-include=C:\Ruby32-x64\msys64\ucrt64\include\freetds call copy C:\Ruby32-x64\msys64\ucrt64\bin\libsybdb-5.dll C:\Ruby32-x64\bin ``` -------------------------------- ### Configure Working Directory Behavior in OCRAN Source: https://context7.com/largo/ocran/llms.txt Controls the working directory when the executable starts. The `--chdir-first` option changes the working directory to the application's directory before running the script, ensuring consistent file operations. Without this, the working directory is where the user launches the executable, which can lead to issues with file associations or command prompt locations. ```bash # Change to application directory before running script ocran myapp.rb --chdir-first ``` -------------------------------- ### Detect Runtime Execution Context in Ruby for OCRAN Source: https://context7.com/largo/ocran/llms.txt Checks if code is running under OCRAN during build to conditionally execute code. The `defined?(Ocran)` check prevents actions like starting a GUI or connecting to a database during the build process, ensuring a smoother dependency detection phase. It also allows access to runtime environment variables like `OCRAN_EXECUTABLE`. ```ruby # Conditionally execute code only in production, not during OCRAN build app = MyApplication.new # Don't start GUI or server during OCRAN dependency detection app.start unless defined?(Ocran) # Example: Skip database connections during build unless defined?(Ocran) DB = Sequel.connect('sqlite://production.db') app.run end # Access runtime environment variables in packaged executable if ENV['OCRAN_EXECUTABLE'] # Running as packaged executable app_dir = File.dirname(ENV['OCRAN_EXECUTABLE']) log_file = File.join(app_dir, 'application.log') else # Running as regular Ruby script log_file = 'development.log' end ``` -------------------------------- ### Adding Additional Files and Directories with Ocran Source: https://github.com/largo/ocran/blob/master/README.md This command demonstrates how to include additional files (e.g., images, documents) and directories in the generated Ocran executable. Files are added as-is, directories are included recursively, and glob patterns can specify specific file sets. ```bash ocran mainscript.rb someimage.jpeg docs/document.txt ``` ```bash ocran script.rb assets/**/*.png ``` -------------------------------- ### Build Executable with Gemfile Dependencies using OCRAN Source: https://context7.com/largo/ocran/llms.txt Includes all gems specified in a Gemfile for complete dependency resolution. This command is useful for complex applications like Rails. ```bash # Package a Rails application with all gem dependencies ocran app/script/rails app --output myapp.exe --add-all-core \ --gemfile app/Gemfile --no-dep-run --gem-full --chdir-first -- server # Gemfile example: # source 'https://rubygems.org' # gem 'rails', '~> 7.0' # gem 'sqlite3' # gem 'puma' # --gemfile: Use Bundler Gemfile for dependency detection # --add-all-core: Include all Ruby standard libraries # --no-dep-run: Don't execute script during build (faster for large apps) # --gem-full: Include all files from gems, not just loaded ones # --chdir-first: Change to app directory before running # -- server: Arguments passed to the script at runtime ``` -------------------------------- ### OCRAN Command Line Usage Source: https://github.com/largo/ocran/blob/master/README.md The general command-line syntax for OCRAN, allowing for options and script arguments. This enables customization of the build process and the final executable's behavior. ```bash ocran [options] script.rb [ ...] [--