Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crystal: new port #1611

Merged
merged 1 commit into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
100 changes: 100 additions & 0 deletions lang/crystal/Portfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup github 1.0

github.setup crystal-lang crystal 0.24.2
categories lang
platforms darwin
supported_archs x86_64
license Apache-2
maintainers {outlook.com:mohd.akram @mohd-akram} openmaintainer

description Crystal programming language

long_description Crystal is a fast, compiled programming language with a \
Ruby-inspired syntax.

homepage https://crystal-lang.org

depends_lib port:boehmgc \
port:gmp \
port:libedit \
port:libevent \
port:libiconv \
port:libxml2 \
port:libyaml \
port:llvm-5.0 \
port:openssl \
port:pcre \
port:zlib

# Use a prebuilt version of Crystal to build itself
set cr_ver ${version}
set cr_full_ver ${cr_ver}-1

master_sites-append https://github.com/crystal-lang/${name}/releases/download/${cr_ver}/:bootstrap
distfiles-append ${name}-${cr_full_ver}-${os.platform}-${build_arch}${extract.suffix}:bootstrap

checksums ${distname}${extract.suffix} \
rmd160 382ecf4067be4e1228942c9124f4bdcb2aae6e3c \
sha256 4689a4d7f6e6838b01d81a2d1bf1484dd556907b324e87efb39749ce75d87ee9 \
${name}-${cr_full_ver}-${os.platform}-${build_arch}${extract.suffix} \
rmd160 f120f3d7573a9ad3f35e8246c7bd20b92210df1d \
sha256 05028a6ac8507b27a6dd5153f218deb255778d63ab7b45588cef3d974b5ce8ef

patchfiles patch-compiler.diff patch-link.diff patch-readline.diff \
patch-crypto.diff patch-ssl.diff patch-xml.diff

if {${os.platform} eq "darwin" && ${os.major} <= 15} {
pre-fetch {
ui_error "${name} ${version} requires macOS 10.12 or greater at present."
return -code error "incompatible OS X version"
}
}

post-patch {
reinplace "s|\"/usr/lib\", \"/usr/local/lib\"|\"${prefix}/lib\"|" \
${worksrcpath}/src/compiler/crystal/codegen/link.cr

file copy -force ${worksrcpath}/src/lib_c/amd64-unknown-openbsd/c/iconv.cr \
${worksrcpath}/src/lib_c/x86_64-macosx-darwin/c/iconv.cr
}

configure.cmd env | grep -v ^PATH=
configure.pre_args > Makefile.local

set llvm_config LLVM_CONFIG=llvm-config-mp-5.0

build.args BUILD_PATH="PATH=${workpath}/${name}-${cr_full_ver}/bin:\$PATH" \
CC="${configure.cc} -L${prefix}/lib" \
EXPORTS="CRYSTAL_CONFIG_PATH=lib:${prefix}/lib/${name}" \
FLAGS="--no-debug --release"

build.env ${llvm_config}

post-build {
system -W ${worksrcpath} "${llvm_config} ${build.cmd} docs"
}

test.run yes
test.target spec
test.env ${llvm_config} PATH=${worksrcpath}/bin:$env(PATH)

destroot {
xinstall ${worksrcpath}/.build/${name} ${destroot}${prefix}/bin
xinstall ${worksrcpath}/man/${name}.1 ${destroot}${prefix}/share/man/man1
file copy ${worksrcpath}/src ${destroot}${prefix}/lib/${name}

file copy ${worksrcpath}/docs ${destroot}${prefix}/share/doc/${name}
file copy ${worksrcpath}/samples \
${destroot}${prefix}/share/doc/${name}/examples

xinstall -d ${destroot}${prefix}/etc/bash_completion.d
xinstall ${worksrcpath}/etc/completion.bash \
${destroot}${prefix}/etc/bash_completion.d/${name}

xinstall -d ${destroot}${prefix}/share/zsh/site-functions
xinstall ${worksrcpath}/etc/completion.zsh \
${destroot}${prefix}/share/zsh/site-functions/_${name}
}
10 changes: 10 additions & 0 deletions lang/crystal/files/patch-compiler.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- src/compiler/crystal/compiler.cr.orig 2018-04-19 22:03:27.000000000 +0400
+++ src/compiler/crystal/compiler.cr 2018-04-19 22:09:25.000000000 +0400
@@ -324,7 +324,6 @@

link_flags = @link_flags || ""
link_flags += " -rdynamic"
- link_flags += " -static" if static?

%(#{cc} #{object_name} -o '#{output_filename}' #{link_flags} #{program.lib_flags})
end
11 changes: 11 additions & 0 deletions lang/crystal/files/patch-crypto.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- src/openssl/lib_crypto.cr.orig 2018-04-19 22:03:27.000000000 +0400
+++ src/openssl/lib_crypto.cr 2018-04-19 23:14:14.000000000 +0400
@@ -5,7 +5,7 @@
end
{% end %}

-@[Link(ldflags: "`command -v pkg-config > /dev/null && pkg-config --libs libcrypto || printf %s '-lcrypto'`")]
+@[Link("crypto")]
lib LibCrypto
alias Char = LibC::Char
alias Int = LibC::Int
19 changes: 19 additions & 0 deletions lang/crystal/files/patch-link.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--- src/compiler/crystal/codegen/link.cr.orig 2018-04-19 22:04:29.000000000 +0400
+++ src/compiler/crystal/codegen/link.cr 2018-04-19 22:08:10.000000000 +0400
@@ -114,10 +114,12 @@
has_pkg_config = Process.run("which", {"pkg-config"}, output: Process::Redirect::Close).success?
end

- if has_pkg_config && (libflags = pkg_config_flags(libname, attr.static?, library_path))
- flags << " " << libflags
- elsif attr.static? && (static_lib = find_static_lib(libname, library_path))
- flags << " " << static_lib
+ static = has_flag?("static") || attr.static?
+
+ if has_pkg_config && (libflags = pkg_config_flags(libname, static, library_path))
+ flags << ' ' << libflags
+ elsif static && (static_lib = find_static_lib(libname, library_path))
+ flags << ' ' << static_lib
else
flags << " -l" << libname
end
9 changes: 9 additions & 0 deletions lang/crystal/files/patch-readline.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--- src/readline.cr.orig 2018-04-19 22:03:27.000000000 +0400
+++ src/readline.cr 2018-04-19 23:38:13.000000000 +0400
@@ -1,4 +1,5 @@
-@[Link("readline")]
+@[Link("edit")]
+@[Link("ncurses")]
{% if flag?(:openbsd) %}
@[Link("termcap")]
{% end %}
11 changes: 11 additions & 0 deletions lang/crystal/files/patch-ssl.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- src/openssl/lib_ssl.cr.orig 2018-04-19 22:03:27.000000000 +0400
+++ src/openssl/lib_ssl.cr 2018-04-19 23:13:43.000000000 +0400
@@ -7,7 +7,7 @@
end
{% end %}

-@[Link(ldflags: "`command -v pkg-config > /dev/null && pkg-config --libs libssl || printf %s '-lssl -lcrypto'`")]
+@[Link("ssl")]
lib LibSSL
alias Int = LibC::Int
alias Char = LibC::Char
10 changes: 10 additions & 0 deletions lang/crystal/files/patch-xml.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- src/xml/libxml2.cr.orig 2018-04-20 19:09:06.000000000 +0400
+++ src/xml/libxml2.cr 2018-04-20 19:31:42.000000000 +0400
@@ -4,6 +4,7 @@
require "./save_options"

@[Link("xml2")]
+@[Link("lzma")]
lib LibXML
alias Int = LibC::Int