Skip to content

Commit

Permalink
Build Windows installer with meson
Browse files Browse the repository at this point in the history
  • Loading branch information
tschoonj committed Aug 6, 2024
1 parent ae8b16f commit b595805
Show file tree
Hide file tree
Showing 10 changed files with 438 additions and 336 deletions.
656 changes: 326 additions & 330 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

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',
)
12 changes: 12 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,10 @@ ENDPROGRAM f2003_main

endif
endif

if host_system == 'windows' and \
cc.get_id() == 'gcc' and \
get_option('windows-installer').enabled() and \
meson.version().version_compare('>=1.4.0')
subdir('windows')
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
66 changes: 66 additions & 0 deletions windows/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
fs = import('fs')

windows_src_dir = meson.current_source_dir()
windows_bld_dir = meson.current_build_dir()

unix2dos_cmd = find_program('unix2dos', required : true)
lib_cmd = find_program('lib', required : true)
iscc_cmd = find_program('iscc', required: true)

unix2dos_input_files = {
join_paths(project_source_root, 'README') : 'README.txt',
join_paths(project_source_root, 'AUTHORS') : 'AUTHORS.txt',
join_paths(project_source_root, 'TODO') : 'TODO.txt',
join_paths(project_source_root, 'Changelog') : 'Changelog.txt',
join_paths(windows_src_dir, 'README') : 'README2.txt',
}

foreach f: xraylib_headers + doc_files + windows_installer_example_files + pascal_source_files + cplusplus_source_files
unix2dos_input_files += {
f.full_path() : fs.name(f)
}
endforeach

unix2dos_custom_targets = []

foreach input, output : unix2dos_input_files
unix2dos_custom_targets += custom_target(
command: [unix2dos_cmd, '-n', '@INPUT@', '@OUTPUT@'],
input: [input],
output: [output],
build_by_default: true
)
endforeach

lib_custom_target = custom_target(
command: [
lib_cmd,
'/machine:X64',
'/def:@0@'.format(libxrl_def_file),
'/out:@OUTPUT0@',
],
output: [
'libxrl-@[email protected]'.format(lib_current_minus_age),
'libxrl-@[email protected]'.format(lib_current_minus_age),
],
build_by_default: true,
depends: [xraylib_lib]
)

iscc_custom_target = custom_target(
command: [
iscc_cmd,
'-dXRL64',
'-dLIB_CURRENT_MINUS_AGE=@0@'.format(lib_current_minus_age),
'-dMyAppVersion=@0@'.format(meson.project_version()),
'-dabs_top_srcdir_win=@0@'.format(project_source_root),
'-dabs_top_builddir_win=@0@'.format(project_build_root),
'@INPUT0@',
],
input: files('xraylib.iss'),
output: [
'xraylib-@[email protected]'.format(meson.project_version())
],
build_by_default: true,
depends: [lib_custom_target, unix2dos_custom_targets]
)
4 changes: 2 additions & 2 deletions windows/xraylib.iss
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Name: "dotnet" ; Description: ".NET/C# bindings" ; Types: full
Name: "pascal" ; Description: "Delphi/Pascal" ; Types: full

[Files]
Source: "{#builddir}\src\.libs\libxrl-{#LIB_CURRENT_MINUS_AGE}.dll"; DestDir: "{sys}" ; Flags: sharedfile ; Components: core
Source: "{#builddir}\src\libxrl-{#LIB_CURRENT_MINUS_AGE}.dll"; DestDir: "{sys}" ; Flags: sharedfile ; Components: core
Source: "{#builddir}\windows\README.txt" ; DestDir: "{app}" ; Flags: isreadme ; Components: core
Source: "{#builddir}\windows\AUTHORS.txt" ; DestDir: "{app}" ; Components: core
Source: "{#builddir}\windows\Changelog.txt" ; DestDir: "{app}" ; Components: core
Expand All @@ -69,7 +69,7 @@ Source: "{#builddir}\windows\xraydoc.txt" ; DestDir: "{app}\Doc" ; Components: c

Source: "{#builddir}\windows\libxrl-{#LIB_CURRENT_MINUS_AGE}.lib" ; DestDir: "{app}\Lib" ; Components: sdk
Source: "{#builddir}\windows\libxrl-{#LIB_CURRENT_MINUS_AGE}.exp" ; DestDir: "{app}\Lib" ; Components: sdk
Source: "{#builddir}\src\.libs\libxrl.dll.a" ; DestDir: "{app}\Lib" ; Components: sdk
Source: "{#builddir}\src\libxrl.dll.a" ; DestDir: "{app}\Lib" ; Components: sdk
Source: "{#builddir}\src\libxrl-{#LIB_CURRENT_MINUS_AGE}.def" ; DestDir: "{app}\Lib" ; Components: sdk
Source: "{#builddir}\windows\README2.txt" ; DestDir: "{app}\Doc" ; DestName: "README.txt";Components: sdk
Source: "{#builddir}\windows\xrlexample1.c" ; DestDir: "{app}\Example" ; Components: sdk
Expand Down

0 comments on commit b595805

Please sign in to comment.