This commit is contained in:
Connor Olding 2017-05-16 16:52:18 +00:00
commit ade2887205
14 changed files with 626 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
*/src
*/pkg
*/*.tar
*/*.gz
*/*.bz2
*/*.xz

19
README.md Normal file
View File

@ -0,0 +1,19 @@
here are some PKGBUILDs i've either modified or written over the years.
some of them are for Arch Linux, some of them are for MSYS2,
some of them work with both.
heads up: these are likely to be out of date.
### mingw-w64-nim-git
patches nim to compile with MSYS2, and use MSYS2 paths/DLLs.
a few things aren't working yet, but the core functionality is there.
### mingw-w64-tbox
patches tbox to compile/run with MSYS2.
*a lot of stuff* isn't working yet.
### xml2
modified to download from a mirror.
the original URL is offline.

4
mingw-w64-nim-git/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
Nim
nimble
nimsuggest
csources

View File

@ -0,0 +1,29 @@
From 9f3ebed8efebc45b74fa3baf2a4295352465ade9 Mon Sep 17 00:00:00 2001
From: David Macek <david.macek.0@gmail.com>
Date: Tue, 13 Jan 2015 17:48:53 +0100
Subject: [PATCH] Use unixy filenames even on Windows
---
compiler/platform.nim | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/compiler/platform.nim b/compiler/platform.nim
index c6cb3d2..b0e0862 100644
--- a/compiler/platform.nim
+++ b/compiler/platform.nim
@@ -43,9 +43,9 @@ const
parDir: "..", dllFrmt: "$1.dll", altDirSep: "/", objExt: ".obj",
newLine: "\x0D\x0A", pathSep: ";", dirSep: "\\", scriptExt: ".bat",
curDir: ".", exeExt: ".exe", extSep: ".", props: {ospCaseInsensitive}),
- (name: "Windows", parDir: "..", dllFrmt: "$1.dll", altDirSep: "/",
- objExt: ".obj", newLine: "\x0D\x0A", pathSep: ";", dirSep: "\\",
- scriptExt: ".bat", curDir: ".", exeExt: ".exe", extSep: ".",
+ (name: "Windows", parDir: "..", dllFrmt: "lib$1.dll", altDirSep: "/",
+ objExt: ".a", newLine: "\x0D\x0A", pathSep: ";", dirSep: "\\",
+ scriptExt: ".cmd", curDir: ".", exeExt: ".exe", extSep: ".",
props: {ospCaseInsensitive}),
(name: "OS2", parDir: "..",
dllFrmt: "$1.dll", altDirSep: "/",
--
1.9.4.msysgit.2

View File

@ -0,0 +1,13 @@
diff --git a/compiler/nimconf.nim b/compiler/nimconf.nim
index 808159b..12e0b49 100644
--- a/compiler/nimconf.nim
+++ b/compiler/nimconf.nim
@@ -221,7 +221,7 @@ proc getSystemConfigPath(filename: string): string =
# the UNIX way)
let p = getPrefixDir()
result = joinPath([p, "config", filename])
- when defined(unix):
+ when true:
if not existsFile(result): result = joinPath([p, "etc", filename])
if not existsFile(result): result = "/etc/" & filename

View File

@ -0,0 +1,15 @@
diff --git a/compiler/options.nim b/compiler/options.nim
index 6372cdd..1354da0 100644
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -229,6 +229,10 @@ proc setDefaultLibpath*() =
else: libpath = joinPath(prefix, "lib")
else: libpath = joinPath(prefix, "lib")
+ if not fileExists(libpath / "system.nim") and
+ fileExists(libpath / "nim" / "system.nim"):
+ libpath = libpath / "nim"
+
# Special rule to support other tools (nimble) which import the compiler
# modules and make use of them.
let realNimPath = findExe("nim")

View File

@ -0,0 +1,52 @@
diff --git a/lib/wrappers/openssl.nim b/lib/wrappers/openssl.nim
index 5521476..2453c16 100644
--- a/lib/wrappers/openssl.nim
+++ b/lib/wrappers/openssl.nim
@@ -14,7 +14,7 @@
const useWinVersion = defined(Windows) or defined(nimdoc)
when useWinVersion:
- when not defined(nimOldDlls) and defined(cpu64):
+ when not true and defined(cpu64):
const
DLLSSLName = "(ssleay64|libssl64).dll"
DLLUtilName = "libeay64.dll"
diff --git a/lib/wrappers/pcre.nim b/lib/wrappers/pcre.nim
index 6c7088b..8b0e7f6 100644
--- a/lib/wrappers/pcre.nim
+++ b/lib/wrappers/pcre.nim
@@ -310,7 +310,7 @@ type
when not defined(usePcreHeader):
when hostOS == "windows":
- when defined(nimOldDlls):
+ when true:
const pcreDll = "pcre.dll"
elif defined(cpu64):
const pcreDll = "pcre64.dll"
diff --git a/lib/wrappers/pdcurses.nim b/lib/wrappers/pdcurses.nim
index 2d64ac9..a46134c 100644
--- a/lib/wrappers/pdcurses.nim
+++ b/lib/wrappers/pdcurses.nim
@@ -42,7 +42,7 @@ pdcwin.h:
when defined(windows):
import windows
- when defined(nimOldDlls):
+ when true:
const pdcursesdll = "pdcurses.dll"
elif defined(cpu64):
const pdcursesdll = "pdcurses64.dll"
diff --git a/lib/wrappers/sqlite3.nim b/lib/wrappers/sqlite3.nim
index a129458..5e84a9b 100644
--- a/lib/wrappers/sqlite3.nim
+++ b/lib/wrappers/sqlite3.nim
@@ -9,7 +9,7 @@
{.deadCodeElim: on.}
when defined(windows):
- when defined(nimOldDlls):
+ when true:
const Lib = "sqlite3.dll"
elif defined(cpu64):
const Lib = "sqlite3_64.dll"

131
mingw-w64-nim-git/PKGBUILD Normal file
View File

@ -0,0 +1,131 @@
pkgbase=mingw-w64-nim-git
pkgname=("${MINGW_PACKAGE_PREFIX}-nim-git")
pkgver=20170404
pkgrel=1
arch=('i686' 'x86_64')
groups=('nim')
depends=("${MINGW_PACKAGE_PREFIX}-openssl")
makedepends=('git')
source=(git+https://github.com/nim-lang/Nim
git+https://github.com/nim-lang/csources
git+https://github.com/nim-lang/nimble
git+https://github.com/nim-lang/nimsuggest
"0001-Use-unixy-filenames-even-on-Windows.patch"
"0002-Always-look-in-unix-paths.patch"
"0003-Check-lib-nim-subdirectory.patch"
"0004-Use-nimOldDlls.patch")
sha256sums=('SKIP' 'SKIP' 'SKIP' 'SKIP'
'3010acbe7769ea214dd51f5889e3a26b44925001905deb04b060beaede2578f4'
'fac04c8caa29a545275cd19a0fac597649c8ad9e7556fe65802e28c88c8905ac'
'3cfe161bd1e19f621e2ff824a59362e4f3d4d2a4d27a2653bae1d83ba23ab9b1'
'bbfa440d05cc2788caabd94623e35275519f0692f6ddfa00a7afcdddbb274888')
pkgver() {
cd "$srcdir/Nim"
git log -1 --format="%cd" --date=short | sed "s|-||g"
}
prepare() {
cd "$srcdir/Nim"
msg2 'Cloning csources...'
[ -d csources ] && rm -rf csources
git clone --local "$srcdir/csources"
patch -p1 -i "${srcdir}/0001-Use-unixy-filenames-even-on-Windows.patch"
patch -p1 -i "${srcdir}/0002-Always-look-in-unix-paths.patch"
patch -p1 -i "${srcdir}/0003-Check-lib-nim-subdirectory.patch"
patch -p1 -i "${srcdir}/0004-Use-nimOldDlls.patch"
}
build() {
cd "$srcdir/Nim"
msg2 'Building csources...'
pushd csources
sh build.sh
popd
msg2 'Building Nim...'
./bin/nim c -d:release koch
./koch boot -d:release -d:nativeStacktrace -d:useGnuReadline
msg2 'Building Nimble...'
./koch nimble
msg2 'Building nimgrep and nimsuggest...'
./koch tools
msg2 'Building libnimrtl...'
pushd lib
../bin/nim c --app:lib -d:createNimRtl -d:release nimrtl.nim
popd
}
package() {
pkgdesc="Compiled, garbage-collected systems programming language which has an excellent productivity/performance ratio"
url="https://github.com/nim-lang/Nim"
license=('MIT')
options=('!emptydirs')
provides=('nim' 'nimble')
conflicts=('nim' 'nimble')
cd "$srcdir/Nim"
msg2 'Installing Nim license...'
install -Dm 644 "copying.txt" -t "$pkgdir$MINGW_PREFIX/share/licenses/nim"
msg2 'Installing Nim documentation...'
install -dm 755 "$pkgdir$MINGW_PREFIX/share/doc/nim"
cp -dpr --no-preserve=ownership examples web doc/* "$pkgdir$MINGW_PREFIX/share/doc/nim"
msg2 'Installing Nim...'
./koch install "$pkgdir"
install -Dm 755 bin/{nim,nimgrep} -t "$pkgdir$MINGW_PREFIX/bin"
cd "$pkgdir/nim"
install -dm 755 "$pkgdir$MINGW_PREFIX/etc" "$pkgdir$MINGW_PREFIX/lib/nim"
find lib -mindepth 1 -maxdepth 1 -exec \
cp -dpr --no-preserve=ownership '{}' "$pkgdir$MINGW_PREFIX/lib/nim" \;
find config -mindepth 1 -maxdepth 1 -exec \
cp -dpr --no-preserve=ownership '{}' "$pkgdir$MINGW_PREFIX/etc/" \;
cp -dpr --no-preserve=ownership "$srcdir/Nim/lib/packages" \
"$pkgdir$MINGW_PREFIX/lib/nim"
# https://bugs.archlinux.org/task/50252
msg2 'Fixing unusual placement of header files...'
install -dm 755 "$pkgdir$MINGW_PREFIX/include"
for _header in cycle nimbase; do
cp "$pkgdir$MINGW_PREFIX/lib/nim/${_header}.h" "$pkgdir$MINGW_PREFIX/include/${_header}.h"
done
msg2 'Fixing unusual placement of shared object files...'
cp "$pkgdir$MINGW_PREFIX/lib/nim/libnimrtl.dll" "$pkgdir$MINGW_PREFIX/lib/libnimrtl.dll"
msg2 'Cleaning up pkgdir...'
find "$pkgdir" -type d -name .git -exec rm -r '{}' +
find "$pkgdir" -type f -name .gitignore -exec rm -r '{}' +
rm -rf "$pkgdir/nim"
# nimble
cd "$srcdir/nimble"
msg2 'Installing Nimble license...'
install -Dm 644 license.txt -t "$pkgdir$MINGW_PREFIX/share/licenses/nimble"
msg2 'Installing Nimble documentation...'
install -Dm 644 *.markdown -t "$pkgdir$MINGW_PREFIX/share/doc/nimble"
msg2 'Installing Nimble...'
install -Dm 755 "$srcdir/Nim/bin/nimble" -t "$pkgdir$MINGW_PREFIX/bin"
# Nimble looks for nimscriptapi.nim in /usr/bin/nimblepkg/, of all places.
install -dm 755 "$pkgdir$MINGW_PREFIX/share/nimble"
cp -dpr --no-preserve=ownership src/nimblepkg "$pkgdir$MINGW_PREFIX/share/nimble"
cp -dpr --no-preserve=ownership "$pkgdir$MINGW_PREFIX/share/nimble" "$pkgdir$MINGW_PREFIX/bin/nimblepkg"
msg2 'Installing Nimble bash completion...'
install -Dm 644 nimble.bash-completion \
"$pkgdir$MINGW_PREFIX/share/bash-completion/completions/nimble"
}

51
mingw-w64-tbox/PKGBUILD Normal file
View File

@ -0,0 +1,51 @@
_pkgname=tbox
pkgbase="mingw-w64-${_pkgname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_pkgname}"
pkgver=1.6.1
pkgrel=1
pkgdesc="A glib-like multi-platform C library"
arch=('i686' 'x86_64')
url="https://github.com/tboox/tbox"
license=('Apache')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
"${MINGW_PACKAGE_PREFIX}-openssl"
"${MINGW_PACKAGE_PREFIX}-pcre"
"${MINGW_PACKAGE_PREFIX}-sqlite3"
"${MINGW_PACKAGE_PREFIX}-winpthreads-git"
"${MINGW_PACKAGE_PREFIX}-zlib")
# NOTE: xmake isn't available for msys2 yet,
# so instead, I recommend that you download it from
# https://github.com/tboox/xmake/releases
# and put it to your PATH.
#makedepends=('xmake')
source=("${pkgname}.zip::https://github.com/tboox/tbox/archive/v${pkgver}.zip"
"msys2.patch"
"context_x86.obj" # sorry for including assembled object files,
"context_x64.obj") # but this avoids depending on MASM for now.
sha256sums=('d389027f63c11d3170b09fb51a9b75b55c34a7f0fb82de49d7c5be17c8cb3239'
'ca4a70de41338fea3422cb7957c2249cfb7e7464e5f9b12120751574965a128d'
'd5a3dddee337f0aad5912cfc4271f2ea46b0093ee2cd1fcc037a3ad2788a4744'
'44eb2adb0f5abb86c4fdb70868be3d91d94a4f73841a625de47dae99a532dc33')
prepare() {
cd "${srcdir}/${_pkgname}-${pkgver}"
patch -p2 -i "${srcdir}/msys2.patch"
cp "${srcdir}/context_x86.obj" src/tbox/platform/arch/x86/context.o
cp "${srcdir}/context_x64.obj" src/tbox/platform/arch/x64/context.o
}
build() {
cd "${srcdir}/${_pkgname}-${pkgver}"
[ "${MSYSTEM}" == "MINGW64" ] && arch=x86_64 || arch=i386
xmake config -c -p mingw -a "${arch}"
xmake build
}
package() {
cd "${srcdir}/${_pkgname}-${pkgver}"
mkdir -p "${pkgdir}${MINGW_PREFIX}/lib"
mkdir -p "${pkgdir}${MINGW_PREFIX}/share/tbox"
cp "build/libtbox.a" "${pkgdir}${MINGW_PREFIX}/lib/"
cp "build/demo.exe" "${pkgdir}${MINGW_PREFIX}/share/tbox/"
}

Binary file not shown.

Binary file not shown.

109
mingw-w64-tbox/msys2.patch Normal file
View File

@ -0,0 +1,109 @@
diff --git a/tbox-1.6.1/src/tbox/network/impl/ssl/openssl.c b/tbox-1.6.1-msys2/src/tbox/network/impl/ssl/openssl.c
index f5ca14d..f1f5163 100644
--- a/tbox-1.6.1/src/tbox/network/impl/ssl/openssl.c
+++ b/tbox-1.6.1-msys2/src/tbox/network/impl/ssl/openssl.c
@@ -27,6 +27,7 @@
/* //////////////////////////////////////////////////////////////////////////////////////
* includes
*/
+#include <winsock2.h>
#include "prefix.h"
#include "openssl/openssl.h"
#include "../../../utils/utils.h"
@@ -80,7 +81,7 @@ static tb_int_t tb_ssl_bio_method_init(BIO* bio);
static tb_int_t tb_ssl_bio_method_exit(BIO* bio);
static tb_int_t tb_ssl_bio_method_read(BIO* bio, tb_char_t* data, tb_int_t size);
static tb_int_t tb_ssl_bio_method_writ(BIO* bio, tb_char_t const* data, tb_int_t size);
-static tb_long_t tb_ssl_bio_method_ctrl(BIO* bio, tb_int_t cmd, tb_long_t num, tb_pointer_t ptr);
+static long tb_ssl_bio_method_ctrl(BIO* bio, tb_int_t cmd, long num, tb_pointer_t ptr);
static tb_int_t tb_ssl_bio_method_puts(BIO* bio, tb_char_t const* data);
static tb_int_t tb_ssl_bio_method_gets(BIO* bio, tb_char_t* data, tb_int_t size);
@@ -296,7 +297,7 @@ static tb_int_t tb_ssl_bio_method_writ(BIO* bio, tb_char_t const* data, tb_int_t
// ok?
return (tb_int_t)real;
}
-static tb_long_t tb_ssl_bio_method_ctrl(BIO* bio, tb_int_t cmd, tb_long_t num, tb_pointer_t ptr)
+static long tb_ssl_bio_method_ctrl(BIO* bio, tb_int_t cmd, long num, tb_pointer_t ptr)
{
// check
tb_assert_and_check_return_val(bio, -1);
diff --git a/tbox-1.6.1/src/tbox/platform/arch/x64/context.S b/tbox-1.6.1-msys2/src/tbox/platform/arch/x64/context.S
index 1f3e7f0..258a05b 100644
--- a/tbox-1.6.1/src/tbox/platform/arch/x64/context.S
+++ b/tbox-1.6.1-msys2/src/tbox/platform/arch/x64/context.S
@@ -109,7 +109,7 @@ __end:
#ifdef TB_ARCH_ELF
call _exit@PLT
#else
- call __exit
+ call _exit
#endif
hlt
diff --git a/tbox-1.6.1/src/tbox/platform/windows/ifaddrs.c b/tbox-1.6.1-msys2/src/tbox/platform/windows/ifaddrs.c
index 69c25e0..b2f39b4 100644
--- a/tbox-1.6.1/src/tbox/platform/windows/ifaddrs.c
+++ b/tbox-1.6.1-msys2/src/tbox/platform/windows/ifaddrs.c
@@ -29,6 +29,10 @@
#include "../posix/sockaddr.h"
#include "interface/interface.h"
+#ifdef interface
+#undef interface
+#endif
+
/* //////////////////////////////////////////////////////////////////////////////////////
* private implementation
*/
diff --git a/tbox-1.6.1/src/tbox/prefix/type.h b/tbox-1.6.1-msys2/src/tbox/prefix/type.h
index e4a108c..13f00f0 100644
--- a/tbox-1.6.1/src/tbox/prefix/type.h
+++ b/tbox-1.6.1-msys2/src/tbox/prefix/type.h
@@ -109,9 +109,9 @@ typedef tb_int32_t tb_wchar_t;
#if defined(TB_COMPILER_IS_MSVC)
typedef __int64 tb_int64_t;
typedef unsigned __int64 tb_uint64_t;
-#elif (TB_CPU_BITSIZE == 64)
-typedef signed long tb_int64_t;
-typedef unsigned long tb_uint64_t;
+//#elif (TB_CPU_BITSIZE == 64)
+//typedef signed long tb_int64_t;
+//typedef unsigned long tb_uint64_t;
#else
typedef signed long long tb_int64_t;
typedef unsigned long long tb_uint64_t;
diff --git a/tbox-1.6.1/src/tbox/prefix/x86/prefix.S b/tbox-1.6.1-msys2/src/tbox/prefix/x86/prefix.S
index 0866baa..60225cb 100644
--- a/tbox-1.6.1/src/tbox/prefix/x86/prefix.S
+++ b/tbox-1.6.1-msys2/src/tbox/prefix/x86/prefix.S
@@ -45,8 +45,8 @@ name:
# define function(name) \
.text ;\
.align TB_CPU_BITBYTE ; \
- .global _##name ;\
-_##name:
+ .global name ;\
+name:
#endif
// end function
diff --git a/tbox-1.6.1/src/tbox/xmake.lua b/tbox-1.6.1-msys2/src/tbox/xmake.lua
index e2bb8ee..745a77e 100644
--- a/tbox-1.6.1/src/tbox/xmake.lua
+++ b/tbox-1.6.1-msys2/src/tbox/xmake.lua
@@ -85,10 +85,10 @@ target("tbox")
-- add the source files for the coroutine module
if is_option("coroutine") then
add_files("platform/context.c")
- if is_plat("windows") then
- add_files("platform/arch/$(arch)/context.asm")
- else
- add_files("platform/arch/context.S")
+ if is_arch("x86_64") then
+ add_files("platform/arch/x64/context.o")
+ elseif is_arch("i386") then
+ add_files("platform/arch/x86/context.o")
end
add_files("coroutine/**.c")
end

169
mingw-w64-tbox/testall Normal file
View File

@ -0,0 +1,169 @@
#!/usr/bin/env bash
set -e
# known not to work
failing=(
# coroutine_echo_client
# coroutine_echo_server
# coroutine_file_client
# coroutine_file_server
# coroutine_http_server
coroutine_lock
memory_check
platform_lock
platform_thread_pool
platform_timer
stream_cache
stream_charset
stream_null
stream_zip
)
# probably expecting input or arguments
stalling=(
# lo_coroutine_echo_client
# lo_coroutine_echo_server
# lo_coroutine_file_client
# lo_coroutine_file_server
# lo_coroutine_http_server
network_whois
platform_event
platform_ltimer
platform_semaphore
platform_thread
platform_thread_local
)
# and finally, the stuff that works
# TODO: pass arguments to those that expect them (e.g. stream)
running=(
algorithm_find
algorithm_sort
container_bloom_filter
container_circle_queue
container_hash_map
container_hash_set
container_heap
container_list
container_list_entry
container_queue
container_single_list
container_single_list_entry
container_stack
container_vector
coroutine_channel
coroutine_nest
coroutine_semaphore
coroutine_sleep
coroutine_spider
coroutine_switch
database_sql
hash_adler32
hash_benchmark
hash_crc16
hash_crc32
hash_crc8
hash_djb2
hash_fnv32
hash_fnv64
hash_md5
hash_sdbm
hash_sha
hash_uuid
libc_mbstowcs
libc_stdlib
libc_string
libc_time
libc_wchar
libc_wcstombs
libm_double
libm_float
libm_integer
lo_coroutine_lock
lo_coroutine_nest
lo_coroutine_sleep
lo_coroutine_switch
math_fixed
math_random
memory_buffer
memory_default_allocator
memory_fixed_pool
memory_impl_static_fixed_pool
memory_large_allocator
memory_memops
memory_queue_buffer
memory_small_allocator
memory_static_buffer
memory_string_pool
network_cookies
network_dns
network_http
network_hwaddr
network_impl_date
network_ipaddr
network_ipv4
network_ipv6
network_url
object_bin
object_bplist
object_dump
object_jcat
object_json
object_xml
object_xplist
other_charset
other_test
platform_addrinfo
platform_atomic
platform_atomic64
platform_backtrace
platform_barrier
platform_cache_time
platform_context
platform_directory
platform_environment
platform_file
platform_hostname
platform_ifaddrs
platform_path
platform_process
platform_processor
platform_utils
regex
stream
string_static_string
string_string
utils_base32
utils_base64
utils_bits
utils_dump
utils_option
utils_url
xml_document
xml_reader
xml_writer
)
testall() {
local demo="$1"
shift || { echo "expected path to demo program" >&2; return -1; }
local ret=0
for d in "${running[@]}"; do
echo "testing: $d" >&2
fail=0
"$demo" "$d" > /tmp/demo_stdout || fail=1
if [ $fail -eq 1 ]; then
cat /tmp/demo_stdout
echo "TEST FAILED: $d" >&2
let ret++
#break
fi
done
rm /tmp/demo_stdout
return $ret
}
testall "$@"

28
xml2/PKGBUILD Normal file
View File

@ -0,0 +1,28 @@
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Orivej Desh <masecretaire@gmx.fr>
pkgname=xml2
pkgver=0.5
pkgrel=1
pkgdesc="XML/Unix Processing Tools to convert XML and HTML to and from a line-oriented format more amenable to processing by classic Unix pipeline processing tools"
arch=("i686" "x86_64")
url="http://www.ofb.net/~egnor/xml2/"
license=("GPL")
depends=("libxml2")
source=("http://pkgs.fedoraproject.org/repo/pkgs/xml2/xml2-0.5.tar.gz/48eacf64b01ca3a4a5afb1a36f5906e6/xml2-0.5.tar.gz")
md5sums=('48eacf64b01ca3a4a5afb1a36f5906e6')
build() {
cd "$srcdir/$pkgname-$pkgver"
./configure --prefix=/usr
make
}
package() {
cd "$srcdir/$pkgname-$pkgver"
make DESTDIR="$pkgdir" install
cd "$pkgdir/usr/bin"
rm html2 2html
ln -s xml2 html2
ln -s 2xml 2html
}