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

Build Windows installer with meson #243

Merged
merged 5 commits into from
Aug 6, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 6 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ jobs:
fail-fast: false
matrix:
buildsystem:
# - autotools
- meson
cc:
- clang
Expand All @@ -63,9 +62,9 @@ jobs:
run:
shell: msys2 {0}
steps:
# - uses: crazy-max/ghaction-chocolatey@v2.0.0
# with:
# args: install innosetup lazarus
- uses: crazy-max/ghaction-chocolatey@v3
with:
args: install innosetup
# required for the lib command
- uses: ilammy/[email protected]
with:
Expand All @@ -89,64 +88,25 @@ jobs:
mingw-w64-x86_64-python3-numpy
mingw-w64-x86_64-meson
mingw-w64-x86_64-swig
automake
autoconf
libtool
make
patch
wget
tar
- uses: actions/checkout@v4
- name: Primary build and test with Meson
if: matrix.buildsystem == 'meson'
run: |
set -ex
meson setup meson-build -Dpython-bindings=enabled -Dpython-numpy-bindings=enabled
meson setup meson-build -Dpython-bindings=enabled -Dpython-numpy-bindings=enabled -Dwindows-installer=enabled
meson compile -C meson-build
meson test -C meson-build || (cat meson-build/meson-logs/testlog.txt && exit 1)

set +ex
env:
CC: ${{matrix.cc}}
CXX: ${{matrix.cxx}}
- name: Primary build and test with Autotools
if: matrix.buildsystem == 'autotools'
run: |
set -ex

autoreconf -fi
./configure --disable-all-bindings --disable-shared --enable-static
make -j$(nproc)
make check
make distclean

./configure --disable-python --disable-python-numpy --enable-fortran2003 --disable-ruby
make -j$(nproc)
make check
make distclean

./configure --enable-python --enable-python-numpy PYTHON=python3 --disable-ruby
make -j$(nproc)
find . -name '*pyd' -print0 | xargs -0 ls -l
find . -name 'xraylib.py' -print0 | xargs -0 ls -l
make check || (cat python/tests/test-suite.log && exit 1)
make distclean

./configure --disable-all-bindings CFLAGS="-std=c89 -pedantic" || (cat config.log && exit 1)
make -j$(nproc)
make check
make windows

set +ex
env:
CC: ${{matrix.cc}}
CXX: ${{matrix.cxx}}
- name: Upload Windows installer
if: matrix.buildsystem == 'autotools' && matrix.cc == 'gcc'
if: matrix.buildsystem == 'meson' && matrix.cc == 'gcc'
uses: actions/upload-artifact@v4
with:
name: windows-installer
path: windows\xraylib-*-win64.exe
path: meson-build\windows\xraylib-*-win64.exe
retention-days: 1

macos:
Expand All @@ -156,7 +116,6 @@ jobs:
fail-fast: false
matrix:
buildsystem:
# - autotools
- meson
compiler:
- llvm
Expand Down
7 changes: 0 additions & 7 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ SUBDIRS = include \
doc \
data \
java \
windows \
perl \
lua \
fortran \
Expand All @@ -36,10 +35,4 @@ if ENABLE_FORTRAN
pkgconfig_DATA += libxrlf03.pc
endif

windows:
$(MAKE) -C windows windows


EXTRA_DIST = xraylib.spec Changelog meson.build meson_options.txt

.PHONY: windows
16 changes: 0 additions & 16 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,6 @@ AC_CONFIG_FILES([Makefile
java/tests/Makefile
java/build.gradle
java/settings.gradle
windows/Makefile
perl/Makefile
lua/Makefile
fortran/Makefile
Expand Down Expand Up @@ -1074,21 +1073,6 @@ abs_top_srcdir=`pwd -P`
cd $abs_top_builddir
AC_SUBST(abs_top_srcdir)

#windows slashes versions
if test x$OS_WINDOWS = "x1" ; then
abs_top_builddir_win=`pwd -W`
AC_SUBST(abs_top_builddir_win)
abs_top_srcdir_win=`AS_DIRNAME([$0])`
cd $abs_top_srcdir_win
abs_top_srcdir_win=`pwd -W`
cd $abs_top_builddir_win
AC_SUBST(abs_top_srcdir_win)
cd
abs_homedir_win=`pwd -W`
AC_SUBST(abs_homedir_win)
cd $abs_top_builddir_win
fi

AM_CONDITIONAL([ABS_SRC_BUILD_EQUAL],[test x$abs_top_builddir = x$abs_top_srcdir])

AC_OUTPUT
Expand Down
4 changes: 3 additions & 1 deletion cplusplus/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
install_headers(files('xraylib++.h'), subdir: 'xraylib')
cplusplus_source_files = files('xraylib++.h')

install_headers(cplusplus_source_files, subdir: 'xraylib')

cplusplus_source_dir = meson.current_source_dir()

Expand Down
8 changes: 8 additions & 0 deletions doc/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
docs_src_dir = meson.current_source_dir()
docs_bld_dir = meson.current_build_dir()

doc_files = files(
'xraydoc.txt'
)

install_data(doc_files)
6 changes: 6 additions & 0 deletions example/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
windows_installer_example_files = files(
'xrlexample1.c',
'xrlexample6.cpp',
'xrlexample8.cs',
'xrlexample14.pas',
)
15 changes: 15 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ lib_current = 12
lib_revision = 1
lib_age = 1

lib_current_minus_age = lib_current - lib_age

version = '@0@.@1@.@2@'.format((lib_current - lib_age), lib_age, lib_revision)

current = lib_current + 1
Expand Down Expand Up @@ -98,9 +100,12 @@ xraylib_build_dep = [m_dep]
pkgconfig = import('pkgconfig')

subdir('include')
subdir('doc')
subdir('src')
subdir('tests')
subdir('cplusplus')
subdir('example')
subdir('pascal')

if not (get_option('python-bindings').disabled() and get_option('python-numpy-bindings').disabled())
pymod = import('python')
Expand Down Expand Up @@ -189,3 +194,13 @@ ENDPROGRAM f2003_main

endif
endif

if get_option('windows-installer').enabled()
if host_system == 'windows' and \
cc.get_id() == 'gcc' and \
meson.version().version_compare('>=1.4.0')
subdir('windows')
else
warning('The windows-installer option is only supported on Windows systems with gcc selected as compiler')
endif
endif
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ option('fortran-bindings', type: 'feature', value: 'auto', description: 'Build F
option('python-bindings', type: 'feature', value: 'auto', description: 'Build classic Python bindings')
option('python-numpy-bindings', type: 'feature', value: 'auto', description: 'Build numpy Python bindings')
option('swig', type : 'string', value : 'swig', description: 'Path to swig executable')
option('windows-installer', type: 'feature', value: 'disabled', description: 'Build Windows installer')
6 changes: 6 additions & 0 deletions pascal/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pascal_source_files = files(
'xraylib.pas',
'xraylib_const.pas',
'xraylib_iface.pas',
'xraylib_impl.pas',
)
11 changes: 8 additions & 3 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
src_source_dir = meson.current_source_dir()
src_build_dir = meson.current_build_dir()

core_c_args = [
'-DHAVE_CONFIG_H',
'-D_GNU_SOURCE',
Expand Down Expand Up @@ -108,6 +111,10 @@ libxrl_sources = shared_sources + [xrayglob_inline] + files(
'xrf_cross_sections_aux.c',
)

libxrl_def_file = join_paths(src_build_dir, 'libxrl-@[email protected]'.format(lib_current_minus_age))

libxrl_link_args = cc.get_supported_link_arguments(['-Wl,--output-def,@0@'.format(libxrl_def_file)])

xraylib_lib = library(
'xrl',
libxrl_sources,
Expand All @@ -118,6 +125,7 @@ xraylib_lib = library(
c_args: core_c_args + xraylib_error_flags,
gnu_symbol_visibility: 'hidden',
include_directories: extra_include_dirs,
link_args: libxrl_link_args
)

xraylib_lib_dep = declare_dependency(
Expand All @@ -128,9 +136,6 @@ xraylib_lib_dep = declare_dependency(

swig_interface = files('xraylib.i')

src_source_dir = meson.current_source_dir()
src_build_dir = meson.current_build_dir()

pkgconfig.generate(
xraylib_lib,
name: 'xraylib',
Expand Down
61 changes: 0 additions & 61 deletions windows/Makefile.am

This file was deleted.

17 changes: 0 additions & 17 deletions windows/README
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
Some info on how we have built the Windows package:

We use two separate Windows 7 64-bit VirtualBox VMs, one with 32-bit versions of GCC, and a second one with 64-bit counterparts of these. All work is done using a MSYS shell. In both cases the GCC compilers were packaged by the TDM-GCC project.

Compilation starts out as on Linux/Mac OS X...

./configure && make

... followed by:

make windows

followed by running InnoSetup to create the installer package.

This procedure is heavily adapted to my own directory layout and will require considerable changes to get it working on your system.


.NET bindings
=============

Expand Down
Loading
Loading