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

Add meson support & use for cross-compilation of releases #35

Merged
merged 31 commits into from
Apr 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e314c3c
Add basic meson support
maxfierke Nov 12, 2021
92d9256
Fix meson compilation on macOS
maxfierke Feb 12, 2022
dcef3ab
Enable static linking of libraries w/ meson
maxfierke Feb 17, 2022
b00f803
Set crystal build flags based on buildtype
maxfierke Feb 17, 2022
bb41251
Remove .gitignore of builddir
maxfierke Feb 17, 2022
dd3856b
Replace readline with Term::Prompt
maxfierke Apr 11, 2022
c09252e
Make cross-compilation really work under meson
maxfierke Apr 11, 2022
fc0d1f9
Ensure meson is installed in CI
maxfierke Apr 11, 2022
5cfd4b4
Set PKG_CONFIG_PATH for Crystal's openssl version detection
maxfierke Apr 11, 2022
6281c51
Ensure ninja gets installed on ubuntu runners
maxfierke Apr 11, 2022
e03a78b
Use openssl@3 on macOS CI
maxfierke Apr 11, 2022
8b9d23f
Remove libedit from allowed dynlibs
maxfierke Apr 11, 2022
7856366
of course the order has changed to
maxfierke Apr 11, 2022
a10e8c5
Generate pkg-config for embedded openssl for Crystal to use for OpenS…
maxfierke Apr 12, 2022
3681244
Hopefully fix static linux-amd64 builds
maxfierke Apr 12, 2022
886df4c
set env vars for build compiler im x86_64 linux build
maxfierke Apr 14, 2022
63795a3
Don't generate pkgconfig for openssl if we're using openssl via pkgco…
maxfierke Apr 14, 2022
249e9f9
Use non-musl gcc for build machine on x86_64
maxfierke Apr 14, 2022
3a7fa70
specify CC_FOR_BUILD
maxfierke Apr 14, 2022
6f5c310
Add macOS arm64 build
maxfierke Apr 14, 2022
eccd3ad
Bump pcre wrap to 8.45-1
maxfierke Apr 14, 2022
7d68935
turn on verbose mode
maxfierke Apr 15, 2022
3a8825c
Be more explicit about LD, AR, and RANLIB
maxfierke Apr 15, 2022
89fab34
Fix AR, RANLIB paths, use absolute for _FOR_BUILD
maxfierke Apr 15, 2022
20f168d
idk maybe clang works
maxfierke Apr 15, 2022
3a1c480
try musl gcc on linux-x86_64 again for build machine
maxfierke Apr 15, 2022
0cc758d
ensure macos builds are stripped
maxfierke Apr 15, 2022
8c9dc91
:facepalm: maybe use the x86_64 musl cross since we're on gnu
maxfierke Apr 15, 2022
9dac7ba
Remove unknown- from cross-compiler setup
maxfierke Apr 16, 2022
4270bfe
Ensure musl gets statically linked properly
maxfierke Apr 16, 2022
c221a6b
Fix cross-compilation on Apple clang
maxfierke Apr 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/lib/
/bin/
/dist/
/builddir/
maxfierke marked this conversation as resolved.
Show resolved Hide resolved
/.crystal/
/.shards/
*.dwarf
Expand Down
80 changes: 80 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
project('mstrap',
'c',
meson_version : '>= 0.57.0',
license : 'MIT',
version : '0.4.0',
default_options : [
'default_library=static'
]
)

cc = meson.get_compiler('c')
crystal = find_program('crystal', required : true)
shards = find_program('shards', required : true)

libcrypto = dependency('libcrypto', version : '>= 1.1.1')
libevent = dependency('libevent', version : '>= 2.1.2')
libgc = dependency('bdw-gc', version : '>= 8.0.4' )
libm = cc.find_library('m', required : false)
libpcre = dependency('libpcre', version : '>= 8.37')
libssl = dependency('libssl', version : '>= 1.1.1')
readline = dependency('readline')
zlib = dependency('zlib')
thread_dep = dependency('threads')

target_arch = host_machine.cpu_family()
target_system = host_machine.system()
target_triple = target_arch + '-unknown-' + target_system

if target_system == 'linux'
# TODO: musl
target_triple += '-gnu'
endif

if run_command(shards, 'check').returncode() != 0
run_command(shards, 'install', '--frozen', check : true)
endif

crystal_path = run_command(
crystal, 'env', 'CRYSTAL_PATH',
check : true
).stdout().strip()
env = environment({
'CRYSTAL_PATH': crystal_path
})
env.prepend('CRYSTAL_PATH', join_paths(meson.project_source_root(), 'lib'))

mstrap_o = custom_target(
'mstrap.o',
build_always_stale : true,
command : [
crystal,
'build',
'--cross-compile',
'--target',
target_triple,
'-o',
'mstrap',
'@INPUT@'
],
depend_files : [files('shard.lock')],
env : env,
input : [files('src/cli.cr')],
output : ['mstrap.o']
)

executable(
'mstrap',
mstrap_o,
dependencies : [
libcrypto,
libevent,
libgc,
libm,
libpcre,
libssl,
readline,
zlib,
thread_dep
],
)
14 changes: 14 additions & 0 deletions subprojects/openssl.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[wrap-file]
directory = openssl-1.1.1l
source_url = https://www.openssl.org/source/openssl-1.1.1l.tar.gz
source_filename = openssl-1.1.1l.tar.gz
source_hash = 0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1
patch_filename = openssl_1.1.1l-2_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/openssl_1.1.1l-2/get_patch
patch_hash = 852521fb016fa2deee8ebf9ffeeee0292c6de86a03c775cf72ac04e86f9f177e

[provide]
libcrypto = libcrypto_dep
libssl = libssl_dep
openssl = openssl_dep