Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PolarGoose committed May 12, 2024
0 parents commit 01b8559
Show file tree
Hide file tree
Showing 15 changed files with 14,999 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
max_line_length = 150
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
18 changes: 18 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
on: push

jobs:
build:
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- run: ./build.ps1
- uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: build/publish/*.zip
fail_on_unmatched_files: true
- uses: actions/upload-artifact@v4
with:
name: Build artifacts
path: build/publish/*.zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Ragel source code built for Windows
This repository produces a statically linked [Ragel](https://github.com/adrian-thurston/ragel) x64 binary for Windows, using the MSVC compiler.<br>
The source code is taken from the <br>
For detailed information about Ragel itself, please refer to the original repository.

# How to use
Download the [latest release](https://github.com/PolarGoose/Ragel-for-Windows/releases)

# System requirements
Windows 7 x64 or higher

## How to generate files from `patch_files\ragel` folder
These files are generated during the build of the Ragel codebase on Linux.
The instructions below explain how to get these files in case they need to be updated in this repository.
* Use WSL Ubuntu
* Clone the https://github.com/adrian-thurston/ragel
* Checkout the `ragel-6.10` tag
* Install prerequisites: `sudo apt-get install build-essential autoconf ragel kelbt fig2dev`
* cd into the repository folder
* Execute the following commands:
```
./autogen.sh
./configure --disable-manual
make
```

## How to build this repository
* Run `.\build.ps1`
60 changes: 60 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Function Info($msg) {
Write-Host -ForegroundColor DarkGreen "`nINFO: $msg`n"
}

Function Error($msg) {
Write-Host `n`n
Write-Error $msg
exit 1
}

Function CheckReturnCodeOfPreviousCommand($msg) {
if(-Not $?) {
Error "${msg}. Error code: $LastExitCode"
}
}

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
Add-Type -AssemblyName System.IO.Compression.FileSystem

$root = $PSScriptRoot
$buildDir = "$root/build"

Info "Find Visual Studio installation path"
$vswhereCommand = Get-Command -Name "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$installationPath = & $vswhereCommand -prerelease -latest -property installationPath

Info "Open Visual Studio 2022 Developer PowerShell"
& "$installationPath\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64

Info "Remove '$buildDir' folder if it exists"
Remove-Item $buildDir -Force -Recurse -ErrorAction SilentlyContinue
New-Item $buildDir -Force -ItemType "directory" > $null

Info "Download Ragel source code"
Invoke-WebRequest -Uri https://codeload.github.com/adrian-thurston/ragel/zip/refs/tags/ragel-6.10 -OutFile $buildDir/ragel.zip

Info "Extract the source code"
[System.IO.Compression.ZipFile]::ExtractToDirectory("$buildDir/ragel.zip", "$buildDir")

Info "Copy patch files to the Ragel sources"
Copy-Item -Path $root/patch_files/* -Destination $buildDir/ragel-ragel-6.10 -Recurse -Force

Info "Cmake generate cache"
cmake `
-S $buildDir/ragel-ragel-6.10 `
-B $buildDir/out `
-G Ninja `
-DCMAKE_BUILD_TYPE=Release
CheckReturnCodeOfPreviousCommand "cmake cache failed"

Info "Cmake build"
cmake --build $buildDir/out
CheckReturnCodeOfPreviousCommand "cmake build failed"

Info "Copy the executable to the publish directory and archive it"
New-Item $buildDir/publish -Force -ItemType "directory" > $null
Copy-Item -Path $buildDir/out/Ragel.exe -Destination $buildDir/publish
Compress-Archive -Path "$buildDir/publish/*.exe" -DestinationPath $buildDir/publish/Ragel.zip
9 changes: 9 additions & 0 deletions patch_files/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required (VERSION 3.28)
project(RagelForWindows LANGUAGES CXX)
set(CMAKE_DISABLE_FIND_PACKAGE_Python ON)

set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
file(GLOB_RECURSE src_files CONFIGURE_DEPENDS "ragel/*.h" "ragel/*.cpp" "aapl/*.h")
add_executable(Ragel ${src_files})
target_include_directories(Ragel PRIVATE ${CMAKE_SOURCE_DIR}/aapl ${CMAKE_SOURCE_DIR}/linux_headers)
target_compile_options(Ragel PRIVATE /W0 /permissive- )
Empty file.
26 changes: 26 additions & 0 deletions patch_files/ragel/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* ragel/config.h. Generated from config.h.in by configure. */
/* ragel/config.h.in. Generated from configure.ac by autoheader. */

/* Name of package */
#define PACKAGE "ragel"

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""

/* Define to the full name of this package. */
#define PACKAGE_NAME "ragel"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "ragel 6.10"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "ragel"

/* Define to the home page for this package. */
#define PACKAGE_URL ""

/* Define to the version of this package. */
#define PACKAGE_VERSION "6.10"

/* Version number of package */
#define VERSION "6.10"
Loading

0 comments on commit 01b8559

Please sign in to comment.