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: fix python search for gobject integration #266

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
44 changes: 43 additions & 1 deletion .github/workflows/msvc-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,57 @@ on:
jobs:
build:
runs-on: windows-latest
name: Build with introspection=${{ matrix.build_introspection }}
env:
PYTHONIOENCODING: "utf-8"
GIR_BUILD: ""
strategy:
fail-fast: false
matrix:
build_introspection: [ true, false ]
steps:
- uses: actions/checkout@master
- uses: actions/setup-python@v1
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: seanmiddleditch/gha-setup-vsdevenv@master
- name: Install GTK
if: matrix.build_introspection
run: |
$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile("https://github.com/wingtk/gvsbuild/releases/download/2024.8.1/GTK4_Gvsbuild_2024.8.1_x64.zip","C:\GTK.zip")
7z x C:\GTK.zip -oC:\GTK
echo "C:\GTK\lib" | Out-File -FilePath $env:GITHUB_PATH -Append
echo "C:\GTK\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
echo "C:\GTK" | Out-File -FilePath $env:GITHUB_PATH -Append
echo "GIR_BUILD=-Dintrospection=enabled" >> $GITHUB_ENV
python -m pip install setuptools
python -m pip install C:\GTK\python\pycairo-1.26.1-cp312-cp312-win_amd64.whl C:\GTK\python\pygobject-3.48.2-cp312-cp312-win_amd64.whl
- name: Prebuild
run: |
write-host PWD
$pwd.Path
write-host PWD content
get-childitem $pwd
write-host python checks
(get-command py).Path
(get-command python).Path
py -0p
py -V
python -V
write-host install meson and check
python -m pip install meson
(get-command meson).Path
write-host run py g-ir-scanner
py C:\GTK\bin\g-ir-scanner --help
write-host run python g-ir-scanner
python C:\GTK\bin\g-ir-scanner --help
write-host meson setup
meson setup _build
- uses: BSFishy/[email protected]
with:
action: test
directory: _build
setup-options: ${{ env.GIR_BUILD }}
options: "--verbose"
meson-version: "1.0.0"
13 changes: 10 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ endif
# then we don't build introspection data either.
#
# We only build introspection if we can run binaries on the host.
message('find_program g-ir-scanner')
gir = find_program('g-ir-scanner', required: get_option('introspection'))
build_gir = get_option('introspection').allowed() and build_gobject and gir.found() and meson.can_run_host_binaries()

Expand Down Expand Up @@ -277,6 +278,7 @@ graphene_conf = configuration_data()
graphene_simd = []

# SSE intrinsics
message('get_option sse2')
sse2_cflags = []
if get_option('sse2')
sse_prog = '''
Expand Down Expand Up @@ -314,6 +316,7 @@ int main () {
endif

# GCC/Clang vector intrinsics
message('get_option gcc_vector')
if get_option('gcc_vector')
vector_intrin_prog = '''
#if defined(__GNUC__) // Clang advertises __GNUC__ too
Expand Down Expand Up @@ -349,6 +352,7 @@ int main () {
endif

# ARM NEON intrinsics
message('get_option arm_neon')
neon_cflags = []
if get_option('arm_neon')
neon_prog = '''
Expand Down Expand Up @@ -427,23 +431,26 @@ if graphene_build_static_only
graphene_conf.set('GRAPHENE_STATIC_COMPILATION', '1')
endif


message('importing python and gnome')
python = import('python')
gnome = import('gnome')

message('subdir include')
subdir('include')

message('include_directories src')
src_inc = include_directories('src')
message('subdir src')
subdir('src')

message('get_option tests')
if get_option('tests')
if cc.get_id() == 'msvc' and cc.version().version_compare('<19')
warning('Tests, specifically the mutest library, cannot be built for pre-2015 Visual Studio builds.')
warning('Use \'meson configure -Dtests=false\' if you are sure you want to proceed.')
endif
subdir('tests')
endif

message('get_option gtk_doc')
if get_option('gtk_doc')
subdir('doc')
endif
Expand Down
23 changes: 19 additions & 4 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
message('in src/meson.build')
sources = [
'graphene-alloc.c',
'graphene-box.c',
Expand All @@ -22,23 +23,26 @@ simd_sources = [
'graphene-simd4f.c',
'graphene-simd4x4f.c',
]

message('if build_gobject 1')
if build_gobject
sources += [ 'graphene-gobject.c' ]
endif

# Internal configuration header
message('configure_file')
configure_file(
output: 'config.h',
configuration: conf,
)

platform_deps = []

message('if build_gobject 2')
if build_gobject
platform_deps += gobject
endif

message('library libgraphene')
libgraphene = library(
graphene_api_path,
include_directories: graphene_inc,
Expand All @@ -55,10 +59,12 @@ libgraphene = library(
link_args: common_ldflags,
)

message('foreach simd')
foreach simd: [ 'sse2', 'gcc', 'neon', 'scalar', ]
set_variable('has_' + simd, graphene_simd.contains(simd) ? '1' : '0')
endforeach

message('import pkgconfig')
pkgconfig = import('pkgconfig')
pkgconfig.generate(
libgraphene,
Expand All @@ -78,6 +84,7 @@ pkgconfig.generate(
] + sse2_cflags + neon_cflags,
)

message('if build_gobject 3')
if build_gobject
pkgconfig.generate(
name: 'Graphene-GObject',
Expand All @@ -98,18 +105,20 @@ endif
graphene_dep_sources = []

# Introspection
message('if build_gir')
if build_gir
python = python.find_installation('python3')
message('python.find_installation')
python = python.find_installation()
identfilter_py = meson.current_source_dir() / 'identfilter.py'

gir_extra_args = [
'--identifier-filter-cmd=@0@ "@1@"'.format(python.full_path(), identfilter_py),
'--accept-unprefixed',
'--quiet',
# '--quiet',
'--warn-all',
'-DGRAPHENE_COMPILATION',
]

message('gnome.generate_gir')
graphene_gir = gnome.generate_gir(libgraphene,
include_directories: graphene_inc,
sources: [graphene_config_h] + sources + graphene_public_headers,
Expand All @@ -128,14 +137,18 @@ if build_gir
endif

# Dependency for tests and subproject usage
message('declare_dependency')
graphene_dep = declare_dependency(
sources: graphene_dep_sources,
link_with: libgraphene,
include_directories: [ graphene_inc ],
dependencies: [ mathlib, threadlib ] + platform_deps,
)
message('override_dependency graphene-1.0')
meson.override_dependency('graphene-1.0', graphene_dep)
message('if build_gobject 4')
if build_gobject
message('override_dependency graphene-gobject-1.0')
meson.override_dependency('graphene-gobject-1.0', graphene_dep)
endif

Expand All @@ -144,8 +157,10 @@ endif
# directly as part of the dependency() fallback logic instead of having to
# poke at the build_gobject subproject variable. This mirrors the pkg-config
# lookup logic where we have a dedicated .pc file for graphene-gobject as well.
message('if build_gobject 5')
if build_gobject
graphene_gobject_dep = graphene_dep
else
graphene_gobject_dep = dependency('', required: false)
endif
message('exit src/meson.build')
9 changes: 6 additions & 3 deletions tests/meson.build
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
message('In tests/meson.build')
unit_tests = [
'box',
'box2d',
Expand All @@ -20,8 +21,10 @@ unit_tests = [
'vec4'
]

message('find "gen-installed-test.py"')
gen_installed_test = find_program('gen-installed-test.py')

message('build paths')
installed_test_datadir = get_option('prefix') / get_option('datadir') / 'installed-tests' / graphene_api_path
installed_test_bindir = get_option('prefix') / get_option('libexecdir') / 'installed-tests' / graphene_api_path

Expand All @@ -33,7 +36,7 @@ mutest_dep = dependency('mutest-1',
required: false,
disabler: true,
)

message('if mutest_dep.found')
if mutest_dep.found()
foreach unit: unit_tests
wrapper = '@[email protected]'.format(unit)
Expand Down Expand Up @@ -65,8 +68,8 @@ if mutest_dep.found()
endif

src_build_path = meson.current_build_dir() / '../src'

if build_gir and host_system == 'linux' and not meson.is_cross_build()
message('if build_gir and not meson.is_cross_build')
if build_gir and not meson.is_cross_build()
foreach unit: ['introspection.py']
if get_option('installed_tests')
install_data(unit, install_dir: installed_test_bindir)
Expand Down