Skip to content
This repository was archived by the owner on May 18, 2026. It is now read-only.

Commit ef65348

Browse files
committed
Initial commit
0 parents  commit ef65348

31 files changed

Lines changed: 2521 additions & 0 deletions

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
indent_style = tab
6+
trim_trailing_whitespace = true
7+
insert_final_newline = true

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/build.yml

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
name: Build
2+
3+
on:
4+
schedule:
5+
- cron: '30 5 * * *'
6+
workflow_dispatch:
7+
branches:
8+
- '**'
9+
push:
10+
branches:
11+
- '**'
12+
13+
permissions: write-all
14+
15+
jobs:
16+
cross-build:
17+
runs-on: ubuntu-latest
18+
continue-on-error: true
19+
strategy:
20+
matrix:
21+
target: [
22+
# Windows
23+
'x86_64-w64-mingw32',
24+
'i686-w64-mingw32',
25+
26+
# macOS
27+
'aarch64-unknown-apple-darwin',
28+
'x86_64-unknown-apple-darwin',
29+
30+
# Linux (glibc)
31+
'x86_64-unknown-linux-gnu',
32+
'i386-unknown-linux-gnu',
33+
'arm-unknown-linux-gnueabi',
34+
'arm-unknown-linux-gnueabihf',
35+
'aarch64-unknown-linux-gnu',
36+
37+
# Linux (musl)
38+
'aarch64-unknown-linux-musl',
39+
'x86_64-unknown-linux-musl',
40+
'armv6-unknown-linux-musleabihf',
41+
'armv7-unknown-linux-musleabihf',
42+
'i386-unknown-linux-musl',
43+
44+
# FreeBSD
45+
'x86_64-unknown-freebsd',
46+
'aarch64-unknown-freebsd',
47+
'i386-unknown-freebsd',
48+
49+
# NetBSD
50+
'i386-unknown-netbsdelf',
51+
'x86_64-unknown-netbsd',
52+
53+
# DragonFly BSD
54+
'x86_64-unknown-dragonfly',
55+
56+
# Android
57+
'x86_64-unknown-linux-android',
58+
'i686-unknown-linux-android21',
59+
'aarch64-unknown-linux-android',
60+
'riscv64-unknown-linux-android',
61+
'armv7-unknown-linux-androideabi21',
62+
]
63+
steps:
64+
- name: Checkout repository
65+
uses: actions/checkout@main
66+
- name: Cross-compile revf to ${{ matrix.target }}
67+
working-directory: './'
68+
env:
69+
CMAKE_INSTALL_PREFIX: /tmp/revf
70+
run: |
71+
if [[ '${{ matrix.target }}' = *'-linux-musl'* ]]; then
72+
declare -r RAIDEN_TARBALL='/tmp/toolchain.tar.xz'
73+
declare -r RAIDEN_URL="https://github.com/AmanoTeam/musl-gcc-cross/releases/latest/download/x86_64-unknown-linux-gnu.tar.xz"
74+
75+
curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${RAIDEN_URL}" --output "${RAIDEN_TARBALL}"
76+
tar --directory="$(dirname "${RAIDEN_TARBALL}")" --extract --file="${RAIDEN_TARBALL}"
77+
78+
export RAIDEN_HOME='/tmp/musl-gcc-cross'
79+
export PATH="${RAIDEN_HOME}/bin:${PATH}"
80+
81+
source "${RAIDEN_HOME}/build/autotools/${{ matrix.target }}.sh"
82+
elif [[ '${{ matrix.target }}' = *'-linux-gnu'* ]]; then
83+
declare -r OBGGCC_TARBALL='/tmp/toolchain.tar.xz'
84+
declare -r OBGGCC_URL="https://github.com/AmanoTeam/obggcc/releases/latest/download/x86_64-unknown-linux-gnu.tar.xz"
85+
86+
curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${OBGGCC_URL}" --output "${OBGGCC_TARBALL}"
87+
tar --directory="$(dirname "${OBGGCC_TARBALL}")" --extract --file="${OBGGCC_TARBALL}"
88+
89+
export OBGGCC_HOME='/tmp/obggcc'
90+
export PATH="${OBGGCC_HOME}/bin:${PATH}"
91+
92+
source "${OBGGCC_HOME}/build/autotools/${{ matrix.target }}.sh"
93+
elif [[ '${{ matrix.target }}' = *'-freebsd' ]]; then
94+
declare -r LOKI_TARBALL='/tmp/toolchain.tar.xz'
95+
declare -r LOKI_URL="https://github.com/AmanoTeam/freebsd-gcc-cross/releases/latest/download/x86_64-unknown-linux-gnu.tar.xz"
96+
97+
curl --silent --connect-timeout '10' --retry '15' --retry-all-errors --fail --location --url "${LOKI_URL}" --output "${LOKI_TARBALL}"
98+
tar --directory="$(dirname "${LOKI_TARBALL}")" --extract --file="${LOKI_TARBALL}"
99+
100+
export LOKI_HOME='/tmp/freebsd-gcc-cross'
101+
export PATH="${LOKI_HOME}/bin:${PATH}"
102+
103+
source "${LOKI_HOME}/build/autotools/${{ matrix.target }}.sh"
104+
elif [[ '${{ matrix.target }}' = *'-netbsd'* ]]; then
105+
declare -r DAKINI_TARBALL='/tmp/toolchain.tar.xz'
106+
declare -r DAKINI_URL="https://github.com/AmanoTeam/netbsd-gcc-cross/releases/latest/download/x86_64-unknown-linux-gnu.tar.xz"
107+
108+
curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${DAKINI_URL}" --output "${DAKINI_TARBALL}"
109+
tar --directory="$(dirname "${DAKINI_TARBALL}")" --extract --file="${DAKINI_TARBALL}"
110+
111+
export DAKINI_HOME='/tmp/netbsd-gcc-cross'
112+
export PATH="${DAKINI_HOME}/bin:${PATH}"
113+
114+
source "${DAKINI_HOME}/build/autotools/${{ matrix.target }}.sh"
115+
elif [[ '${{ matrix.target }}' = *'-dragonfly' ]]; then
116+
declare -r VENTI_TARBALL='/tmp/toolchain.tar.xz'
117+
declare -r VENTI_URL="https://github.com/AmanoTeam/dragonfly-gcc-cross/releases/latest/download/x86_64-unknown-linux-gnu.tar.xz"
118+
119+
curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${VENTI_URL}" --output "${VENTI_TARBALL}"
120+
tar --directory="$(dirname "${VENTI_TARBALL}")" --extract --file="${VENTI_TARBALL}"
121+
122+
export VENTI_HOME='/tmp/dragonfly-gcc-cross'
123+
export PATH="${VENTI_HOME}/bin:${PATH}"
124+
125+
source "${VENTI_HOME}/build/autotools/${{ matrix.target }}.sh"
126+
elif [[ '${{ matrix.target }}' = *'-mingw32' ]]; then
127+
declare -r MINGW_TARBALL='/tmp/toolchain.tar.xz'
128+
declare -r MINGW_URL="https://github.com/AmanoTeam/mingw-gcc-cross/releases/latest/download/x86_64-unknown-linux-gnu.tar.xz"
129+
130+
curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${MINGW_URL}" --output "${MINGW_TARBALL}"
131+
tar --directory="$(dirname "${MINGW_TARBALL}")" --extract --file="${MINGW_TARBALL}"
132+
133+
export MINGW_HOME='/tmp/mingw-gcc-cross'
134+
export PATH="${MINGW_HOME}/bin:${PATH}"
135+
136+
source "${MINGW_HOME}/build/autotools/${{ matrix.target }}.sh"
137+
elif [[ '${{ matrix.target }}' = *'-darwin' ]]; then
138+
curl \
139+
--silent \
140+
--show-error \
141+
--fail \
142+
--url 'https://raw.githubusercontent.com/AmanoTeam/darwin-gcc-cross/refs/heads/master/main.sh' \
143+
| bash -s -- install
144+
145+
export DARWIN_HOME='/tmp/darwin-gcc-cross'
146+
export PATH="${DARWIN_HOME}/bin:${PATH}"
147+
148+
source "${DARWIN_HOME}/build/autotools/${{ matrix.target }}.sh"
149+
elif [[ '${{ matrix.target }}' = *'-android'* ]]; then
150+
declare -r PINO_TARBALL='/tmp/toolchain.tar.xz'
151+
declare -r PINO_URL="https://github.com/AmanoTeam/android-gcc-cross/releases/latest/download/x86_64-unknown-linux-gnu.tar.xz"
152+
153+
curl --connect-timeout '10' --retry '15' --retry-all-errors --fail --silent --location --url "${PINO_URL}" --output "${PINO_TARBALL}"
154+
tar --directory="$(dirname "${PINO_TARBALL}")" --extract --file="${PINO_TARBALL}"
155+
156+
export PINO_HOME='/tmp/android-gcc-cross'
157+
export PATH="${PINO_HOME}/bin:${PATH}"
158+
159+
source "${PINO_HOME}/build/autotools/${{ matrix.target }}.sh"
160+
161+
sudo sed \
162+
--in-place \
163+
'/CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG/d' \
164+
'/usr/local/share/cmake-'*'/Modules/Platform/Android.cmake'
165+
fi
166+
167+
echo "CROSS_COMPILE_TRIPLET=${CROSS_COMPILE_TRIPLET}" >> "${GITHUB_ENV}"
168+
169+
cmake \
170+
-DCMAKE_BUILD_TYPE='Release' \
171+
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION='ON' \
172+
-S "${PWD}" \
173+
-B "${PWD}/build"
174+
175+
cmake --build "${PWD}/build" -- --jobs
176+
cmake --install "${PWD}/build" --strip
177+
- name: Generate tarball
178+
run: |
179+
if [[ '${{ env.CROSS_COMPILE_TRIPLET }}' = *'-mingw32' ]]; then
180+
declare tarball_filename='/tmp/${{ env.CROSS_COMPILE_TRIPLET }}.zip'
181+
cd '/tmp'
182+
zip --recurse-paths -9 "${tarball_filename}" 'revf'
183+
else
184+
declare tarball_filename='/tmp/${{ env.CROSS_COMPILE_TRIPLET }}.tar.xz'
185+
tar --directory='/tmp' --create --file=- 'revf' | xz --threads='0' --extreme --memlimit-compress='100%' --compress -9 > "${tarball_filename}"
186+
fi
187+
sha256sum "${tarball_filename}" | sed 's|/tmp/||' > "${tarball_filename}.sha256"
188+
- name: Upload artifact
189+
uses: actions/upload-artifact@main
190+
with:
191+
name: ${{ env.CROSS_COMPILE_TRIPLET }}
192+
if-no-files-found: error
193+
path: |
194+
/tmp/${{ env.CROSS_COMPILE_TRIPLET }}.*
195+
196+
release:
197+
needs: cross-build
198+
runs-on: ubuntu-latest
199+
name: Create release
200+
steps:
201+
- name: Download all artifacts
202+
uses: actions/download-artifact@main
203+
- name: Create release
204+
uses: softprops/action-gh-release@master
205+
with:
206+
tag_name: '0.2'
207+
name: 'revf v0.2'
208+
files: ./*/*.{tar.xz,zip}
209+
draft: false
210+
prerelease: false
211+
fail_on_unmatched_files: true
212+
body: '* Final release'
213+
env:
214+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
215+

CMakeLists.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
3+
project(
4+
revf
5+
VERSION 0.1
6+
DESCRIPTION "Reverse the content of files"
7+
HOMEPAGE_URL "https://github.com/AmanoTeam/revf"
8+
LANGUAGES C
9+
)
10+
11+
option(REVF_ENABLE_LTO "Turn on compiler Link Time Optimizations" OFF)
12+
13+
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
14+
15+
include_directories(
16+
"${CMAKE_SOURCE_DIR}/src"
17+
)
18+
19+
add_executable(
20+
revf
21+
src/argparser.c
22+
src/errors.c
23+
src/fileinfo.c
24+
src/filesystem.c
25+
src/fstream.c
26+
src/main.c
27+
src/os.c
28+
src/reverse_memcpy.c
29+
src/stringu.c
30+
src/terminal.c
31+
src/walkdir.c
32+
)
33+
34+
if (REVF_ENABLE_LTO)
35+
set(REVF_HAS_LTO OFF)
36+
37+
include(CheckIPOSupported)
38+
check_ipo_supported(RESULT REVF_HAS_LTO LANGUAGES C)
39+
40+
if (REVF_HAS_LTO)
41+
set_target_properties(
42+
revf
43+
PROPERTIES
44+
INTERPROCEDURAL_OPTIMIZATION TRUE
45+
)
46+
endif()
47+
endif()
48+
49+
install(
50+
TARGETS revf
51+
RUNTIME DESTINATION bin
52+
LIBRARY DESTINATION lib
53+
)

0 commit comments

Comments
 (0)