frida 16.2.0 → 16.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BSDmakefile +6 -0
- package/Makefile +16 -0
- package/README.md +14 -11
- package/configure +18 -0
- package/configure.bat +22 -0
- package/dist/native.js +0 -8
- package/lib/application.ts +98 -0
- package/lib/authentication.ts +3 -0
- package/lib/build.py +50 -0
- package/lib/bus.ts +30 -0
- package/lib/cancellable.ts +33 -0
- package/lib/child.ts +15 -0
- package/lib/crash.ts +11 -0
- package/lib/device.ts +329 -0
- package/lib/device_manager.ts +69 -0
- package/lib/endpoint_parameters.ts +56 -0
- package/lib/icon.ts +15 -0
- package/lib/index.ts +311 -0
- package/lib/iostream.ts +78 -0
- package/lib/meson.build +53 -0
- package/lib/native.ts +9 -0
- package/lib/portal_membership.ts +10 -0
- package/lib/portal_service.ts +105 -0
- package/lib/process.ts +57 -0
- package/lib/relay.ts +44 -0
- package/lib/script.ts +352 -0
- package/lib/session.ts +113 -0
- package/lib/signals.ts +45 -0
- package/lib/socket_address.ts +35 -0
- package/lib/spawn.ts +4 -0
- package/lib/system_parameters.ts +78 -0
- package/make.bat +23 -0
- package/meson.build +160 -0
- package/meson.options +11 -0
- package/package.json +27 -6
- package/releng/deps.py +1133 -0
- package/releng/deps.toml +391 -0
- package/releng/devkit-assets/frida-core-example-unix.c +188 -0
- package/releng/devkit-assets/frida-core-example-windows.c +197 -0
- package/releng/devkit-assets/frida-core-example.sln +28 -0
- package/releng/devkit-assets/frida-core-example.vcxproj +157 -0
- package/releng/devkit-assets/frida-core-example.vcxproj.filters +27 -0
- package/releng/devkit-assets/frida-gum-example-unix.c +122 -0
- package/releng/devkit-assets/frida-gum-example-windows.c +132 -0
- package/releng/devkit-assets/frida-gum-example.sln +28 -0
- package/releng/devkit-assets/frida-gum-example.vcxproj +157 -0
- package/releng/devkit-assets/frida-gum-example.vcxproj.filters +27 -0
- package/releng/devkit-assets/frida-gumjs-example-unix.c +84 -0
- package/releng/devkit-assets/frida-gumjs-example-windows.c +91 -0
- package/releng/devkit-assets/frida-gumjs-example.sln +28 -0
- package/releng/devkit-assets/frida-gumjs-example.vcxproj +157 -0
- package/releng/devkit-assets/frida-gumjs-example.vcxproj.filters +27 -0
- package/releng/devkit.py +535 -0
- package/releng/env.py +420 -0
- package/releng/env_android.py +150 -0
- package/releng/env_apple.py +176 -0
- package/releng/env_generic.py +373 -0
- package/releng/frida_version.py +69 -0
- package/releng/machine_file.py +44 -0
- package/releng/machine_spec.py +290 -0
- package/releng/meson/meson.py +27 -0
- package/releng/meson/mesonbuild/__init__.py +0 -0
- package/releng/meson/mesonbuild/_pathlib.py +63 -0
- package/releng/meson/mesonbuild/_typing.py +69 -0
- package/releng/meson/mesonbuild/arglist.py +321 -0
- package/releng/meson/mesonbuild/ast/__init__.py +23 -0
- package/releng/meson/mesonbuild/ast/interpreter.py +441 -0
- package/releng/meson/mesonbuild/ast/introspection.py +374 -0
- package/releng/meson/mesonbuild/ast/postprocess.py +109 -0
- package/releng/meson/mesonbuild/ast/printer.py +620 -0
- package/releng/meson/mesonbuild/ast/visitor.py +161 -0
- package/releng/meson/mesonbuild/backend/__init__.py +0 -0
- package/releng/meson/mesonbuild/backend/backends.py +2047 -0
- package/releng/meson/mesonbuild/backend/ninjabackend.py +3808 -0
- package/releng/meson/mesonbuild/backend/nonebackend.py +26 -0
- package/releng/meson/mesonbuild/backend/vs2010backend.py +2078 -0
- package/releng/meson/mesonbuild/backend/vs2012backend.py +35 -0
- package/releng/meson/mesonbuild/backend/vs2013backend.py +34 -0
- package/releng/meson/mesonbuild/backend/vs2015backend.py +35 -0
- package/releng/meson/mesonbuild/backend/vs2017backend.py +59 -0
- package/releng/meson/mesonbuild/backend/vs2019backend.py +54 -0
- package/releng/meson/mesonbuild/backend/vs2022backend.py +54 -0
- package/releng/meson/mesonbuild/backend/xcodebackend.py +1781 -0
- package/releng/meson/mesonbuild/build.py +3249 -0
- package/releng/meson/mesonbuild/cargo/__init__.py +5 -0
- package/releng/meson/mesonbuild/cargo/builder.py +238 -0
- package/releng/meson/mesonbuild/cargo/cfg.py +274 -0
- package/releng/meson/mesonbuild/cargo/interpreter.py +733 -0
- package/releng/meson/mesonbuild/cargo/manifest.py +227 -0
- package/releng/meson/mesonbuild/cargo/version.py +95 -0
- package/releng/meson/mesonbuild/cmake/__init__.py +28 -0
- package/releng/meson/mesonbuild/cmake/common.py +331 -0
- package/releng/meson/mesonbuild/cmake/data/__init__.py +0 -0
- package/releng/meson/mesonbuild/cmake/data/preload.cmake +82 -0
- package/releng/meson/mesonbuild/cmake/executor.py +241 -0
- package/releng/meson/mesonbuild/cmake/fileapi.py +324 -0
- package/releng/meson/mesonbuild/cmake/generator.py +186 -0
- package/releng/meson/mesonbuild/cmake/interpreter.py +1267 -0
- package/releng/meson/mesonbuild/cmake/toolchain.py +248 -0
- package/releng/meson/mesonbuild/cmake/traceparser.py +814 -0
- package/releng/meson/mesonbuild/cmake/tracetargets.py +161 -0
- package/releng/meson/mesonbuild/compilers/__init__.py +86 -0
- package/releng/meson/mesonbuild/compilers/asm.py +307 -0
- package/releng/meson/mesonbuild/compilers/c.py +788 -0
- package/releng/meson/mesonbuild/compilers/c_function_attributes.py +143 -0
- package/releng/meson/mesonbuild/compilers/compilers.py +1388 -0
- package/releng/meson/mesonbuild/compilers/cpp.py +1035 -0
- package/releng/meson/mesonbuild/compilers/cs.py +136 -0
- package/releng/meson/mesonbuild/compilers/cuda.py +806 -0
- package/releng/meson/mesonbuild/compilers/cython.py +91 -0
- package/releng/meson/mesonbuild/compilers/d.py +861 -0
- package/releng/meson/mesonbuild/compilers/detect.py +1396 -0
- package/releng/meson/mesonbuild/compilers/fortran.py +523 -0
- package/releng/meson/mesonbuild/compilers/java.py +113 -0
- package/releng/meson/mesonbuild/compilers/mixins/__init__.py +0 -0
- package/releng/meson/mesonbuild/compilers/mixins/arm.py +167 -0
- package/releng/meson/mesonbuild/compilers/mixins/ccrx.py +113 -0
- package/releng/meson/mesonbuild/compilers/mixins/clang.py +170 -0
- package/releng/meson/mesonbuild/compilers/mixins/clike.py +1330 -0
- package/releng/meson/mesonbuild/compilers/mixins/compcert.py +117 -0
- package/releng/meson/mesonbuild/compilers/mixins/elbrus.py +93 -0
- package/releng/meson/mesonbuild/compilers/mixins/emscripten.py +89 -0
- package/releng/meson/mesonbuild/compilers/mixins/gnu.py +629 -0
- package/releng/meson/mesonbuild/compilers/mixins/intel.py +167 -0
- package/releng/meson/mesonbuild/compilers/mixins/islinker.py +120 -0
- package/releng/meson/mesonbuild/compilers/mixins/metrowerks.py +279 -0
- package/releng/meson/mesonbuild/compilers/mixins/pgi.py +88 -0
- package/releng/meson/mesonbuild/compilers/mixins/ti.py +130 -0
- package/releng/meson/mesonbuild/compilers/mixins/visualstudio.py +458 -0
- package/releng/meson/mesonbuild/compilers/mixins/xc16.py +111 -0
- package/releng/meson/mesonbuild/compilers/objc.py +120 -0
- package/releng/meson/mesonbuild/compilers/objcpp.py +102 -0
- package/releng/meson/mesonbuild/compilers/rust.py +230 -0
- package/releng/meson/mesonbuild/compilers/swift.py +131 -0
- package/releng/meson/mesonbuild/compilers/vala.py +121 -0
- package/releng/meson/mesonbuild/coredata.py +1532 -0
- package/releng/meson/mesonbuild/dependencies/__init__.py +252 -0
- package/releng/meson/mesonbuild/dependencies/base.py +663 -0
- package/releng/meson/mesonbuild/dependencies/boost.py +1083 -0
- package/releng/meson/mesonbuild/dependencies/cmake.py +656 -0
- package/releng/meson/mesonbuild/dependencies/coarrays.py +80 -0
- package/releng/meson/mesonbuild/dependencies/configtool.py +163 -0
- package/releng/meson/mesonbuild/dependencies/cuda.py +295 -0
- package/releng/meson/mesonbuild/dependencies/data/CMakeLists.txt +102 -0
- package/releng/meson/mesonbuild/dependencies/data/CMakeListsLLVM.txt +204 -0
- package/releng/meson/mesonbuild/dependencies/data/CMakePathInfo.txt +31 -0
- package/releng/meson/mesonbuild/dependencies/data/__init__.py +0 -0
- package/releng/meson/mesonbuild/dependencies/detect.py +225 -0
- package/releng/meson/mesonbuild/dependencies/dev.py +707 -0
- package/releng/meson/mesonbuild/dependencies/dub.py +424 -0
- package/releng/meson/mesonbuild/dependencies/factory.py +146 -0
- package/releng/meson/mesonbuild/dependencies/framework.py +111 -0
- package/releng/meson/mesonbuild/dependencies/hdf5.py +168 -0
- package/releng/meson/mesonbuild/dependencies/misc.py +618 -0
- package/releng/meson/mesonbuild/dependencies/mpi.py +231 -0
- package/releng/meson/mesonbuild/dependencies/pkgconfig.py +570 -0
- package/releng/meson/mesonbuild/dependencies/platform.py +52 -0
- package/releng/meson/mesonbuild/dependencies/python.py +431 -0
- package/releng/meson/mesonbuild/dependencies/qt.py +484 -0
- package/releng/meson/mesonbuild/dependencies/scalapack.py +142 -0
- package/releng/meson/mesonbuild/dependencies/ui.py +281 -0
- package/releng/meson/mesonbuild/depfile.py +82 -0
- package/releng/meson/mesonbuild/envconfig.py +480 -0
- package/releng/meson/mesonbuild/environment.py +987 -0
- package/releng/meson/mesonbuild/interpreter/__init__.py +47 -0
- package/releng/meson/mesonbuild/interpreter/compiler.py +900 -0
- package/releng/meson/mesonbuild/interpreter/dependencyfallbacks.py +386 -0
- package/releng/meson/mesonbuild/interpreter/interpreter.py +3595 -0
- package/releng/meson/mesonbuild/interpreter/interpreterobjects.py +1096 -0
- package/releng/meson/mesonbuild/interpreter/kwargs.py +479 -0
- package/releng/meson/mesonbuild/interpreter/mesonmain.py +487 -0
- package/releng/meson/mesonbuild/interpreter/primitives/__init__.py +29 -0
- package/releng/meson/mesonbuild/interpreter/primitives/array.py +108 -0
- package/releng/meson/mesonbuild/interpreter/primitives/boolean.py +52 -0
- package/releng/meson/mesonbuild/interpreter/primitives/dict.py +88 -0
- package/releng/meson/mesonbuild/interpreter/primitives/integer.py +86 -0
- package/releng/meson/mesonbuild/interpreter/primitives/range.py +38 -0
- package/releng/meson/mesonbuild/interpreter/primitives/string.py +247 -0
- package/releng/meson/mesonbuild/interpreter/type_checking.py +853 -0
- package/releng/meson/mesonbuild/interpreterbase/__init__.py +126 -0
- package/releng/meson/mesonbuild/interpreterbase/_unholder.py +25 -0
- package/releng/meson/mesonbuild/interpreterbase/baseobjects.py +174 -0
- package/releng/meson/mesonbuild/interpreterbase/decorators.py +806 -0
- package/releng/meson/mesonbuild/interpreterbase/disabler.py +35 -0
- package/releng/meson/mesonbuild/interpreterbase/exceptions.py +22 -0
- package/releng/meson/mesonbuild/interpreterbase/helpers.py +67 -0
- package/releng/meson/mesonbuild/interpreterbase/interpreterbase.py +665 -0
- package/releng/meson/mesonbuild/interpreterbase/operator.py +32 -0
- package/releng/meson/mesonbuild/linkers/__init__.py +20 -0
- package/releng/meson/mesonbuild/linkers/base.py +39 -0
- package/releng/meson/mesonbuild/linkers/detect.py +229 -0
- package/releng/meson/mesonbuild/linkers/linkers.py +1614 -0
- package/releng/meson/mesonbuild/mcompile.py +380 -0
- package/releng/meson/mesonbuild/mconf.py +368 -0
- package/releng/meson/mesonbuild/mdevenv.py +234 -0
- package/releng/meson/mesonbuild/mdist.py +376 -0
- package/releng/meson/mesonbuild/mesondata.py +38 -0
- package/releng/meson/mesonbuild/mesonlib.py +23 -0
- package/releng/meson/mesonbuild/mesonmain.py +289 -0
- package/releng/meson/mesonbuild/minit.py +204 -0
- package/releng/meson/mesonbuild/minstall.py +864 -0
- package/releng/meson/mesonbuild/mintro.py +667 -0
- package/releng/meson/mesonbuild/mlog.py +542 -0
- package/releng/meson/mesonbuild/modules/__init__.py +270 -0
- package/releng/meson/mesonbuild/modules/cmake.py +442 -0
- package/releng/meson/mesonbuild/modules/cuda.py +377 -0
- package/releng/meson/mesonbuild/modules/dlang.py +117 -0
- package/releng/meson/mesonbuild/modules/external_project.py +306 -0
- package/releng/meson/mesonbuild/modules/fs.py +323 -0
- package/releng/meson/mesonbuild/modules/gnome.py +2215 -0
- package/releng/meson/mesonbuild/modules/hotdoc.py +487 -0
- package/releng/meson/mesonbuild/modules/i18n.py +405 -0
- package/releng/meson/mesonbuild/modules/icestorm.py +123 -0
- package/releng/meson/mesonbuild/modules/java.py +112 -0
- package/releng/meson/mesonbuild/modules/keyval.py +65 -0
- package/releng/meson/mesonbuild/modules/modtest.py +33 -0
- package/releng/meson/mesonbuild/modules/pkgconfig.py +744 -0
- package/releng/meson/mesonbuild/modules/python.py +556 -0
- package/releng/meson/mesonbuild/modules/python3.py +85 -0
- package/releng/meson/mesonbuild/modules/qt.py +621 -0
- package/releng/meson/mesonbuild/modules/qt4.py +23 -0
- package/releng/meson/mesonbuild/modules/qt5.py +23 -0
- package/releng/meson/mesonbuild/modules/qt6.py +22 -0
- package/releng/meson/mesonbuild/modules/rust.py +355 -0
- package/releng/meson/mesonbuild/modules/simd.py +114 -0
- package/releng/meson/mesonbuild/modules/sourceset.py +291 -0
- package/releng/meson/mesonbuild/modules/wayland.py +151 -0
- package/releng/meson/mesonbuild/modules/windows.py +207 -0
- package/releng/meson/mesonbuild/mparser.py +1114 -0
- package/releng/meson/mesonbuild/msetup.py +365 -0
- package/releng/meson/mesonbuild/msubprojects.py +764 -0
- package/releng/meson/mesonbuild/mtest.py +2201 -0
- package/releng/meson/mesonbuild/munstable_coredata.py +107 -0
- package/releng/meson/mesonbuild/optinterpreter.py +276 -0
- package/releng/meson/mesonbuild/programs.py +367 -0
- package/releng/meson/mesonbuild/rewriter.py +1075 -0
- package/releng/meson/mesonbuild/scripts/__init__.py +10 -0
- package/releng/meson/mesonbuild/scripts/clangformat.py +55 -0
- package/releng/meson/mesonbuild/scripts/clangtidy.py +30 -0
- package/releng/meson/mesonbuild/scripts/cleantrees.py +35 -0
- package/releng/meson/mesonbuild/scripts/cmake_run_ctgt.py +103 -0
- package/releng/meson/mesonbuild/scripts/cmd_or_ps.ps1 +17 -0
- package/releng/meson/mesonbuild/scripts/copy.py +19 -0
- package/releng/meson/mesonbuild/scripts/coverage.py +214 -0
- package/releng/meson/mesonbuild/scripts/delwithsuffix.py +27 -0
- package/releng/meson/mesonbuild/scripts/depfixer.py +495 -0
- package/releng/meson/mesonbuild/scripts/depscan.py +198 -0
- package/releng/meson/mesonbuild/scripts/dirchanger.py +20 -0
- package/releng/meson/mesonbuild/scripts/env2mfile.py +402 -0
- package/releng/meson/mesonbuild/scripts/externalproject.py +106 -0
- package/releng/meson/mesonbuild/scripts/gettext.py +86 -0
- package/releng/meson/mesonbuild/scripts/gtkdochelper.py +286 -0
- package/releng/meson/mesonbuild/scripts/hotdochelper.py +40 -0
- package/releng/meson/mesonbuild/scripts/itstool.py +77 -0
- package/releng/meson/mesonbuild/scripts/meson_exe.py +115 -0
- package/releng/meson/mesonbuild/scripts/msgfmthelper.py +29 -0
- package/releng/meson/mesonbuild/scripts/pycompile.py +54 -0
- package/releng/meson/mesonbuild/scripts/python_info.py +121 -0
- package/releng/meson/mesonbuild/scripts/regen_checker.py +55 -0
- package/releng/meson/mesonbuild/scripts/run_tool.py +58 -0
- package/releng/meson/mesonbuild/scripts/scanbuild.py +57 -0
- package/releng/meson/mesonbuild/scripts/symbolextractor.py +322 -0
- package/releng/meson/mesonbuild/scripts/tags.py +44 -0
- package/releng/meson/mesonbuild/scripts/test_loaded_modules.py +14 -0
- package/releng/meson/mesonbuild/scripts/uninstall.py +41 -0
- package/releng/meson/mesonbuild/scripts/vcstagger.py +35 -0
- package/releng/meson/mesonbuild/scripts/yasm.py +24 -0
- package/releng/meson/mesonbuild/templates/__init__.py +0 -0
- package/releng/meson/mesonbuild/templates/cpptemplates.py +143 -0
- package/releng/meson/mesonbuild/templates/cstemplates.py +90 -0
- package/releng/meson/mesonbuild/templates/ctemplates.py +126 -0
- package/releng/meson/mesonbuild/templates/cudatemplates.py +143 -0
- package/releng/meson/mesonbuild/templates/dlangtemplates.py +109 -0
- package/releng/meson/mesonbuild/templates/fortrantemplates.py +101 -0
- package/releng/meson/mesonbuild/templates/javatemplates.py +94 -0
- package/releng/meson/mesonbuild/templates/mesontemplates.py +70 -0
- package/releng/meson/mesonbuild/templates/objcpptemplates.py +126 -0
- package/releng/meson/mesonbuild/templates/objctemplates.py +126 -0
- package/releng/meson/mesonbuild/templates/rusttemplates.py +79 -0
- package/releng/meson/mesonbuild/templates/samplefactory.py +41 -0
- package/releng/meson/mesonbuild/templates/sampleimpl.py +160 -0
- package/releng/meson/mesonbuild/templates/valatemplates.py +82 -0
- package/releng/meson/mesonbuild/utils/__init__.py +0 -0
- package/releng/meson/mesonbuild/utils/core.py +166 -0
- package/releng/meson/mesonbuild/utils/platform.py +27 -0
- package/releng/meson/mesonbuild/utils/posix.py +32 -0
- package/releng/meson/mesonbuild/utils/universal.py +2445 -0
- package/releng/meson/mesonbuild/utils/vsenv.py +126 -0
- package/releng/meson/mesonbuild/utils/win32.py +29 -0
- package/releng/meson/mesonbuild/wrap/__init__.py +59 -0
- package/releng/meson/mesonbuild/wrap/wrap.py +846 -0
- package/releng/meson/mesonbuild/wrap/wraptool.py +198 -0
- package/releng/meson-scripts/BSDmakefile +6 -0
- package/releng/meson-scripts/Makefile +16 -0
- package/releng/meson-scripts/configure +18 -0
- package/releng/meson-scripts/configure.bat +22 -0
- package/releng/meson-scripts/make.bat +23 -0
- package/releng/meson_configure.py +506 -0
- package/releng/meson_make.py +131 -0
- package/releng/mkdevkit.py +107 -0
- package/releng/mkfatmacho.py +54 -0
- package/releng/post-process-oabi.py +97 -0
- package/releng/progress.py +14 -0
- package/releng/sync-from-upstream.py +185 -0
- package/releng/tomlkit/tomlkit/__init__.py +59 -0
- package/releng/tomlkit/tomlkit/_compat.py +22 -0
- package/releng/tomlkit/tomlkit/_types.py +83 -0
- package/releng/tomlkit/tomlkit/_utils.py +158 -0
- package/releng/tomlkit/tomlkit/api.py +308 -0
- package/releng/tomlkit/tomlkit/container.py +875 -0
- package/releng/tomlkit/tomlkit/exceptions.py +227 -0
- package/releng/tomlkit/tomlkit/items.py +1967 -0
- package/releng/tomlkit/tomlkit/parser.py +1141 -0
- package/releng/tomlkit/tomlkit/py.typed +0 -0
- package/releng/tomlkit/tomlkit/source.py +180 -0
- package/releng/tomlkit/tomlkit/toml_char.py +52 -0
- package/releng/tomlkit/tomlkit/toml_document.py +7 -0
- package/releng/tomlkit/tomlkit/toml_file.py +58 -0
- package/releng/winenv.py +140 -0
- package/scripts/adjust-version.py +19 -0
- package/scripts/detect-version.py +40 -0
- package/scripts/fetch-abi-bits.py +343 -0
- package/scripts/install.js +23 -0
- package/scripts/package.py +15 -0
- package/src/addon.cc +76 -0
- package/src/application.cc +148 -0
- package/src/application.h +31 -0
- package/src/authentication.cc +174 -0
- package/src/authentication.h +24 -0
- package/src/bus.cc +167 -0
- package/src/bus.h +33 -0
- package/src/cancellable.cc +117 -0
- package/src/cancellable.h +31 -0
- package/src/child.cc +150 -0
- package/src/child.h +32 -0
- package/src/crash.cc +122 -0
- package/src/crash.h +30 -0
- package/src/device.cc +1302 -0
- package/src/device.h +55 -0
- package/src/device_manager.cc +362 -0
- package/src/device_manager.h +35 -0
- package/src/endpoint_parameters.cc +171 -0
- package/src/endpoint_parameters.h +28 -0
- package/src/glib_context.cc +62 -0
- package/src/glib_context.h +29 -0
- package/src/glib_object.cc +25 -0
- package/src/glib_object.h +37 -0
- package/src/iostream.cc +247 -0
- package/src/iostream.h +30 -0
- package/src/meson.build +26 -0
- package/src/operation.h +94 -0
- package/src/portal_membership.cc +100 -0
- package/src/portal_membership.h +26 -0
- package/src/portal_service.cc +401 -0
- package/src/portal_service.h +40 -0
- package/src/process.cc +135 -0
- package/src/process.h +30 -0
- package/src/relay.cc +139 -0
- package/src/relay.h +31 -0
- package/src/runtime.cc +443 -0
- package/src/runtime.h +64 -0
- package/src/script.cc +301 -0
- package/src/script.h +36 -0
- package/src/session.cc +860 -0
- package/src/session.h +42 -0
- package/src/signals.cc +334 -0
- package/src/signals.h +47 -0
- package/src/spawn.cc +95 -0
- package/src/spawn.h +27 -0
- package/src/usage_monitor.h +117 -0
- package/src/uv_context.cc +118 -0
- package/src/uv_context.h +40 -0
- package/src/win_delay_load_hook.cc +63 -0
- package/subprojects/frida-core.wrap +8 -0
- package/subprojects/nan.wrap +9 -0
- package/subprojects/packagefiles/nan.patch +13 -0
- package/test/data/index.ts +13 -0
- package/test/data/unixvictim-linux-x86 +0 -0
- package/test/data/unixvictim-linux-x86_64 +0 -0
- package/test/data/unixvictim-macos +0 -0
- package/test/device.ts +27 -0
- package/test/device_manager.ts +16 -0
- package/test/labrat.ts +32 -0
- package/test/script.ts +176 -0
- package/test/session.ts +73 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,2047 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright 2012-2016 The Meson development team
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from collections import OrderedDict
|
|
7
|
+
from dataclasses import dataclass, InitVar
|
|
8
|
+
from functools import lru_cache
|
|
9
|
+
from itertools import chain
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
import copy
|
|
12
|
+
import enum
|
|
13
|
+
import json
|
|
14
|
+
import os
|
|
15
|
+
import pickle
|
|
16
|
+
import re
|
|
17
|
+
import shlex
|
|
18
|
+
import shutil
|
|
19
|
+
import typing as T
|
|
20
|
+
import hashlib
|
|
21
|
+
|
|
22
|
+
from .. import build
|
|
23
|
+
from .. import dependencies
|
|
24
|
+
from .. import programs
|
|
25
|
+
from .. import mesonlib
|
|
26
|
+
from .. import mlog
|
|
27
|
+
from ..compilers import LANGUAGES_USING_LDFLAGS, detect
|
|
28
|
+
from ..mesonlib import (
|
|
29
|
+
File, MachineChoice, MesonException, OrderedSet,
|
|
30
|
+
ExecutableSerialisation, classify_unity_sources, OptionKey
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
if T.TYPE_CHECKING:
|
|
34
|
+
from .._typing import ImmutableListProtocol
|
|
35
|
+
from ..arglist import CompilerArgs
|
|
36
|
+
from ..compilers import Compiler
|
|
37
|
+
from ..environment import Environment
|
|
38
|
+
from ..interpreter import Interpreter, Test
|
|
39
|
+
from ..linkers.linkers import StaticLinker
|
|
40
|
+
from ..mesonlib import FileMode, FileOrString
|
|
41
|
+
|
|
42
|
+
from typing_extensions import TypedDict
|
|
43
|
+
|
|
44
|
+
_ALL_SOURCES_TYPE = T.List[T.Union[File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]]
|
|
45
|
+
|
|
46
|
+
class TargetIntrospectionData(TypedDict):
|
|
47
|
+
|
|
48
|
+
language: str
|
|
49
|
+
compiler: T.List[str]
|
|
50
|
+
parameters: T.List[str]
|
|
51
|
+
sources: T.List[str]
|
|
52
|
+
generated_sources: T.List[str]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# Languages that can mix with C or C++ but don't support unity builds yet
|
|
56
|
+
# because the syntax we use for unity builds is specific to C/++/ObjC/++.
|
|
57
|
+
# Assembly files cannot be unitified and neither can LLVM IR files
|
|
58
|
+
LANGS_CANT_UNITY = ('d', 'fortran', 'vala')
|
|
59
|
+
|
|
60
|
+
@dataclass(eq=False)
|
|
61
|
+
class RegenInfo:
|
|
62
|
+
source_dir: str
|
|
63
|
+
build_dir: str
|
|
64
|
+
depfiles: T.List[str]
|
|
65
|
+
|
|
66
|
+
class TestProtocol(enum.Enum):
|
|
67
|
+
|
|
68
|
+
EXITCODE = 0
|
|
69
|
+
TAP = 1
|
|
70
|
+
GTEST = 2
|
|
71
|
+
RUST = 3
|
|
72
|
+
|
|
73
|
+
@classmethod
|
|
74
|
+
def from_str(cls, string: str) -> 'TestProtocol':
|
|
75
|
+
if string == 'exitcode':
|
|
76
|
+
return cls.EXITCODE
|
|
77
|
+
elif string == 'tap':
|
|
78
|
+
return cls.TAP
|
|
79
|
+
elif string == 'gtest':
|
|
80
|
+
return cls.GTEST
|
|
81
|
+
elif string == 'rust':
|
|
82
|
+
return cls.RUST
|
|
83
|
+
raise MesonException(f'unknown test format {string}')
|
|
84
|
+
|
|
85
|
+
def __str__(self) -> str:
|
|
86
|
+
cls = type(self)
|
|
87
|
+
if self is cls.EXITCODE:
|
|
88
|
+
return 'exitcode'
|
|
89
|
+
elif self is cls.GTEST:
|
|
90
|
+
return 'gtest'
|
|
91
|
+
elif self is cls.RUST:
|
|
92
|
+
return 'rust'
|
|
93
|
+
return 'tap'
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@dataclass(eq=False)
|
|
97
|
+
class CleanTrees:
|
|
98
|
+
'''
|
|
99
|
+
Directories outputted by custom targets that have to be manually cleaned
|
|
100
|
+
because on Linux `ninja clean` only deletes empty directories.
|
|
101
|
+
'''
|
|
102
|
+
build_dir: str
|
|
103
|
+
trees: T.List[str]
|
|
104
|
+
|
|
105
|
+
@dataclass(eq=False)
|
|
106
|
+
class InstallData:
|
|
107
|
+
source_dir: str
|
|
108
|
+
build_dir: str
|
|
109
|
+
prefix: str
|
|
110
|
+
libdir: str
|
|
111
|
+
strip_bin: T.List[str]
|
|
112
|
+
# TODO: in python 3.8 or with typing_Extensions this could be:
|
|
113
|
+
# `T.Union[T.Literal['preserve'], int]`, which would be more accurate.
|
|
114
|
+
install_umask: T.Union[str, int]
|
|
115
|
+
mesonintrospect: T.List[str]
|
|
116
|
+
version: str
|
|
117
|
+
|
|
118
|
+
def __post_init__(self) -> None:
|
|
119
|
+
self.targets: T.List[TargetInstallData] = []
|
|
120
|
+
self.headers: T.List[InstallDataBase] = []
|
|
121
|
+
self.man: T.List[InstallDataBase] = []
|
|
122
|
+
self.emptydir: T.List[InstallEmptyDir] = []
|
|
123
|
+
self.data: T.List[InstallDataBase] = []
|
|
124
|
+
self.symlinks: T.List[InstallSymlinkData] = []
|
|
125
|
+
self.install_scripts: T.List[ExecutableSerialisation] = []
|
|
126
|
+
self.install_subdirs: T.List[SubdirInstallData] = []
|
|
127
|
+
|
|
128
|
+
@dataclass(eq=False)
|
|
129
|
+
class TargetInstallData:
|
|
130
|
+
fname: str
|
|
131
|
+
outdir: str
|
|
132
|
+
outdir_name: InitVar[T.Optional[str]]
|
|
133
|
+
strip: bool
|
|
134
|
+
install_name_mappings: T.Mapping[str, str]
|
|
135
|
+
rpath_dirs_to_remove: T.Set[bytes]
|
|
136
|
+
install_rpath: str
|
|
137
|
+
# TODO: install_mode should just always be a FileMode object
|
|
138
|
+
install_mode: T.Optional['FileMode']
|
|
139
|
+
subproject: str
|
|
140
|
+
optional: bool = False
|
|
141
|
+
tag: T.Optional[str] = None
|
|
142
|
+
can_strip: bool = False
|
|
143
|
+
|
|
144
|
+
def __post_init__(self, outdir_name: T.Optional[str]) -> None:
|
|
145
|
+
if outdir_name is None:
|
|
146
|
+
outdir_name = os.path.join('{prefix}', self.outdir)
|
|
147
|
+
self.out_name = os.path.join(outdir_name, os.path.basename(self.fname))
|
|
148
|
+
|
|
149
|
+
@dataclass(eq=False)
|
|
150
|
+
class InstallEmptyDir:
|
|
151
|
+
path: str
|
|
152
|
+
install_mode: 'FileMode'
|
|
153
|
+
subproject: str
|
|
154
|
+
tag: T.Optional[str] = None
|
|
155
|
+
|
|
156
|
+
@dataclass(eq=False)
|
|
157
|
+
class InstallDataBase:
|
|
158
|
+
path: str
|
|
159
|
+
install_path: str
|
|
160
|
+
install_path_name: str
|
|
161
|
+
install_mode: 'FileMode'
|
|
162
|
+
subproject: str
|
|
163
|
+
tag: T.Optional[str] = None
|
|
164
|
+
data_type: T.Optional[str] = None
|
|
165
|
+
follow_symlinks: T.Optional[bool] = None
|
|
166
|
+
|
|
167
|
+
@dataclass(eq=False)
|
|
168
|
+
class InstallSymlinkData:
|
|
169
|
+
target: str
|
|
170
|
+
name: str
|
|
171
|
+
install_path: str
|
|
172
|
+
subproject: str
|
|
173
|
+
tag: T.Optional[str] = None
|
|
174
|
+
allow_missing: bool = False
|
|
175
|
+
|
|
176
|
+
# cannot use dataclass here because "exclude" is out of order
|
|
177
|
+
class SubdirInstallData(InstallDataBase):
|
|
178
|
+
def __init__(self, path: str, install_path: str, install_path_name: str,
|
|
179
|
+
install_mode: 'FileMode', exclude: T.Tuple[T.Set[str], T.Set[str]],
|
|
180
|
+
subproject: str, tag: T.Optional[str] = None, data_type: T.Optional[str] = None,
|
|
181
|
+
follow_symlinks: T.Optional[bool] = None):
|
|
182
|
+
super().__init__(path, install_path, install_path_name, install_mode, subproject, tag, data_type, follow_symlinks)
|
|
183
|
+
self.exclude = exclude
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
@dataclass(eq=False)
|
|
187
|
+
class TestSerialisation:
|
|
188
|
+
name: str
|
|
189
|
+
project_name: str
|
|
190
|
+
suite: T.List[str]
|
|
191
|
+
fname: T.List[str]
|
|
192
|
+
is_cross_built: bool
|
|
193
|
+
exe_wrapper: T.Optional[programs.ExternalProgram]
|
|
194
|
+
needs_exe_wrapper: bool
|
|
195
|
+
is_parallel: bool
|
|
196
|
+
cmd_args: T.List[str]
|
|
197
|
+
env: mesonlib.EnvironmentVariables
|
|
198
|
+
should_fail: bool
|
|
199
|
+
timeout: T.Optional[int]
|
|
200
|
+
workdir: T.Optional[str]
|
|
201
|
+
extra_paths: T.List[str]
|
|
202
|
+
protocol: TestProtocol
|
|
203
|
+
priority: int
|
|
204
|
+
cmd_is_built: bool
|
|
205
|
+
cmd_is_exe: bool
|
|
206
|
+
depends: T.List[str]
|
|
207
|
+
version: str
|
|
208
|
+
verbose: bool
|
|
209
|
+
|
|
210
|
+
def __post_init__(self) -> None:
|
|
211
|
+
if self.exe_wrapper is not None:
|
|
212
|
+
assert isinstance(self.exe_wrapper, programs.ExternalProgram)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def get_backend_from_name(backend: str, build: T.Optional[build.Build] = None, interpreter: T.Optional['Interpreter'] = None) -> T.Optional['Backend']:
|
|
216
|
+
if backend == 'ninja':
|
|
217
|
+
from . import ninjabackend
|
|
218
|
+
return ninjabackend.NinjaBackend(build, interpreter)
|
|
219
|
+
elif backend == 'vs':
|
|
220
|
+
from . import vs2010backend
|
|
221
|
+
return vs2010backend.autodetect_vs_version(build, interpreter)
|
|
222
|
+
elif backend == 'vs2010':
|
|
223
|
+
from . import vs2010backend
|
|
224
|
+
return vs2010backend.Vs2010Backend(build, interpreter)
|
|
225
|
+
elif backend == 'vs2012':
|
|
226
|
+
from . import vs2012backend
|
|
227
|
+
return vs2012backend.Vs2012Backend(build, interpreter)
|
|
228
|
+
elif backend == 'vs2013':
|
|
229
|
+
from . import vs2013backend
|
|
230
|
+
return vs2013backend.Vs2013Backend(build, interpreter)
|
|
231
|
+
elif backend == 'vs2015':
|
|
232
|
+
from . import vs2015backend
|
|
233
|
+
return vs2015backend.Vs2015Backend(build, interpreter)
|
|
234
|
+
elif backend == 'vs2017':
|
|
235
|
+
from . import vs2017backend
|
|
236
|
+
return vs2017backend.Vs2017Backend(build, interpreter)
|
|
237
|
+
elif backend == 'vs2019':
|
|
238
|
+
from . import vs2019backend
|
|
239
|
+
return vs2019backend.Vs2019Backend(build, interpreter)
|
|
240
|
+
elif backend == 'vs2022':
|
|
241
|
+
from . import vs2022backend
|
|
242
|
+
return vs2022backend.Vs2022Backend(build, interpreter)
|
|
243
|
+
elif backend == 'xcode':
|
|
244
|
+
from . import xcodebackend
|
|
245
|
+
return xcodebackend.XCodeBackend(build, interpreter)
|
|
246
|
+
elif backend == 'none':
|
|
247
|
+
from . import nonebackend
|
|
248
|
+
return nonebackend.NoneBackend(build, interpreter)
|
|
249
|
+
return None
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def get_genvslite_backend(genvsname: str, build: T.Optional[build.Build] = None, interpreter: T.Optional['Interpreter'] = None) -> T.Optional['Backend']:
|
|
253
|
+
if genvsname == 'vs2022':
|
|
254
|
+
from . import vs2022backend
|
|
255
|
+
return vs2022backend.Vs2022Backend(build, interpreter, gen_lite = True)
|
|
256
|
+
return None
|
|
257
|
+
|
|
258
|
+
# This class contains the basic functionality that is needed by all backends.
|
|
259
|
+
# Feel free to move stuff in and out of it as you see fit.
|
|
260
|
+
class Backend:
|
|
261
|
+
|
|
262
|
+
environment: T.Optional['Environment']
|
|
263
|
+
name = '<UNKNOWN>'
|
|
264
|
+
|
|
265
|
+
def __init__(self, build: T.Optional[build.Build], interpreter: T.Optional['Interpreter']):
|
|
266
|
+
# Make it possible to construct a dummy backend
|
|
267
|
+
# This is used for introspection without a build directory
|
|
268
|
+
if build is None:
|
|
269
|
+
self.environment = None
|
|
270
|
+
return
|
|
271
|
+
self.build = build
|
|
272
|
+
self.interpreter = interpreter
|
|
273
|
+
self.environment = build.environment
|
|
274
|
+
self.processed_targets: T.Set[str] = set()
|
|
275
|
+
self.build_dir = self.environment.get_build_dir()
|
|
276
|
+
self.source_dir = self.environment.get_source_dir()
|
|
277
|
+
self.build_to_src = mesonlib.relpath(self.environment.get_source_dir(),
|
|
278
|
+
self.environment.get_build_dir())
|
|
279
|
+
self.src_to_build = mesonlib.relpath(self.environment.get_build_dir(),
|
|
280
|
+
self.environment.get_source_dir())
|
|
281
|
+
|
|
282
|
+
# If requested via 'capture = True', returns captured compile args per
|
|
283
|
+
# target (e.g. captured_args[target]) that can be used later, for example,
|
|
284
|
+
# to populate things like intellisense fields in generated visual studio
|
|
285
|
+
# projects (as is the case when using '--genvslite').
|
|
286
|
+
#
|
|
287
|
+
# 'vslite_ctx' is only provided when
|
|
288
|
+
# we expect this backend setup/generation to make use of previously captured
|
|
289
|
+
# compile args (as is the case when using '--genvslite').
|
|
290
|
+
def generate(self, capture: bool = False, vslite_ctx: dict = None) -> T.Optional[dict]:
|
|
291
|
+
raise RuntimeError(f'generate is not implemented in {type(self).__name__}')
|
|
292
|
+
|
|
293
|
+
def get_target_filename(self, t: T.Union[build.Target, build.CustomTargetIndex], *, warn_multi_output: bool = True) -> str:
|
|
294
|
+
if isinstance(t, build.CustomTarget):
|
|
295
|
+
if warn_multi_output and len(t.get_outputs()) != 1:
|
|
296
|
+
mlog.warning(f'custom_target {t.name!r} has more than one output! '
|
|
297
|
+
f'Using the first one. Consider using `{t.name}[0]`.')
|
|
298
|
+
filename = t.get_outputs()[0]
|
|
299
|
+
elif isinstance(t, build.CustomTargetIndex):
|
|
300
|
+
filename = t.get_outputs()[0]
|
|
301
|
+
else:
|
|
302
|
+
assert isinstance(t, build.BuildTarget), t
|
|
303
|
+
filename = t.get_filename()
|
|
304
|
+
return os.path.join(self.get_target_dir(t), filename)
|
|
305
|
+
|
|
306
|
+
def get_target_filename_abs(self, target: T.Union[build.Target, build.CustomTargetIndex]) -> str:
|
|
307
|
+
return os.path.join(self.environment.get_build_dir(), self.get_target_filename(target))
|
|
308
|
+
|
|
309
|
+
def get_target_debug_filename(self, target: build.BuildTarget) -> T.Optional[str]:
|
|
310
|
+
assert isinstance(target, build.BuildTarget), target
|
|
311
|
+
if target.get_debug_filename():
|
|
312
|
+
debug_filename = target.get_debug_filename()
|
|
313
|
+
return os.path.join(self.get_target_dir(target), debug_filename)
|
|
314
|
+
else:
|
|
315
|
+
return None
|
|
316
|
+
|
|
317
|
+
def get_target_debug_filename_abs(self, target: build.BuildTarget) -> T.Optional[str]:
|
|
318
|
+
assert isinstance(target, build.BuildTarget), target
|
|
319
|
+
if not target.get_debug_filename():
|
|
320
|
+
return None
|
|
321
|
+
return os.path.join(self.environment.get_build_dir(), self.get_target_debug_filename(target))
|
|
322
|
+
|
|
323
|
+
def get_source_dir_include_args(self, target: build.BuildTarget, compiler: 'Compiler', *, absolute_path: bool = False) -> T.List[str]:
|
|
324
|
+
curdir = target.get_source_subdir()
|
|
325
|
+
if absolute_path:
|
|
326
|
+
lead = self.source_dir
|
|
327
|
+
else:
|
|
328
|
+
lead = self.build_to_src
|
|
329
|
+
tmppath = os.path.normpath(os.path.join(lead, curdir))
|
|
330
|
+
return compiler.get_include_args(tmppath, False)
|
|
331
|
+
|
|
332
|
+
def get_build_dir_include_args(self, target: build.BuildTarget, compiler: 'Compiler', *, absolute_path: bool = False) -> T.List[str]:
|
|
333
|
+
if absolute_path:
|
|
334
|
+
curdir = os.path.join(self.build_dir, target.get_output_subdir())
|
|
335
|
+
else:
|
|
336
|
+
curdir = target.get_output_subdir()
|
|
337
|
+
if curdir == '':
|
|
338
|
+
curdir = '.'
|
|
339
|
+
return compiler.get_include_args(curdir, False)
|
|
340
|
+
|
|
341
|
+
def get_target_filename_for_linking(self, target: T.Union[build.Target, build.CustomTargetIndex]) -> T.Optional[str]:
|
|
342
|
+
# On some platforms (msvc for instance), the file that is used for
|
|
343
|
+
# dynamic linking is not the same as the dynamic library itself. This
|
|
344
|
+
# file is called an import library, and we want to link against that.
|
|
345
|
+
# On all other platforms, we link to the library directly.
|
|
346
|
+
if isinstance(target, build.SharedLibrary):
|
|
347
|
+
link_lib = target.get_import_filename() or target.get_filename()
|
|
348
|
+
# In AIX, if we archive .so, the blibpath must link to archived shared library otherwise to the .so file.
|
|
349
|
+
if mesonlib.is_aix() and target.aix_so_archive:
|
|
350
|
+
link_lib = re.sub('[.][a]([.]?([0-9]+))*([.]?([a-z]+))*', '.a', link_lib.replace('.so', '.a'))
|
|
351
|
+
return Path(self.get_target_dir(target), link_lib).as_posix()
|
|
352
|
+
elif isinstance(target, build.StaticLibrary):
|
|
353
|
+
return Path(self.get_target_dir(target), target.get_filename()).as_posix()
|
|
354
|
+
elif isinstance(target, (build.CustomTarget, build.CustomTargetIndex)):
|
|
355
|
+
if not target.is_linkable_target():
|
|
356
|
+
raise MesonException(f'Tried to link against custom target "{target.name}", which is not linkable.')
|
|
357
|
+
return Path(self.get_target_dir(target), target.get_filename()).as_posix()
|
|
358
|
+
elif isinstance(target, build.Executable):
|
|
359
|
+
if target.import_filename:
|
|
360
|
+
return Path(self.get_target_dir(target), target.get_import_filename()).as_posix()
|
|
361
|
+
else:
|
|
362
|
+
return None
|
|
363
|
+
raise AssertionError(f'BUG: Tried to link to {target!r} which is not linkable')
|
|
364
|
+
|
|
365
|
+
@lru_cache(maxsize=None)
|
|
366
|
+
def get_target_dir(self, target: T.Union[build.Target, build.CustomTargetIndex]) -> str:
|
|
367
|
+
if isinstance(target, build.RunTarget):
|
|
368
|
+
# this produces no output, only a dummy top-level name
|
|
369
|
+
dirname = ''
|
|
370
|
+
elif self.environment.coredata.get_option(OptionKey('layout')) == 'mirror':
|
|
371
|
+
dirname = target.get_output_subdir()
|
|
372
|
+
else:
|
|
373
|
+
dirname = 'meson-out'
|
|
374
|
+
return dirname
|
|
375
|
+
|
|
376
|
+
def get_target_dir_relative_to(self, t: build.Target, o: build.Target) -> str:
|
|
377
|
+
'''Get a target dir relative to another target's directory'''
|
|
378
|
+
target_dir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(t))
|
|
379
|
+
othert_dir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(o))
|
|
380
|
+
return os.path.relpath(target_dir, othert_dir)
|
|
381
|
+
|
|
382
|
+
def get_target_source_dir(self, target: build.Target) -> str:
|
|
383
|
+
# if target dir is empty, avoid extraneous trailing / from os.path.join()
|
|
384
|
+
target_dir = self.get_target_dir(target)
|
|
385
|
+
if target_dir:
|
|
386
|
+
return os.path.join(self.build_to_src, target_dir)
|
|
387
|
+
return self.build_to_src
|
|
388
|
+
|
|
389
|
+
def get_target_private_dir(self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]) -> str:
|
|
390
|
+
return os.path.join(self.get_target_filename(target, warn_multi_output=False) + '.p')
|
|
391
|
+
|
|
392
|
+
def get_target_private_dir_abs(self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]) -> str:
|
|
393
|
+
return os.path.join(self.environment.get_build_dir(), self.get_target_private_dir(target))
|
|
394
|
+
|
|
395
|
+
@lru_cache(maxsize=None)
|
|
396
|
+
def get_target_generated_dir(
|
|
397
|
+
self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex],
|
|
398
|
+
gensrc: T.Union[build.CustomTarget, build.CustomTargetIndex, build.GeneratedList],
|
|
399
|
+
src: str) -> str:
|
|
400
|
+
"""
|
|
401
|
+
Takes a BuildTarget, a generator source (CustomTarget or GeneratedList),
|
|
402
|
+
and a generated source filename.
|
|
403
|
+
Returns the full path of the generated source relative to the build root
|
|
404
|
+
"""
|
|
405
|
+
# CustomTarget generators output to the build dir of the CustomTarget
|
|
406
|
+
if isinstance(gensrc, (build.CustomTarget, build.CustomTargetIndex)):
|
|
407
|
+
return os.path.join(self.get_target_dir(gensrc), src)
|
|
408
|
+
# GeneratedList generators output to the private build directory of the
|
|
409
|
+
# target that the GeneratedList is used in
|
|
410
|
+
return os.path.join(self.get_target_private_dir(target), src)
|
|
411
|
+
|
|
412
|
+
def get_unity_source_file(self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex],
|
|
413
|
+
suffix: str, number: int) -> mesonlib.File:
|
|
414
|
+
# There is a potential conflict here, but it is unlikely that
|
|
415
|
+
# anyone both enables unity builds and has a file called foo-unity.cpp.
|
|
416
|
+
osrc = f'{target.name}-unity{number}.{suffix}'
|
|
417
|
+
return mesonlib.File.from_built_file(self.get_target_private_dir(target), osrc)
|
|
418
|
+
|
|
419
|
+
def generate_unity_files(self, target: build.BuildTarget, unity_src: str) -> T.List[mesonlib.File]:
|
|
420
|
+
abs_files: T.List[str] = []
|
|
421
|
+
result: T.List[mesonlib.File] = []
|
|
422
|
+
compsrcs = classify_unity_sources(target.compilers.values(), unity_src)
|
|
423
|
+
unity_size = target.get_option(OptionKey('unity_size'))
|
|
424
|
+
assert isinstance(unity_size, int), 'for mypy'
|
|
425
|
+
|
|
426
|
+
def init_language_file(suffix: str, unity_file_number: int) -> T.TextIO:
|
|
427
|
+
unity_src = self.get_unity_source_file(target, suffix, unity_file_number)
|
|
428
|
+
outfileabs = unity_src.absolute_path(self.environment.get_source_dir(),
|
|
429
|
+
self.environment.get_build_dir())
|
|
430
|
+
outfileabs_tmp = outfileabs + '.tmp'
|
|
431
|
+
abs_files.append(outfileabs)
|
|
432
|
+
outfileabs_tmp_dir = os.path.dirname(outfileabs_tmp)
|
|
433
|
+
if not os.path.exists(outfileabs_tmp_dir):
|
|
434
|
+
os.makedirs(outfileabs_tmp_dir)
|
|
435
|
+
result.append(unity_src)
|
|
436
|
+
return open(outfileabs_tmp, 'w', encoding='utf-8')
|
|
437
|
+
|
|
438
|
+
# For each language, generate unity source files and return the list
|
|
439
|
+
for comp, srcs in compsrcs.items():
|
|
440
|
+
files_in_current = unity_size + 1
|
|
441
|
+
unity_file_number = 0
|
|
442
|
+
# TODO: this could be simplified with an algorithm that pre-sorts
|
|
443
|
+
# the sources into the size of chunks we want
|
|
444
|
+
ofile = None
|
|
445
|
+
for src in srcs:
|
|
446
|
+
if files_in_current >= unity_size:
|
|
447
|
+
if ofile:
|
|
448
|
+
ofile.close()
|
|
449
|
+
ofile = init_language_file(comp.get_default_suffix(), unity_file_number)
|
|
450
|
+
unity_file_number += 1
|
|
451
|
+
files_in_current = 0
|
|
452
|
+
ofile.write(f'#include<{src}>\n')
|
|
453
|
+
files_in_current += 1
|
|
454
|
+
if ofile:
|
|
455
|
+
ofile.close()
|
|
456
|
+
|
|
457
|
+
for x in abs_files:
|
|
458
|
+
mesonlib.replace_if_different(x, x + '.tmp')
|
|
459
|
+
return result
|
|
460
|
+
|
|
461
|
+
@staticmethod
|
|
462
|
+
def relpath(todir: str, fromdir: str) -> str:
|
|
463
|
+
return os.path.relpath(os.path.join('dummyprefixdir', todir),
|
|
464
|
+
os.path.join('dummyprefixdir', fromdir))
|
|
465
|
+
|
|
466
|
+
def flatten_object_list(self, target: build.BuildTarget, proj_dir_to_build_root: str = ''
|
|
467
|
+
) -> T.Tuple[T.List[str], T.List[build.BuildTargetTypes]]:
|
|
468
|
+
obj_list, deps = self._flatten_object_list(target, target.get_objects(), proj_dir_to_build_root)
|
|
469
|
+
return list(dict.fromkeys(obj_list)), deps
|
|
470
|
+
|
|
471
|
+
def determine_ext_objs(self, objects: build.ExtractedObjects, proj_dir_to_build_root: str = '') -> T.List[str]:
|
|
472
|
+
obj_list, _ = self._flatten_object_list(objects.target, [objects], proj_dir_to_build_root)
|
|
473
|
+
return list(dict.fromkeys(obj_list))
|
|
474
|
+
|
|
475
|
+
def _flatten_object_list(self, target: build.BuildTarget,
|
|
476
|
+
objects: T.Sequence[T.Union[str, 'File', build.ExtractedObjects]],
|
|
477
|
+
proj_dir_to_build_root: str) -> T.Tuple[T.List[str], T.List[build.BuildTargetTypes]]:
|
|
478
|
+
obj_list: T.List[str] = []
|
|
479
|
+
deps: T.List[build.BuildTargetTypes] = []
|
|
480
|
+
for obj in objects:
|
|
481
|
+
if isinstance(obj, str):
|
|
482
|
+
o = os.path.join(proj_dir_to_build_root,
|
|
483
|
+
self.build_to_src, target.get_source_subdir(), obj)
|
|
484
|
+
obj_list.append(o)
|
|
485
|
+
elif isinstance(obj, mesonlib.File):
|
|
486
|
+
if obj.is_built:
|
|
487
|
+
o = os.path.join(proj_dir_to_build_root,
|
|
488
|
+
obj.rel_to_builddir(self.build_to_src))
|
|
489
|
+
obj_list.append(o)
|
|
490
|
+
else:
|
|
491
|
+
o = os.path.join(proj_dir_to_build_root,
|
|
492
|
+
self.build_to_src)
|
|
493
|
+
obj_list.append(obj.rel_to_builddir(o))
|
|
494
|
+
elif isinstance(obj, build.ExtractedObjects):
|
|
495
|
+
if obj.recursive:
|
|
496
|
+
objs, d = self._flatten_object_list(obj.target, obj.objlist, proj_dir_to_build_root)
|
|
497
|
+
obj_list.extend(objs)
|
|
498
|
+
deps.extend(d)
|
|
499
|
+
obj_list.extend(self._determine_ext_objs(obj, proj_dir_to_build_root))
|
|
500
|
+
deps.append(obj.target)
|
|
501
|
+
else:
|
|
502
|
+
raise MesonException('Unknown data type in object list.')
|
|
503
|
+
return obj_list, deps
|
|
504
|
+
|
|
505
|
+
@staticmethod
|
|
506
|
+
def is_swift_target(target: build.BuildTarget) -> bool:
|
|
507
|
+
for s in target.sources:
|
|
508
|
+
if isinstance(s, (str, File)) and s.endswith('swift'):
|
|
509
|
+
return True
|
|
510
|
+
return False
|
|
511
|
+
|
|
512
|
+
def determine_swift_dep_dirs(self, target: build.BuildTarget) -> T.List[str]:
|
|
513
|
+
result: T.List[str] = []
|
|
514
|
+
for l in target.link_targets:
|
|
515
|
+
result.append(self.get_target_private_dir_abs(l))
|
|
516
|
+
return result
|
|
517
|
+
|
|
518
|
+
def get_executable_serialisation(
|
|
519
|
+
self, cmd: T.Sequence[T.Union[programs.ExternalProgram, build.BuildTarget, build.CustomTarget, File, str]],
|
|
520
|
+
workdir: T.Optional[str] = None,
|
|
521
|
+
extra_bdeps: T.Optional[T.List[build.BuildTarget]] = None,
|
|
522
|
+
capture: T.Optional[str] = None,
|
|
523
|
+
feed: T.Optional[str] = None,
|
|
524
|
+
env: T.Optional[mesonlib.EnvironmentVariables] = None,
|
|
525
|
+
tag: T.Optional[str] = None,
|
|
526
|
+
verbose: bool = False,
|
|
527
|
+
installdir_map: T.Optional[T.Dict[str, str]] = None) -> 'ExecutableSerialisation':
|
|
528
|
+
|
|
529
|
+
# XXX: cmd_args either need to be lowered to strings, or need to be checked for non-string arguments, right?
|
|
530
|
+
exe, *raw_cmd_args = cmd
|
|
531
|
+
if isinstance(exe, programs.ExternalProgram):
|
|
532
|
+
exe_cmd = exe.get_command()
|
|
533
|
+
exe_for_machine = exe.for_machine
|
|
534
|
+
elif isinstance(exe, build.BuildTarget):
|
|
535
|
+
exe_cmd = [self.get_target_filename_abs(exe)]
|
|
536
|
+
exe_for_machine = exe.for_machine
|
|
537
|
+
elif isinstance(exe, build.CustomTarget):
|
|
538
|
+
# The output of a custom target can either be directly runnable
|
|
539
|
+
# or not, that is, a script, a native binary or a cross compiled
|
|
540
|
+
# binary when exe wrapper is available and when it is not.
|
|
541
|
+
# This implementation is not exhaustive but it works in the
|
|
542
|
+
# common cases.
|
|
543
|
+
exe_cmd = [self.get_target_filename_abs(exe)]
|
|
544
|
+
exe_for_machine = MachineChoice.BUILD
|
|
545
|
+
elif isinstance(exe, mesonlib.File):
|
|
546
|
+
exe_cmd = [exe.rel_to_builddir(self.environment.source_dir)]
|
|
547
|
+
exe_for_machine = MachineChoice.BUILD
|
|
548
|
+
else:
|
|
549
|
+
exe_cmd = [exe]
|
|
550
|
+
exe_for_machine = MachineChoice.BUILD
|
|
551
|
+
|
|
552
|
+
cmd_args: T.List[str] = []
|
|
553
|
+
for c in raw_cmd_args:
|
|
554
|
+
if isinstance(c, programs.ExternalProgram):
|
|
555
|
+
p = c.get_path()
|
|
556
|
+
assert isinstance(p, str)
|
|
557
|
+
cmd_args.append(p)
|
|
558
|
+
elif isinstance(c, (build.BuildTarget, build.CustomTarget)):
|
|
559
|
+
cmd_args.append(self.get_target_filename_abs(c))
|
|
560
|
+
elif isinstance(c, mesonlib.File):
|
|
561
|
+
cmd_args.append(c.rel_to_builddir(self.environment.source_dir))
|
|
562
|
+
else:
|
|
563
|
+
cmd_args.append(c)
|
|
564
|
+
|
|
565
|
+
machine = self.environment.machines[exe_for_machine]
|
|
566
|
+
if machine.is_windows() or machine.is_cygwin():
|
|
567
|
+
extra_paths = self.determine_windows_extra_paths(exe, extra_bdeps or [])
|
|
568
|
+
else:
|
|
569
|
+
extra_paths = []
|
|
570
|
+
|
|
571
|
+
if self.environment.need_exe_wrapper(exe_for_machine):
|
|
572
|
+
if not self.environment.has_exe_wrapper():
|
|
573
|
+
msg = 'An exe_wrapper is needed but was not found. Please define one ' \
|
|
574
|
+
'in cross file and check the command and/or add it to PATH.'
|
|
575
|
+
raise MesonException(msg)
|
|
576
|
+
exe_wrapper = self.environment.get_exe_wrapper()
|
|
577
|
+
else:
|
|
578
|
+
if exe_cmd[0].endswith('.jar'):
|
|
579
|
+
exe_cmd = ['java', '-jar'] + exe_cmd
|
|
580
|
+
elif exe_cmd[0].endswith('.exe') and not (mesonlib.is_windows() or mesonlib.is_cygwin() or mesonlib.is_wsl()):
|
|
581
|
+
exe_cmd = ['mono'] + exe_cmd
|
|
582
|
+
exe_wrapper = None
|
|
583
|
+
|
|
584
|
+
workdir = workdir or self.environment.get_build_dir()
|
|
585
|
+
return ExecutableSerialisation(exe_cmd + cmd_args, env,
|
|
586
|
+
exe_wrapper, workdir,
|
|
587
|
+
extra_paths, capture, feed, tag, verbose, installdir_map)
|
|
588
|
+
|
|
589
|
+
def as_meson_exe_cmdline(self, exe: T.Union[str, mesonlib.File, build.BuildTarget, build.CustomTarget, programs.ExternalProgram],
|
|
590
|
+
cmd_args: T.Sequence[T.Union[str, mesonlib.File, build.BuildTarget, build.CustomTarget, programs.ExternalProgram]],
|
|
591
|
+
workdir: T.Optional[str] = None,
|
|
592
|
+
extra_bdeps: T.Optional[T.List[build.BuildTarget]] = None,
|
|
593
|
+
capture: T.Optional[str] = None,
|
|
594
|
+
feed: T.Optional[str] = None,
|
|
595
|
+
force_serialize: bool = False,
|
|
596
|
+
env: T.Optional[mesonlib.EnvironmentVariables] = None,
|
|
597
|
+
verbose: bool = False) -> T.Tuple[T.Sequence[T.Union[str, File, build.Target, programs.ExternalProgram]], str]:
|
|
598
|
+
'''
|
|
599
|
+
Serialize an executable for running with a generator or a custom target
|
|
600
|
+
'''
|
|
601
|
+
cmd: T.List[T.Union[str, mesonlib.File, build.BuildTarget, build.CustomTarget, programs.ExternalProgram]] = []
|
|
602
|
+
cmd.append(exe)
|
|
603
|
+
cmd.extend(cmd_args)
|
|
604
|
+
es = self.get_executable_serialisation(cmd, workdir, extra_bdeps, capture, feed, env, verbose=verbose)
|
|
605
|
+
reasons: T.List[str] = []
|
|
606
|
+
if es.extra_paths:
|
|
607
|
+
reasons.append('to set PATH')
|
|
608
|
+
|
|
609
|
+
if es.exe_wrapper:
|
|
610
|
+
reasons.append('to use exe_wrapper')
|
|
611
|
+
|
|
612
|
+
if workdir:
|
|
613
|
+
reasons.append('to set workdir')
|
|
614
|
+
|
|
615
|
+
if any('\n' in c for c in es.cmd_args):
|
|
616
|
+
reasons.append('because command contains newlines')
|
|
617
|
+
|
|
618
|
+
if env and env.varnames:
|
|
619
|
+
reasons.append('to set env')
|
|
620
|
+
|
|
621
|
+
# force_serialize passed to this function means that the VS backend has
|
|
622
|
+
# decided it absolutely cannot use real commands. This is "always",
|
|
623
|
+
# because it's not clear what will work (other than compilers) and so
|
|
624
|
+
# we don't bother to handle a variety of common cases that probably do
|
|
625
|
+
# work.
|
|
626
|
+
#
|
|
627
|
+
# It's also overridden for a few conditions that can't be handled
|
|
628
|
+
# inside a command line
|
|
629
|
+
|
|
630
|
+
can_use_env = not force_serialize
|
|
631
|
+
force_serialize = force_serialize or bool(reasons)
|
|
632
|
+
|
|
633
|
+
if capture:
|
|
634
|
+
reasons.append('to capture output')
|
|
635
|
+
if feed:
|
|
636
|
+
reasons.append('to feed input')
|
|
637
|
+
|
|
638
|
+
if can_use_env and reasons == ['to set env'] and shutil.which('env'):
|
|
639
|
+
envlist = []
|
|
640
|
+
for k, v in env.get_env({}).items():
|
|
641
|
+
envlist.append(f'{k}={v}')
|
|
642
|
+
return ['env'] + envlist + es.cmd_args, ', '.join(reasons)
|
|
643
|
+
|
|
644
|
+
if not force_serialize:
|
|
645
|
+
if not capture and not feed:
|
|
646
|
+
return es.cmd_args, ''
|
|
647
|
+
args: T.List[str] = []
|
|
648
|
+
if capture:
|
|
649
|
+
args += ['--capture', capture]
|
|
650
|
+
if feed:
|
|
651
|
+
args += ['--feed', feed]
|
|
652
|
+
|
|
653
|
+
return (
|
|
654
|
+
self.environment.get_build_command() + ['--internal', 'exe'] + args + ['--'] + es.cmd_args,
|
|
655
|
+
', '.join(reasons)
|
|
656
|
+
)
|
|
657
|
+
|
|
658
|
+
if isinstance(exe, (programs.ExternalProgram,
|
|
659
|
+
build.BuildTarget, build.CustomTarget)):
|
|
660
|
+
basename = os.path.basename(exe.name)
|
|
661
|
+
elif isinstance(exe, mesonlib.File):
|
|
662
|
+
basename = os.path.basename(exe.fname)
|
|
663
|
+
else:
|
|
664
|
+
basename = os.path.basename(exe)
|
|
665
|
+
|
|
666
|
+
# Can't just use exe.name here; it will likely be run more than once
|
|
667
|
+
# Take a digest of the cmd args, env, workdir, capture, and feed. This
|
|
668
|
+
# avoids collisions and also makes the name deterministic over
|
|
669
|
+
# regenerations which avoids a rebuild by Ninja because the cmdline
|
|
670
|
+
# stays the same.
|
|
671
|
+
hasher = hashlib.sha1()
|
|
672
|
+
if es.env:
|
|
673
|
+
es.env.hash(hasher)
|
|
674
|
+
hasher.update(bytes(str(es.cmd_args), encoding='utf-8'))
|
|
675
|
+
hasher.update(bytes(str(es.workdir), encoding='utf-8'))
|
|
676
|
+
hasher.update(bytes(str(capture), encoding='utf-8'))
|
|
677
|
+
hasher.update(bytes(str(feed), encoding='utf-8'))
|
|
678
|
+
digest = hasher.hexdigest()
|
|
679
|
+
scratch_file = f'meson_exe_{basename}_{digest}.dat'
|
|
680
|
+
exe_data = os.path.join(self.environment.get_scratch_dir(), scratch_file)
|
|
681
|
+
with open(exe_data, 'wb') as f:
|
|
682
|
+
pickle.dump(es, f)
|
|
683
|
+
return (self.environment.get_build_command() + ['--internal', 'exe', '--unpickle', exe_data],
|
|
684
|
+
', '.join(reasons))
|
|
685
|
+
|
|
686
|
+
def serialize_tests(self) -> T.Tuple[str, str]:
|
|
687
|
+
test_data = os.path.join(self.environment.get_scratch_dir(), 'meson_test_setup.dat')
|
|
688
|
+
with open(test_data, 'wb') as datafile:
|
|
689
|
+
self.write_test_file(datafile)
|
|
690
|
+
benchmark_data = os.path.join(self.environment.get_scratch_dir(), 'meson_benchmark_setup.dat')
|
|
691
|
+
with open(benchmark_data, 'wb') as datafile:
|
|
692
|
+
self.write_benchmark_file(datafile)
|
|
693
|
+
return test_data, benchmark_data
|
|
694
|
+
|
|
695
|
+
def determine_linker_and_stdlib_args(self, target: build.BuildTarget) -> T.Tuple[T.Union['Compiler', 'StaticLinker'], T.List[str]]:
|
|
696
|
+
'''
|
|
697
|
+
If we're building a static library, there is only one static linker.
|
|
698
|
+
Otherwise, we query the target for the dynamic linker.
|
|
699
|
+
'''
|
|
700
|
+
if isinstance(target, build.StaticLibrary):
|
|
701
|
+
return self.build.static_linker[target.for_machine], []
|
|
702
|
+
l, stdlib_args = target.get_clink_dynamic_linker_and_stdlibs()
|
|
703
|
+
return l, stdlib_args
|
|
704
|
+
|
|
705
|
+
@staticmethod
|
|
706
|
+
def _libdir_is_system(libdir: str, compilers: T.Mapping[str, 'Compiler'], env: 'Environment') -> bool:
|
|
707
|
+
libdir = os.path.normpath(libdir)
|
|
708
|
+
for cc in compilers.values():
|
|
709
|
+
if libdir in cc.get_library_dirs(env):
|
|
710
|
+
return True
|
|
711
|
+
return False
|
|
712
|
+
|
|
713
|
+
def get_external_rpath_dirs(self, target: build.BuildTarget) -> T.Set[str]:
|
|
714
|
+
args: T.List[str] = []
|
|
715
|
+
for lang in LANGUAGES_USING_LDFLAGS:
|
|
716
|
+
try:
|
|
717
|
+
e = self.environment.coredata.get_external_link_args(target.for_machine, lang)
|
|
718
|
+
if isinstance(e, str):
|
|
719
|
+
args.append(e)
|
|
720
|
+
else:
|
|
721
|
+
args.extend(e)
|
|
722
|
+
except Exception:
|
|
723
|
+
pass
|
|
724
|
+
return self.get_rpath_dirs_from_link_args(args)
|
|
725
|
+
|
|
726
|
+
@staticmethod
|
|
727
|
+
def get_rpath_dirs_from_link_args(args: T.List[str]) -> T.Set[str]:
|
|
728
|
+
dirs: T.Set[str] = set()
|
|
729
|
+
# Match rpath formats:
|
|
730
|
+
# -Wl,-rpath=
|
|
731
|
+
# -Wl,-rpath,
|
|
732
|
+
rpath_regex = re.compile(r'-Wl,-rpath[=,]([^,]+)')
|
|
733
|
+
# Match solaris style compat runpath formats:
|
|
734
|
+
# -Wl,-R
|
|
735
|
+
# -Wl,-R,
|
|
736
|
+
runpath_regex = re.compile(r'-Wl,-R[,]?([^,]+)')
|
|
737
|
+
# Match symbols formats:
|
|
738
|
+
# -Wl,--just-symbols=
|
|
739
|
+
# -Wl,--just-symbols,
|
|
740
|
+
symbols_regex = re.compile(r'-Wl,--just-symbols[=,]([^,]+)')
|
|
741
|
+
for arg in args:
|
|
742
|
+
rpath_match = rpath_regex.match(arg)
|
|
743
|
+
if rpath_match:
|
|
744
|
+
for dir in rpath_match.group(1).split(':'):
|
|
745
|
+
dirs.add(dir)
|
|
746
|
+
runpath_match = runpath_regex.match(arg)
|
|
747
|
+
if runpath_match:
|
|
748
|
+
for dir in runpath_match.group(1).split(':'):
|
|
749
|
+
# The symbols arg is an rpath if the path is a directory
|
|
750
|
+
if Path(dir).is_dir():
|
|
751
|
+
dirs.add(dir)
|
|
752
|
+
symbols_match = symbols_regex.match(arg)
|
|
753
|
+
if symbols_match:
|
|
754
|
+
for dir in symbols_match.group(1).split(':'):
|
|
755
|
+
# Prevent usage of --just-symbols to specify rpath
|
|
756
|
+
if Path(dir).is_dir():
|
|
757
|
+
raise MesonException(f'Invalid arg for --just-symbols, {dir} is a directory.')
|
|
758
|
+
return dirs
|
|
759
|
+
|
|
760
|
+
@lru_cache(maxsize=None)
|
|
761
|
+
def rpaths_for_non_system_absolute_shared_libraries(self, target: build.BuildTarget, exclude_system: bool = True) -> 'ImmutableListProtocol[str]':
|
|
762
|
+
paths: OrderedSet[str] = OrderedSet()
|
|
763
|
+
srcdir = self.environment.get_source_dir()
|
|
764
|
+
|
|
765
|
+
for dep in target.external_deps:
|
|
766
|
+
if dep.type_name not in {'library', 'pkgconfig', 'cmake'}:
|
|
767
|
+
continue
|
|
768
|
+
for libpath in dep.link_args:
|
|
769
|
+
# For all link args that are absolute paths to a library file, add RPATH args
|
|
770
|
+
if not os.path.isabs(libpath):
|
|
771
|
+
continue
|
|
772
|
+
libdir = os.path.dirname(libpath)
|
|
773
|
+
if exclude_system and self._libdir_is_system(libdir, target.compilers, self.environment):
|
|
774
|
+
# No point in adding system paths.
|
|
775
|
+
continue
|
|
776
|
+
# Don't remove rpaths specified in LDFLAGS.
|
|
777
|
+
if libdir in self.get_external_rpath_dirs(target):
|
|
778
|
+
continue
|
|
779
|
+
# Windows doesn't support rpaths, but we use this function to
|
|
780
|
+
# emulate rpaths by setting PATH
|
|
781
|
+
# .dll is there for mingw gcc
|
|
782
|
+
# .so's may be extended with version information, e.g. libxyz.so.1.2.3
|
|
783
|
+
if not (
|
|
784
|
+
os.path.splitext(libpath)[1] in {'.dll', '.lib', '.so', '.dylib'}
|
|
785
|
+
or re.match(r'.+\.so(\.|$)', os.path.basename(libpath))
|
|
786
|
+
):
|
|
787
|
+
continue
|
|
788
|
+
|
|
789
|
+
try:
|
|
790
|
+
commonpath = os.path.commonpath((libdir, srcdir))
|
|
791
|
+
except ValueError: # when paths are on different drives on Windows
|
|
792
|
+
commonpath = ''
|
|
793
|
+
|
|
794
|
+
if commonpath == srcdir:
|
|
795
|
+
rel_to_src = libdir[len(srcdir) + 1:]
|
|
796
|
+
assert not os.path.isabs(rel_to_src), f'rel_to_src: {rel_to_src} is absolute'
|
|
797
|
+
paths.add(os.path.join(self.build_to_src, rel_to_src))
|
|
798
|
+
else:
|
|
799
|
+
paths.add(libdir)
|
|
800
|
+
# Don't remove rpaths specified by the dependency
|
|
801
|
+
paths.difference_update(self.get_rpath_dirs_from_link_args(dep.link_args))
|
|
802
|
+
for i in chain(target.link_targets, target.link_whole_targets):
|
|
803
|
+
if isinstance(i, build.BuildTarget):
|
|
804
|
+
paths.update(self.rpaths_for_non_system_absolute_shared_libraries(i, exclude_system))
|
|
805
|
+
return list(paths)
|
|
806
|
+
|
|
807
|
+
# This may take other types
|
|
808
|
+
def determine_rpath_dirs(self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]
|
|
809
|
+
) -> T.Tuple[str, ...]:
|
|
810
|
+
result: OrderedSet[str]
|
|
811
|
+
if self.environment.coredata.get_option(OptionKey('layout')) == 'mirror':
|
|
812
|
+
# Need a copy here
|
|
813
|
+
result = OrderedSet(target.get_link_dep_subdirs())
|
|
814
|
+
else:
|
|
815
|
+
result = OrderedSet()
|
|
816
|
+
result.add('meson-out')
|
|
817
|
+
if isinstance(target, build.BuildTarget):
|
|
818
|
+
result.update(self.rpaths_for_non_system_absolute_shared_libraries(target))
|
|
819
|
+
target.rpath_dirs_to_remove.update([d.encode('utf-8') for d in result])
|
|
820
|
+
return tuple(result)
|
|
821
|
+
|
|
822
|
+
@staticmethod
|
|
823
|
+
def canonicalize_filename(fname: str) -> str:
|
|
824
|
+
parts = Path(fname).parts
|
|
825
|
+
hashed = ''
|
|
826
|
+
if len(parts) > 5:
|
|
827
|
+
temp = '/'.join(parts[-5:])
|
|
828
|
+
# is it shorter to hash the beginning of the path?
|
|
829
|
+
if len(fname) > len(temp) + 41:
|
|
830
|
+
hashed = hashlib.sha1(fname.encode('utf-8')).hexdigest() + '_'
|
|
831
|
+
fname = temp
|
|
832
|
+
for ch in ('/', '\\', ':'):
|
|
833
|
+
fname = fname.replace(ch, '_')
|
|
834
|
+
return hashed + fname
|
|
835
|
+
|
|
836
|
+
def object_filename_from_source(self, target: build.BuildTarget, source: 'FileOrString', targetdir: T.Optional[str] = None) -> str:
|
|
837
|
+
assert isinstance(source, mesonlib.File)
|
|
838
|
+
if isinstance(target, build.CompileTarget):
|
|
839
|
+
return target.sources_map[source]
|
|
840
|
+
build_dir = self.environment.get_build_dir()
|
|
841
|
+
rel_src = source.rel_to_builddir(self.build_to_src)
|
|
842
|
+
|
|
843
|
+
# foo.vala files compile down to foo.c and then foo.c.o, not foo.vala.o
|
|
844
|
+
if rel_src.endswith(('.vala', '.gs')):
|
|
845
|
+
# See description in generate_vala_compile for this logic.
|
|
846
|
+
if source.is_built:
|
|
847
|
+
if os.path.isabs(rel_src):
|
|
848
|
+
rel_src = rel_src[len(build_dir) + 1:]
|
|
849
|
+
rel_src = os.path.relpath(rel_src, self.get_target_private_dir(target))
|
|
850
|
+
else:
|
|
851
|
+
rel_src = os.path.basename(rel_src)
|
|
852
|
+
# A meson- prefixed directory is reserved; hopefully no-one creates a file name with such a weird prefix.
|
|
853
|
+
gen_source = 'meson-generated_' + rel_src[:-5] + '.c'
|
|
854
|
+
elif source.is_built:
|
|
855
|
+
if os.path.isabs(rel_src):
|
|
856
|
+
rel_src = rel_src[len(build_dir) + 1:]
|
|
857
|
+
# A meson- prefixed directory is reserved; hopefully no-one creates a file name with such a weird prefix.
|
|
858
|
+
gen_source = 'meson-generated_' + os.path.relpath(rel_src, self.get_target_private_dir(target))
|
|
859
|
+
else:
|
|
860
|
+
if os.path.isabs(rel_src):
|
|
861
|
+
# Use the absolute path directly to avoid file name conflicts
|
|
862
|
+
gen_source = rel_src
|
|
863
|
+
else:
|
|
864
|
+
gen_source = os.path.relpath(os.path.join(build_dir, rel_src),
|
|
865
|
+
os.path.join(self.environment.get_source_dir(), target.get_source_subdir()))
|
|
866
|
+
machine = self.environment.machines[target.for_machine]
|
|
867
|
+
ret = self.canonicalize_filename(gen_source) + '.' + machine.get_object_suffix()
|
|
868
|
+
if targetdir is not None:
|
|
869
|
+
return os.path.join(targetdir, ret)
|
|
870
|
+
return ret
|
|
871
|
+
|
|
872
|
+
def _determine_ext_objs(self, extobj: 'build.ExtractedObjects', proj_dir_to_build_root: str) -> T.List[str]:
|
|
873
|
+
result: T.List[str] = []
|
|
874
|
+
|
|
875
|
+
targetdir = self.get_target_private_dir(extobj.target)
|
|
876
|
+
|
|
877
|
+
# Merge sources and generated sources
|
|
878
|
+
raw_sources = list(extobj.srclist)
|
|
879
|
+
for gensrc in extobj.genlist:
|
|
880
|
+
for r in gensrc.get_outputs():
|
|
881
|
+
path = self.get_target_generated_dir(extobj.target, gensrc, r)
|
|
882
|
+
dirpart, fnamepart = os.path.split(path)
|
|
883
|
+
raw_sources.append(File(True, dirpart, fnamepart))
|
|
884
|
+
|
|
885
|
+
# Filter out headers and all non-source files
|
|
886
|
+
sources: T.List['FileOrString'] = []
|
|
887
|
+
for s in raw_sources:
|
|
888
|
+
if self.environment.is_source(s):
|
|
889
|
+
sources.append(s)
|
|
890
|
+
elif self.environment.is_object(s):
|
|
891
|
+
result.append(s.relative_name())
|
|
892
|
+
|
|
893
|
+
# MSVC generate an object file for PCH
|
|
894
|
+
if extobj.pch and self.target_uses_pch(extobj.target):
|
|
895
|
+
for lang, pch in extobj.target.pch.items():
|
|
896
|
+
compiler = extobj.target.compilers[lang]
|
|
897
|
+
if compiler.get_argument_syntax() == 'msvc':
|
|
898
|
+
objname = self.get_msvc_pch_objname(lang, pch)
|
|
899
|
+
result.append(os.path.join(proj_dir_to_build_root, targetdir, objname))
|
|
900
|
+
|
|
901
|
+
# extobj could contain only objects and no sources
|
|
902
|
+
if not sources:
|
|
903
|
+
return result
|
|
904
|
+
|
|
905
|
+
# With unity builds, sources don't map directly to objects,
|
|
906
|
+
# we only support extracting all the objects in this mode,
|
|
907
|
+
# so just return all object files.
|
|
908
|
+
if extobj.target.is_unity:
|
|
909
|
+
compsrcs = classify_unity_sources(extobj.target.compilers.values(), sources)
|
|
910
|
+
sources = []
|
|
911
|
+
unity_size = extobj.target.get_option(OptionKey('unity_size'))
|
|
912
|
+
assert isinstance(unity_size, int), 'for mypy'
|
|
913
|
+
|
|
914
|
+
for comp, srcs in compsrcs.items():
|
|
915
|
+
if comp.language in LANGS_CANT_UNITY:
|
|
916
|
+
sources += srcs
|
|
917
|
+
continue
|
|
918
|
+
for i in range((len(srcs) + unity_size - 1) // unity_size):
|
|
919
|
+
_src = self.get_unity_source_file(extobj.target,
|
|
920
|
+
comp.get_default_suffix(), i)
|
|
921
|
+
sources.append(_src)
|
|
922
|
+
|
|
923
|
+
for osrc in sources:
|
|
924
|
+
objname = self.object_filename_from_source(extobj.target, osrc, targetdir)
|
|
925
|
+
objpath = os.path.join(proj_dir_to_build_root, objname)
|
|
926
|
+
result.append(objpath)
|
|
927
|
+
|
|
928
|
+
return result
|
|
929
|
+
|
|
930
|
+
def get_pch_include_args(self, compiler: 'Compiler', target: build.BuildTarget) -> T.List[str]:
|
|
931
|
+
args: T.List[str] = []
|
|
932
|
+
pchpath = self.get_target_private_dir(target)
|
|
933
|
+
includeargs = compiler.get_include_args(pchpath, False)
|
|
934
|
+
p = target.get_pch(compiler.get_language())
|
|
935
|
+
if p:
|
|
936
|
+
args += compiler.get_pch_use_args(pchpath, p[0])
|
|
937
|
+
return includeargs + args
|
|
938
|
+
|
|
939
|
+
def get_msvc_pch_objname(self, lang: str, pch: T.List[str]) -> str:
|
|
940
|
+
if len(pch) == 1:
|
|
941
|
+
# Same name as in create_msvc_pch_implementation() below.
|
|
942
|
+
return f'meson_pch-{lang}.obj'
|
|
943
|
+
return os.path.splitext(pch[1])[0] + '.obj'
|
|
944
|
+
|
|
945
|
+
def create_msvc_pch_implementation(self, target: build.BuildTarget, lang: str, pch_header: str) -> str:
|
|
946
|
+
# We have to include the language in the file name, otherwise
|
|
947
|
+
# pch.c and pch.cpp will both end up as pch.obj in VS backends.
|
|
948
|
+
impl_name = f'meson_pch-{lang}.{lang}'
|
|
949
|
+
pch_rel_to_build = os.path.join(self.get_target_private_dir(target), impl_name)
|
|
950
|
+
# Make sure to prepend the build dir, since the working directory is
|
|
951
|
+
# not defined. Otherwise, we might create the file in the wrong path.
|
|
952
|
+
pch_file = os.path.join(self.build_dir, pch_rel_to_build)
|
|
953
|
+
os.makedirs(os.path.dirname(pch_file), exist_ok=True)
|
|
954
|
+
|
|
955
|
+
content = f'#include "{os.path.basename(pch_header)}"'
|
|
956
|
+
pch_file_tmp = pch_file + '.tmp'
|
|
957
|
+
with open(pch_file_tmp, 'w', encoding='utf-8') as f:
|
|
958
|
+
f.write(content)
|
|
959
|
+
mesonlib.replace_if_different(pch_file, pch_file_tmp)
|
|
960
|
+
return pch_rel_to_build
|
|
961
|
+
|
|
962
|
+
def target_uses_pch(self, target: build.BuildTarget) -> bool:
|
|
963
|
+
try:
|
|
964
|
+
return T.cast('bool', target.get_option(OptionKey('b_pch')))
|
|
965
|
+
except KeyError:
|
|
966
|
+
return False
|
|
967
|
+
|
|
968
|
+
@staticmethod
|
|
969
|
+
def escape_extra_args(args: T.List[str]) -> T.List[str]:
|
|
970
|
+
# all backslashes in defines are doubly-escaped
|
|
971
|
+
extra_args: T.List[str] = []
|
|
972
|
+
for arg in args:
|
|
973
|
+
if arg.startswith(('-D', '/D')):
|
|
974
|
+
arg = arg.replace('\\', '\\\\')
|
|
975
|
+
extra_args.append(arg)
|
|
976
|
+
|
|
977
|
+
return extra_args
|
|
978
|
+
|
|
979
|
+
def get_no_stdlib_args(self, target: 'build.BuildTarget', compiler: 'Compiler') -> T.List[str]:
|
|
980
|
+
if compiler.language in self.build.stdlibs[target.for_machine]:
|
|
981
|
+
return compiler.get_no_stdinc_args()
|
|
982
|
+
return []
|
|
983
|
+
|
|
984
|
+
def generate_basic_compiler_args(self, target: build.BuildTarget, compiler: 'Compiler') -> 'CompilerArgs':
|
|
985
|
+
# Create an empty commands list, and start adding arguments from
|
|
986
|
+
# various sources in the order in which they must override each other
|
|
987
|
+
# starting from hard-coded defaults followed by build options and so on.
|
|
988
|
+
commands = compiler.compiler_args()
|
|
989
|
+
|
|
990
|
+
copt_proxy = target.get_options()
|
|
991
|
+
# First, the trivial ones that are impossible to override.
|
|
992
|
+
#
|
|
993
|
+
# Add -nostdinc/-nostdinc++ if needed; can't be overridden
|
|
994
|
+
commands += self.get_no_stdlib_args(target, compiler)
|
|
995
|
+
# Add things like /NOLOGO or -pipe; usually can't be overridden
|
|
996
|
+
commands += compiler.get_always_args()
|
|
997
|
+
# warning_level is a string, but mypy can't determine that
|
|
998
|
+
commands += compiler.get_warn_args(T.cast('str', target.get_option(OptionKey('warning_level'))))
|
|
999
|
+
# Add -Werror if werror=true is set in the build options set on the
|
|
1000
|
+
# command-line or default_options inside project(). This only sets the
|
|
1001
|
+
# action to be done for warnings if/when they are emitted, so it's ok
|
|
1002
|
+
# to set it after or get_warn_args().
|
|
1003
|
+
if target.get_option(OptionKey('werror')):
|
|
1004
|
+
commands += compiler.get_werror_args()
|
|
1005
|
+
# Add compile args for c_* or cpp_* build options set on the
|
|
1006
|
+
# command-line or default_options inside project().
|
|
1007
|
+
commands += compiler.get_option_compile_args(copt_proxy)
|
|
1008
|
+
|
|
1009
|
+
optimization = target.get_option(OptionKey('optimization'))
|
|
1010
|
+
assert isinstance(optimization, str), 'for mypy'
|
|
1011
|
+
commands += compiler.get_optimization_args(optimization)
|
|
1012
|
+
|
|
1013
|
+
debug = target.get_option(OptionKey('debug'))
|
|
1014
|
+
assert isinstance(debug, bool), 'for mypy'
|
|
1015
|
+
commands += compiler.get_debug_args(debug)
|
|
1016
|
+
|
|
1017
|
+
# Add compile args added using add_project_arguments()
|
|
1018
|
+
commands += self.build.get_project_args(compiler, target.subproject, target.for_machine)
|
|
1019
|
+
# Add compile args added using add_global_arguments()
|
|
1020
|
+
# These override per-project arguments
|
|
1021
|
+
commands += self.build.get_global_args(compiler, target.for_machine)
|
|
1022
|
+
# Compile args added from the env: CFLAGS/CXXFLAGS, etc, or the cross
|
|
1023
|
+
# file. We want these to override all the defaults, but not the
|
|
1024
|
+
# per-target compile args.
|
|
1025
|
+
commands += self.environment.coredata.get_external_args(target.for_machine, compiler.get_language())
|
|
1026
|
+
# Using both /Z7 or /ZI and /Zi at the same times produces a compiler warning.
|
|
1027
|
+
# We do not add /Z7 or /ZI by default. If it is being used it is because the user has explicitly enabled it.
|
|
1028
|
+
# /Zi needs to be removed in that case to avoid cl's warning to that effect (D9025 : overriding '/Zi' with '/ZI')
|
|
1029
|
+
if ('/Zi' in commands) and (('/ZI' in commands) or ('/Z7' in commands)):
|
|
1030
|
+
commands.remove('/Zi')
|
|
1031
|
+
# Always set -fPIC for shared libraries
|
|
1032
|
+
if isinstance(target, build.SharedLibrary):
|
|
1033
|
+
commands += compiler.get_pic_args()
|
|
1034
|
+
# Set -fPIC for static libraries by default unless explicitly disabled
|
|
1035
|
+
if isinstance(target, build.StaticLibrary) and target.pic:
|
|
1036
|
+
commands += compiler.get_pic_args()
|
|
1037
|
+
elif isinstance(target, (build.StaticLibrary, build.Executable)) and target.pie:
|
|
1038
|
+
commands += compiler.get_pie_args()
|
|
1039
|
+
# Add compile args needed to find external dependencies. Link args are
|
|
1040
|
+
# added while generating the link command.
|
|
1041
|
+
# NOTE: We must preserve the order in which external deps are
|
|
1042
|
+
# specified, so we reverse the list before iterating over it.
|
|
1043
|
+
for dep in reversed(target.get_external_deps()):
|
|
1044
|
+
if not dep.found():
|
|
1045
|
+
continue
|
|
1046
|
+
|
|
1047
|
+
if compiler.language == 'vala':
|
|
1048
|
+
if dep.type_name == 'pkgconfig':
|
|
1049
|
+
assert isinstance(dep, dependencies.ExternalDependency)
|
|
1050
|
+
if dep.name == 'glib-2.0' and dep.version_reqs is not None:
|
|
1051
|
+
for req in dep.version_reqs:
|
|
1052
|
+
if req.startswith(('>=', '==')):
|
|
1053
|
+
commands += ['--target-glib', req[2:].lstrip()]
|
|
1054
|
+
break
|
|
1055
|
+
commands += ['--pkg', dep.name]
|
|
1056
|
+
elif isinstance(dep, dependencies.ExternalLibrary):
|
|
1057
|
+
commands += dep.get_link_args('vala')
|
|
1058
|
+
else:
|
|
1059
|
+
commands += compiler.get_dependency_compile_args(dep)
|
|
1060
|
+
# Qt needs -fPIC for executables
|
|
1061
|
+
# XXX: We should move to -fPIC for all executables
|
|
1062
|
+
if isinstance(target, build.Executable):
|
|
1063
|
+
commands += dep.get_exe_args(compiler)
|
|
1064
|
+
# For 'automagic' deps: Boost and GTest. Also dependency('threads').
|
|
1065
|
+
# pkg-config puts the thread flags itself via `Cflags:`
|
|
1066
|
+
# Fortran requires extra include directives.
|
|
1067
|
+
if compiler.language == 'fortran':
|
|
1068
|
+
for lt in chain(target.link_targets, target.link_whole_targets):
|
|
1069
|
+
priv_dir = self.get_target_private_dir(lt)
|
|
1070
|
+
commands += compiler.get_include_args(priv_dir, False)
|
|
1071
|
+
return commands
|
|
1072
|
+
|
|
1073
|
+
def build_target_link_arguments(self, compiler: 'Compiler', deps: T.List[build.Target]) -> T.List[str]:
|
|
1074
|
+
args: T.List[str] = []
|
|
1075
|
+
for d in deps:
|
|
1076
|
+
if not d.is_linkable_target():
|
|
1077
|
+
raise RuntimeError(f'Tried to link with a non-library target "{d.get_basename()}".')
|
|
1078
|
+
arg = self.get_target_filename_for_linking(d)
|
|
1079
|
+
if not arg:
|
|
1080
|
+
continue
|
|
1081
|
+
if compiler.get_language() == 'd':
|
|
1082
|
+
arg = '-Wl,' + arg
|
|
1083
|
+
else:
|
|
1084
|
+
arg = compiler.get_linker_lib_prefix() + arg
|
|
1085
|
+
args.append(arg)
|
|
1086
|
+
return args
|
|
1087
|
+
|
|
1088
|
+
def get_mingw_extra_paths(self, target: build.BuildTarget) -> T.List[str]:
|
|
1089
|
+
paths: OrderedSet[str] = OrderedSet()
|
|
1090
|
+
# The cross bindir
|
|
1091
|
+
root = self.environment.properties[target.for_machine].get_root()
|
|
1092
|
+
if root:
|
|
1093
|
+
paths.add(os.path.join(root, 'bin'))
|
|
1094
|
+
# The toolchain bindir
|
|
1095
|
+
sys_root = self.environment.properties[target.for_machine].get_sys_root()
|
|
1096
|
+
if sys_root:
|
|
1097
|
+
paths.add(os.path.join(sys_root, 'bin'))
|
|
1098
|
+
# Get program and library dirs from all target compilers
|
|
1099
|
+
if isinstance(target, build.BuildTarget):
|
|
1100
|
+
for cc in target.compilers.values():
|
|
1101
|
+
paths.update(cc.get_program_dirs(self.environment))
|
|
1102
|
+
paths.update(cc.get_library_dirs(self.environment))
|
|
1103
|
+
return list(paths)
|
|
1104
|
+
|
|
1105
|
+
@staticmethod
|
|
1106
|
+
@lru_cache(maxsize=None)
|
|
1107
|
+
def search_dll_path(link_arg: str) -> T.Optional[str]:
|
|
1108
|
+
if link_arg.startswith(('-l', '-L')):
|
|
1109
|
+
link_arg = link_arg[2:]
|
|
1110
|
+
|
|
1111
|
+
p = Path(link_arg)
|
|
1112
|
+
if not p.is_absolute():
|
|
1113
|
+
return None
|
|
1114
|
+
|
|
1115
|
+
try:
|
|
1116
|
+
p = p.resolve(strict=True)
|
|
1117
|
+
except FileNotFoundError:
|
|
1118
|
+
return None
|
|
1119
|
+
|
|
1120
|
+
for f in p.parent.glob('*.dll'):
|
|
1121
|
+
# path contains dlls
|
|
1122
|
+
return str(p.parent)
|
|
1123
|
+
|
|
1124
|
+
if p.is_file():
|
|
1125
|
+
p = p.parent
|
|
1126
|
+
# Heuristic: replace *last* occurence of '/lib'
|
|
1127
|
+
binpath = Path('/bin'.join(p.as_posix().rsplit('/lib', maxsplit=1)))
|
|
1128
|
+
for _ in binpath.glob('*.dll'):
|
|
1129
|
+
return str(binpath)
|
|
1130
|
+
|
|
1131
|
+
return None
|
|
1132
|
+
|
|
1133
|
+
@classmethod
|
|
1134
|
+
@lru_cache(maxsize=None)
|
|
1135
|
+
def extract_dll_paths(cls, target: build.BuildTarget) -> T.Set[str]:
|
|
1136
|
+
"""Find paths to all DLLs needed for a given target, since
|
|
1137
|
+
we link against import libs, and we don't know the actual
|
|
1138
|
+
path of the DLLs.
|
|
1139
|
+
|
|
1140
|
+
1. If there are DLLs in the same directory than the .lib dir, use it
|
|
1141
|
+
2. If there is a sibbling directory named 'bin' with DLLs in it, use it
|
|
1142
|
+
"""
|
|
1143
|
+
results = set()
|
|
1144
|
+
for dep in target.external_deps:
|
|
1145
|
+
|
|
1146
|
+
if dep.type_name == 'pkgconfig':
|
|
1147
|
+
# If by chance pkg-config knows the bin dir...
|
|
1148
|
+
bindir = dep.get_variable(pkgconfig='bindir', default_value='')
|
|
1149
|
+
if bindir:
|
|
1150
|
+
results.add(bindir)
|
|
1151
|
+
continue
|
|
1152
|
+
|
|
1153
|
+
results.update(filter(None, map(cls.search_dll_path, dep.link_args))) # pylint: disable=bad-builtin
|
|
1154
|
+
|
|
1155
|
+
for i in chain(target.link_targets, target.link_whole_targets):
|
|
1156
|
+
if isinstance(i, build.BuildTarget):
|
|
1157
|
+
results.update(cls.extract_dll_paths(i))
|
|
1158
|
+
|
|
1159
|
+
return results
|
|
1160
|
+
|
|
1161
|
+
def determine_windows_extra_paths(
|
|
1162
|
+
self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex, programs.ExternalProgram, mesonlib.File, str],
|
|
1163
|
+
extra_bdeps: T.Sequence[T.Union[build.BuildTarget, build.CustomTarget]]) -> T.List[str]:
|
|
1164
|
+
"""On Windows there is no such thing as an rpath.
|
|
1165
|
+
|
|
1166
|
+
We must determine all locations of DLLs that this exe
|
|
1167
|
+
links to and return them so they can be used in unit
|
|
1168
|
+
tests.
|
|
1169
|
+
"""
|
|
1170
|
+
result: T.Set[str] = set()
|
|
1171
|
+
prospectives: T.Set[build.BuildTargetTypes] = set()
|
|
1172
|
+
if isinstance(target, build.BuildTarget):
|
|
1173
|
+
prospectives.update(target.get_transitive_link_deps())
|
|
1174
|
+
# External deps
|
|
1175
|
+
result.update(self.extract_dll_paths(target))
|
|
1176
|
+
|
|
1177
|
+
for bdep in extra_bdeps:
|
|
1178
|
+
prospectives.add(bdep)
|
|
1179
|
+
if isinstance(bdep, build.BuildTarget):
|
|
1180
|
+
prospectives.update(bdep.get_transitive_link_deps())
|
|
1181
|
+
# Internal deps
|
|
1182
|
+
for ld in prospectives:
|
|
1183
|
+
dirseg = os.path.join(self.environment.get_build_dir(), self.get_target_dir(ld))
|
|
1184
|
+
result.add(dirseg)
|
|
1185
|
+
if (isinstance(target, build.BuildTarget) and
|
|
1186
|
+
not self.environment.machines.matches_build_machine(target.for_machine)):
|
|
1187
|
+
result.update(self.get_mingw_extra_paths(target))
|
|
1188
|
+
return list(result)
|
|
1189
|
+
|
|
1190
|
+
def write_benchmark_file(self, datafile: T.BinaryIO) -> None:
|
|
1191
|
+
self.write_test_serialisation(self.build.get_benchmarks(), datafile)
|
|
1192
|
+
|
|
1193
|
+
def write_test_file(self, datafile: T.BinaryIO) -> None:
|
|
1194
|
+
self.write_test_serialisation(self.build.get_tests(), datafile)
|
|
1195
|
+
|
|
1196
|
+
def create_test_serialisation(self, tests: T.List['Test']) -> T.List[TestSerialisation]:
|
|
1197
|
+
arr: T.List[TestSerialisation] = []
|
|
1198
|
+
for t in sorted(tests, key=lambda tst: -1 * tst.priority):
|
|
1199
|
+
exe = t.get_exe()
|
|
1200
|
+
if isinstance(exe, programs.ExternalProgram):
|
|
1201
|
+
cmd = exe.get_command()
|
|
1202
|
+
else:
|
|
1203
|
+
cmd = [os.path.join(self.environment.get_build_dir(), self.get_target_filename(exe))]
|
|
1204
|
+
if isinstance(exe, (build.BuildTarget, programs.ExternalProgram)):
|
|
1205
|
+
test_for_machine = exe.for_machine
|
|
1206
|
+
else:
|
|
1207
|
+
# E.g. an external verifier or simulator program run on a generated executable.
|
|
1208
|
+
# Can always be run without a wrapper.
|
|
1209
|
+
test_for_machine = MachineChoice.BUILD
|
|
1210
|
+
|
|
1211
|
+
# we allow passing compiled executables to tests, which may be cross built.
|
|
1212
|
+
# We need to consider these as well when considering whether the target is cross or not.
|
|
1213
|
+
for a in t.cmd_args:
|
|
1214
|
+
if isinstance(a, build.BuildTarget):
|
|
1215
|
+
if a.for_machine is MachineChoice.HOST:
|
|
1216
|
+
test_for_machine = MachineChoice.HOST
|
|
1217
|
+
break
|
|
1218
|
+
|
|
1219
|
+
is_cross = self.environment.is_cross_build(test_for_machine)
|
|
1220
|
+
exe_wrapper = self.environment.get_exe_wrapper()
|
|
1221
|
+
machine = self.environment.machines[exe.for_machine]
|
|
1222
|
+
if machine.is_windows() or machine.is_cygwin():
|
|
1223
|
+
extra_bdeps: T.List[T.Union[build.BuildTarget, build.CustomTarget]] = []
|
|
1224
|
+
if isinstance(exe, build.CustomTarget):
|
|
1225
|
+
extra_bdeps = list(exe.get_transitive_build_target_deps())
|
|
1226
|
+
extra_paths = self.determine_windows_extra_paths(exe, extra_bdeps)
|
|
1227
|
+
for a in t.cmd_args:
|
|
1228
|
+
if isinstance(a, build.BuildTarget):
|
|
1229
|
+
for p in self.determine_windows_extra_paths(a, []):
|
|
1230
|
+
if p not in extra_paths:
|
|
1231
|
+
extra_paths.append(p)
|
|
1232
|
+
else:
|
|
1233
|
+
extra_paths = []
|
|
1234
|
+
|
|
1235
|
+
cmd_args: T.List[str] = []
|
|
1236
|
+
depends: T.Set[build.Target] = set(t.depends)
|
|
1237
|
+
if isinstance(exe, build.Target):
|
|
1238
|
+
depends.add(exe)
|
|
1239
|
+
for a in t.cmd_args:
|
|
1240
|
+
if isinstance(a, build.Target):
|
|
1241
|
+
depends.add(a)
|
|
1242
|
+
elif isinstance(a, build.CustomTargetIndex):
|
|
1243
|
+
depends.add(a.target)
|
|
1244
|
+
|
|
1245
|
+
if isinstance(a, mesonlib.File):
|
|
1246
|
+
a = os.path.join(self.environment.get_build_dir(), a.rel_to_builddir(self.build_to_src))
|
|
1247
|
+
cmd_args.append(a)
|
|
1248
|
+
elif isinstance(a, str):
|
|
1249
|
+
cmd_args.append(a)
|
|
1250
|
+
elif isinstance(a, (build.Target, build.CustomTargetIndex)):
|
|
1251
|
+
cmd_args.extend(self.construct_target_rel_paths(a, t.workdir))
|
|
1252
|
+
else:
|
|
1253
|
+
raise MesonException('Bad object in test command.')
|
|
1254
|
+
|
|
1255
|
+
t_env = copy.deepcopy(t.env)
|
|
1256
|
+
if not machine.is_windows() and not machine.is_cygwin() and not machine.is_darwin():
|
|
1257
|
+
ld_lib_path: T.Set[str] = set()
|
|
1258
|
+
for d in depends:
|
|
1259
|
+
if isinstance(d, build.BuildTarget):
|
|
1260
|
+
for l in d.get_all_link_deps():
|
|
1261
|
+
if isinstance(l, build.SharedLibrary):
|
|
1262
|
+
ld_lib_path.add(os.path.join(self.environment.get_build_dir(), l.get_output_subdir()))
|
|
1263
|
+
if ld_lib_path:
|
|
1264
|
+
t_env.prepend('LD_LIBRARY_PATH', list(ld_lib_path), ':')
|
|
1265
|
+
|
|
1266
|
+
ts = TestSerialisation(t.get_name(), t.project_name, t.suite, cmd, is_cross,
|
|
1267
|
+
exe_wrapper, self.environment.need_exe_wrapper(),
|
|
1268
|
+
t.is_parallel, cmd_args, t_env,
|
|
1269
|
+
t.should_fail, t.timeout, t.workdir,
|
|
1270
|
+
extra_paths, t.protocol, t.priority,
|
|
1271
|
+
isinstance(exe, (build.Target, build.CustomTargetIndex)),
|
|
1272
|
+
isinstance(exe, build.Executable),
|
|
1273
|
+
[x.get_id() for x in depends],
|
|
1274
|
+
self.environment.coredata.version,
|
|
1275
|
+
t.verbose)
|
|
1276
|
+
arr.append(ts)
|
|
1277
|
+
return arr
|
|
1278
|
+
|
|
1279
|
+
def write_test_serialisation(self, tests: T.List['Test'], datafile: T.BinaryIO) -> None:
|
|
1280
|
+
pickle.dump(self.create_test_serialisation(tests), datafile)
|
|
1281
|
+
|
|
1282
|
+
def construct_target_rel_paths(self, t: T.Union[build.Target, build.CustomTargetIndex], workdir: T.Optional[str]) -> T.List[str]:
|
|
1283
|
+
target_dir = self.get_target_dir(t)
|
|
1284
|
+
# ensure that test executables can be run when passed as arguments
|
|
1285
|
+
if isinstance(t, build.Executable) and workdir is None:
|
|
1286
|
+
target_dir = target_dir or '.'
|
|
1287
|
+
|
|
1288
|
+
if isinstance(t, build.BuildTarget):
|
|
1289
|
+
outputs = [t.get_filename()]
|
|
1290
|
+
else:
|
|
1291
|
+
assert isinstance(t, (build.CustomTarget, build.CustomTargetIndex))
|
|
1292
|
+
outputs = t.get_outputs()
|
|
1293
|
+
|
|
1294
|
+
outputs = [os.path.join(target_dir, x) for x in outputs]
|
|
1295
|
+
if workdir is not None:
|
|
1296
|
+
assert os.path.isabs(workdir)
|
|
1297
|
+
outputs = [os.path.join(self.environment.get_build_dir(), x) for x in outputs]
|
|
1298
|
+
outputs = [os.path.relpath(x, workdir) for x in outputs]
|
|
1299
|
+
return outputs
|
|
1300
|
+
|
|
1301
|
+
def generate_depmf_install(self, d: InstallData) -> None:
|
|
1302
|
+
depmf_path = self.build.dep_manifest_name
|
|
1303
|
+
if depmf_path is None:
|
|
1304
|
+
option_dir = self.environment.coredata.get_option(OptionKey('licensedir'))
|
|
1305
|
+
assert isinstance(option_dir, str), 'for mypy'
|
|
1306
|
+
if option_dir:
|
|
1307
|
+
depmf_path = os.path.join(option_dir, 'depmf.json')
|
|
1308
|
+
else:
|
|
1309
|
+
return
|
|
1310
|
+
ifilename = os.path.join(self.environment.get_build_dir(), 'depmf.json')
|
|
1311
|
+
ofilename = os.path.join(self.environment.get_prefix(), depmf_path)
|
|
1312
|
+
odirname = os.path.join(self.environment.get_prefix(), os.path.dirname(depmf_path))
|
|
1313
|
+
out_name = os.path.join('{prefix}', depmf_path)
|
|
1314
|
+
out_dir = os.path.join('{prefix}', os.path.dirname(depmf_path))
|
|
1315
|
+
mfobj = {'type': 'dependency manifest', 'version': '1.0',
|
|
1316
|
+
'projects': {k: v.to_json() for k, v in self.build.dep_manifest.items()}}
|
|
1317
|
+
with open(ifilename, 'w', encoding='utf-8') as f:
|
|
1318
|
+
f.write(json.dumps(mfobj))
|
|
1319
|
+
# Copy file from, to, and with mode unchanged
|
|
1320
|
+
d.data.append(InstallDataBase(ifilename, ofilename, out_name, None, '',
|
|
1321
|
+
tag='devel', data_type='depmf'))
|
|
1322
|
+
for m in self.build.dep_manifest.values():
|
|
1323
|
+
for ifilename, name in m.license_files:
|
|
1324
|
+
ofilename = os.path.join(odirname, name.relative_name())
|
|
1325
|
+
out_name = os.path.join(out_dir, name.relative_name())
|
|
1326
|
+
d.data.append(InstallDataBase(ifilename, ofilename, out_name, None,
|
|
1327
|
+
m.subproject, tag='devel', data_type='depmf'))
|
|
1328
|
+
|
|
1329
|
+
def get_regen_filelist(self) -> T.List[str]:
|
|
1330
|
+
'''List of all files whose alteration means that the build
|
|
1331
|
+
definition needs to be regenerated.'''
|
|
1332
|
+
deps = OrderedSet([str(Path(self.build_to_src) / df)
|
|
1333
|
+
for df in self.interpreter.get_build_def_files()])
|
|
1334
|
+
if self.environment.is_cross_build():
|
|
1335
|
+
deps.update(self.environment.coredata.cross_files)
|
|
1336
|
+
deps.update(self.environment.coredata.config_files)
|
|
1337
|
+
deps.add('meson-private/coredata.dat')
|
|
1338
|
+
self.check_clock_skew(deps)
|
|
1339
|
+
return list(deps)
|
|
1340
|
+
|
|
1341
|
+
def generate_regen_info(self) -> None:
|
|
1342
|
+
deps = self.get_regen_filelist()
|
|
1343
|
+
regeninfo = RegenInfo(self.environment.get_source_dir(),
|
|
1344
|
+
self.environment.get_build_dir(),
|
|
1345
|
+
deps)
|
|
1346
|
+
filename = os.path.join(self.environment.get_scratch_dir(),
|
|
1347
|
+
'regeninfo.dump')
|
|
1348
|
+
with open(filename, 'wb') as f:
|
|
1349
|
+
pickle.dump(regeninfo, f)
|
|
1350
|
+
|
|
1351
|
+
def check_clock_skew(self, file_list: T.Iterable[str]) -> None:
|
|
1352
|
+
# If a file that leads to reconfiguration has a time
|
|
1353
|
+
# stamp in the future, it will trigger an eternal reconfigure
|
|
1354
|
+
# loop.
|
|
1355
|
+
import time
|
|
1356
|
+
now = time.time()
|
|
1357
|
+
for f in file_list:
|
|
1358
|
+
absf = os.path.join(self.environment.get_build_dir(), f)
|
|
1359
|
+
ftime = os.path.getmtime(absf)
|
|
1360
|
+
delta = ftime - now
|
|
1361
|
+
# On Windows disk time stamps sometimes point
|
|
1362
|
+
# to the future by a minuscule amount, less than
|
|
1363
|
+
# 0.001 seconds. I don't know why.
|
|
1364
|
+
if delta > 0.001:
|
|
1365
|
+
raise MesonException(f'Clock skew detected. File {absf} has a time stamp {delta:.4f}s in the future.')
|
|
1366
|
+
|
|
1367
|
+
def build_target_to_cmd_array(self, bt: T.Union[build.BuildTarget, programs.ExternalProgram]) -> T.List[str]:
|
|
1368
|
+
if isinstance(bt, build.BuildTarget):
|
|
1369
|
+
arr = [os.path.join(self.environment.get_build_dir(), self.get_target_filename(bt))]
|
|
1370
|
+
else:
|
|
1371
|
+
arr = bt.get_command()
|
|
1372
|
+
return arr
|
|
1373
|
+
|
|
1374
|
+
def replace_extra_args(self, args: T.List[str], genlist: 'build.GeneratedList') -> T.List[str]:
|
|
1375
|
+
final_args: T.List[str] = []
|
|
1376
|
+
for a in args:
|
|
1377
|
+
if a == '@EXTRA_ARGS@':
|
|
1378
|
+
final_args += genlist.get_extra_args()
|
|
1379
|
+
else:
|
|
1380
|
+
final_args.append(a)
|
|
1381
|
+
return final_args
|
|
1382
|
+
|
|
1383
|
+
def replace_outputs(self, args: T.List[str], private_dir: str, output_list: T.List[str]) -> T.List[str]:
|
|
1384
|
+
newargs: T.List[str] = []
|
|
1385
|
+
regex = re.compile(r'@OUTPUT(\d+)@')
|
|
1386
|
+
for arg in args:
|
|
1387
|
+
m = regex.search(arg)
|
|
1388
|
+
while m is not None:
|
|
1389
|
+
index = int(m.group(1))
|
|
1390
|
+
src = f'@OUTPUT{index}@'
|
|
1391
|
+
arg = arg.replace(src, os.path.join(private_dir, output_list[index]))
|
|
1392
|
+
m = regex.search(arg)
|
|
1393
|
+
newargs.append(arg)
|
|
1394
|
+
return newargs
|
|
1395
|
+
|
|
1396
|
+
def get_build_by_default_targets(self) -> 'T.OrderedDict[str, T.Union[build.BuildTarget, build.CustomTarget]]':
|
|
1397
|
+
result: 'T.OrderedDict[str, T.Union[build.BuildTarget, build.CustomTarget]]' = OrderedDict()
|
|
1398
|
+
# Get all build and custom targets that must be built by default
|
|
1399
|
+
for name, b in self.build.get_targets().items():
|
|
1400
|
+
if b.build_by_default:
|
|
1401
|
+
result[name] = b
|
|
1402
|
+
return result
|
|
1403
|
+
|
|
1404
|
+
def get_testlike_targets(self, benchmark: bool = False) -> T.OrderedDict[str, T.Union[build.BuildTarget, build.CustomTarget]]:
|
|
1405
|
+
result: T.OrderedDict[str, T.Union[build.BuildTarget, build.CustomTarget]] = OrderedDict()
|
|
1406
|
+
targets = self.build.get_benchmarks() if benchmark else self.build.get_tests()
|
|
1407
|
+
for t in targets:
|
|
1408
|
+
exe = t.exe
|
|
1409
|
+
if isinstance(exe, (build.CustomTarget, build.BuildTarget)):
|
|
1410
|
+
result[exe.get_id()] = exe
|
|
1411
|
+
for arg in t.cmd_args:
|
|
1412
|
+
if not isinstance(arg, (build.CustomTarget, build.BuildTarget)):
|
|
1413
|
+
continue
|
|
1414
|
+
result[arg.get_id()] = arg
|
|
1415
|
+
for dep in t.depends:
|
|
1416
|
+
assert isinstance(dep, (build.CustomTarget, build.BuildTarget))
|
|
1417
|
+
result[dep.get_id()] = dep
|
|
1418
|
+
return result
|
|
1419
|
+
|
|
1420
|
+
@lru_cache(maxsize=None)
|
|
1421
|
+
def get_custom_target_provided_by_generated_source(self, generated_source: build.CustomTarget) -> 'ImmutableListProtocol[str]':
|
|
1422
|
+
libs: T.List[str] = []
|
|
1423
|
+
for f in generated_source.get_outputs():
|
|
1424
|
+
if self.environment.is_library(f):
|
|
1425
|
+
libs.append(os.path.join(self.get_target_dir(generated_source), f))
|
|
1426
|
+
return libs
|
|
1427
|
+
|
|
1428
|
+
@lru_cache(maxsize=None)
|
|
1429
|
+
def get_custom_target_provided_libraries(self, target: T.Union[build.BuildTarget, build.CustomTarget]) -> 'ImmutableListProtocol[str]':
|
|
1430
|
+
libs: T.List[str] = []
|
|
1431
|
+
for t in target.get_generated_sources():
|
|
1432
|
+
if not isinstance(t, build.CustomTarget):
|
|
1433
|
+
continue
|
|
1434
|
+
libs.extend(self.get_custom_target_provided_by_generated_source(t))
|
|
1435
|
+
return libs
|
|
1436
|
+
|
|
1437
|
+
def get_custom_target_sources(self, target: build.CustomTarget) -> T.List[str]:
|
|
1438
|
+
'''
|
|
1439
|
+
Custom target sources can be of various object types; strings, File,
|
|
1440
|
+
BuildTarget, even other CustomTargets.
|
|
1441
|
+
Returns the path to them relative to the build root directory.
|
|
1442
|
+
'''
|
|
1443
|
+
srcs: T.List[str] = []
|
|
1444
|
+
for i in target.get_sources():
|
|
1445
|
+
if isinstance(i, str):
|
|
1446
|
+
fname = [os.path.join(self.build_to_src, target.get_source_subdir(), i)]
|
|
1447
|
+
elif isinstance(i, build.BuildTarget):
|
|
1448
|
+
fname = [self.get_target_filename(i)]
|
|
1449
|
+
elif isinstance(i, (build.CustomTarget, build.CustomTargetIndex)):
|
|
1450
|
+
fname = [os.path.join(self.get_custom_target_output_dir(i), p) for p in i.get_outputs()]
|
|
1451
|
+
elif isinstance(i, build.GeneratedList):
|
|
1452
|
+
fname = [os.path.join(self.get_target_private_dir(target), p) for p in i.get_outputs()]
|
|
1453
|
+
elif isinstance(i, build.ExtractedObjects):
|
|
1454
|
+
fname = self.determine_ext_objs(i)
|
|
1455
|
+
elif isinstance(i, programs.ExternalProgram):
|
|
1456
|
+
assert i.found(), "This shouldn't be possible"
|
|
1457
|
+
assert i.path is not None, 'for mypy'
|
|
1458
|
+
fname = [i.path]
|
|
1459
|
+
else:
|
|
1460
|
+
fname = [i.rel_to_builddir(self.build_to_src)]
|
|
1461
|
+
if target.absolute_paths:
|
|
1462
|
+
fname = [os.path.join(self.environment.get_build_dir(), f) for f in fname]
|
|
1463
|
+
srcs += fname
|
|
1464
|
+
return srcs
|
|
1465
|
+
|
|
1466
|
+
def get_target_depend_files(self, target: T.Union[build.CustomTarget, build.BuildTarget], absolute_paths: bool = False) -> T.List[str]:
|
|
1467
|
+
deps: T.List[str] = []
|
|
1468
|
+
for i in target.depend_files:
|
|
1469
|
+
if isinstance(i, mesonlib.File):
|
|
1470
|
+
if absolute_paths:
|
|
1471
|
+
deps.append(i.absolute_path(self.environment.get_source_dir(),
|
|
1472
|
+
self.environment.get_build_dir()))
|
|
1473
|
+
else:
|
|
1474
|
+
deps.append(i.rel_to_builddir(self.build_to_src))
|
|
1475
|
+
else:
|
|
1476
|
+
if absolute_paths:
|
|
1477
|
+
deps.append(os.path.join(self.environment.get_source_dir(), target.get_output_subdir(), i))
|
|
1478
|
+
else:
|
|
1479
|
+
deps.append(os.path.join(self.build_to_src, target.get_output_subdir(), i))
|
|
1480
|
+
return deps
|
|
1481
|
+
|
|
1482
|
+
def get_custom_target_output_dir(self, target: T.Union[build.Target, build.CustomTargetIndex]) -> str:
|
|
1483
|
+
# The XCode backend is special. A target foo/bar does
|
|
1484
|
+
# not go to ${BUILDDIR}/foo/bar but instead to
|
|
1485
|
+
# ${BUILDDIR}/${BUILDTYPE}/foo/bar.
|
|
1486
|
+
# Currently we set the include dir to be the former,
|
|
1487
|
+
# and not the latter. Thus we need this extra customisation
|
|
1488
|
+
# point. If in the future we make include dirs et al match
|
|
1489
|
+
# ${BUILDDIR}/${BUILDTYPE} instead, this becomes unnecessary.
|
|
1490
|
+
return self.get_target_dir(target)
|
|
1491
|
+
|
|
1492
|
+
@lru_cache(maxsize=None)
|
|
1493
|
+
def get_normpath_target(self, source: str) -> str:
|
|
1494
|
+
return os.path.normpath(source)
|
|
1495
|
+
|
|
1496
|
+
def get_custom_target_dirs(self, target: build.CustomTarget, compiler: 'Compiler', *,
|
|
1497
|
+
absolute_path: bool = False) -> T.List[str]:
|
|
1498
|
+
custom_target_include_dirs: T.List[str] = []
|
|
1499
|
+
for i in target.get_generated_sources():
|
|
1500
|
+
# Generator output goes into the target private dir which is
|
|
1501
|
+
# already in the include paths list. Only custom targets have their
|
|
1502
|
+
# own target build dir.
|
|
1503
|
+
if not isinstance(i, (build.CustomTarget, build.CustomTargetIndex)):
|
|
1504
|
+
continue
|
|
1505
|
+
idir = self.get_normpath_target(self.get_custom_target_output_dir(i))
|
|
1506
|
+
if not idir:
|
|
1507
|
+
idir = '.'
|
|
1508
|
+
if absolute_path:
|
|
1509
|
+
idir = os.path.join(self.environment.get_build_dir(), idir)
|
|
1510
|
+
if idir not in custom_target_include_dirs:
|
|
1511
|
+
custom_target_include_dirs.append(idir)
|
|
1512
|
+
return custom_target_include_dirs
|
|
1513
|
+
|
|
1514
|
+
def get_custom_target_dir_include_args(
|
|
1515
|
+
self, target: build.CustomTarget, compiler: 'Compiler', *,
|
|
1516
|
+
absolute_path: bool = False) -> T.List[str]:
|
|
1517
|
+
incs: T.List[str] = []
|
|
1518
|
+
for i in self.get_custom_target_dirs(target, compiler, absolute_path=absolute_path):
|
|
1519
|
+
incs += compiler.get_include_args(i, False)
|
|
1520
|
+
return incs
|
|
1521
|
+
|
|
1522
|
+
def eval_custom_target_command(
|
|
1523
|
+
self, target: build.CustomTarget, absolute_outputs: bool = False) -> \
|
|
1524
|
+
T.Tuple[T.List[str], T.List[str], T.List[str]]:
|
|
1525
|
+
# We want the outputs to be absolute only when using the VS backend
|
|
1526
|
+
# XXX: Maybe allow the vs backend to use relative paths too?
|
|
1527
|
+
source_root = self.build_to_src
|
|
1528
|
+
build_root = '.'
|
|
1529
|
+
outdir = self.get_custom_target_output_dir(target)
|
|
1530
|
+
if absolute_outputs:
|
|
1531
|
+
source_root = self.environment.get_source_dir()
|
|
1532
|
+
build_root = self.environment.get_build_dir()
|
|
1533
|
+
outdir = os.path.join(self.environment.get_build_dir(), outdir)
|
|
1534
|
+
outputs = [os.path.join(outdir, i) for i in target.get_outputs()]
|
|
1535
|
+
inputs = self.get_custom_target_sources(target)
|
|
1536
|
+
# Evaluate the command list
|
|
1537
|
+
cmd: T.List[str] = []
|
|
1538
|
+
for i in target.command:
|
|
1539
|
+
if isinstance(i, build.BuildTarget):
|
|
1540
|
+
cmd += self.build_target_to_cmd_array(i)
|
|
1541
|
+
continue
|
|
1542
|
+
elif isinstance(i, build.CustomTarget):
|
|
1543
|
+
# GIR scanner will attempt to execute this binary but
|
|
1544
|
+
# it assumes that it is in path, so always give it a full path.
|
|
1545
|
+
tmp = i.get_outputs()[0]
|
|
1546
|
+
i = os.path.join(self.get_custom_target_output_dir(i), tmp)
|
|
1547
|
+
elif isinstance(i, mesonlib.File):
|
|
1548
|
+
i = i.rel_to_builddir(self.build_to_src)
|
|
1549
|
+
if target.absolute_paths or absolute_outputs:
|
|
1550
|
+
i = os.path.join(self.environment.get_build_dir(), i)
|
|
1551
|
+
# FIXME: str types are blindly added ignoring 'target.absolute_paths'
|
|
1552
|
+
# because we can't know if they refer to a file or just a string
|
|
1553
|
+
elif isinstance(i, str):
|
|
1554
|
+
if '@SOURCE_ROOT@' in i:
|
|
1555
|
+
i = i.replace('@SOURCE_ROOT@', source_root)
|
|
1556
|
+
if '@BUILD_ROOT@' in i:
|
|
1557
|
+
i = i.replace('@BUILD_ROOT@', build_root)
|
|
1558
|
+
if '@CURRENT_SOURCE_DIR@' in i:
|
|
1559
|
+
i = i.replace('@CURRENT_SOURCE_DIR@', os.path.join(source_root, target.get_source_subdir()))
|
|
1560
|
+
if '@DEPFILE@' in i:
|
|
1561
|
+
if target.depfile is None:
|
|
1562
|
+
msg = f'Custom target {target.name!r} has @DEPFILE@ but no depfile ' \
|
|
1563
|
+
'keyword argument.'
|
|
1564
|
+
raise MesonException(msg)
|
|
1565
|
+
dfilename = os.path.join(outdir, target.depfile)
|
|
1566
|
+
i = i.replace('@DEPFILE@', dfilename)
|
|
1567
|
+
if '@PRIVATE_DIR@' in i:
|
|
1568
|
+
if target.absolute_paths:
|
|
1569
|
+
pdir = self.get_target_private_dir_abs(target)
|
|
1570
|
+
else:
|
|
1571
|
+
pdir = self.get_target_private_dir(target)
|
|
1572
|
+
i = i.replace('@PRIVATE_DIR@', pdir)
|
|
1573
|
+
else:
|
|
1574
|
+
raise RuntimeError(f'Argument {i} is of unknown type {type(i)}')
|
|
1575
|
+
cmd.append(i)
|
|
1576
|
+
# Substitute the rest of the template strings
|
|
1577
|
+
values = mesonlib.get_filenames_templates_dict(inputs, outputs)
|
|
1578
|
+
cmd = mesonlib.substitute_values(cmd, values)
|
|
1579
|
+
# This should not be necessary but removing it breaks
|
|
1580
|
+
# building GStreamer on Windows. The underlying issue
|
|
1581
|
+
# is problems with quoting backslashes on Windows
|
|
1582
|
+
# which is the seventh circle of hell. The downside is
|
|
1583
|
+
# that this breaks custom targets whose command lines
|
|
1584
|
+
# have backslashes. If you try to fix this be sure to
|
|
1585
|
+
# check that it does not break GST.
|
|
1586
|
+
#
|
|
1587
|
+
# The bug causes file paths such as c:\foo to get escaped
|
|
1588
|
+
# into c:\\foo.
|
|
1589
|
+
#
|
|
1590
|
+
# Unfortunately we have not been able to come up with an
|
|
1591
|
+
# isolated test case for this so unless you manage to come up
|
|
1592
|
+
# with one, the only way is to test the building with Gst's
|
|
1593
|
+
# setup. Note this in your MR or ping us and we will get it
|
|
1594
|
+
# fixed.
|
|
1595
|
+
#
|
|
1596
|
+
# https://github.com/mesonbuild/meson/pull/737
|
|
1597
|
+
cmd = [i.replace('\\', '/') for i in cmd]
|
|
1598
|
+
return inputs, outputs, cmd
|
|
1599
|
+
|
|
1600
|
+
def get_introspect_command(self) -> str:
|
|
1601
|
+
return ' '.join(shlex.quote(x) for x in self.environment.get_build_command() + ['introspect'])
|
|
1602
|
+
|
|
1603
|
+
def get_run_target_env(self, target: build.RunTarget) -> mesonlib.EnvironmentVariables:
|
|
1604
|
+
env = target.env if target.env else mesonlib.EnvironmentVariables()
|
|
1605
|
+
if target.default_env:
|
|
1606
|
+
env.set('MESON_SOURCE_ROOT', [self.environment.get_source_dir()])
|
|
1607
|
+
env.set('MESON_BUILD_ROOT', [self.environment.get_build_dir()])
|
|
1608
|
+
env.set('MESON_SUBDIR', [target.get_source_subdir()])
|
|
1609
|
+
env.set('MESONINTROSPECT', [self.get_introspect_command()])
|
|
1610
|
+
return env
|
|
1611
|
+
|
|
1612
|
+
def run_postconf_scripts(self) -> None:
|
|
1613
|
+
from ..scripts.meson_exe import run_exe
|
|
1614
|
+
env = {'MESON_SOURCE_ROOT': self.environment.get_source_dir(),
|
|
1615
|
+
'MESON_BUILD_ROOT': self.environment.get_build_dir(),
|
|
1616
|
+
'MESONINTROSPECT': self.get_introspect_command(),
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
for s in self.build.postconf_scripts:
|
|
1620
|
+
name = ' '.join(s.cmd_args)
|
|
1621
|
+
mlog.log(f'Running postconf script {name!r}')
|
|
1622
|
+
rc = run_exe(s, env)
|
|
1623
|
+
if rc != 0:
|
|
1624
|
+
raise MesonException(f'Postconf script \'{name}\' failed with exit code {rc}.')
|
|
1625
|
+
|
|
1626
|
+
def create_install_data(self) -> InstallData:
|
|
1627
|
+
strip_bin = self.environment.lookup_binary_entry(MachineChoice.HOST, 'strip')
|
|
1628
|
+
if strip_bin is None:
|
|
1629
|
+
if self.environment.is_cross_build():
|
|
1630
|
+
mlog.warning('Cross file does not specify strip binary, result will not be stripped.')
|
|
1631
|
+
else:
|
|
1632
|
+
# TODO go through all candidates, like others
|
|
1633
|
+
strip_bin = [detect.defaults['strip'][0]]
|
|
1634
|
+
|
|
1635
|
+
umask = self.environment.coredata.get_option(OptionKey('install_umask'))
|
|
1636
|
+
assert isinstance(umask, (str, int)), 'for mypy'
|
|
1637
|
+
|
|
1638
|
+
d = InstallData(self.environment.get_source_dir(),
|
|
1639
|
+
self.environment.get_build_dir(),
|
|
1640
|
+
self.environment.get_prefix(),
|
|
1641
|
+
self.environment.get_libdir(),
|
|
1642
|
+
strip_bin,
|
|
1643
|
+
umask,
|
|
1644
|
+
self.environment.get_build_command() + ['introspect'],
|
|
1645
|
+
self.environment.coredata.version)
|
|
1646
|
+
self.generate_depmf_install(d)
|
|
1647
|
+
self.generate_target_install(d)
|
|
1648
|
+
self.generate_header_install(d)
|
|
1649
|
+
self.generate_man_install(d)
|
|
1650
|
+
self.generate_emptydir_install(d)
|
|
1651
|
+
self.generate_data_install(d)
|
|
1652
|
+
self.generate_symlink_install(d)
|
|
1653
|
+
self.generate_custom_install_script(d)
|
|
1654
|
+
self.generate_subdir_install(d)
|
|
1655
|
+
return d
|
|
1656
|
+
|
|
1657
|
+
def create_install_data_files(self) -> None:
|
|
1658
|
+
install_data_file = os.path.join(self.environment.get_scratch_dir(), 'install.dat')
|
|
1659
|
+
with open(install_data_file, 'wb') as ofile:
|
|
1660
|
+
pickle.dump(self.create_install_data(), ofile)
|
|
1661
|
+
|
|
1662
|
+
def guess_install_tag(self, fname: str, outdir: T.Optional[str] = None) -> T.Optional[str]:
|
|
1663
|
+
prefix = self.environment.get_prefix()
|
|
1664
|
+
bindir = Path(prefix, self.environment.get_bindir())
|
|
1665
|
+
libdir = Path(prefix, self.environment.get_libdir())
|
|
1666
|
+
incdir = Path(prefix, self.environment.get_includedir())
|
|
1667
|
+
_ldir = self.environment.coredata.get_option(mesonlib.OptionKey('localedir'))
|
|
1668
|
+
assert isinstance(_ldir, str), 'for mypy'
|
|
1669
|
+
localedir = Path(prefix, _ldir)
|
|
1670
|
+
dest_path = Path(prefix, outdir, Path(fname).name) if outdir else Path(prefix, fname)
|
|
1671
|
+
if bindir in dest_path.parents:
|
|
1672
|
+
return 'runtime'
|
|
1673
|
+
elif libdir in dest_path.parents:
|
|
1674
|
+
if dest_path.suffix in {'.a', '.pc'}:
|
|
1675
|
+
return 'devel'
|
|
1676
|
+
elif dest_path.suffix in {'.so', '.dll'}:
|
|
1677
|
+
return 'runtime'
|
|
1678
|
+
elif incdir in dest_path.parents:
|
|
1679
|
+
return 'devel'
|
|
1680
|
+
elif localedir in dest_path.parents:
|
|
1681
|
+
return 'i18n'
|
|
1682
|
+
elif 'installed-tests' in dest_path.parts:
|
|
1683
|
+
return 'tests'
|
|
1684
|
+
elif 'systemtap' in dest_path.parts:
|
|
1685
|
+
return 'systemtap'
|
|
1686
|
+
mlog.debug('Failed to guess install tag for', dest_path)
|
|
1687
|
+
return None
|
|
1688
|
+
|
|
1689
|
+
def generate_target_install(self, d: InstallData) -> None:
|
|
1690
|
+
for t in self.build.get_targets().values():
|
|
1691
|
+
if not t.should_install():
|
|
1692
|
+
continue
|
|
1693
|
+
outdirs, install_dir_names, custom_install_dir = t.get_install_dir()
|
|
1694
|
+
# Sanity-check the outputs and install_dirs
|
|
1695
|
+
num_outdirs, num_out = len(outdirs), len(t.get_outputs())
|
|
1696
|
+
if num_outdirs not in {1, num_out}:
|
|
1697
|
+
m = 'Target {!r} has {} outputs: {!r}, but only {} "install_dir"s were found.\n' \
|
|
1698
|
+
"Pass 'false' for outputs that should not be installed and 'true' for\n" \
|
|
1699
|
+
'using the default installation directory for an output.'
|
|
1700
|
+
raise MesonException(m.format(t.name, num_out, t.get_outputs(), num_outdirs))
|
|
1701
|
+
assert len(t.install_tag) == num_out
|
|
1702
|
+
install_mode = t.get_custom_install_mode()
|
|
1703
|
+
# because mypy gets confused type narrowing in lists
|
|
1704
|
+
first_outdir = outdirs[0]
|
|
1705
|
+
first_outdir_name = install_dir_names[0]
|
|
1706
|
+
|
|
1707
|
+
# Install the target output(s)
|
|
1708
|
+
if isinstance(t, build.BuildTarget):
|
|
1709
|
+
# In general, stripping static archives is tricky and full of pitfalls.
|
|
1710
|
+
# Wholesale stripping of static archives with a command such as
|
|
1711
|
+
#
|
|
1712
|
+
# strip libfoo.a
|
|
1713
|
+
#
|
|
1714
|
+
# is broken, as GNU's strip will remove *every* symbol in a static
|
|
1715
|
+
# archive. One solution to this nonintuitive behaviour would be
|
|
1716
|
+
# to only strip local/debug symbols. Unfortunately, strip arguments
|
|
1717
|
+
# are not specified by POSIX and therefore not portable. GNU's `-g`
|
|
1718
|
+
# option (i.e. remove debug symbols) is equivalent to Apple's `-S`.
|
|
1719
|
+
#
|
|
1720
|
+
# TODO: Create GNUStrip/AppleStrip/etc. hierarchy for more
|
|
1721
|
+
# fine-grained stripping of static archives.
|
|
1722
|
+
can_strip = not isinstance(t, build.StaticLibrary)
|
|
1723
|
+
should_strip = can_strip and t.get_option(OptionKey('strip'))
|
|
1724
|
+
assert isinstance(should_strip, bool), 'for mypy'
|
|
1725
|
+
# Install primary build output (library/executable/jar, etc)
|
|
1726
|
+
# Done separately because of strip/aliases/rpath
|
|
1727
|
+
if first_outdir is not False:
|
|
1728
|
+
tag = t.install_tag[0] or ('devel' if isinstance(t, build.StaticLibrary) else 'runtime')
|
|
1729
|
+
mappings = t.get_link_deps_mapping(d.prefix)
|
|
1730
|
+
i = TargetInstallData(self.get_target_filename(t), first_outdir,
|
|
1731
|
+
first_outdir_name,
|
|
1732
|
+
should_strip, mappings, t.rpath_dirs_to_remove,
|
|
1733
|
+
t.install_rpath, install_mode, t.subproject,
|
|
1734
|
+
tag=tag, can_strip=can_strip)
|
|
1735
|
+
d.targets.append(i)
|
|
1736
|
+
|
|
1737
|
+
for alias, to, tag in t.get_aliases():
|
|
1738
|
+
alias = os.path.join(first_outdir, alias)
|
|
1739
|
+
s = InstallSymlinkData(to, alias, first_outdir, t.subproject, tag, allow_missing=True)
|
|
1740
|
+
d.symlinks.append(s)
|
|
1741
|
+
|
|
1742
|
+
if isinstance(t, (build.SharedLibrary, build.SharedModule, build.Executable)):
|
|
1743
|
+
# On toolchains/platforms that use an import library for
|
|
1744
|
+
# linking (separate from the shared library with all the
|
|
1745
|
+
# code), we need to install that too (dll.a/.lib).
|
|
1746
|
+
if t.get_import_filename():
|
|
1747
|
+
if custom_install_dir:
|
|
1748
|
+
# If the DLL is installed into a custom directory,
|
|
1749
|
+
# install the import library into the same place so
|
|
1750
|
+
# it doesn't go into a surprising place
|
|
1751
|
+
implib_install_dir = first_outdir
|
|
1752
|
+
else:
|
|
1753
|
+
implib_install_dir = self.environment.get_import_lib_dir()
|
|
1754
|
+
# Install the import library; may not exist for shared modules
|
|
1755
|
+
i = TargetInstallData(self.get_target_filename_for_linking(t),
|
|
1756
|
+
implib_install_dir, first_outdir_name,
|
|
1757
|
+
False, {}, set(), '', install_mode,
|
|
1758
|
+
t.subproject, optional=isinstance(t, build.SharedModule),
|
|
1759
|
+
tag='devel')
|
|
1760
|
+
d.targets.append(i)
|
|
1761
|
+
|
|
1762
|
+
if not should_strip and t.get_debug_filename():
|
|
1763
|
+
debug_file = os.path.join(self.get_target_dir(t), t.get_debug_filename())
|
|
1764
|
+
i = TargetInstallData(debug_file, first_outdir,
|
|
1765
|
+
first_outdir_name,
|
|
1766
|
+
False, {}, set(), '',
|
|
1767
|
+
install_mode, t.subproject,
|
|
1768
|
+
optional=True, tag='devel')
|
|
1769
|
+
d.targets.append(i)
|
|
1770
|
+
# Install secondary outputs. Only used for Vala right now.
|
|
1771
|
+
if num_outdirs > 1:
|
|
1772
|
+
for output, outdir, outdir_name, tag in zip(t.get_outputs()[1:], outdirs[1:], install_dir_names[1:], t.install_tag[1:]):
|
|
1773
|
+
# User requested that we not install this output
|
|
1774
|
+
if outdir is False:
|
|
1775
|
+
continue
|
|
1776
|
+
f = os.path.join(self.get_target_dir(t), output)
|
|
1777
|
+
i = TargetInstallData(f, outdir, outdir_name, False, {}, set(), None,
|
|
1778
|
+
install_mode, t.subproject,
|
|
1779
|
+
tag=tag)
|
|
1780
|
+
d.targets.append(i)
|
|
1781
|
+
elif isinstance(t, build.CustomTarget):
|
|
1782
|
+
# If only one install_dir is specified, assume that all
|
|
1783
|
+
# outputs will be installed into it. This is for
|
|
1784
|
+
# backwards-compatibility and because it makes sense to
|
|
1785
|
+
# avoid repetition since this is a common use-case.
|
|
1786
|
+
#
|
|
1787
|
+
# To selectively install only some outputs, pass `false` as
|
|
1788
|
+
# the install_dir for the corresponding output by index
|
|
1789
|
+
#
|
|
1790
|
+
# XXX: this wouldn't be needed if we just always matches outdirs
|
|
1791
|
+
# to the length of outputs…
|
|
1792
|
+
if num_outdirs == 1 and num_out > 1:
|
|
1793
|
+
if first_outdir is not False:
|
|
1794
|
+
for output, tag in zip(t.get_outputs(), t.install_tag):
|
|
1795
|
+
tag = tag or self.guess_install_tag(output, first_outdir)
|
|
1796
|
+
f = os.path.join(self.get_target_dir(t), output)
|
|
1797
|
+
i = TargetInstallData(f, first_outdir, first_outdir_name,
|
|
1798
|
+
False, {}, set(), None, install_mode,
|
|
1799
|
+
t.subproject, optional=not t.build_by_default,
|
|
1800
|
+
tag=tag)
|
|
1801
|
+
d.targets.append(i)
|
|
1802
|
+
else:
|
|
1803
|
+
for output, outdir, outdir_name, tag in zip(t.get_outputs(), outdirs, install_dir_names, t.install_tag):
|
|
1804
|
+
# User requested that we not install this output
|
|
1805
|
+
if outdir is False:
|
|
1806
|
+
continue
|
|
1807
|
+
tag = tag or self.guess_install_tag(output, outdir)
|
|
1808
|
+
f = os.path.join(self.get_target_dir(t), output)
|
|
1809
|
+
i = TargetInstallData(f, outdir, outdir_name,
|
|
1810
|
+
False, {}, set(), None, install_mode,
|
|
1811
|
+
t.subproject, optional=not t.build_by_default,
|
|
1812
|
+
tag=tag)
|
|
1813
|
+
d.targets.append(i)
|
|
1814
|
+
|
|
1815
|
+
def generate_custom_install_script(self, d: InstallData) -> None:
|
|
1816
|
+
d.install_scripts = self.build.install_scripts
|
|
1817
|
+
for i in d.install_scripts:
|
|
1818
|
+
if not i.tag:
|
|
1819
|
+
mlog.debug('Failed to guess install tag for install script:', ' '.join(i.cmd_args))
|
|
1820
|
+
|
|
1821
|
+
def generate_header_install(self, d: InstallData) -> None:
|
|
1822
|
+
incroot = self.environment.get_includedir()
|
|
1823
|
+
headers = self.build.get_headers()
|
|
1824
|
+
|
|
1825
|
+
srcdir = self.environment.get_source_dir()
|
|
1826
|
+
builddir = self.environment.get_build_dir()
|
|
1827
|
+
for h in headers:
|
|
1828
|
+
outdir = outdir_name = h.get_custom_install_dir()
|
|
1829
|
+
if outdir is None:
|
|
1830
|
+
subdir = h.get_install_subdir()
|
|
1831
|
+
if subdir is None:
|
|
1832
|
+
outdir = incroot
|
|
1833
|
+
outdir_name = '{includedir}'
|
|
1834
|
+
else:
|
|
1835
|
+
outdir = os.path.join(incroot, subdir)
|
|
1836
|
+
outdir_name = os.path.join('{includedir}', subdir)
|
|
1837
|
+
|
|
1838
|
+
for f in h.get_sources():
|
|
1839
|
+
abspath = f.absolute_path(srcdir, builddir)
|
|
1840
|
+
i = InstallDataBase(abspath, outdir, outdir_name, h.get_custom_install_mode(), h.subproject, tag='devel', follow_symlinks=h.follow_symlinks)
|
|
1841
|
+
d.headers.append(i)
|
|
1842
|
+
|
|
1843
|
+
def generate_man_install(self, d: InstallData) -> None:
|
|
1844
|
+
manroot = self.environment.get_mandir()
|
|
1845
|
+
man = self.build.get_man()
|
|
1846
|
+
for m in man:
|
|
1847
|
+
for f in m.get_sources():
|
|
1848
|
+
num = f.split('.')[-1]
|
|
1849
|
+
subdir = m.get_custom_install_dir()
|
|
1850
|
+
if subdir is None:
|
|
1851
|
+
if m.locale:
|
|
1852
|
+
subdir = os.path.join('{mandir}', m.locale, 'man' + num)
|
|
1853
|
+
else:
|
|
1854
|
+
subdir = os.path.join('{mandir}', 'man' + num)
|
|
1855
|
+
fname = f.fname
|
|
1856
|
+
if m.locale: # strip locale from file name
|
|
1857
|
+
fname = fname.replace(f'.{m.locale}', '')
|
|
1858
|
+
srcabs = f.absolute_path(self.environment.get_source_dir(), self.environment.get_build_dir())
|
|
1859
|
+
dstname = os.path.join(subdir, os.path.basename(fname))
|
|
1860
|
+
dstabs = dstname.replace('{mandir}', manroot)
|
|
1861
|
+
i = InstallDataBase(srcabs, dstabs, dstname, m.get_custom_install_mode(), m.subproject, tag='man')
|
|
1862
|
+
d.man.append(i)
|
|
1863
|
+
|
|
1864
|
+
def generate_emptydir_install(self, d: InstallData) -> None:
|
|
1865
|
+
emptydir: T.List[build.EmptyDir] = self.build.get_emptydir()
|
|
1866
|
+
for e in emptydir:
|
|
1867
|
+
tag = e.install_tag or self.guess_install_tag(e.path)
|
|
1868
|
+
i = InstallEmptyDir(e.path, e.install_mode, e.subproject, tag)
|
|
1869
|
+
d.emptydir.append(i)
|
|
1870
|
+
|
|
1871
|
+
def generate_data_install(self, d: InstallData) -> None:
|
|
1872
|
+
data = self.build.get_data()
|
|
1873
|
+
srcdir = self.environment.get_source_dir()
|
|
1874
|
+
builddir = self.environment.get_build_dir()
|
|
1875
|
+
for de in data:
|
|
1876
|
+
assert isinstance(de, build.Data)
|
|
1877
|
+
subdir = de.install_dir
|
|
1878
|
+
subdir_name = de.install_dir_name
|
|
1879
|
+
for src_file, dst_name in zip(de.sources, de.rename):
|
|
1880
|
+
assert isinstance(src_file, mesonlib.File)
|
|
1881
|
+
dst_abs = os.path.join(subdir, dst_name)
|
|
1882
|
+
dstdir_name = os.path.join(subdir_name, dst_name)
|
|
1883
|
+
tag = de.install_tag or self.guess_install_tag(dst_abs)
|
|
1884
|
+
i = InstallDataBase(src_file.absolute_path(srcdir, builddir), dst_abs, dstdir_name,
|
|
1885
|
+
de.install_mode, de.subproject, tag=tag, data_type=de.data_type,
|
|
1886
|
+
follow_symlinks=de.follow_symlinks)
|
|
1887
|
+
d.data.append(i)
|
|
1888
|
+
|
|
1889
|
+
def generate_symlink_install(self, d: InstallData) -> None:
|
|
1890
|
+
links: T.List[build.SymlinkData] = self.build.get_symlinks()
|
|
1891
|
+
for l in links:
|
|
1892
|
+
assert isinstance(l, build.SymlinkData)
|
|
1893
|
+
install_dir = l.install_dir
|
|
1894
|
+
name_abs = os.path.join(install_dir, l.name)
|
|
1895
|
+
tag = l.install_tag or self.guess_install_tag(name_abs)
|
|
1896
|
+
s = InstallSymlinkData(l.target, name_abs, install_dir, l.subproject, tag)
|
|
1897
|
+
d.symlinks.append(s)
|
|
1898
|
+
|
|
1899
|
+
def generate_subdir_install(self, d: InstallData) -> None:
|
|
1900
|
+
for sd in self.build.get_install_subdirs():
|
|
1901
|
+
if sd.from_source_dir:
|
|
1902
|
+
from_dir = self.environment.get_source_dir()
|
|
1903
|
+
else:
|
|
1904
|
+
from_dir = self.environment.get_build_dir()
|
|
1905
|
+
src_dir = os.path.join(from_dir,
|
|
1906
|
+
sd.source_subdir,
|
|
1907
|
+
sd.installable_subdir).rstrip('/')
|
|
1908
|
+
dst_dir = os.path.join(self.environment.get_prefix(),
|
|
1909
|
+
sd.install_dir)
|
|
1910
|
+
dst_name = os.path.join('{prefix}', sd.install_dir)
|
|
1911
|
+
if sd.install_dir != sd.install_dir_name:
|
|
1912
|
+
dst_name = sd.install_dir_name
|
|
1913
|
+
if not sd.strip_directory:
|
|
1914
|
+
dst_dir = os.path.join(dst_dir, os.path.basename(src_dir))
|
|
1915
|
+
dst_name = os.path.join(dst_name, os.path.basename(src_dir))
|
|
1916
|
+
tag = sd.install_tag or self.guess_install_tag(os.path.join(sd.install_dir, 'dummy'))
|
|
1917
|
+
i = SubdirInstallData(src_dir, dst_dir, dst_name, sd.install_mode, sd.exclude, sd.subproject, tag,
|
|
1918
|
+
follow_symlinks=sd.follow_symlinks)
|
|
1919
|
+
d.install_subdirs.append(i)
|
|
1920
|
+
|
|
1921
|
+
def get_introspection_data(self, target_id: str, target: build.Target) -> T.List['TargetIntrospectionData']:
|
|
1922
|
+
'''
|
|
1923
|
+
Returns a list of source dicts with the following format for a given target:
|
|
1924
|
+
[
|
|
1925
|
+
{
|
|
1926
|
+
"language": "<LANG>",
|
|
1927
|
+
"compiler": ["result", "of", "comp.get_exelist()"],
|
|
1928
|
+
"parameters": ["list", "of", "compiler", "parameters],
|
|
1929
|
+
"sources": ["list", "of", "all", "<LANG>", "source", "files"],
|
|
1930
|
+
"generated_sources": ["list", "of", "generated", "source", "files"]
|
|
1931
|
+
}
|
|
1932
|
+
]
|
|
1933
|
+
|
|
1934
|
+
This is a limited fallback / reference implementation. The backend should override this method.
|
|
1935
|
+
'''
|
|
1936
|
+
if isinstance(target, (build.CustomTarget, build.BuildTarget)):
|
|
1937
|
+
source_list_raw = target.sources
|
|
1938
|
+
source_list = []
|
|
1939
|
+
for j in source_list_raw:
|
|
1940
|
+
if isinstance(j, mesonlib.File):
|
|
1941
|
+
source_list += [j.absolute_path(self.source_dir, self.build_dir)]
|
|
1942
|
+
elif isinstance(j, str):
|
|
1943
|
+
source_list += [os.path.join(self.source_dir, j)]
|
|
1944
|
+
elif isinstance(j, (build.CustomTarget, build.BuildTarget)):
|
|
1945
|
+
source_list += [os.path.join(self.build_dir, j.get_output_subdir(), o) for o in j.get_outputs()]
|
|
1946
|
+
source_list = [os.path.normpath(s) for s in source_list]
|
|
1947
|
+
|
|
1948
|
+
compiler: T.List[str] = []
|
|
1949
|
+
if isinstance(target, build.CustomTarget):
|
|
1950
|
+
tmp_compiler = target.command
|
|
1951
|
+
for j in tmp_compiler:
|
|
1952
|
+
if isinstance(j, mesonlib.File):
|
|
1953
|
+
compiler += [j.absolute_path(self.source_dir, self.build_dir)]
|
|
1954
|
+
elif isinstance(j, str):
|
|
1955
|
+
compiler += [j]
|
|
1956
|
+
elif isinstance(j, (build.BuildTarget, build.CustomTarget)):
|
|
1957
|
+
compiler += j.get_outputs()
|
|
1958
|
+
else:
|
|
1959
|
+
raise RuntimeError(f'Type "{type(j).__name__}" is not supported in get_introspection_data. This is a bug')
|
|
1960
|
+
|
|
1961
|
+
return [{
|
|
1962
|
+
'language': 'unknown',
|
|
1963
|
+
'compiler': compiler,
|
|
1964
|
+
'parameters': [],
|
|
1965
|
+
'sources': source_list,
|
|
1966
|
+
'generated_sources': []
|
|
1967
|
+
}]
|
|
1968
|
+
|
|
1969
|
+
return []
|
|
1970
|
+
|
|
1971
|
+
def get_devenv(self) -> mesonlib.EnvironmentVariables:
|
|
1972
|
+
env = mesonlib.EnvironmentVariables()
|
|
1973
|
+
extra_paths = set()
|
|
1974
|
+
library_paths = set()
|
|
1975
|
+
build_machine = self.environment.machines[MachineChoice.BUILD]
|
|
1976
|
+
host_machine = self.environment.machines[MachineChoice.HOST]
|
|
1977
|
+
need_wine = not build_machine.is_windows() and host_machine.is_windows()
|
|
1978
|
+
for t in self.build.get_targets().values():
|
|
1979
|
+
in_default_dir = t.should_install() and not t.get_install_dir()[2]
|
|
1980
|
+
if t.for_machine != MachineChoice.HOST or not in_default_dir:
|
|
1981
|
+
continue
|
|
1982
|
+
tdir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(t))
|
|
1983
|
+
if isinstance(t, build.Executable):
|
|
1984
|
+
# Add binaries that are going to be installed in bindir into PATH
|
|
1985
|
+
# so they get used by default instead of searching on system when
|
|
1986
|
+
# in developer environment.
|
|
1987
|
+
extra_paths.add(tdir)
|
|
1988
|
+
if host_machine.is_windows() or host_machine.is_cygwin():
|
|
1989
|
+
# On windows we cannot rely on rpath to run executables from build
|
|
1990
|
+
# directory. We have to add in PATH the location of every DLL needed.
|
|
1991
|
+
library_paths.update(self.determine_windows_extra_paths(t, []))
|
|
1992
|
+
elif isinstance(t, build.SharedLibrary):
|
|
1993
|
+
# Add libraries that are going to be installed in libdir into
|
|
1994
|
+
# LD_LIBRARY_PATH. This allows running system applications using
|
|
1995
|
+
# that library.
|
|
1996
|
+
library_paths.add(tdir)
|
|
1997
|
+
if need_wine:
|
|
1998
|
+
# Executable paths should be in both PATH and WINEPATH.
|
|
1999
|
+
# - Having them in PATH makes bash completion find it,
|
|
2000
|
+
# and make running "foo.exe" find it when wine-binfmt is installed.
|
|
2001
|
+
# - Having them in WINEPATH makes "wine foo.exe" find it.
|
|
2002
|
+
library_paths.update(extra_paths)
|
|
2003
|
+
if library_paths:
|
|
2004
|
+
if need_wine:
|
|
2005
|
+
env.prepend('WINEPATH', list(library_paths), separator=';')
|
|
2006
|
+
elif host_machine.is_windows() or host_machine.is_cygwin():
|
|
2007
|
+
extra_paths.update(library_paths)
|
|
2008
|
+
elif host_machine.is_darwin():
|
|
2009
|
+
env.prepend('DYLD_LIBRARY_PATH', list(library_paths))
|
|
2010
|
+
else:
|
|
2011
|
+
env.prepend('LD_LIBRARY_PATH', list(library_paths))
|
|
2012
|
+
if extra_paths:
|
|
2013
|
+
env.prepend('PATH', list(extra_paths))
|
|
2014
|
+
return env
|
|
2015
|
+
|
|
2016
|
+
def compiler_to_generator(self, target: build.BuildTarget,
|
|
2017
|
+
compiler: 'Compiler',
|
|
2018
|
+
sources: _ALL_SOURCES_TYPE,
|
|
2019
|
+
output_templ: str,
|
|
2020
|
+
depends: T.Optional[T.List[T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]]] = None,
|
|
2021
|
+
) -> build.GeneratedList:
|
|
2022
|
+
'''
|
|
2023
|
+
Some backends don't support custom compilers. This is a convenience
|
|
2024
|
+
method to convert a Compiler to a Generator.
|
|
2025
|
+
'''
|
|
2026
|
+
exelist = compiler.get_exelist()
|
|
2027
|
+
exe = programs.ExternalProgram(exelist[0])
|
|
2028
|
+
args = exelist[1:]
|
|
2029
|
+
# FIXME: There are many other args missing
|
|
2030
|
+
commands = self.generate_basic_compiler_args(target, compiler)
|
|
2031
|
+
commands += compiler.get_dependency_gen_args('@OUTPUT@', '@DEPFILE@')
|
|
2032
|
+
commands += compiler.get_output_args('@OUTPUT@')
|
|
2033
|
+
commands += compiler.get_compile_only_args() + ['@INPUT@']
|
|
2034
|
+
commands += self.get_source_dir_include_args(target, compiler)
|
|
2035
|
+
commands += self.get_build_dir_include_args(target, compiler)
|
|
2036
|
+
# Add per-target compile args, f.ex, `c_args : ['-DFOO']`. We set these
|
|
2037
|
+
# near the end since these are supposed to override everything else.
|
|
2038
|
+
commands += self.escape_extra_args(target.get_extra_args(compiler.get_language()))
|
|
2039
|
+
generator = build.Generator(exe, args + commands.to_native(),
|
|
2040
|
+
[output_templ], depfile='@PLAINNAME@.d',
|
|
2041
|
+
depends=depends)
|
|
2042
|
+
return generator.process_files(sources, self.interpreter)
|
|
2043
|
+
|
|
2044
|
+
def compile_target_to_generator(self, target: build.CompileTarget) -> build.GeneratedList:
|
|
2045
|
+
all_sources = T.cast('_ALL_SOURCES_TYPE', target.sources) + T.cast('_ALL_SOURCES_TYPE', target.generated)
|
|
2046
|
+
return self.compiler_to_generator(target, target.compiler, all_sources,
|
|
2047
|
+
target.output_templ, target.depends)
|