frida 16.2.1 → 16.2.3
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,2078 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright 2014-2016 The Meson development team
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
import copy
|
|
6
|
+
import itertools
|
|
7
|
+
import os
|
|
8
|
+
import xml.dom.minidom
|
|
9
|
+
import xml.etree.ElementTree as ET
|
|
10
|
+
import uuid
|
|
11
|
+
import typing as T
|
|
12
|
+
from pathlib import Path, PurePath, PureWindowsPath
|
|
13
|
+
import re
|
|
14
|
+
from collections import Counter
|
|
15
|
+
|
|
16
|
+
from . import backends
|
|
17
|
+
from .. import build
|
|
18
|
+
from .. import mlog
|
|
19
|
+
from .. import compilers
|
|
20
|
+
from .. import mesonlib
|
|
21
|
+
from ..mesonlib import (
|
|
22
|
+
File, MesonBugException, MesonException, replace_if_different, OptionKey, version_compare, MachineChoice
|
|
23
|
+
)
|
|
24
|
+
from ..environment import Environment, build_filename
|
|
25
|
+
from .. import coredata
|
|
26
|
+
|
|
27
|
+
if T.TYPE_CHECKING:
|
|
28
|
+
from ..arglist import CompilerArgs
|
|
29
|
+
from ..interpreter import Interpreter
|
|
30
|
+
|
|
31
|
+
Project = T.Tuple[str, Path, str, MachineChoice]
|
|
32
|
+
|
|
33
|
+
def autodetect_vs_version(build: T.Optional[build.Build], interpreter: T.Optional[Interpreter]) -> backends.Backend:
|
|
34
|
+
vs_version = os.getenv('VisualStudioVersion', None)
|
|
35
|
+
vs_install_dir = os.getenv('VSINSTALLDIR', None)
|
|
36
|
+
if not vs_install_dir:
|
|
37
|
+
raise MesonException('Could not detect Visual Studio: Environment variable VSINSTALLDIR is not set!\n'
|
|
38
|
+
'Are you running meson from the Visual Studio Developer Command Prompt?')
|
|
39
|
+
# VisualStudioVersion is set since Visual Studio 11.0, but sometimes
|
|
40
|
+
# vcvarsall.bat doesn't set it, so also use VSINSTALLDIR
|
|
41
|
+
if vs_version == '11.0' or 'Visual Studio 11' in vs_install_dir:
|
|
42
|
+
from mesonbuild.backend.vs2012backend import Vs2012Backend
|
|
43
|
+
return Vs2012Backend(build, interpreter)
|
|
44
|
+
if vs_version == '12.0' or 'Visual Studio 12' in vs_install_dir:
|
|
45
|
+
from mesonbuild.backend.vs2013backend import Vs2013Backend
|
|
46
|
+
return Vs2013Backend(build, interpreter)
|
|
47
|
+
if vs_version == '14.0' or 'Visual Studio 14' in vs_install_dir:
|
|
48
|
+
from mesonbuild.backend.vs2015backend import Vs2015Backend
|
|
49
|
+
return Vs2015Backend(build, interpreter)
|
|
50
|
+
if vs_version == '15.0' or 'Visual Studio 17' in vs_install_dir or \
|
|
51
|
+
'Visual Studio\\2017' in vs_install_dir:
|
|
52
|
+
from mesonbuild.backend.vs2017backend import Vs2017Backend
|
|
53
|
+
return Vs2017Backend(build, interpreter)
|
|
54
|
+
if vs_version == '16.0' or 'Visual Studio 19' in vs_install_dir or \
|
|
55
|
+
'Visual Studio\\2019' in vs_install_dir:
|
|
56
|
+
from mesonbuild.backend.vs2019backend import Vs2019Backend
|
|
57
|
+
return Vs2019Backend(build, interpreter)
|
|
58
|
+
if vs_version == '17.0' or 'Visual Studio 22' in vs_install_dir or \
|
|
59
|
+
'Visual Studio\\2022' in vs_install_dir:
|
|
60
|
+
from mesonbuild.backend.vs2022backend import Vs2022Backend
|
|
61
|
+
return Vs2022Backend(build, interpreter)
|
|
62
|
+
if 'Visual Studio 10.0' in vs_install_dir:
|
|
63
|
+
return Vs2010Backend(build, interpreter)
|
|
64
|
+
raise MesonException('Could not detect Visual Studio using VisualStudioVersion: {!r} or VSINSTALLDIR: {!r}!\n'
|
|
65
|
+
'Please specify the exact backend to use.'.format(vs_version, vs_install_dir))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def split_o_flags_args(args: T.List[str]) -> T.List[str]:
|
|
69
|
+
"""
|
|
70
|
+
Splits any /O args and returns them. Does not take care of flags overriding
|
|
71
|
+
previous ones. Skips non-O flag arguments.
|
|
72
|
+
|
|
73
|
+
['/Ox', '/Ob1'] returns ['/Ox', '/Ob1']
|
|
74
|
+
['/Oxj', '/MP'] returns ['/Ox', '/Oj']
|
|
75
|
+
"""
|
|
76
|
+
o_flags = []
|
|
77
|
+
for arg in args:
|
|
78
|
+
if not arg.startswith('/O'):
|
|
79
|
+
continue
|
|
80
|
+
flags = list(arg[2:])
|
|
81
|
+
# Assume that this one can't be clumped with the others since it takes
|
|
82
|
+
# an argument itself
|
|
83
|
+
if 'b' in flags:
|
|
84
|
+
o_flags.append(arg)
|
|
85
|
+
else:
|
|
86
|
+
o_flags += ['/O' + f for f in flags]
|
|
87
|
+
return o_flags
|
|
88
|
+
|
|
89
|
+
def generate_guid_from_path(path, path_type) -> str:
|
|
90
|
+
return str(uuid.uuid5(uuid.NAMESPACE_URL, 'meson-vs-' + path_type + ':' + str(path))).upper()
|
|
91
|
+
|
|
92
|
+
def detect_microsoft_gdk(platform: str) -> bool:
|
|
93
|
+
return re.match(r'Gaming\.(Desktop|Xbox.XboxOne|Xbox.Scarlett)\.x64', platform, re.IGNORECASE)
|
|
94
|
+
|
|
95
|
+
def filtered_src_langs_generator(sources: T.List[str]):
|
|
96
|
+
for src in sources:
|
|
97
|
+
ext = src.split('.')[-1]
|
|
98
|
+
if compilers.compilers.is_source_suffix(ext):
|
|
99
|
+
yield compilers.compilers.SUFFIX_TO_LANG[ext]
|
|
100
|
+
|
|
101
|
+
# Returns the source language (i.e. a key from 'lang_suffixes') of the most frequent source language in the given
|
|
102
|
+
# list of sources.
|
|
103
|
+
# We choose the most frequent language as 'primary' because it means the most sources in a target/project can
|
|
104
|
+
# simply refer to the project's shared intellisense define and include fields, rather than have to fill out their
|
|
105
|
+
# own duplicate full set of defines/includes/opts intellisense fields. All of which helps keep the vcxproj file
|
|
106
|
+
# size down.
|
|
107
|
+
def get_primary_source_lang(target_sources: T.List[File], custom_sources: T.List[str]) -> T.Optional[str]:
|
|
108
|
+
lang_counts = Counter([compilers.compilers.SUFFIX_TO_LANG[src.suffix] for src in target_sources if compilers.compilers.is_source_suffix(src.suffix)])
|
|
109
|
+
lang_counts += Counter(filtered_src_langs_generator(custom_sources))
|
|
110
|
+
most_common_lang_list = lang_counts.most_common(1)
|
|
111
|
+
# It may be possible that we have a target with no actual src files of interest (e.g. a generator target),
|
|
112
|
+
# leaving us with an empty list, which we should handle -
|
|
113
|
+
return most_common_lang_list[0][0] if most_common_lang_list else None
|
|
114
|
+
|
|
115
|
+
# Returns a dictionary (by [src type][build type]) that contains a tuple of -
|
|
116
|
+
# (pre-processor defines, include paths, additional compiler options)
|
|
117
|
+
# fields to use to fill in the respective intellisense fields of sources that can't simply
|
|
118
|
+
# reference and re-use the shared 'primary' language intellisense fields of the vcxproj.
|
|
119
|
+
def get_non_primary_lang_intellisense_fields(vslite_ctx: dict,
|
|
120
|
+
target_id: str,
|
|
121
|
+
primary_src_lang: str) -> T.Dict[str, T.Dict[str, T.Tuple[str, str, str]]]:
|
|
122
|
+
defs_paths_opts_per_lang_and_buildtype = {}
|
|
123
|
+
for buildtype in coredata.get_genvs_default_buildtype_list():
|
|
124
|
+
captured_build_args = vslite_ctx[buildtype][target_id] # Results in a 'Src types to compile args' dict
|
|
125
|
+
non_primary_build_args_per_src_lang = [(lang, build_args) for lang, build_args in captured_build_args.items() if lang != primary_src_lang] # Only need to individually populate intellisense fields for sources of non-primary types.
|
|
126
|
+
for src_lang, args_list in non_primary_build_args_per_src_lang:
|
|
127
|
+
if src_lang not in defs_paths_opts_per_lang_and_buildtype:
|
|
128
|
+
defs_paths_opts_per_lang_and_buildtype[src_lang] = {}
|
|
129
|
+
defs_paths_opts_per_lang_and_buildtype[src_lang][buildtype] = Vs2010Backend._extract_nmake_fields(args_list)
|
|
130
|
+
return defs_paths_opts_per_lang_and_buildtype
|
|
131
|
+
|
|
132
|
+
class Vs2010Backend(backends.Backend):
|
|
133
|
+
|
|
134
|
+
name = 'vs2010'
|
|
135
|
+
|
|
136
|
+
def __init__(self, build: T.Optional[build.Build], interpreter: T.Optional[Interpreter], gen_lite: bool = False):
|
|
137
|
+
super().__init__(build, interpreter)
|
|
138
|
+
self.project_file_version = '10.0.30319.1'
|
|
139
|
+
self.sln_file_version = '11.00'
|
|
140
|
+
self.sln_version_comment = '2010'
|
|
141
|
+
self.platform_toolset = None
|
|
142
|
+
self.vs_version = '2010'
|
|
143
|
+
self.windows_target_platform_version = None
|
|
144
|
+
self.subdirs = {}
|
|
145
|
+
self.handled_target_deps = {}
|
|
146
|
+
self.gen_lite = gen_lite # Synonymous with generating the simpler makefile-style multi-config projects that invoke 'meson compile' builds, avoiding native MSBuild complications
|
|
147
|
+
|
|
148
|
+
def get_target_private_dir(self, target):
|
|
149
|
+
return os.path.join(self.get_target_dir(target), target.get_id())
|
|
150
|
+
|
|
151
|
+
def generate_genlist_for_target(self, genlist: T.Union[build.GeneratedList, build.CustomTarget, build.CustomTargetIndex], target: build.BuildTarget, parent_node: ET.Element, generator_output_files: T.List[str], custom_target_include_dirs: T.List[str], custom_target_output_files: T.List[str]) -> None:
|
|
152
|
+
if isinstance(genlist, build.GeneratedList):
|
|
153
|
+
for x in genlist.depends:
|
|
154
|
+
self.generate_genlist_for_target(x, target, parent_node, [], [], [])
|
|
155
|
+
target_private_dir = self.relpath(self.get_target_private_dir(target), self.get_target_dir(target))
|
|
156
|
+
down = self.target_to_build_root(target)
|
|
157
|
+
if isinstance(genlist, (build.CustomTarget, build.CustomTargetIndex)):
|
|
158
|
+
for i in genlist.get_outputs():
|
|
159
|
+
# Path to the generated source from the current vcxproj dir via the build root
|
|
160
|
+
ipath = os.path.join(down, self.get_target_dir(genlist), i)
|
|
161
|
+
custom_target_output_files.append(ipath)
|
|
162
|
+
idir = self.relpath(self.get_target_dir(genlist), self.get_target_dir(target))
|
|
163
|
+
if idir not in custom_target_include_dirs:
|
|
164
|
+
custom_target_include_dirs.append(idir)
|
|
165
|
+
else:
|
|
166
|
+
generator = genlist.get_generator()
|
|
167
|
+
exe = generator.get_exe()
|
|
168
|
+
infilelist = genlist.get_inputs()
|
|
169
|
+
outfilelist = genlist.get_outputs()
|
|
170
|
+
source_dir = os.path.join(down, self.build_to_src, genlist.subdir)
|
|
171
|
+
idgroup = ET.SubElement(parent_node, 'ItemGroup')
|
|
172
|
+
samelen = len(infilelist) == len(outfilelist)
|
|
173
|
+
for i, curfile in enumerate(infilelist):
|
|
174
|
+
if samelen:
|
|
175
|
+
sole_output = os.path.join(target_private_dir, outfilelist[i])
|
|
176
|
+
else:
|
|
177
|
+
sole_output = ''
|
|
178
|
+
infilename = os.path.join(down, curfile.rel_to_builddir(self.build_to_src, target_private_dir))
|
|
179
|
+
deps = self.get_target_depend_files(genlist, True)
|
|
180
|
+
base_args = generator.get_arglist(infilename)
|
|
181
|
+
outfiles_rel = genlist.get_outputs_for(curfile)
|
|
182
|
+
outfiles = [os.path.join(target_private_dir, of) for of in outfiles_rel]
|
|
183
|
+
generator_output_files += outfiles
|
|
184
|
+
args = [x.replace("@INPUT@", infilename).replace('@OUTPUT@', sole_output)
|
|
185
|
+
for x in base_args]
|
|
186
|
+
args = self.replace_outputs(args, target_private_dir, outfiles_rel)
|
|
187
|
+
args = [x.replace("@SOURCE_DIR@", self.environment.get_source_dir())
|
|
188
|
+
.replace("@BUILD_DIR@", target_private_dir)
|
|
189
|
+
for x in args]
|
|
190
|
+
args = [x.replace("@CURRENT_SOURCE_DIR@", source_dir) for x in args]
|
|
191
|
+
args = [x.replace("@SOURCE_ROOT@", self.environment.get_source_dir())
|
|
192
|
+
.replace("@BUILD_ROOT@", self.environment.get_build_dir())
|
|
193
|
+
for x in args]
|
|
194
|
+
args = [x.replace('\\', '/') for x in args]
|
|
195
|
+
# Always use a wrapper because MSBuild eats random characters when
|
|
196
|
+
# there are many arguments.
|
|
197
|
+
tdir_abs = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target))
|
|
198
|
+
cmd, _ = self.as_meson_exe_cmdline(
|
|
199
|
+
exe,
|
|
200
|
+
self.replace_extra_args(args, genlist),
|
|
201
|
+
workdir=tdir_abs,
|
|
202
|
+
capture=outfiles[0] if generator.capture else None,
|
|
203
|
+
force_serialize=True,
|
|
204
|
+
env=genlist.env
|
|
205
|
+
)
|
|
206
|
+
deps = cmd[-1:] + deps
|
|
207
|
+
abs_pdir = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target))
|
|
208
|
+
os.makedirs(abs_pdir, exist_ok=True)
|
|
209
|
+
cbs = ET.SubElement(idgroup, 'CustomBuild', Include=infilename)
|
|
210
|
+
ET.SubElement(cbs, 'Command').text = ' '.join(self.quote_arguments(cmd))
|
|
211
|
+
ET.SubElement(cbs, 'Outputs').text = ';'.join(outfiles)
|
|
212
|
+
ET.SubElement(cbs, 'AdditionalInputs').text = ';'.join(deps)
|
|
213
|
+
|
|
214
|
+
def generate_custom_generator_commands(self, target, parent_node):
|
|
215
|
+
generator_output_files = []
|
|
216
|
+
custom_target_include_dirs = []
|
|
217
|
+
custom_target_output_files = []
|
|
218
|
+
for genlist in target.get_generated_sources():
|
|
219
|
+
self.generate_genlist_for_target(genlist, target, parent_node, generator_output_files, custom_target_include_dirs, custom_target_output_files)
|
|
220
|
+
return generator_output_files, custom_target_output_files, custom_target_include_dirs
|
|
221
|
+
|
|
222
|
+
def generate(self,
|
|
223
|
+
capture: bool = False,
|
|
224
|
+
vslite_ctx: dict = None) -> T.Optional[dict]:
|
|
225
|
+
# Check for (currently) unexpected capture arg use cases -
|
|
226
|
+
if capture:
|
|
227
|
+
raise MesonBugException('We do not expect any vs backend to generate with \'capture = True\'')
|
|
228
|
+
host_machine = self.environment.machines.host.cpu_family
|
|
229
|
+
if host_machine in {'64', 'x86_64'}:
|
|
230
|
+
# amd64 or x86_64
|
|
231
|
+
target_system = self.environment.machines.host.system
|
|
232
|
+
if detect_microsoft_gdk(target_system):
|
|
233
|
+
self.platform = target_system
|
|
234
|
+
else:
|
|
235
|
+
self.platform = 'x64'
|
|
236
|
+
elif host_machine == 'x86':
|
|
237
|
+
# x86
|
|
238
|
+
self.platform = 'Win32'
|
|
239
|
+
elif host_machine in {'aarch64', 'arm64'}:
|
|
240
|
+
target_cpu = self.environment.machines.host.cpu
|
|
241
|
+
if target_cpu == 'arm64ec':
|
|
242
|
+
self.platform = 'arm64ec'
|
|
243
|
+
else:
|
|
244
|
+
self.platform = 'arm64'
|
|
245
|
+
elif 'arm' in host_machine.lower():
|
|
246
|
+
self.platform = 'ARM'
|
|
247
|
+
else:
|
|
248
|
+
raise MesonException('Unsupported Visual Studio platform: ' + host_machine)
|
|
249
|
+
|
|
250
|
+
build_machine = self.environment.machines.build.cpu_family
|
|
251
|
+
if build_machine in {'64', 'x86_64'}:
|
|
252
|
+
# amd64 or x86_64
|
|
253
|
+
self.build_platform = 'x64'
|
|
254
|
+
elif build_machine == 'x86':
|
|
255
|
+
# x86
|
|
256
|
+
self.build_platform = 'Win32'
|
|
257
|
+
elif build_machine in {'aarch64', 'arm64'}:
|
|
258
|
+
target_cpu = self.environment.machines.build.cpu
|
|
259
|
+
if target_cpu == 'arm64ec':
|
|
260
|
+
self.build_platform = 'arm64ec'
|
|
261
|
+
else:
|
|
262
|
+
self.build_platform = 'arm64'
|
|
263
|
+
elif 'arm' in build_machine.lower():
|
|
264
|
+
self.build_platform = 'ARM'
|
|
265
|
+
else:
|
|
266
|
+
raise MesonException('Unsupported Visual Studio platform: ' + build_machine)
|
|
267
|
+
|
|
268
|
+
self.buildtype = self.environment.coredata.get_option(OptionKey('buildtype'))
|
|
269
|
+
self.optimization = self.environment.coredata.get_option(OptionKey('optimization'))
|
|
270
|
+
self.debug = self.environment.coredata.get_option(OptionKey('debug'))
|
|
271
|
+
try:
|
|
272
|
+
self.sanitize = self.environment.coredata.get_option(OptionKey('b_sanitize'))
|
|
273
|
+
except MesonException:
|
|
274
|
+
self.sanitize = 'none'
|
|
275
|
+
sln_filename = os.path.join(self.environment.get_build_dir(), self.build.project_name + '.sln')
|
|
276
|
+
projlist = self.generate_projects(vslite_ctx)
|
|
277
|
+
self.gen_testproj()
|
|
278
|
+
self.gen_installproj()
|
|
279
|
+
self.gen_regenproj()
|
|
280
|
+
self.generate_solution(sln_filename, projlist)
|
|
281
|
+
self.generate_regen_info()
|
|
282
|
+
Vs2010Backend.touch_regen_timestamp(self.environment.get_build_dir())
|
|
283
|
+
|
|
284
|
+
@staticmethod
|
|
285
|
+
def get_regen_stampfile(build_dir: str) -> None:
|
|
286
|
+
return os.path.join(os.path.join(build_dir, Environment.private_dir), 'regen.stamp')
|
|
287
|
+
|
|
288
|
+
@staticmethod
|
|
289
|
+
def touch_regen_timestamp(build_dir: str) -> None:
|
|
290
|
+
with open(Vs2010Backend.get_regen_stampfile(build_dir), 'w', encoding='utf-8'):
|
|
291
|
+
pass
|
|
292
|
+
|
|
293
|
+
def get_vcvars_command(self):
|
|
294
|
+
has_arch_values = 'VSCMD_ARG_TGT_ARCH' in os.environ and 'VSCMD_ARG_HOST_ARCH' in os.environ
|
|
295
|
+
|
|
296
|
+
# Use vcvarsall.bat if we found it.
|
|
297
|
+
if 'VCINSTALLDIR' in os.environ:
|
|
298
|
+
vs_version = os.environ['VisualStudioVersion'] \
|
|
299
|
+
if 'VisualStudioVersion' in os.environ else None
|
|
300
|
+
relative_path = 'Auxiliary\\Build\\' if vs_version is not None and vs_version >= '15.0' else ''
|
|
301
|
+
script_path = os.environ['VCINSTALLDIR'] + relative_path + 'vcvarsall.bat'
|
|
302
|
+
if os.path.exists(script_path):
|
|
303
|
+
if has_arch_values:
|
|
304
|
+
target_arch = os.environ['VSCMD_ARG_TGT_ARCH']
|
|
305
|
+
host_arch = os.environ['VSCMD_ARG_HOST_ARCH']
|
|
306
|
+
else:
|
|
307
|
+
target_arch = os.environ.get('Platform', 'x86')
|
|
308
|
+
host_arch = target_arch
|
|
309
|
+
arch = host_arch + '_' + target_arch if host_arch != target_arch else target_arch
|
|
310
|
+
return f'"{script_path}" {arch}'
|
|
311
|
+
|
|
312
|
+
# Otherwise try the VS2017 Developer Command Prompt.
|
|
313
|
+
if 'VS150COMNTOOLS' in os.environ and has_arch_values:
|
|
314
|
+
script_path = os.environ['VS150COMNTOOLS'] + 'VsDevCmd.bat'
|
|
315
|
+
if os.path.exists(script_path):
|
|
316
|
+
return '"%s" -arch=%s -host_arch=%s' % \
|
|
317
|
+
(script_path, os.environ['VSCMD_ARG_TGT_ARCH'], os.environ['VSCMD_ARG_HOST_ARCH'])
|
|
318
|
+
return ''
|
|
319
|
+
|
|
320
|
+
def get_obj_target_deps(self, obj_list):
|
|
321
|
+
result = {}
|
|
322
|
+
for o in obj_list:
|
|
323
|
+
if isinstance(o, build.ExtractedObjects):
|
|
324
|
+
result[o.target.get_id()] = o.target
|
|
325
|
+
return result.items()
|
|
326
|
+
|
|
327
|
+
def get_target_deps(self, t: T.Dict[T.Any, build.Target], recursive=False):
|
|
328
|
+
all_deps: T.Dict[str, build.Target] = {}
|
|
329
|
+
for target in t.values():
|
|
330
|
+
if isinstance(target, build.CustomTarget):
|
|
331
|
+
for d in target.get_target_dependencies():
|
|
332
|
+
# FIXME: this isn't strictly correct, as the target doesn't
|
|
333
|
+
# Get dependencies on non-targets, such as Files
|
|
334
|
+
if isinstance(d, build.Target):
|
|
335
|
+
all_deps[d.get_id()] = d
|
|
336
|
+
elif isinstance(target, build.RunTarget):
|
|
337
|
+
for d in target.get_dependencies():
|
|
338
|
+
all_deps[d.get_id()] = d
|
|
339
|
+
elif isinstance(target, build.BuildTarget):
|
|
340
|
+
for ldep in target.link_targets:
|
|
341
|
+
if isinstance(ldep, build.CustomTargetIndex):
|
|
342
|
+
all_deps[ldep.get_id()] = ldep.target
|
|
343
|
+
else:
|
|
344
|
+
all_deps[ldep.get_id()] = ldep
|
|
345
|
+
for ldep in target.link_whole_targets:
|
|
346
|
+
if isinstance(ldep, build.CustomTargetIndex):
|
|
347
|
+
all_deps[ldep.get_id()] = ldep.target
|
|
348
|
+
else:
|
|
349
|
+
all_deps[ldep.get_id()] = ldep
|
|
350
|
+
|
|
351
|
+
for ldep in target.link_depends:
|
|
352
|
+
if isinstance(ldep, build.CustomTargetIndex):
|
|
353
|
+
all_deps[ldep.get_id()] = ldep.target
|
|
354
|
+
elif isinstance(ldep, File):
|
|
355
|
+
# Already built, no target references needed
|
|
356
|
+
pass
|
|
357
|
+
else:
|
|
358
|
+
all_deps[ldep.get_id()] = ldep
|
|
359
|
+
|
|
360
|
+
for obj_id, objdep in self.get_obj_target_deps(target.objects):
|
|
361
|
+
all_deps[obj_id] = objdep
|
|
362
|
+
else:
|
|
363
|
+
raise MesonException(f'Unknown target type for target {target}')
|
|
364
|
+
|
|
365
|
+
for gendep in target.get_generated_sources():
|
|
366
|
+
if isinstance(gendep, build.CustomTarget):
|
|
367
|
+
all_deps[gendep.get_id()] = gendep
|
|
368
|
+
elif isinstance(gendep, build.CustomTargetIndex):
|
|
369
|
+
all_deps[gendep.target.get_id()] = gendep.target
|
|
370
|
+
else:
|
|
371
|
+
generator = gendep.get_generator()
|
|
372
|
+
gen_exe = generator.get_exe()
|
|
373
|
+
if isinstance(gen_exe, build.Executable):
|
|
374
|
+
all_deps[gen_exe.get_id()] = gen_exe
|
|
375
|
+
for d in itertools.chain(generator.depends, gendep.depends):
|
|
376
|
+
if isinstance(d, build.CustomTargetIndex):
|
|
377
|
+
all_deps[d.get_id()] = d.target
|
|
378
|
+
elif isinstance(d, build.Target):
|
|
379
|
+
all_deps[d.get_id()] = d
|
|
380
|
+
# FIXME: we don't handle other kinds of deps correctly here, such
|
|
381
|
+
# as GeneratedLists, StructuredSources, and generated File.
|
|
382
|
+
|
|
383
|
+
if not t or not recursive:
|
|
384
|
+
return all_deps
|
|
385
|
+
ret = self.get_target_deps(all_deps, recursive)
|
|
386
|
+
ret.update(all_deps)
|
|
387
|
+
return ret
|
|
388
|
+
|
|
389
|
+
def generate_solution_dirs(self, ofile: str, parents: T.Sequence[Path]) -> None:
|
|
390
|
+
prj_templ = 'Project("{%s}") = "%s", "%s", "{%s}"\n'
|
|
391
|
+
iterpaths = reversed(parents)
|
|
392
|
+
# Skip first path
|
|
393
|
+
next(iterpaths)
|
|
394
|
+
for path in iterpaths:
|
|
395
|
+
if path not in self.subdirs:
|
|
396
|
+
basename = path.name
|
|
397
|
+
identifier = generate_guid_from_path(path, 'subdir')
|
|
398
|
+
# top-level directories have None as their parent_dir
|
|
399
|
+
parent_dir = path.parent
|
|
400
|
+
parent_identifier = self.subdirs[parent_dir][0] \
|
|
401
|
+
if parent_dir != PurePath('.') else None
|
|
402
|
+
self.subdirs[path] = (identifier, parent_identifier)
|
|
403
|
+
prj_line = prj_templ % (
|
|
404
|
+
self.environment.coredata.lang_guids['directory'],
|
|
405
|
+
basename, basename, self.subdirs[path][0])
|
|
406
|
+
ofile.write(prj_line)
|
|
407
|
+
ofile.write('EndProject\n')
|
|
408
|
+
|
|
409
|
+
def generate_solution(self, sln_filename: str, projlist: T.List[Project]) -> None:
|
|
410
|
+
default_projlist = self.get_build_by_default_targets()
|
|
411
|
+
default_projlist.update(self.get_testlike_targets())
|
|
412
|
+
sln_filename_tmp = sln_filename + '~'
|
|
413
|
+
# Note using the utf-8 BOM requires the blank line, otherwise Visual Studio Version Selector fails.
|
|
414
|
+
# Without the BOM, VSVS fails if there is a blank line.
|
|
415
|
+
with open(sln_filename_tmp, 'w', encoding='utf-8-sig') as ofile:
|
|
416
|
+
ofile.write('\nMicrosoft Visual Studio Solution File, Format Version %s\n' % self.sln_file_version)
|
|
417
|
+
ofile.write('# Visual Studio %s\n' % self.sln_version_comment)
|
|
418
|
+
prj_templ = 'Project("{%s}") = "%s", "%s", "{%s}"\n'
|
|
419
|
+
for prj in projlist:
|
|
420
|
+
if self.environment.coredata.get_option(OptionKey('layout')) == 'mirror':
|
|
421
|
+
self.generate_solution_dirs(ofile, prj[1].parents)
|
|
422
|
+
target = self.build.targets[prj[0]]
|
|
423
|
+
lang = 'default'
|
|
424
|
+
if hasattr(target, 'compilers') and target.compilers:
|
|
425
|
+
for lang_out in target.compilers.keys():
|
|
426
|
+
lang = lang_out
|
|
427
|
+
break
|
|
428
|
+
prj_line = prj_templ % (
|
|
429
|
+
self.environment.coredata.lang_guids[lang],
|
|
430
|
+
prj[0], prj[1], prj[2])
|
|
431
|
+
ofile.write(prj_line)
|
|
432
|
+
target_dict = {target.get_id(): target}
|
|
433
|
+
# Get recursive deps
|
|
434
|
+
recursive_deps = self.get_target_deps(
|
|
435
|
+
target_dict, recursive=True)
|
|
436
|
+
ofile.write('EndProject\n')
|
|
437
|
+
for dep, target in recursive_deps.items():
|
|
438
|
+
if prj[0] in default_projlist:
|
|
439
|
+
default_projlist[dep] = target
|
|
440
|
+
|
|
441
|
+
test_line = prj_templ % (self.environment.coredata.lang_guids['default'],
|
|
442
|
+
'RUN_TESTS', 'RUN_TESTS.vcxproj',
|
|
443
|
+
self.environment.coredata.test_guid)
|
|
444
|
+
ofile.write(test_line)
|
|
445
|
+
ofile.write('EndProject\n')
|
|
446
|
+
if self.gen_lite: # REGEN is replaced by the lighter-weight RECONFIGURE utility, for now. See comment in 'gen_regenproj'
|
|
447
|
+
regen_proj_name = 'RECONFIGURE'
|
|
448
|
+
regen_proj_fname = 'RECONFIGURE.vcxproj'
|
|
449
|
+
else:
|
|
450
|
+
regen_proj_name = 'REGEN'
|
|
451
|
+
regen_proj_fname = 'REGEN.vcxproj'
|
|
452
|
+
regen_line = prj_templ % (self.environment.coredata.lang_guids['default'],
|
|
453
|
+
regen_proj_name, regen_proj_fname,
|
|
454
|
+
self.environment.coredata.regen_guid)
|
|
455
|
+
ofile.write(regen_line)
|
|
456
|
+
ofile.write('EndProject\n')
|
|
457
|
+
install_line = prj_templ % (self.environment.coredata.lang_guids['default'],
|
|
458
|
+
'RUN_INSTALL', 'RUN_INSTALL.vcxproj',
|
|
459
|
+
self.environment.coredata.install_guid)
|
|
460
|
+
ofile.write(install_line)
|
|
461
|
+
ofile.write('EndProject\n')
|
|
462
|
+
ofile.write('Global\n')
|
|
463
|
+
ofile.write('\tGlobalSection(SolutionConfigurationPlatforms) = '
|
|
464
|
+
'preSolution\n')
|
|
465
|
+
multi_config_buildtype_list = coredata.get_genvs_default_buildtype_list() if self.gen_lite else [self.buildtype]
|
|
466
|
+
for buildtype in multi_config_buildtype_list:
|
|
467
|
+
ofile.write('\t\t%s|%s = %s|%s\n' %
|
|
468
|
+
(buildtype, self.platform, buildtype,
|
|
469
|
+
self.platform))
|
|
470
|
+
ofile.write('\tEndGlobalSection\n')
|
|
471
|
+
ofile.write('\tGlobalSection(ProjectConfigurationPlatforms) = '
|
|
472
|
+
'postSolution\n')
|
|
473
|
+
# REGEN project (multi-)configurations
|
|
474
|
+
for buildtype in multi_config_buildtype_list:
|
|
475
|
+
ofile.write('\t\t{%s}.%s|%s.ActiveCfg = %s|%s\n' %
|
|
476
|
+
(self.environment.coredata.regen_guid, buildtype,
|
|
477
|
+
self.platform, buildtype, self.platform))
|
|
478
|
+
if not self.gen_lite: # With a 'genvslite'-generated solution, the regen (i.e. reconfigure) utility is only intended to run when the user explicitly builds this proj.
|
|
479
|
+
ofile.write('\t\t{%s}.%s|%s.Build.0 = %s|%s\n' %
|
|
480
|
+
(self.environment.coredata.regen_guid, buildtype,
|
|
481
|
+
self.platform, buildtype, self.platform))
|
|
482
|
+
# Create the solution configuration
|
|
483
|
+
for project_index, p in enumerate(projlist):
|
|
484
|
+
if p[3] is MachineChoice.BUILD:
|
|
485
|
+
config_platform = self.build_platform
|
|
486
|
+
else:
|
|
487
|
+
config_platform = self.platform
|
|
488
|
+
# Add to the list of projects in this solution
|
|
489
|
+
for buildtype in multi_config_buildtype_list:
|
|
490
|
+
ofile.write('\t\t{%s}.%s|%s.ActiveCfg = %s|%s\n' %
|
|
491
|
+
(p[2], buildtype, self.platform,
|
|
492
|
+
buildtype, config_platform))
|
|
493
|
+
# If we're building the solution with Visual Studio's build system, enable building of buildable
|
|
494
|
+
# projects. However, if we're building with meson (via --genvslite), then, since each project's
|
|
495
|
+
# 'build' action just ends up doing the same 'meson compile ...' we don't want the 'solution build'
|
|
496
|
+
# repeatedly going off and doing the same 'meson compile ...' multiple times over, so we default
|
|
497
|
+
# to building the startup project, which is the first listed project in the solution file by
|
|
498
|
+
# default for Visual Studio. The user is free to change this afterwards, but this provides a
|
|
499
|
+
# sensible default.
|
|
500
|
+
if (not self.gen_lite or project_index == 0) and \
|
|
501
|
+
p[0] in default_projlist and \
|
|
502
|
+
not isinstance(self.build.targets[p[0]], build.RunTarget):
|
|
503
|
+
ofile.write('\t\t{%s}.%s|%s.Build.0 = %s|%s\n' %
|
|
504
|
+
(p[2], buildtype, self.platform,
|
|
505
|
+
buildtype, config_platform))
|
|
506
|
+
# RUN_TESTS and RUN_INSTALL project (multi-)configurations
|
|
507
|
+
for buildtype in multi_config_buildtype_list:
|
|
508
|
+
ofile.write('\t\t{%s}.%s|%s.ActiveCfg = %s|%s\n' %
|
|
509
|
+
(self.environment.coredata.test_guid, buildtype,
|
|
510
|
+
self.platform, buildtype, self.platform))
|
|
511
|
+
ofile.write('\t\t{%s}.%s|%s.ActiveCfg = %s|%s\n' %
|
|
512
|
+
(self.environment.coredata.install_guid, buildtype,
|
|
513
|
+
self.platform, buildtype, self.platform))
|
|
514
|
+
ofile.write('\tEndGlobalSection\n')
|
|
515
|
+
ofile.write('\tGlobalSection(SolutionProperties) = preSolution\n')
|
|
516
|
+
ofile.write('\t\tHideSolutionNode = FALSE\n')
|
|
517
|
+
ofile.write('\tEndGlobalSection\n')
|
|
518
|
+
if self.subdirs:
|
|
519
|
+
ofile.write('\tGlobalSection(NestedProjects) = '
|
|
520
|
+
'preSolution\n')
|
|
521
|
+
for p in projlist:
|
|
522
|
+
if p[1].parent != PurePath('.'):
|
|
523
|
+
ofile.write("\t\t{{{}}} = {{{}}}\n".format(p[2], self.subdirs[p[1].parent][0]))
|
|
524
|
+
for subdir in self.subdirs.values():
|
|
525
|
+
if subdir[1]:
|
|
526
|
+
ofile.write("\t\t{{{}}} = {{{}}}\n".format(subdir[0], subdir[1]))
|
|
527
|
+
ofile.write('\tEndGlobalSection\n')
|
|
528
|
+
ofile.write('EndGlobal\n')
|
|
529
|
+
replace_if_different(sln_filename, sln_filename_tmp)
|
|
530
|
+
|
|
531
|
+
def generate_projects(self, vslite_ctx: dict = None) -> T.List[Project]:
|
|
532
|
+
startup_project = self.environment.coredata.options[OptionKey('backend_startup_project')].value
|
|
533
|
+
projlist: T.List[Project] = []
|
|
534
|
+
startup_idx = 0
|
|
535
|
+
for (i, (name, target)) in enumerate(self.build.targets.items()):
|
|
536
|
+
if startup_project and startup_project == target.get_basename():
|
|
537
|
+
startup_idx = i
|
|
538
|
+
outdir = Path(
|
|
539
|
+
self.environment.get_build_dir(),
|
|
540
|
+
self.get_target_dir(target)
|
|
541
|
+
)
|
|
542
|
+
outdir.mkdir(exist_ok=True, parents=True)
|
|
543
|
+
fname = name + '.vcxproj'
|
|
544
|
+
target_dir = PurePath(self.get_target_dir(target))
|
|
545
|
+
relname = target_dir / fname
|
|
546
|
+
projfile_path = outdir / fname
|
|
547
|
+
proj_uuid = self.environment.coredata.target_guids[name]
|
|
548
|
+
generated = self.gen_vcxproj(target, str(projfile_path), proj_uuid, vslite_ctx)
|
|
549
|
+
if generated:
|
|
550
|
+
projlist.append((name, relname, proj_uuid, target.for_machine))
|
|
551
|
+
|
|
552
|
+
# Put the startup project first in the project list
|
|
553
|
+
if startup_idx:
|
|
554
|
+
projlist.insert(0, projlist.pop(startup_idx))
|
|
555
|
+
|
|
556
|
+
return projlist
|
|
557
|
+
|
|
558
|
+
def split_sources(self, srclist):
|
|
559
|
+
sources = []
|
|
560
|
+
headers = []
|
|
561
|
+
objects = []
|
|
562
|
+
languages = []
|
|
563
|
+
for i in srclist:
|
|
564
|
+
if self.environment.is_header(i):
|
|
565
|
+
headers.append(i)
|
|
566
|
+
elif self.environment.is_object(i):
|
|
567
|
+
objects.append(i)
|
|
568
|
+
elif self.environment.is_source(i):
|
|
569
|
+
sources.append(i)
|
|
570
|
+
lang = self.lang_from_source_file(i)
|
|
571
|
+
if lang not in languages:
|
|
572
|
+
languages.append(lang)
|
|
573
|
+
elif self.environment.is_library(i):
|
|
574
|
+
pass
|
|
575
|
+
else:
|
|
576
|
+
# Everything that is not an object or source file is considered a header.
|
|
577
|
+
headers.append(i)
|
|
578
|
+
return sources, headers, objects, languages
|
|
579
|
+
|
|
580
|
+
def target_to_build_root(self, target):
|
|
581
|
+
if self.get_target_dir(target) == '':
|
|
582
|
+
return ''
|
|
583
|
+
|
|
584
|
+
directories = os.path.normpath(self.get_target_dir(target)).split(os.sep)
|
|
585
|
+
return os.sep.join(['..'] * len(directories))
|
|
586
|
+
|
|
587
|
+
def quote_arguments(self, arr):
|
|
588
|
+
return ['"%s"' % i for i in arr]
|
|
589
|
+
|
|
590
|
+
def add_project_reference(self, root: ET.Element, include: str, projid: str, link_outputs: bool = False) -> None:
|
|
591
|
+
ig = ET.SubElement(root, 'ItemGroup')
|
|
592
|
+
pref = ET.SubElement(ig, 'ProjectReference', Include=include)
|
|
593
|
+
ET.SubElement(pref, 'Project').text = '{%s}' % projid
|
|
594
|
+
if not link_outputs:
|
|
595
|
+
# Do not link in generated .lib files from dependencies automatically.
|
|
596
|
+
# We only use the dependencies for ordering and link in the generated
|
|
597
|
+
# objects and .lib files manually.
|
|
598
|
+
ET.SubElement(pref, 'LinkLibraryDependencies').text = 'false'
|
|
599
|
+
|
|
600
|
+
def add_target_deps(self, root: ET.Element, target):
|
|
601
|
+
target_dict = {target.get_id(): target}
|
|
602
|
+
for dep in self.get_target_deps(target_dict).values():
|
|
603
|
+
if dep.get_id() in self.handled_target_deps[target.get_id()]:
|
|
604
|
+
# This dependency was already handled manually.
|
|
605
|
+
continue
|
|
606
|
+
relpath = self.get_target_dir_relative_to(dep, target)
|
|
607
|
+
vcxproj = os.path.join(relpath, dep.get_id() + '.vcxproj')
|
|
608
|
+
tid = self.environment.coredata.target_guids[dep.get_id()]
|
|
609
|
+
self.add_project_reference(root, vcxproj, tid)
|
|
610
|
+
|
|
611
|
+
def create_basic_project(self, target_name, *,
|
|
612
|
+
temp_dir,
|
|
613
|
+
guid,
|
|
614
|
+
conftype='Utility',
|
|
615
|
+
target_ext=None,
|
|
616
|
+
target_platform=None) -> T.Tuple[ET.Element, ET.Element]:
|
|
617
|
+
root = ET.Element('Project', {'DefaultTargets': "Build",
|
|
618
|
+
'ToolsVersion': '4.0',
|
|
619
|
+
'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003'})
|
|
620
|
+
|
|
621
|
+
confitems = ET.SubElement(root, 'ItemGroup', {'Label': 'ProjectConfigurations'})
|
|
622
|
+
if not target_platform:
|
|
623
|
+
target_platform = self.platform
|
|
624
|
+
|
|
625
|
+
multi_config_buildtype_list = coredata.get_genvs_default_buildtype_list() if self.gen_lite else [self.buildtype]
|
|
626
|
+
for buildtype in multi_config_buildtype_list:
|
|
627
|
+
prjconf = ET.SubElement(confitems, 'ProjectConfiguration',
|
|
628
|
+
{'Include': buildtype + '|' + target_platform})
|
|
629
|
+
ET.SubElement(prjconf, 'Configuration').text = buildtype
|
|
630
|
+
ET.SubElement(prjconf, 'Platform').text = target_platform
|
|
631
|
+
|
|
632
|
+
# Globals
|
|
633
|
+
globalgroup = ET.SubElement(root, 'PropertyGroup', Label='Globals')
|
|
634
|
+
guidelem = ET.SubElement(globalgroup, 'ProjectGuid')
|
|
635
|
+
guidelem.text = '{%s}' % guid
|
|
636
|
+
kw = ET.SubElement(globalgroup, 'Keyword')
|
|
637
|
+
kw.text = self.platform + 'Proj'
|
|
638
|
+
|
|
639
|
+
ET.SubElement(root, 'Import', Project=r'$(VCTargetsPath)\Microsoft.Cpp.Default.props')
|
|
640
|
+
|
|
641
|
+
# Configuration
|
|
642
|
+
type_config = ET.SubElement(root, 'PropertyGroup', Label='Configuration')
|
|
643
|
+
ET.SubElement(type_config, 'ConfigurationType').text = conftype
|
|
644
|
+
if self.platform_toolset:
|
|
645
|
+
ET.SubElement(type_config, 'PlatformToolset').text = self.platform_toolset
|
|
646
|
+
|
|
647
|
+
# This must come AFTER the '<PropertyGroup Label="Configuration">' element; importing before the 'PlatformToolset' elt
|
|
648
|
+
# gets set leads to msbuild failures reporting -
|
|
649
|
+
# "The build tools for v142 (Platform Toolset = 'v142') cannot be found. ... please install v142 build tools."
|
|
650
|
+
# This is extremely unhelpful and misleading since the v14x build tools ARE installed.
|
|
651
|
+
ET.SubElement(root, 'Import', Project=r'$(VCTargetsPath)\Microsoft.Cpp.props')
|
|
652
|
+
|
|
653
|
+
# This attribute makes sure project names are displayed as expected in solution files even when their project file names differ
|
|
654
|
+
pname = ET.SubElement(globalgroup, 'ProjectName')
|
|
655
|
+
pname.text = target_name
|
|
656
|
+
|
|
657
|
+
if not self.gen_lite: # Plenty of elements aren't necessary for 'makefile'-style project that just redirects to meson builds
|
|
658
|
+
# XXX Wasn't here before for anything but gen_vcxproj , but seems fine?
|
|
659
|
+
ns = ET.SubElement(globalgroup, 'RootNamespace')
|
|
660
|
+
ns.text = target_name
|
|
661
|
+
|
|
662
|
+
p = ET.SubElement(globalgroup, 'Platform')
|
|
663
|
+
p.text = target_platform
|
|
664
|
+
if self.windows_target_platform_version:
|
|
665
|
+
ET.SubElement(globalgroup, 'WindowsTargetPlatformVersion').text = self.windows_target_platform_version
|
|
666
|
+
ET.SubElement(globalgroup, 'UseMultiToolTask').text = 'true'
|
|
667
|
+
|
|
668
|
+
ET.SubElement(type_config, 'CharacterSet').text = 'MultiByte'
|
|
669
|
+
# Fixme: wasn't here before for gen_vcxproj()
|
|
670
|
+
ET.SubElement(type_config, 'UseOfMfc').text = 'false'
|
|
671
|
+
|
|
672
|
+
# Project information
|
|
673
|
+
direlem = ET.SubElement(root, 'PropertyGroup')
|
|
674
|
+
fver = ET.SubElement(direlem, '_ProjectFileVersion')
|
|
675
|
+
fver.text = self.project_file_version
|
|
676
|
+
outdir = ET.SubElement(direlem, 'OutDir')
|
|
677
|
+
outdir.text = '.\\'
|
|
678
|
+
intdir = ET.SubElement(direlem, 'IntDir')
|
|
679
|
+
intdir.text = temp_dir + '\\'
|
|
680
|
+
|
|
681
|
+
tname = ET.SubElement(direlem, 'TargetName')
|
|
682
|
+
tname.text = target_name
|
|
683
|
+
|
|
684
|
+
if target_ext:
|
|
685
|
+
ET.SubElement(direlem, 'TargetExt').text = target_ext
|
|
686
|
+
|
|
687
|
+
ET.SubElement(direlem, 'EmbedManifest').text = 'false'
|
|
688
|
+
|
|
689
|
+
return (root, type_config)
|
|
690
|
+
|
|
691
|
+
def gen_run_target_vcxproj(self, target: build.RunTarget, ofname: str, guid: str) -> None:
|
|
692
|
+
(root, type_config) = self.create_basic_project(target.name,
|
|
693
|
+
temp_dir=target.get_id(),
|
|
694
|
+
guid=guid)
|
|
695
|
+
depend_files = self.get_target_depend_files(target)
|
|
696
|
+
|
|
697
|
+
if not target.command:
|
|
698
|
+
# This is an alias target and thus doesn't run any command. It's
|
|
699
|
+
# enough to emit the references to the other projects for them to
|
|
700
|
+
# be built/run/..., if necessary.
|
|
701
|
+
assert isinstance(target, build.AliasTarget)
|
|
702
|
+
assert len(depend_files) == 0
|
|
703
|
+
else:
|
|
704
|
+
assert not isinstance(target, build.AliasTarget)
|
|
705
|
+
|
|
706
|
+
target_env = self.get_run_target_env(target)
|
|
707
|
+
_, _, cmd_raw = self.eval_custom_target_command(target)
|
|
708
|
+
wrapper_cmd, _ = self.as_meson_exe_cmdline(target.command[0], cmd_raw[1:],
|
|
709
|
+
force_serialize=True, env=target_env,
|
|
710
|
+
verbose=True)
|
|
711
|
+
self.add_custom_build(root, 'run_target', ' '.join(self.quote_arguments(wrapper_cmd)),
|
|
712
|
+
deps=depend_files)
|
|
713
|
+
|
|
714
|
+
# The import is needed even for alias targets, otherwise the build
|
|
715
|
+
# target isn't defined
|
|
716
|
+
ET.SubElement(root, 'Import', Project=r'$(VCTargetsPath)\Microsoft.Cpp.targets')
|
|
717
|
+
self.add_regen_dependency(root)
|
|
718
|
+
self.add_target_deps(root, target)
|
|
719
|
+
self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname)
|
|
720
|
+
|
|
721
|
+
def gen_custom_target_vcxproj(self, target: build.CustomTarget, ofname: str, guid: str) -> None:
|
|
722
|
+
if target.for_machine is MachineChoice.BUILD:
|
|
723
|
+
platform = self.build_platform
|
|
724
|
+
else:
|
|
725
|
+
platform = self.platform
|
|
726
|
+
(root, type_config) = self.create_basic_project(target.name,
|
|
727
|
+
temp_dir=target.get_id(),
|
|
728
|
+
guid=guid,
|
|
729
|
+
target_platform=platform)
|
|
730
|
+
# We need to always use absolute paths because our invocation is always
|
|
731
|
+
# from the target dir, not the build root.
|
|
732
|
+
target.absolute_paths = True
|
|
733
|
+
(srcs, ofilenames, cmd) = self.eval_custom_target_command(target, True)
|
|
734
|
+
depend_files = self.get_target_depend_files(target, True)
|
|
735
|
+
# Always use a wrapper because MSBuild eats random characters when
|
|
736
|
+
# there are many arguments.
|
|
737
|
+
tdir_abs = os.path.join(self.environment.get_build_dir(), self.get_target_dir(target))
|
|
738
|
+
extra_bdeps = target.get_transitive_build_target_deps()
|
|
739
|
+
wrapper_cmd, _ = self.as_meson_exe_cmdline(target.command[0], cmd[1:],
|
|
740
|
+
# All targets run from the target dir
|
|
741
|
+
workdir=tdir_abs,
|
|
742
|
+
extra_bdeps=extra_bdeps,
|
|
743
|
+
capture=ofilenames[0] if target.capture else None,
|
|
744
|
+
feed=srcs[0] if target.feed else None,
|
|
745
|
+
force_serialize=True,
|
|
746
|
+
env=target.env,
|
|
747
|
+
verbose=target.console)
|
|
748
|
+
if target.build_always_stale:
|
|
749
|
+
# Use a nonexistent file to always consider the target out-of-date.
|
|
750
|
+
ofilenames += [self.nonexistent_file(os.path.join(self.environment.get_scratch_dir(),
|
|
751
|
+
'outofdate.file'))]
|
|
752
|
+
self.add_custom_build(root, 'custom_target', ' '.join(self.quote_arguments(wrapper_cmd)),
|
|
753
|
+
deps=wrapper_cmd[-1:] + srcs + depend_files, outputs=ofilenames,
|
|
754
|
+
verify_files=not target.build_always_stale)
|
|
755
|
+
ET.SubElement(root, 'Import', Project=r'$(VCTargetsPath)\Microsoft.Cpp.targets')
|
|
756
|
+
self.generate_custom_generator_commands(target, root)
|
|
757
|
+
self.add_regen_dependency(root)
|
|
758
|
+
self.add_target_deps(root, target)
|
|
759
|
+
self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname)
|
|
760
|
+
|
|
761
|
+
def gen_compile_target_vcxproj(self, target: build.CompileTarget, ofname: str, guid: str) -> None:
|
|
762
|
+
if target.for_machine is MachineChoice.BUILD:
|
|
763
|
+
platform = self.build_platform
|
|
764
|
+
else:
|
|
765
|
+
platform = self.platform
|
|
766
|
+
(root, type_config) = self.create_basic_project(target.name,
|
|
767
|
+
temp_dir=target.get_id(),
|
|
768
|
+
guid=guid,
|
|
769
|
+
target_platform=platform)
|
|
770
|
+
ET.SubElement(root, 'Import', Project=r'$(VCTargetsPath)\Microsoft.Cpp.targets')
|
|
771
|
+
target.generated = [self.compile_target_to_generator(target)]
|
|
772
|
+
target.sources = []
|
|
773
|
+
self.generate_custom_generator_commands(target, root)
|
|
774
|
+
self.add_regen_dependency(root)
|
|
775
|
+
self.add_target_deps(root, target)
|
|
776
|
+
self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname)
|
|
777
|
+
|
|
778
|
+
@classmethod
|
|
779
|
+
def lang_from_source_file(cls, src):
|
|
780
|
+
ext = src.split('.')[-1]
|
|
781
|
+
if ext in compilers.c_suffixes:
|
|
782
|
+
return 'c'
|
|
783
|
+
if ext in compilers.cpp_suffixes:
|
|
784
|
+
return 'cpp'
|
|
785
|
+
raise MesonException(f'Could not guess language from source file {src}.')
|
|
786
|
+
|
|
787
|
+
def add_pch(self, pch_sources, lang, inc_cl):
|
|
788
|
+
if lang in pch_sources:
|
|
789
|
+
self.use_pch(pch_sources, lang, inc_cl)
|
|
790
|
+
|
|
791
|
+
def create_pch(self, pch_sources, lang, inc_cl):
|
|
792
|
+
pch = ET.SubElement(inc_cl, 'PrecompiledHeader')
|
|
793
|
+
pch.text = 'Create'
|
|
794
|
+
self.add_pch_files(pch_sources, lang, inc_cl)
|
|
795
|
+
|
|
796
|
+
def use_pch(self, pch_sources, lang, inc_cl):
|
|
797
|
+
pch = ET.SubElement(inc_cl, 'PrecompiledHeader')
|
|
798
|
+
pch.text = 'Use'
|
|
799
|
+
header = self.add_pch_files(pch_sources, lang, inc_cl)
|
|
800
|
+
pch_include = ET.SubElement(inc_cl, 'ForcedIncludeFiles')
|
|
801
|
+
pch_include.text = header + ';%(ForcedIncludeFiles)'
|
|
802
|
+
|
|
803
|
+
def add_pch_files(self, pch_sources, lang, inc_cl):
|
|
804
|
+
header = os.path.basename(pch_sources[lang][0])
|
|
805
|
+
pch_file = ET.SubElement(inc_cl, 'PrecompiledHeaderFile')
|
|
806
|
+
# When USING PCHs, MSVC will not do the regular include
|
|
807
|
+
# directory lookup, but simply use a string match to find the
|
|
808
|
+
# PCH to use. That means the #include directive must match the
|
|
809
|
+
# pch_file.text used during PCH CREATION verbatim.
|
|
810
|
+
# When CREATING a PCH, MSVC will do the include directory
|
|
811
|
+
# lookup to find the actual PCH header to use. Thus, the PCH
|
|
812
|
+
# header must either be in the include_directories of the target
|
|
813
|
+
# or be in the same directory as the PCH implementation.
|
|
814
|
+
pch_file.text = header
|
|
815
|
+
pch_out = ET.SubElement(inc_cl, 'PrecompiledHeaderOutputFile')
|
|
816
|
+
pch_out.text = f'$(IntDir)$(TargetName)-{lang}.pch'
|
|
817
|
+
|
|
818
|
+
# Need to set the name for the pdb, as cl otherwise gives it a static
|
|
819
|
+
# name. Which leads to problems when there is more than one pch
|
|
820
|
+
# (e.g. for different languages).
|
|
821
|
+
pch_pdb = ET.SubElement(inc_cl, 'ProgramDataBaseFileName')
|
|
822
|
+
pch_pdb.text = f'$(IntDir)$(TargetName)-{lang}.pdb'
|
|
823
|
+
|
|
824
|
+
return header
|
|
825
|
+
|
|
826
|
+
def is_argument_with_msbuild_xml_entry(self, entry):
|
|
827
|
+
# Remove arguments that have a top level XML entry so
|
|
828
|
+
# they are not used twice.
|
|
829
|
+
# FIXME add args as needed.
|
|
830
|
+
if entry[1:].startswith('fsanitize'):
|
|
831
|
+
return True
|
|
832
|
+
return entry[1:].startswith('M')
|
|
833
|
+
|
|
834
|
+
def add_additional_options(self, lang, parent_node, file_args):
|
|
835
|
+
args = []
|
|
836
|
+
for arg in file_args[lang].to_native():
|
|
837
|
+
if self.is_argument_with_msbuild_xml_entry(arg):
|
|
838
|
+
continue
|
|
839
|
+
if arg == '%(AdditionalOptions)':
|
|
840
|
+
args.append(arg)
|
|
841
|
+
else:
|
|
842
|
+
args.append(self.escape_additional_option(arg))
|
|
843
|
+
ET.SubElement(parent_node, "AdditionalOptions").text = ' '.join(args)
|
|
844
|
+
|
|
845
|
+
# Set up each project's source file ('CLCompile') element with appropriate preprocessor, include dir, and compile option values for correct intellisense.
|
|
846
|
+
def add_project_nmake_defs_incs_and_opts(self, parent_node, src: str, defs_paths_opts_per_lang_and_buildtype: dict, platform: str):
|
|
847
|
+
# For compactness, sources whose type matches the primary src type (i.e. most frequent in the set of source types used in the target/project,
|
|
848
|
+
# according to the 'captured_build_args' map), can simply reference the preprocessor definitions, include dirs, and compile option NMake fields of
|
|
849
|
+
# the project itself.
|
|
850
|
+
# However, if a src is of a non-primary type, it could have totally different defs/dirs/options so we're going to have to fill in the full, verbose
|
|
851
|
+
# set of values for these fields, which needs to be fully expanded per build type / configuration.
|
|
852
|
+
#
|
|
853
|
+
# FIXME: Suppose a project contains .cpp and .c src files with different compile defs/dirs/options, while also having .h files, some of which
|
|
854
|
+
# are included by .cpp sources and others included by .c sources: How do we know whether the .h source should be using the .cpp or .c src
|
|
855
|
+
# defs/dirs/options? Might it also be possible for a .h header to be shared between .cpp and .c sources? If so, I don't see how we can
|
|
856
|
+
# correctly configure these intellisense fields.
|
|
857
|
+
# For now, all sources/headers that fail to find their extension's language in the '...nmake_defs_paths_opts...' map will just adopt the project
|
|
858
|
+
# defs/dirs/opts that are set for the nominal 'primary' src type.
|
|
859
|
+
ext = src.split('.')[-1]
|
|
860
|
+
lang = compilers.compilers.SUFFIX_TO_LANG.get(ext, None)
|
|
861
|
+
if lang in defs_paths_opts_per_lang_and_buildtype.keys():
|
|
862
|
+
# This is a non-primary src type for which can't simply reference the project's nmake fields;
|
|
863
|
+
# we must laboriously fill in the fields for all buildtypes.
|
|
864
|
+
for buildtype in coredata.get_genvs_default_buildtype_list():
|
|
865
|
+
(defs, paths, opts) = defs_paths_opts_per_lang_and_buildtype[lang][buildtype]
|
|
866
|
+
condition = f'\'$(Configuration)|$(Platform)\'==\'{buildtype}|{platform}\''
|
|
867
|
+
ET.SubElement(parent_node, 'PreprocessorDefinitions', Condition=condition).text = defs
|
|
868
|
+
ET.SubElement(parent_node, 'AdditionalIncludeDirectories', Condition=condition).text = paths
|
|
869
|
+
ET.SubElement(parent_node, 'AdditionalOptions', Condition=condition).text = opts
|
|
870
|
+
else: # Can't find bespoke nmake defs/dirs/opts fields for this extention, so just reference the project's fields
|
|
871
|
+
ET.SubElement(parent_node, 'PreprocessorDefinitions').text = '$(NMakePreprocessorDefinitions)'
|
|
872
|
+
ET.SubElement(parent_node, 'AdditionalIncludeDirectories').text = '$(NMakeIncludeSearchPath)'
|
|
873
|
+
ET.SubElement(parent_node, 'AdditionalOptions').text = '$(AdditionalOptions)'
|
|
874
|
+
|
|
875
|
+
def add_preprocessor_defines(self, lang, parent_node, file_defines):
|
|
876
|
+
defines = []
|
|
877
|
+
for define in file_defines[lang]:
|
|
878
|
+
if define == '%(PreprocessorDefinitions)':
|
|
879
|
+
defines.append(define)
|
|
880
|
+
else:
|
|
881
|
+
defines.append(self.escape_preprocessor_define(define))
|
|
882
|
+
ET.SubElement(parent_node, "PreprocessorDefinitions").text = ';'.join(defines)
|
|
883
|
+
|
|
884
|
+
def add_include_dirs(self, lang, parent_node, file_inc_dirs):
|
|
885
|
+
dirs = file_inc_dirs[lang]
|
|
886
|
+
ET.SubElement(parent_node, "AdditionalIncludeDirectories").text = ';'.join(dirs)
|
|
887
|
+
|
|
888
|
+
@staticmethod
|
|
889
|
+
def escape_preprocessor_define(define: str) -> str:
|
|
890
|
+
# See: https://msdn.microsoft.com/en-us/library/bb383819.aspx
|
|
891
|
+
table = str.maketrans({'%': '%25', '$': '%24', '@': '%40',
|
|
892
|
+
"'": '%27', ';': '%3B', '?': '%3F', '*': '%2A',
|
|
893
|
+
# We need to escape backslash because it'll be un-escaped by
|
|
894
|
+
# Windows during process creation when it parses the arguments
|
|
895
|
+
# Basically, this converts `\` to `\\`.
|
|
896
|
+
'\\': '\\\\'})
|
|
897
|
+
return define.translate(table)
|
|
898
|
+
|
|
899
|
+
@staticmethod
|
|
900
|
+
def escape_additional_option(option: str) -> str:
|
|
901
|
+
# See: https://msdn.microsoft.com/en-us/library/bb383819.aspx
|
|
902
|
+
table = str.maketrans({'%': '%25', '$': '%24', '@': '%40',
|
|
903
|
+
"'": '%27', ';': '%3B', '?': '%3F', '*': '%2A', ' ': '%20'})
|
|
904
|
+
option = option.translate(table)
|
|
905
|
+
# Since we're surrounding the option with ", if it ends in \ that will
|
|
906
|
+
# escape the " when the process arguments are parsed and the starting
|
|
907
|
+
# " will not terminate. So we escape it if that's the case. I'm not
|
|
908
|
+
# kidding, this is how escaping works for process args on Windows.
|
|
909
|
+
if option.endswith('\\'):
|
|
910
|
+
option += '\\'
|
|
911
|
+
return f'"{option}"'
|
|
912
|
+
|
|
913
|
+
@staticmethod
|
|
914
|
+
def split_link_args(args):
|
|
915
|
+
"""
|
|
916
|
+
Split a list of link arguments into three lists:
|
|
917
|
+
* library search paths
|
|
918
|
+
* library filenames (or paths)
|
|
919
|
+
* other link arguments
|
|
920
|
+
"""
|
|
921
|
+
lpaths = []
|
|
922
|
+
libs = []
|
|
923
|
+
other = []
|
|
924
|
+
for arg in args:
|
|
925
|
+
if arg.startswith('/LIBPATH:'):
|
|
926
|
+
lpath = arg[9:]
|
|
927
|
+
# De-dup library search paths by removing older entries when
|
|
928
|
+
# a new one is found. This is necessary because unlike other
|
|
929
|
+
# search paths such as the include path, the library is
|
|
930
|
+
# searched for in the newest (right-most) search path first.
|
|
931
|
+
if lpath in lpaths:
|
|
932
|
+
lpaths.remove(lpath)
|
|
933
|
+
lpaths.append(lpath)
|
|
934
|
+
elif arg.startswith(('/', '-')):
|
|
935
|
+
other.append(arg)
|
|
936
|
+
# It's ok if we miss libraries with non-standard extensions here.
|
|
937
|
+
# They will go into the general link arguments.
|
|
938
|
+
elif arg.endswith('.lib') or arg.endswith('.a'):
|
|
939
|
+
# De-dup
|
|
940
|
+
if arg not in libs:
|
|
941
|
+
libs.append(arg)
|
|
942
|
+
else:
|
|
943
|
+
other.append(arg)
|
|
944
|
+
return lpaths, libs, other
|
|
945
|
+
|
|
946
|
+
def _get_cl_compiler(self, target):
|
|
947
|
+
for lang, c in target.compilers.items():
|
|
948
|
+
if lang in {'c', 'cpp'}:
|
|
949
|
+
return c
|
|
950
|
+
# No source files, only objects, but we still need a compiler, so
|
|
951
|
+
# return a found compiler
|
|
952
|
+
if len(target.objects) > 0:
|
|
953
|
+
for lang, c in self.environment.coredata.compilers[target.for_machine].items():
|
|
954
|
+
if lang in {'c', 'cpp'}:
|
|
955
|
+
return c
|
|
956
|
+
raise MesonException('Could not find a C or C++ compiler. MSVC can only build C/C++ projects.')
|
|
957
|
+
|
|
958
|
+
def _prettyprint_vcxproj_xml(self, tree: ET.ElementTree, ofname: str) -> None:
|
|
959
|
+
ofname_tmp = ofname + '~'
|
|
960
|
+
tree.write(ofname_tmp, encoding='utf-8', xml_declaration=True)
|
|
961
|
+
|
|
962
|
+
# ElementTree cannot do pretty-printing, so do it manually
|
|
963
|
+
doc = xml.dom.minidom.parse(ofname_tmp)
|
|
964
|
+
with open(ofname_tmp, 'w', encoding='utf-8') as of:
|
|
965
|
+
of.write(doc.toprettyxml())
|
|
966
|
+
replace_if_different(ofname, ofname_tmp)
|
|
967
|
+
|
|
968
|
+
# Returns: (target_args,file_args), (target_defines,file_defines), (target_inc_dirs,file_inc_dirs)
|
|
969
|
+
def get_args_defines_and_inc_dirs(self, target, compiler, generated_files_include_dirs, proj_to_src_root, proj_to_src_dir, build_args):
|
|
970
|
+
# Arguments, include dirs, defines for all files in the current target
|
|
971
|
+
target_args = []
|
|
972
|
+
target_defines = []
|
|
973
|
+
target_inc_dirs = []
|
|
974
|
+
# Arguments, include dirs, defines passed to individual files in
|
|
975
|
+
# a target; perhaps because the args are language-specific
|
|
976
|
+
#
|
|
977
|
+
# file_args is also later split out into defines and include_dirs in
|
|
978
|
+
# case someone passed those in there
|
|
979
|
+
file_args: T.Dict[str, CompilerArgs] = {l: c.compiler_args() for l, c in target.compilers.items()}
|
|
980
|
+
file_defines = {l: [] for l in target.compilers}
|
|
981
|
+
file_inc_dirs = {l: [] for l in target.compilers}
|
|
982
|
+
# The order in which these compile args are added must match
|
|
983
|
+
# generate_single_compile() and generate_basic_compiler_args()
|
|
984
|
+
for l, comp in target.compilers.items():
|
|
985
|
+
if l in file_args:
|
|
986
|
+
file_args[l] += compilers.get_base_compile_args(
|
|
987
|
+
target.get_options(), comp)
|
|
988
|
+
file_args[l] += comp.get_option_compile_args(
|
|
989
|
+
target.get_options())
|
|
990
|
+
|
|
991
|
+
# Add compile args added using add_project_arguments()
|
|
992
|
+
for l, args in self.build.projects_args[target.for_machine].get(target.subproject, {}).items():
|
|
993
|
+
if l in file_args:
|
|
994
|
+
file_args[l] += args
|
|
995
|
+
# Add compile args added using add_global_arguments()
|
|
996
|
+
# These override per-project arguments
|
|
997
|
+
for l, args in self.build.global_args[target.for_machine].items():
|
|
998
|
+
if l in file_args:
|
|
999
|
+
file_args[l] += args
|
|
1000
|
+
# Compile args added from the env or cross file: CFLAGS/CXXFLAGS, etc. We want these
|
|
1001
|
+
# to override all the defaults, but not the per-target compile args.
|
|
1002
|
+
for l in file_args.keys():
|
|
1003
|
+
file_args[l] += target.get_option(OptionKey('args', machine=target.for_machine, lang=l))
|
|
1004
|
+
for args in file_args.values():
|
|
1005
|
+
# This is where Visual Studio will insert target_args, target_defines,
|
|
1006
|
+
# etc, which are added later from external deps (see below).
|
|
1007
|
+
args += ['%(AdditionalOptions)', '%(PreprocessorDefinitions)', '%(AdditionalIncludeDirectories)']
|
|
1008
|
+
# Add custom target dirs as includes automatically, but before
|
|
1009
|
+
# target-specific include dirs. See _generate_single_compile() in
|
|
1010
|
+
# the ninja backend for caveats.
|
|
1011
|
+
args += ['-I' + arg for arg in generated_files_include_dirs]
|
|
1012
|
+
# Add include dirs from the `include_directories:` kwarg on the target
|
|
1013
|
+
# and from `include_directories:` of internal deps of the target.
|
|
1014
|
+
#
|
|
1015
|
+
# Target include dirs should override internal deps include dirs.
|
|
1016
|
+
# This is handled in BuildTarget.process_kwargs()
|
|
1017
|
+
#
|
|
1018
|
+
# Include dirs from internal deps should override include dirs from
|
|
1019
|
+
# external deps and must maintain the order in which they are
|
|
1020
|
+
# specified. Hence, we must reverse so that the order is preserved.
|
|
1021
|
+
#
|
|
1022
|
+
# These are per-target, but we still add them as per-file because we
|
|
1023
|
+
# need them to be looked in first.
|
|
1024
|
+
for d in reversed(target.get_include_dirs()):
|
|
1025
|
+
# reversed is used to keep order of includes
|
|
1026
|
+
for i in reversed(d.expand_incdirs(self.environment.get_build_dir())):
|
|
1027
|
+
try:
|
|
1028
|
+
# Add source subdir first so that the build subdir overrides it
|
|
1029
|
+
args.append('-I' + os.path.join(proj_to_src_root, i.source))
|
|
1030
|
+
if i.build is not None:
|
|
1031
|
+
args.append('-I' + self.relpath(i.build, target.subdir))
|
|
1032
|
+
except ValueError:
|
|
1033
|
+
# Include is on different drive
|
|
1034
|
+
args.append('-I' + os.path.normpath(i.build))
|
|
1035
|
+
for i in d.expand_extra_build_dirs():
|
|
1036
|
+
args.append('-I' + self.relpath(i, target.subdir))
|
|
1037
|
+
# Add per-target compile args, f.ex, `c_args : ['/DFOO']`. We set these
|
|
1038
|
+
# near the end since these are supposed to override everything else.
|
|
1039
|
+
for l, args in target.extra_args.items():
|
|
1040
|
+
if l in file_args:
|
|
1041
|
+
file_args[l] += args
|
|
1042
|
+
# The highest priority includes. In order of directory search:
|
|
1043
|
+
# target private dir, target build dir, target source dir
|
|
1044
|
+
for args in file_args.values():
|
|
1045
|
+
t_inc_dirs = [self.relpath(self.get_target_private_dir(target),
|
|
1046
|
+
self.get_target_dir(target))]
|
|
1047
|
+
if target.implicit_include_directories:
|
|
1048
|
+
t_inc_dirs += ['.', proj_to_src_dir]
|
|
1049
|
+
args += ['-I' + arg for arg in t_inc_dirs]
|
|
1050
|
+
|
|
1051
|
+
# Split preprocessor defines and include directories out of the list of
|
|
1052
|
+
# all extra arguments. The rest go into %(AdditionalOptions).
|
|
1053
|
+
for l, args in file_args.items():
|
|
1054
|
+
for arg in args[:]:
|
|
1055
|
+
if arg.startswith(('-D', '/D')) or arg == '%(PreprocessorDefinitions)':
|
|
1056
|
+
file_args[l].remove(arg)
|
|
1057
|
+
# Don't escape the marker
|
|
1058
|
+
if arg == '%(PreprocessorDefinitions)':
|
|
1059
|
+
define = arg
|
|
1060
|
+
else:
|
|
1061
|
+
define = arg[2:]
|
|
1062
|
+
# De-dup
|
|
1063
|
+
if define not in file_defines[l]:
|
|
1064
|
+
file_defines[l].append(define)
|
|
1065
|
+
elif arg.startswith(('-I', '/I')) or arg == '%(AdditionalIncludeDirectories)':
|
|
1066
|
+
file_args[l].remove(arg)
|
|
1067
|
+
# Don't escape the marker
|
|
1068
|
+
if arg == '%(AdditionalIncludeDirectories)':
|
|
1069
|
+
inc_dir = arg
|
|
1070
|
+
else:
|
|
1071
|
+
inc_dir = arg[2:]
|
|
1072
|
+
# De-dup
|
|
1073
|
+
if inc_dir not in file_inc_dirs[l]:
|
|
1074
|
+
file_inc_dirs[l].append(inc_dir)
|
|
1075
|
+
# Add include dirs to target as well so that "Go to Document" works in headers
|
|
1076
|
+
if inc_dir not in target_inc_dirs:
|
|
1077
|
+
target_inc_dirs.append(inc_dir)
|
|
1078
|
+
|
|
1079
|
+
# Split compile args needed to find external dependencies
|
|
1080
|
+
# Link args are added while generating the link command
|
|
1081
|
+
for d in reversed(target.get_external_deps()):
|
|
1082
|
+
# Cflags required by external deps might have UNIX-specific flags,
|
|
1083
|
+
# so filter them out if needed
|
|
1084
|
+
if d.name != 'openmp':
|
|
1085
|
+
d_compile_args = compiler.unix_args_to_native(d.get_compile_args())
|
|
1086
|
+
for arg in d_compile_args:
|
|
1087
|
+
if arg.startswith(('-D', '/D')):
|
|
1088
|
+
define = arg[2:]
|
|
1089
|
+
# De-dup
|
|
1090
|
+
if define in target_defines:
|
|
1091
|
+
target_defines.remove(define)
|
|
1092
|
+
target_defines.append(define)
|
|
1093
|
+
elif arg.startswith(('-I', '/I')):
|
|
1094
|
+
inc_dir = arg[2:]
|
|
1095
|
+
# De-dup
|
|
1096
|
+
if inc_dir not in target_inc_dirs:
|
|
1097
|
+
target_inc_dirs.append(inc_dir)
|
|
1098
|
+
else:
|
|
1099
|
+
target_args.append(arg)
|
|
1100
|
+
|
|
1101
|
+
if '/Gw' in build_args:
|
|
1102
|
+
target_args.append('/Gw')
|
|
1103
|
+
|
|
1104
|
+
return (target_args, file_args), (target_defines, file_defines), (target_inc_dirs, file_inc_dirs)
|
|
1105
|
+
|
|
1106
|
+
@staticmethod
|
|
1107
|
+
def get_build_args(compiler, optimization_level: str, debug: bool, sanitize: str) -> T.List[str]:
|
|
1108
|
+
build_args = compiler.get_optimization_args(optimization_level)
|
|
1109
|
+
build_args += compiler.get_debug_args(debug)
|
|
1110
|
+
build_args += compiler.sanitizer_compile_args(sanitize)
|
|
1111
|
+
|
|
1112
|
+
return build_args
|
|
1113
|
+
|
|
1114
|
+
# Used in populating a simple nmake-style project's intellisense fields.
|
|
1115
|
+
# Given a list of compile args, for example -
|
|
1116
|
+
# [ '-I..\\some\\dir\\include', '-I../../some/other/dir', '/MDd', '/W2', '/std:c++17', '/Od', '/Zi', '-DSOME_DEF=1', '-DANOTHER_DEF=someval', ...]
|
|
1117
|
+
# returns a tuple of pre-processor defs (for this example) -
|
|
1118
|
+
# 'SOME_DEF=1;ANOTHER_DEF=someval;'
|
|
1119
|
+
# and include paths, e.g. -
|
|
1120
|
+
# '..\\some\\dir\\include;../../some/other/dir;'
|
|
1121
|
+
# and finally any remaining compiler options, e.g. -
|
|
1122
|
+
# '/MDd /W2 /std:c++17 /Od/Zi'
|
|
1123
|
+
@staticmethod
|
|
1124
|
+
def _extract_nmake_fields(captured_build_args: list[str]) -> T.Tuple[str, str, str]:
|
|
1125
|
+
include_dir_options = [
|
|
1126
|
+
'-I',
|
|
1127
|
+
'/I',
|
|
1128
|
+
'-isystem', # regular gcc / clang option to denote system header include search paths
|
|
1129
|
+
'/clang:-isystem', # clang-cl (msvc 'cl'-style clang wrapper) option to pass '-isystem' option to clang driver
|
|
1130
|
+
'/imsvc', # clang-cl option to 'Add directory to system include search path'
|
|
1131
|
+
'/external:I', # msvc cl option to add 'external' include search paths
|
|
1132
|
+
]
|
|
1133
|
+
|
|
1134
|
+
defs = ''
|
|
1135
|
+
paths = '$(VC_IncludePath);$(WindowsSDK_IncludePath);'
|
|
1136
|
+
additional_opts = ''
|
|
1137
|
+
for arg in captured_build_args:
|
|
1138
|
+
if arg.startswith(('-D', '/D')):
|
|
1139
|
+
defs += arg[2:] + ';'
|
|
1140
|
+
else:
|
|
1141
|
+
opt_match = next((opt for opt in include_dir_options if arg.startswith(opt)), None)
|
|
1142
|
+
if opt_match:
|
|
1143
|
+
paths += arg[len(opt_match):] + ';'
|
|
1144
|
+
elif arg.startswith(('-', '/')):
|
|
1145
|
+
additional_opts += arg + ' '
|
|
1146
|
+
return (defs, paths, additional_opts)
|
|
1147
|
+
|
|
1148
|
+
@staticmethod
|
|
1149
|
+
def get_nmake_base_meson_command_and_exe_search_paths() -> T.Tuple[str, str]:
|
|
1150
|
+
meson_cmd_list = mesonlib.get_meson_command()
|
|
1151
|
+
assert (len(meson_cmd_list) == 1) or (len(meson_cmd_list) == 2)
|
|
1152
|
+
# We expect get_meson_command() to either be of the form -
|
|
1153
|
+
# 1: ['path/to/meson.exe']
|
|
1154
|
+
# or -
|
|
1155
|
+
# 2: ['path/to/python.exe', 'and/path/to/meson.py']
|
|
1156
|
+
# so we'd like to ensure our makefile-style project invokes the same meson executable or python src as this instance.
|
|
1157
|
+
exe_search_paths = os.path.dirname(meson_cmd_list[0])
|
|
1158
|
+
nmake_base_meson_command = os.path.basename(meson_cmd_list[0])
|
|
1159
|
+
if len(meson_cmd_list) != 1:
|
|
1160
|
+
# We expect to be dealing with case '2', shown above.
|
|
1161
|
+
# With Windows, it's also possible that we get a path to the second element of meson_cmd_list that contains spaces
|
|
1162
|
+
# (e.g. 'and/path to/meson.py'). So, because this will end up directly in the makefile/NMake command lines, we'd
|
|
1163
|
+
# better always enclose it in quotes. Only strictly necessary for paths with spaces but no harm for paths without -
|
|
1164
|
+
nmake_base_meson_command += ' \"' + meson_cmd_list[1] + '\"'
|
|
1165
|
+
exe_search_paths += ';' + os.path.dirname(meson_cmd_list[1])
|
|
1166
|
+
|
|
1167
|
+
# Additionally, in some cases, we appear to have to add 'C:\Windows\system32;C:\Windows' to the 'Path' environment (via the
|
|
1168
|
+
# ExecutablePath element), without which, the 'meson compile ...' (NMakeBuildCommandLine) command can fail (failure to find
|
|
1169
|
+
# stdio.h and similar), so something is quietly switching some critical build behaviour based on the presence of these in
|
|
1170
|
+
# the 'Path'.
|
|
1171
|
+
# Not sure if this ultimately comes down to some 'find and guess' hidden behaviours within meson or within MSVC tools, but
|
|
1172
|
+
# I guess some projects may implicitly rely on this behaviour.
|
|
1173
|
+
# Things would be cleaner, more robust, repeatable, and portable if meson (and msvc tools) replaced all this kind of
|
|
1174
|
+
# find/guess behaviour with the requirement that things just be explicitly specified by the user.
|
|
1175
|
+
# An example of this can be seen with -
|
|
1176
|
+
# 1: Download https://github.com/facebook/zstd source
|
|
1177
|
+
# 2: cd to the 'zstd-dev\build\meson' dir
|
|
1178
|
+
# 3: meson setup -Dbin_programs=true -Dbin_contrib=true --genvslite vs2022 builddir_vslite
|
|
1179
|
+
# 4: Open the generated 'builddir_vslite_vs\zstd.sln' and build through a project, which should explicitly add the above to
|
|
1180
|
+
# the project's 'Executable Directories' paths and build successfully.
|
|
1181
|
+
# 5: Remove 'C:\Windows\system32;C:\Windows;' from the same project's 'Executable Directories' paths and rebuild.
|
|
1182
|
+
# This should now fail.
|
|
1183
|
+
# It feels uncomfortable to do this but what better alternative is there (and might this introduce new problems)? -
|
|
1184
|
+
exe_search_paths += ';C:\\Windows\\system32;C:\\Windows'
|
|
1185
|
+
# A meson project that explicitly specifies compiler/linker tools and sdk/include paths is not going to have any problems
|
|
1186
|
+
# with this addition.
|
|
1187
|
+
|
|
1188
|
+
return (nmake_base_meson_command, exe_search_paths)
|
|
1189
|
+
|
|
1190
|
+
def add_gen_lite_makefile_vcxproj_elements(self,
|
|
1191
|
+
root: ET.Element,
|
|
1192
|
+
platform: str,
|
|
1193
|
+
target_ext: str,
|
|
1194
|
+
vslite_ctx: dict,
|
|
1195
|
+
target,
|
|
1196
|
+
proj_to_build_root: str,
|
|
1197
|
+
primary_src_lang: T.Optional[str]) -> None:
|
|
1198
|
+
ET.SubElement(root, 'ImportGroup', Label='ExtensionSettings')
|
|
1199
|
+
ET.SubElement(root, 'ImportGroup', Label='Shared')
|
|
1200
|
+
prop_sheets_grp = ET.SubElement(root, 'ImportGroup', Label='PropertySheets')
|
|
1201
|
+
ET.SubElement(prop_sheets_grp, 'Import', {'Project': r'$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props',
|
|
1202
|
+
'Condition': r"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')",
|
|
1203
|
+
'Label': 'LocalAppDataPlatform'
|
|
1204
|
+
})
|
|
1205
|
+
ET.SubElement(root, 'PropertyGroup', Label='UserMacros')
|
|
1206
|
+
|
|
1207
|
+
(nmake_base_meson_command, exe_search_paths) = Vs2010Backend.get_nmake_base_meson_command_and_exe_search_paths()
|
|
1208
|
+
|
|
1209
|
+
# Relative path from this .vcxproj to the directory containing the set of '..._[debug/debugoptimized/release]' setup meson build dirs.
|
|
1210
|
+
proj_to_multiconfigured_builds_parent_dir = os.path.join(proj_to_build_root, '..')
|
|
1211
|
+
|
|
1212
|
+
# Conditional property groups per configuration (buildtype). E.g. -
|
|
1213
|
+
# <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'">
|
|
1214
|
+
multi_config_buildtype_list = coredata.get_genvs_default_buildtype_list()
|
|
1215
|
+
for buildtype in multi_config_buildtype_list:
|
|
1216
|
+
per_config_prop_group = ET.SubElement(root, 'PropertyGroup', Condition=f'\'$(Configuration)|$(Platform)\'==\'{buildtype}|{platform}\'')
|
|
1217
|
+
(_, build_dir_tail) = os.path.split(self.src_to_build)
|
|
1218
|
+
meson_build_dir_for_buildtype = build_dir_tail[:-2] + buildtype # Get the buildtype suffixed 'builddir_[debug/release/etc]' from 'builddir_vs', for example.
|
|
1219
|
+
proj_to_build_dir_for_buildtype = str(os.path.join(proj_to_multiconfigured_builds_parent_dir, meson_build_dir_for_buildtype))
|
|
1220
|
+
ET.SubElement(per_config_prop_group, 'OutDir').text = f'{proj_to_build_dir_for_buildtype}\\'
|
|
1221
|
+
ET.SubElement(per_config_prop_group, 'IntDir').text = f'{proj_to_build_dir_for_buildtype}\\'
|
|
1222
|
+
ET.SubElement(per_config_prop_group, 'NMakeBuildCommandLine').text = f'{nmake_base_meson_command} compile -C "{proj_to_build_dir_for_buildtype}"'
|
|
1223
|
+
ET.SubElement(per_config_prop_group, 'NMakeOutput').text = f'$(OutDir){target.name}{target_ext}'
|
|
1224
|
+
captured_build_args = vslite_ctx[buildtype][target.get_id()]
|
|
1225
|
+
# 'captured_build_args' is a dictionary, mapping from each src file type to a list of compile args to use for that type.
|
|
1226
|
+
# Usually, there's just one but we could have multiple src types. However, since there's only one field for the makefile
|
|
1227
|
+
# project's NMake... preprocessor/include intellisense fields, we'll just use the first src type we have to fill in
|
|
1228
|
+
# these fields. Then, any src files in this VS project that aren't of this first src type will then need to override
|
|
1229
|
+
# its intellisense fields instead of simply referencing the values in the project.
|
|
1230
|
+
ET.SubElement(per_config_prop_group, 'NMakeReBuildCommandLine').text = f'{nmake_base_meson_command} compile -C "{proj_to_build_dir_for_buildtype}" --clean && {nmake_base_meson_command} compile -C "{proj_to_build_dir_for_buildtype}"'
|
|
1231
|
+
ET.SubElement(per_config_prop_group, 'NMakeCleanCommandLine').text = f'{nmake_base_meson_command} compile -C "{proj_to_build_dir_for_buildtype}" --clean'
|
|
1232
|
+
# Need to set the 'ExecutablePath' element for the above NMake... commands to be able to invoke the meson command.
|
|
1233
|
+
ET.SubElement(per_config_prop_group, 'ExecutablePath').text = exe_search_paths
|
|
1234
|
+
# We may not have any src files and so won't have a primary src language. In which case, we've nothing to fill in for this target's intellisense fields -
|
|
1235
|
+
if primary_src_lang:
|
|
1236
|
+
primary_src_type_build_args = captured_build_args[primary_src_lang]
|
|
1237
|
+
preproc_defs, inc_paths, other_compile_opts = Vs2010Backend._extract_nmake_fields(primary_src_type_build_args)
|
|
1238
|
+
ET.SubElement(per_config_prop_group, 'NMakePreprocessorDefinitions').text = preproc_defs
|
|
1239
|
+
ET.SubElement(per_config_prop_group, 'NMakeIncludeSearchPath').text = inc_paths
|
|
1240
|
+
ET.SubElement(per_config_prop_group, 'AdditionalOptions').text = other_compile_opts
|
|
1241
|
+
|
|
1242
|
+
# Unless we explicitly specify the following empty path elements, the project is assigned a load of nasty defaults that fill these
|
|
1243
|
+
# with values like -
|
|
1244
|
+
# $(VC_IncludePath);$(WindowsSDK_IncludePath);
|
|
1245
|
+
# which are all based on the current install environment (a recipe for non-reproducibility problems), not the paths that will be used by
|
|
1246
|
+
# the actual meson compile jobs. Although these elements look like they're only for MSBuild operations, they're not needed with our simple,
|
|
1247
|
+
# lite/makefile-style projects so let's just remove them in case they do get used/confused by intellisense.
|
|
1248
|
+
ET.SubElement(per_config_prop_group, 'IncludePath')
|
|
1249
|
+
ET.SubElement(per_config_prop_group, 'ExternalIncludePath')
|
|
1250
|
+
ET.SubElement(per_config_prop_group, 'ReferencePath')
|
|
1251
|
+
ET.SubElement(per_config_prop_group, 'LibraryPath')
|
|
1252
|
+
ET.SubElement(per_config_prop_group, 'LibraryWPath')
|
|
1253
|
+
ET.SubElement(per_config_prop_group, 'SourcePath')
|
|
1254
|
+
ET.SubElement(per_config_prop_group, 'ExcludePath')
|
|
1255
|
+
|
|
1256
|
+
def add_non_makefile_vcxproj_elements(
|
|
1257
|
+
self,
|
|
1258
|
+
root: ET.Element,
|
|
1259
|
+
type_config: ET.Element,
|
|
1260
|
+
target,
|
|
1261
|
+
platform: str,
|
|
1262
|
+
subsystem,
|
|
1263
|
+
build_args,
|
|
1264
|
+
target_args,
|
|
1265
|
+
target_defines,
|
|
1266
|
+
target_inc_dirs,
|
|
1267
|
+
file_args
|
|
1268
|
+
) -> None:
|
|
1269
|
+
compiler = self._get_cl_compiler(target)
|
|
1270
|
+
buildtype_link_args = compiler.get_optimization_link_args(self.optimization)
|
|
1271
|
+
|
|
1272
|
+
# Prefix to use to access the build root from the vcxproj dir
|
|
1273
|
+
down = self.target_to_build_root(target)
|
|
1274
|
+
|
|
1275
|
+
# FIXME: Should the following just be set in create_basic_project(), even if
|
|
1276
|
+
# irrelevant for current target?
|
|
1277
|
+
|
|
1278
|
+
# FIXME: Meson's LTO support needs to be integrated here
|
|
1279
|
+
ET.SubElement(type_config, 'WholeProgramOptimization').text = 'false'
|
|
1280
|
+
# Let VS auto-set the RTC level
|
|
1281
|
+
ET.SubElement(type_config, 'BasicRuntimeChecks').text = 'Default'
|
|
1282
|
+
# Incremental linking increases code size
|
|
1283
|
+
if '/INCREMENTAL:NO' in buildtype_link_args:
|
|
1284
|
+
ET.SubElement(type_config, 'LinkIncremental').text = 'false'
|
|
1285
|
+
|
|
1286
|
+
# Build information
|
|
1287
|
+
compiles = ET.SubElement(root, 'ItemDefinitionGroup')
|
|
1288
|
+
clconf = ET.SubElement(compiles, 'ClCompile')
|
|
1289
|
+
if True in ((dep.name == 'openmp') for dep in target.get_external_deps()):
|
|
1290
|
+
ET.SubElement(clconf, 'OpenMPSupport').text = 'true'
|
|
1291
|
+
# CRT type; debug or release
|
|
1292
|
+
vscrt_type = target.get_option(OptionKey('b_vscrt'))
|
|
1293
|
+
vscrt_val = compiler.get_crt_val(vscrt_type, self.buildtype)
|
|
1294
|
+
if vscrt_val == 'mdd':
|
|
1295
|
+
ET.SubElement(type_config, 'UseDebugLibraries').text = 'true'
|
|
1296
|
+
ET.SubElement(clconf, 'RuntimeLibrary').text = 'MultiThreadedDebugDLL'
|
|
1297
|
+
elif vscrt_val == 'mt':
|
|
1298
|
+
# FIXME, wrong
|
|
1299
|
+
ET.SubElement(type_config, 'UseDebugLibraries').text = 'false'
|
|
1300
|
+
ET.SubElement(clconf, 'RuntimeLibrary').text = 'MultiThreaded'
|
|
1301
|
+
elif vscrt_val == 'mtd':
|
|
1302
|
+
# FIXME, wrong
|
|
1303
|
+
ET.SubElement(type_config, 'UseDebugLibraries').text = 'true'
|
|
1304
|
+
ET.SubElement(clconf, 'RuntimeLibrary').text = 'MultiThreadedDebug'
|
|
1305
|
+
else:
|
|
1306
|
+
ET.SubElement(type_config, 'UseDebugLibraries').text = 'false'
|
|
1307
|
+
ET.SubElement(clconf, 'RuntimeLibrary').text = 'MultiThreadedDLL'
|
|
1308
|
+
# Sanitizers
|
|
1309
|
+
if '/fsanitize=address' in build_args:
|
|
1310
|
+
ET.SubElement(type_config, 'EnableASAN').text = 'true'
|
|
1311
|
+
# Debug format
|
|
1312
|
+
if '/ZI' in build_args:
|
|
1313
|
+
ET.SubElement(clconf, 'DebugInformationFormat').text = 'EditAndContinue'
|
|
1314
|
+
elif '/Zi' in build_args:
|
|
1315
|
+
ET.SubElement(clconf, 'DebugInformationFormat').text = 'ProgramDatabase'
|
|
1316
|
+
elif '/Z7' in build_args:
|
|
1317
|
+
ET.SubElement(clconf, 'DebugInformationFormat').text = 'OldStyle'
|
|
1318
|
+
else:
|
|
1319
|
+
ET.SubElement(clconf, 'DebugInformationFormat').text = 'None'
|
|
1320
|
+
# Runtime checks
|
|
1321
|
+
if '/RTC1' in build_args:
|
|
1322
|
+
ET.SubElement(clconf, 'BasicRuntimeChecks').text = 'EnableFastChecks'
|
|
1323
|
+
elif '/RTCu' in build_args:
|
|
1324
|
+
ET.SubElement(clconf, 'BasicRuntimeChecks').text = 'UninitializedLocalUsageCheck'
|
|
1325
|
+
elif '/RTCs' in build_args:
|
|
1326
|
+
ET.SubElement(clconf, 'BasicRuntimeChecks').text = 'StackFrameRuntimeCheck'
|
|
1327
|
+
# Exception handling has to be set in the xml in addition to the "AdditionalOptions" because otherwise
|
|
1328
|
+
# cl will give warning D9025: overriding '/Ehs' with cpp_eh value
|
|
1329
|
+
if 'cpp' in target.compilers:
|
|
1330
|
+
eh = target.get_option(OptionKey('eh', machine=target.for_machine, lang='cpp'))
|
|
1331
|
+
if eh == 'a':
|
|
1332
|
+
ET.SubElement(clconf, 'ExceptionHandling').text = 'Async'
|
|
1333
|
+
elif eh == 's':
|
|
1334
|
+
ET.SubElement(clconf, 'ExceptionHandling').text = 'SyncCThrow'
|
|
1335
|
+
elif eh == 'none':
|
|
1336
|
+
ET.SubElement(clconf, 'ExceptionHandling').text = 'false'
|
|
1337
|
+
else: # 'sc' or 'default'
|
|
1338
|
+
ET.SubElement(clconf, 'ExceptionHandling').text = 'Sync'
|
|
1339
|
+
|
|
1340
|
+
if len(target_args) > 0:
|
|
1341
|
+
target_args.append('%(AdditionalOptions)')
|
|
1342
|
+
ET.SubElement(clconf, "AdditionalOptions").text = ' '.join(target_args)
|
|
1343
|
+
ET.SubElement(clconf, 'AdditionalIncludeDirectories').text = ';'.join(target_inc_dirs)
|
|
1344
|
+
target_defines.append('%(PreprocessorDefinitions)')
|
|
1345
|
+
ET.SubElement(clconf, 'PreprocessorDefinitions').text = ';'.join(target_defines)
|
|
1346
|
+
ET.SubElement(clconf, 'FunctionLevelLinking').text = 'true'
|
|
1347
|
+
# Warning level
|
|
1348
|
+
warning_level = T.cast('str', target.get_option(OptionKey('warning_level')))
|
|
1349
|
+
warning_level = 'EnableAllWarnings' if warning_level == 'everything' else 'Level' + str(1 + int(warning_level))
|
|
1350
|
+
ET.SubElement(clconf, 'WarningLevel').text = warning_level
|
|
1351
|
+
if target.get_option(OptionKey('werror')):
|
|
1352
|
+
ET.SubElement(clconf, 'TreatWarningAsError').text = 'true'
|
|
1353
|
+
# Optimization flags
|
|
1354
|
+
o_flags = split_o_flags_args(build_args)
|
|
1355
|
+
if '/Ox' in o_flags:
|
|
1356
|
+
ET.SubElement(clconf, 'Optimization').text = 'Full'
|
|
1357
|
+
elif '/O2' in o_flags:
|
|
1358
|
+
ET.SubElement(clconf, 'Optimization').text = 'MaxSpeed'
|
|
1359
|
+
elif '/O1' in o_flags:
|
|
1360
|
+
ET.SubElement(clconf, 'Optimization').text = 'MinSpace'
|
|
1361
|
+
elif '/Od' in o_flags:
|
|
1362
|
+
ET.SubElement(clconf, 'Optimization').text = 'Disabled'
|
|
1363
|
+
if '/Oi' in o_flags:
|
|
1364
|
+
ET.SubElement(clconf, 'IntrinsicFunctions').text = 'true'
|
|
1365
|
+
if '/Ob1' in o_flags:
|
|
1366
|
+
ET.SubElement(clconf, 'InlineFunctionExpansion').text = 'OnlyExplicitInline'
|
|
1367
|
+
elif '/Ob2' in o_flags:
|
|
1368
|
+
ET.SubElement(clconf, 'InlineFunctionExpansion').text = 'AnySuitable'
|
|
1369
|
+
# Size-preserving flags
|
|
1370
|
+
if '/Os' in o_flags or '/O1' in o_flags:
|
|
1371
|
+
ET.SubElement(clconf, 'FavorSizeOrSpeed').text = 'Size'
|
|
1372
|
+
# Note: setting FavorSizeOrSpeed with clang-cl conflicts with /Od and can make debugging difficult, so don't.
|
|
1373
|
+
elif '/Od' not in o_flags:
|
|
1374
|
+
ET.SubElement(clconf, 'FavorSizeOrSpeed').text = 'Speed'
|
|
1375
|
+
# Note: SuppressStartupBanner is /NOLOGO and is 'true' by default
|
|
1376
|
+
self.generate_lang_standard_info(file_args, clconf)
|
|
1377
|
+
|
|
1378
|
+
resourcecompile = ET.SubElement(compiles, 'ResourceCompile')
|
|
1379
|
+
ET.SubElement(resourcecompile, 'PreprocessorDefinitions')
|
|
1380
|
+
|
|
1381
|
+
# Linker options
|
|
1382
|
+
link = ET.SubElement(compiles, 'Link')
|
|
1383
|
+
extra_link_args = compiler.compiler_args()
|
|
1384
|
+
extra_link_args += compiler.get_optimization_link_args(self.optimization)
|
|
1385
|
+
# Generate Debug info
|
|
1386
|
+
if self.debug:
|
|
1387
|
+
self.generate_debug_information(link)
|
|
1388
|
+
else:
|
|
1389
|
+
ET.SubElement(link, 'GenerateDebugInformation').text = 'false'
|
|
1390
|
+
if not isinstance(target, build.StaticLibrary):
|
|
1391
|
+
if isinstance(target, build.SharedModule):
|
|
1392
|
+
extra_link_args += compiler.get_std_shared_module_link_args(target.get_options())
|
|
1393
|
+
# Add link args added using add_project_link_arguments()
|
|
1394
|
+
extra_link_args += self.build.get_project_link_args(compiler, target.subproject, target.for_machine)
|
|
1395
|
+
# Add link args added using add_global_link_arguments()
|
|
1396
|
+
# These override per-project link arguments
|
|
1397
|
+
extra_link_args += self.build.get_global_link_args(compiler, target.for_machine)
|
|
1398
|
+
# Link args added from the env: LDFLAGS, or the cross file. We want
|
|
1399
|
+
# these to override all the defaults but not the per-target link
|
|
1400
|
+
# args.
|
|
1401
|
+
extra_link_args += self.environment.coredata.get_external_link_args(
|
|
1402
|
+
target.for_machine, compiler.get_language())
|
|
1403
|
+
# Only non-static built targets need link args and link dependencies
|
|
1404
|
+
extra_link_args += target.link_args
|
|
1405
|
+
# External deps must be last because target link libraries may depend on them.
|
|
1406
|
+
for dep in target.get_external_deps():
|
|
1407
|
+
# Extend without reordering or de-dup to preserve `-L -l` sets
|
|
1408
|
+
# https://github.com/mesonbuild/meson/issues/1718
|
|
1409
|
+
if dep.name == 'openmp':
|
|
1410
|
+
ET.SubElement(clconf, 'OpenMPSupport').text = 'true'
|
|
1411
|
+
else:
|
|
1412
|
+
extra_link_args.extend_direct(dep.get_link_args())
|
|
1413
|
+
for d in target.get_dependencies():
|
|
1414
|
+
if isinstance(d, build.StaticLibrary):
|
|
1415
|
+
for dep in d.get_external_deps():
|
|
1416
|
+
if dep.name == 'openmp':
|
|
1417
|
+
ET.SubElement(clconf, 'OpenMPSupport').text = 'true'
|
|
1418
|
+
else:
|
|
1419
|
+
extra_link_args.extend_direct(dep.get_link_args())
|
|
1420
|
+
# Add link args for c_* or cpp_* build options. Currently this only
|
|
1421
|
+
# adds c_winlibs and cpp_winlibs when building for Windows. This needs
|
|
1422
|
+
# to be after all internal and external libraries so that unresolved
|
|
1423
|
+
# symbols from those can be found here. This is needed when the
|
|
1424
|
+
# *_winlibs that we want to link to are static mingw64 libraries.
|
|
1425
|
+
extra_link_args += compiler.get_option_link_args(target.get_options())
|
|
1426
|
+
(additional_libpaths, additional_links, extra_link_args) = self.split_link_args(extra_link_args.to_native())
|
|
1427
|
+
|
|
1428
|
+
# Add more libraries to be linked if needed
|
|
1429
|
+
for t in target.get_dependencies():
|
|
1430
|
+
if isinstance(t, build.CustomTargetIndex):
|
|
1431
|
+
# We don't need the actual project here, just the library name
|
|
1432
|
+
lobj = t
|
|
1433
|
+
else:
|
|
1434
|
+
lobj = self.build.targets[t.get_id()]
|
|
1435
|
+
linkname = os.path.join(down, self.get_target_filename_for_linking(lobj))
|
|
1436
|
+
if t in target.link_whole_targets:
|
|
1437
|
+
if compiler.id == 'msvc' and version_compare(compiler.version, '<19.00.23918'):
|
|
1438
|
+
# Expand our object lists manually if we are on pre-Visual Studio 2015 Update 2
|
|
1439
|
+
l = t.extract_all_objects(False)
|
|
1440
|
+
|
|
1441
|
+
# Unfortunately, we can't use self.object_filename_from_source()
|
|
1442
|
+
for gen in l.genlist:
|
|
1443
|
+
for src in gen.get_outputs():
|
|
1444
|
+
if self.environment.is_source(src):
|
|
1445
|
+
path = self.get_target_generated_dir(t, gen, src)
|
|
1446
|
+
gen_src_ext = '.' + os.path.splitext(path)[1][1:]
|
|
1447
|
+
extra_link_args.append(path[:-len(gen_src_ext)] + '.obj')
|
|
1448
|
+
|
|
1449
|
+
for src in l.srclist:
|
|
1450
|
+
if self.environment.is_source(src):
|
|
1451
|
+
target_private_dir = self.relpath(self.get_target_private_dir(t),
|
|
1452
|
+
self.get_target_dir(t))
|
|
1453
|
+
rel_obj = self.object_filename_from_source(t, src, target_private_dir)
|
|
1454
|
+
extra_link_args.append(rel_obj)
|
|
1455
|
+
|
|
1456
|
+
extra_link_args.extend(self.flatten_object_list(t))
|
|
1457
|
+
else:
|
|
1458
|
+
# /WHOLEARCHIVE:foo must go into AdditionalOptions
|
|
1459
|
+
extra_link_args += compiler.get_link_whole_for(linkname)
|
|
1460
|
+
# To force Visual Studio to build this project even though it
|
|
1461
|
+
# has no sources, we include a reference to the vcxproj file
|
|
1462
|
+
# that builds this target. Technically we should add this only
|
|
1463
|
+
# if the current target has no sources, but it doesn't hurt to
|
|
1464
|
+
# have 'extra' references.
|
|
1465
|
+
trelpath = self.get_target_dir_relative_to(t, target)
|
|
1466
|
+
tvcxproj = os.path.join(trelpath, t.get_id() + '.vcxproj')
|
|
1467
|
+
tid = self.environment.coredata.target_guids[t.get_id()]
|
|
1468
|
+
self.add_project_reference(root, tvcxproj, tid, link_outputs=True)
|
|
1469
|
+
# Mark the dependency as already handled to not have
|
|
1470
|
+
# multiple references to the same target.
|
|
1471
|
+
self.handled_target_deps[target.get_id()].append(t.get_id())
|
|
1472
|
+
else:
|
|
1473
|
+
# Other libraries go into AdditionalDependencies
|
|
1474
|
+
if linkname not in additional_links:
|
|
1475
|
+
additional_links.append(linkname)
|
|
1476
|
+
for lib in self.get_custom_target_provided_libraries(target):
|
|
1477
|
+
additional_links.append(self.relpath(lib, self.get_target_dir(target)))
|
|
1478
|
+
|
|
1479
|
+
if len(extra_link_args) > 0:
|
|
1480
|
+
extra_link_args.append('%(AdditionalOptions)')
|
|
1481
|
+
ET.SubElement(link, "AdditionalOptions").text = ' '.join(extra_link_args)
|
|
1482
|
+
if len(additional_libpaths) > 0:
|
|
1483
|
+
additional_libpaths.insert(0, '%(AdditionalLibraryDirectories)')
|
|
1484
|
+
ET.SubElement(link, 'AdditionalLibraryDirectories').text = ';'.join(additional_libpaths)
|
|
1485
|
+
if len(additional_links) > 0:
|
|
1486
|
+
additional_links.append('%(AdditionalDependencies)')
|
|
1487
|
+
ET.SubElement(link, 'AdditionalDependencies').text = ';'.join(additional_links)
|
|
1488
|
+
ofile = ET.SubElement(link, 'OutputFile')
|
|
1489
|
+
ofile.text = f'$(OutDir){target.get_filename()}'
|
|
1490
|
+
subsys = ET.SubElement(link, 'SubSystem')
|
|
1491
|
+
subsys.text = subsystem
|
|
1492
|
+
if isinstance(target, (build.SharedLibrary, build.Executable)) and target.get_import_filename():
|
|
1493
|
+
# DLLs built with MSVC always have an import library except when
|
|
1494
|
+
# they're data-only DLLs, but we don't support those yet.
|
|
1495
|
+
ET.SubElement(link, 'ImportLibrary').text = target.get_import_filename()
|
|
1496
|
+
if isinstance(target, (build.SharedLibrary, build.Executable)):
|
|
1497
|
+
# Add module definitions file, if provided
|
|
1498
|
+
if target.vs_module_defs:
|
|
1499
|
+
relpath = os.path.join(down, target.vs_module_defs.rel_to_builddir(self.build_to_src))
|
|
1500
|
+
ET.SubElement(link, 'ModuleDefinitionFile').text = relpath
|
|
1501
|
+
if self.debug:
|
|
1502
|
+
pdb = ET.SubElement(link, 'ProgramDataBaseFileName')
|
|
1503
|
+
pdb.text = f'$(OutDir){target.name}.pdb'
|
|
1504
|
+
targetmachine = ET.SubElement(link, 'TargetMachine')
|
|
1505
|
+
if target.for_machine is MachineChoice.BUILD:
|
|
1506
|
+
targetplatform = platform.lower()
|
|
1507
|
+
else:
|
|
1508
|
+
targetplatform = self.platform.lower()
|
|
1509
|
+
if targetplatform == 'win32':
|
|
1510
|
+
targetmachine.text = 'MachineX86'
|
|
1511
|
+
elif targetplatform == 'x64' or detect_microsoft_gdk(targetplatform):
|
|
1512
|
+
targetmachine.text = 'MachineX64'
|
|
1513
|
+
elif targetplatform == 'arm':
|
|
1514
|
+
targetmachine.text = 'MachineARM'
|
|
1515
|
+
elif targetplatform == 'arm64':
|
|
1516
|
+
targetmachine.text = 'MachineARM64'
|
|
1517
|
+
elif targetplatform == 'arm64ec':
|
|
1518
|
+
targetmachine.text = 'MachineARM64EC'
|
|
1519
|
+
else:
|
|
1520
|
+
raise MesonException('Unsupported Visual Studio target machine: ' + targetplatform)
|
|
1521
|
+
# /nologo
|
|
1522
|
+
ET.SubElement(link, 'SuppressStartupBanner').text = 'true'
|
|
1523
|
+
# /release
|
|
1524
|
+
if not target.get_option(OptionKey('debug')):
|
|
1525
|
+
ET.SubElement(link, 'SetChecksum').text = 'true'
|
|
1526
|
+
|
|
1527
|
+
# Visual studio doesn't simply allow the src files of a project to be added with the 'Condition=...' attribute,
|
|
1528
|
+
# to allow us to point to the different debug/debugoptimized/release sets of generated src files for each of
|
|
1529
|
+
# the solution's configurations. Similarly, 'ItemGroup' also doesn't support 'Condition'. So, without knowing
|
|
1530
|
+
# a better (simple) alternative, for now, we'll repoint these generated sources (which will be incorrectly
|
|
1531
|
+
# pointing to non-existent files under our '[builddir]_vs' directory) to the appropriate location under one of
|
|
1532
|
+
# our buildtype build directores (e.g. '[builddir]_debug').
|
|
1533
|
+
# This will at least allow the user to open the files of generated sources listed in the solution explorer,
|
|
1534
|
+
# once a build/compile has generated these sources.
|
|
1535
|
+
#
|
|
1536
|
+
# This modifies the paths in 'gen_files' in place, as opposed to returning a new list of modified paths.
|
|
1537
|
+
def relocate_generated_file_paths_to_concrete_build_dir(self, gen_files: T.List[str], target: T.Union[build.Target, build.CustomTargetIndex]) -> None:
|
|
1538
|
+
(_, build_dir_tail) = os.path.split(self.src_to_build)
|
|
1539
|
+
meson_build_dir_for_buildtype = build_dir_tail[:-2] + coredata.get_genvs_default_buildtype_list()[0] # Get the first buildtype suffixed dir (i.e. '[builddir]_debug') from '[builddir]_vs'
|
|
1540
|
+
# Relative path from this .vcxproj to the directory containing the set of '..._[debug/debugoptimized/release]' setup meson build dirs.
|
|
1541
|
+
proj_to_build_root = self.target_to_build_root(target)
|
|
1542
|
+
proj_to_multiconfigured_builds_parent_dir = os.path.join(proj_to_build_root, '..')
|
|
1543
|
+
proj_to_build_dir_for_buildtype = str(os.path.join(proj_to_multiconfigured_builds_parent_dir, meson_build_dir_for_buildtype))
|
|
1544
|
+
relocate_to_concrete_builddir_target = os.path.normpath(os.path.join(proj_to_build_dir_for_buildtype, self.get_target_dir(target)))
|
|
1545
|
+
for idx, file_path in enumerate(gen_files):
|
|
1546
|
+
gen_files[idx] = os.path.normpath(os.path.join(relocate_to_concrete_builddir_target, file_path))
|
|
1547
|
+
|
|
1548
|
+
# Returns bool indicating whether the .vcxproj has been generated.
|
|
1549
|
+
# Under some circumstances, it's unnecessary to create some .vcxprojs, so, when generating the .sln,
|
|
1550
|
+
# we need to respect that not all targets will have generated a project.
|
|
1551
|
+
def gen_vcxproj(self, target: build.BuildTarget, ofname: str, guid: str, vslite_ctx: dict = None) -> bool:
|
|
1552
|
+
mlog.debug(f'Generating vcxproj {target.name}.')
|
|
1553
|
+
subsystem = 'Windows'
|
|
1554
|
+
self.handled_target_deps[target.get_id()] = []
|
|
1555
|
+
|
|
1556
|
+
if self.gen_lite:
|
|
1557
|
+
if not isinstance(target, build.BuildTarget):
|
|
1558
|
+
# Since we're going to delegate all building to the one true meson build command, we don't need
|
|
1559
|
+
# to generate .vcxprojs for targets that don't add any source files or just perform custom build
|
|
1560
|
+
# commands. These are targets of types CustomTarget or RunTarget. So let's just skip generating
|
|
1561
|
+
# these otherwise insubstantial non-BuildTarget targets.
|
|
1562
|
+
return False
|
|
1563
|
+
conftype = 'Makefile'
|
|
1564
|
+
elif isinstance(target, build.Executable):
|
|
1565
|
+
conftype = 'Application'
|
|
1566
|
+
# If someone knows how to set the version properly,
|
|
1567
|
+
# please send a patch.
|
|
1568
|
+
subsystem = target.win_subsystem.split(',')[0]
|
|
1569
|
+
elif isinstance(target, build.StaticLibrary):
|
|
1570
|
+
conftype = 'StaticLibrary'
|
|
1571
|
+
elif isinstance(target, build.SharedLibrary):
|
|
1572
|
+
conftype = 'DynamicLibrary'
|
|
1573
|
+
elif isinstance(target, build.CustomTarget):
|
|
1574
|
+
self.gen_custom_target_vcxproj(target, ofname, guid)
|
|
1575
|
+
return True
|
|
1576
|
+
elif isinstance(target, build.RunTarget):
|
|
1577
|
+
self.gen_run_target_vcxproj(target, ofname, guid)
|
|
1578
|
+
return True
|
|
1579
|
+
elif isinstance(target, build.CompileTarget):
|
|
1580
|
+
self.gen_compile_target_vcxproj(target, ofname, guid)
|
|
1581
|
+
return True
|
|
1582
|
+
else:
|
|
1583
|
+
raise MesonException(f'Unknown target type for {target.get_basename()}')
|
|
1584
|
+
|
|
1585
|
+
(sources, headers, objects, _languages) = self.split_sources(target.sources)
|
|
1586
|
+
if target.is_unity:
|
|
1587
|
+
sources = self.generate_unity_files(target, sources)
|
|
1588
|
+
if target.for_machine is MachineChoice.BUILD:
|
|
1589
|
+
platform = self.build_platform
|
|
1590
|
+
else:
|
|
1591
|
+
platform = self.platform
|
|
1592
|
+
|
|
1593
|
+
tfilename = os.path.splitext(target.get_filename())
|
|
1594
|
+
|
|
1595
|
+
(root, type_config) = self.create_basic_project(tfilename[0],
|
|
1596
|
+
temp_dir=target.get_id(),
|
|
1597
|
+
guid=guid,
|
|
1598
|
+
conftype=conftype,
|
|
1599
|
+
target_ext=tfilename[1],
|
|
1600
|
+
target_platform=platform)
|
|
1601
|
+
|
|
1602
|
+
generated_files, custom_target_output_files, generated_files_include_dirs = self.generate_custom_generator_commands(
|
|
1603
|
+
target, root)
|
|
1604
|
+
(gen_src, gen_hdrs, gen_objs, _gen_langs) = self.split_sources(generated_files)
|
|
1605
|
+
(custom_src, custom_hdrs, custom_objs, _custom_langs) = self.split_sources(custom_target_output_files)
|
|
1606
|
+
gen_src += custom_src
|
|
1607
|
+
gen_hdrs += custom_hdrs
|
|
1608
|
+
|
|
1609
|
+
compiler = self._get_cl_compiler(target)
|
|
1610
|
+
build_args = Vs2010Backend.get_build_args(compiler, self.optimization, self.debug, self.sanitize)
|
|
1611
|
+
|
|
1612
|
+
assert isinstance(target, (build.Executable, build.SharedLibrary, build.StaticLibrary, build.SharedModule)), 'for mypy'
|
|
1613
|
+
# Prefix to use to access the build root from the vcxproj dir
|
|
1614
|
+
proj_to_build_root = self.target_to_build_root(target)
|
|
1615
|
+
# Prefix to use to access the source tree's root from the vcxproj dir
|
|
1616
|
+
proj_to_src_root = os.path.join(proj_to_build_root, self.build_to_src)
|
|
1617
|
+
# Prefix to use to access the source tree's subdir from the vcxproj dir
|
|
1618
|
+
proj_to_src_dir = os.path.join(proj_to_src_root, self.get_target_dir(target))
|
|
1619
|
+
|
|
1620
|
+
(target_args, file_args), (target_defines, file_defines), (target_inc_dirs, file_inc_dirs) = self.get_args_defines_and_inc_dirs(
|
|
1621
|
+
target, compiler, generated_files_include_dirs, proj_to_src_root, proj_to_src_dir, build_args)
|
|
1622
|
+
|
|
1623
|
+
if self.gen_lite:
|
|
1624
|
+
assert vslite_ctx is not None
|
|
1625
|
+
primary_src_lang = get_primary_source_lang(target.sources, custom_src)
|
|
1626
|
+
self.add_gen_lite_makefile_vcxproj_elements(root, platform, tfilename[1], vslite_ctx, target, proj_to_build_root, primary_src_lang)
|
|
1627
|
+
else:
|
|
1628
|
+
self.add_non_makefile_vcxproj_elements(root, type_config, target, platform, subsystem, build_args, target_args, target_defines, target_inc_dirs, file_args)
|
|
1629
|
+
|
|
1630
|
+
meson_file_group = ET.SubElement(root, 'ItemGroup')
|
|
1631
|
+
ET.SubElement(meson_file_group, 'None', Include=os.path.join(proj_to_src_dir, build_filename))
|
|
1632
|
+
|
|
1633
|
+
# Visual Studio can't load projects that present duplicated items. Filter them out
|
|
1634
|
+
# by keeping track of already added paths.
|
|
1635
|
+
def path_normalize_add(path, lis):
|
|
1636
|
+
normalized = os.path.normcase(os.path.normpath(path))
|
|
1637
|
+
if normalized not in lis:
|
|
1638
|
+
lis.append(normalized)
|
|
1639
|
+
return True
|
|
1640
|
+
else:
|
|
1641
|
+
return False
|
|
1642
|
+
|
|
1643
|
+
pch_sources = {}
|
|
1644
|
+
if self.target_uses_pch(target):
|
|
1645
|
+
for lang in ['c', 'cpp']:
|
|
1646
|
+
pch = target.get_pch(lang)
|
|
1647
|
+
if not pch:
|
|
1648
|
+
continue
|
|
1649
|
+
if compiler.id == 'msvc':
|
|
1650
|
+
if len(pch) == 1:
|
|
1651
|
+
# Auto generate PCH.
|
|
1652
|
+
src = os.path.join(proj_to_build_root, self.create_msvc_pch_implementation(target, lang, pch[0]))
|
|
1653
|
+
pch_header_dir = os.path.dirname(os.path.join(proj_to_src_dir, pch[0]))
|
|
1654
|
+
else:
|
|
1655
|
+
src = os.path.join(proj_to_src_dir, pch[1])
|
|
1656
|
+
pch_header_dir = None
|
|
1657
|
+
pch_sources[lang] = [pch[0], src, lang, pch_header_dir]
|
|
1658
|
+
else:
|
|
1659
|
+
# I don't know whether its relevant but let's handle other compilers
|
|
1660
|
+
# used with a vs backend
|
|
1661
|
+
pch_sources[lang] = [pch[0], None, lang, None]
|
|
1662
|
+
|
|
1663
|
+
previous_includes = []
|
|
1664
|
+
if len(headers) + len(gen_hdrs) + len(target.extra_files) + len(pch_sources) > 0:
|
|
1665
|
+
if self.gen_lite and gen_hdrs:
|
|
1666
|
+
# Although we're constructing our .vcxproj under our '..._vs' directory, we want to reference generated files
|
|
1667
|
+
# in our concrete build directories (e.g. '..._debug'), where generated files will exist after building.
|
|
1668
|
+
self.relocate_generated_file_paths_to_concrete_build_dir(gen_hdrs, target)
|
|
1669
|
+
|
|
1670
|
+
inc_hdrs = ET.SubElement(root, 'ItemGroup')
|
|
1671
|
+
for h in headers:
|
|
1672
|
+
relpath = os.path.join(proj_to_build_root, h.rel_to_builddir(self.build_to_src))
|
|
1673
|
+
if path_normalize_add(relpath, previous_includes):
|
|
1674
|
+
ET.SubElement(inc_hdrs, 'CLInclude', Include=relpath)
|
|
1675
|
+
for h in gen_hdrs:
|
|
1676
|
+
if path_normalize_add(h, previous_includes):
|
|
1677
|
+
ET.SubElement(inc_hdrs, 'CLInclude', Include=h)
|
|
1678
|
+
for h in target.extra_files:
|
|
1679
|
+
relpath = os.path.join(proj_to_build_root, h.rel_to_builddir(self.build_to_src))
|
|
1680
|
+
if path_normalize_add(relpath, previous_includes):
|
|
1681
|
+
ET.SubElement(inc_hdrs, 'CLInclude', Include=relpath)
|
|
1682
|
+
for headers in pch_sources.values():
|
|
1683
|
+
path = os.path.join(proj_to_src_dir, headers[0])
|
|
1684
|
+
if path_normalize_add(path, previous_includes):
|
|
1685
|
+
ET.SubElement(inc_hdrs, 'CLInclude', Include=path)
|
|
1686
|
+
|
|
1687
|
+
previous_sources = []
|
|
1688
|
+
if len(sources) + len(gen_src) + len(pch_sources) > 0:
|
|
1689
|
+
if self.gen_lite:
|
|
1690
|
+
# Get data to fill in intellisense fields for sources that can't reference the project-wide values
|
|
1691
|
+
defs_paths_opts_per_lang_and_buildtype = get_non_primary_lang_intellisense_fields(
|
|
1692
|
+
vslite_ctx,
|
|
1693
|
+
target.get_id(),
|
|
1694
|
+
primary_src_lang)
|
|
1695
|
+
if gen_src:
|
|
1696
|
+
# Although we're constructing our .vcxproj under our '..._vs' directory, we want to reference generated files
|
|
1697
|
+
# in our concrete build directories (e.g. '..._debug'), where generated files will exist after building.
|
|
1698
|
+
self.relocate_generated_file_paths_to_concrete_build_dir(gen_src, target)
|
|
1699
|
+
|
|
1700
|
+
inc_src = ET.SubElement(root, 'ItemGroup')
|
|
1701
|
+
for s in sources:
|
|
1702
|
+
relpath = os.path.join(proj_to_build_root, s.rel_to_builddir(self.build_to_src))
|
|
1703
|
+
if path_normalize_add(relpath, previous_sources):
|
|
1704
|
+
inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=relpath)
|
|
1705
|
+
if self.gen_lite:
|
|
1706
|
+
self.add_project_nmake_defs_incs_and_opts(inc_cl, relpath, defs_paths_opts_per_lang_and_buildtype, platform)
|
|
1707
|
+
else:
|
|
1708
|
+
lang = Vs2010Backend.lang_from_source_file(s)
|
|
1709
|
+
self.add_pch(pch_sources, lang, inc_cl)
|
|
1710
|
+
self.add_additional_options(lang, inc_cl, file_args)
|
|
1711
|
+
self.add_preprocessor_defines(lang, inc_cl, file_defines)
|
|
1712
|
+
self.add_include_dirs(lang, inc_cl, file_inc_dirs)
|
|
1713
|
+
ET.SubElement(inc_cl, 'ObjectFileName').text = "$(IntDir)" + \
|
|
1714
|
+
self.object_filename_from_source(target, s)
|
|
1715
|
+
for s in gen_src:
|
|
1716
|
+
if path_normalize_add(s, previous_sources):
|
|
1717
|
+
inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=s)
|
|
1718
|
+
if self.gen_lite:
|
|
1719
|
+
self.add_project_nmake_defs_incs_and_opts(inc_cl, s, defs_paths_opts_per_lang_and_buildtype, platform)
|
|
1720
|
+
else:
|
|
1721
|
+
lang = Vs2010Backend.lang_from_source_file(s)
|
|
1722
|
+
self.add_pch(pch_sources, lang, inc_cl)
|
|
1723
|
+
self.add_additional_options(lang, inc_cl, file_args)
|
|
1724
|
+
self.add_preprocessor_defines(lang, inc_cl, file_defines)
|
|
1725
|
+
self.add_include_dirs(lang, inc_cl, file_inc_dirs)
|
|
1726
|
+
s = File.from_built_file(target.get_output_subdir(), s)
|
|
1727
|
+
ET.SubElement(inc_cl, 'ObjectFileName').text = "$(IntDir)" + \
|
|
1728
|
+
self.object_filename_from_source(target, s)
|
|
1729
|
+
for lang, headers in pch_sources.items():
|
|
1730
|
+
impl = headers[1]
|
|
1731
|
+
if impl and path_normalize_add(impl, previous_sources):
|
|
1732
|
+
inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=impl)
|
|
1733
|
+
self.create_pch(pch_sources, lang, inc_cl)
|
|
1734
|
+
if self.gen_lite:
|
|
1735
|
+
self.add_project_nmake_defs_incs_and_opts(inc_cl, impl, defs_paths_opts_per_lang_and_buildtype, platform)
|
|
1736
|
+
else:
|
|
1737
|
+
self.add_additional_options(lang, inc_cl, file_args)
|
|
1738
|
+
self.add_preprocessor_defines(lang, inc_cl, file_defines)
|
|
1739
|
+
pch_header_dir = pch_sources[lang][3]
|
|
1740
|
+
if pch_header_dir:
|
|
1741
|
+
inc_dirs = copy.deepcopy(file_inc_dirs)
|
|
1742
|
+
inc_dirs[lang] = [pch_header_dir] + inc_dirs[lang]
|
|
1743
|
+
else:
|
|
1744
|
+
inc_dirs = file_inc_dirs
|
|
1745
|
+
self.add_include_dirs(lang, inc_cl, inc_dirs)
|
|
1746
|
+
# XXX: Do we need to set the object file name here too?
|
|
1747
|
+
|
|
1748
|
+
additional_objects = []
|
|
1749
|
+
for o in self.flatten_object_list(target, proj_to_build_root)[0]:
|
|
1750
|
+
assert isinstance(o, str)
|
|
1751
|
+
additional_objects.append(o)
|
|
1752
|
+
for o in custom_objs:
|
|
1753
|
+
additional_objects.append(o)
|
|
1754
|
+
|
|
1755
|
+
# VS automatically links CustomBuild outputs whose name ends in .obj or .res,
|
|
1756
|
+
# but the others need to be included explicitly
|
|
1757
|
+
explicit_link_gen_objs = [obj for obj in gen_objs if not obj.endswith(('.obj', '.res'))]
|
|
1758
|
+
|
|
1759
|
+
previous_objects = []
|
|
1760
|
+
if len(objects) + len(additional_objects) + len(explicit_link_gen_objs) > 0:
|
|
1761
|
+
inc_objs = ET.SubElement(root, 'ItemGroup')
|
|
1762
|
+
for s in objects:
|
|
1763
|
+
relpath = os.path.join(proj_to_build_root, s.rel_to_builddir(self.build_to_src))
|
|
1764
|
+
if path_normalize_add(relpath, previous_objects):
|
|
1765
|
+
ET.SubElement(inc_objs, 'Object', Include=relpath)
|
|
1766
|
+
for s in additional_objects + explicit_link_gen_objs:
|
|
1767
|
+
if path_normalize_add(s, previous_objects):
|
|
1768
|
+
ET.SubElement(inc_objs, 'Object', Include=s)
|
|
1769
|
+
|
|
1770
|
+
ET.SubElement(root, 'Import', Project=r'$(VCTargetsPath)\Microsoft.Cpp.targets')
|
|
1771
|
+
self.add_regen_dependency(root)
|
|
1772
|
+
if not self.gen_lite:
|
|
1773
|
+
# Injecting further target dependencies into this vcxproj implies and forces a Visual Studio BUILD dependency,
|
|
1774
|
+
# which we don't want when using 'genvslite'. A gen_lite build as little involvement with the visual studio's
|
|
1775
|
+
# build system as possible.
|
|
1776
|
+
self.add_target_deps(root, target)
|
|
1777
|
+
self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname)
|
|
1778
|
+
if self.environment.coredata.get_option(OptionKey('layout')) == 'mirror':
|
|
1779
|
+
self.gen_vcxproj_filters(target, ofname)
|
|
1780
|
+
return True
|
|
1781
|
+
|
|
1782
|
+
def gen_vcxproj_filters(self, target, ofname):
|
|
1783
|
+
# Generate pitchfork of filters based on directory structure.
|
|
1784
|
+
root = ET.Element('Project', {'ToolsVersion': '4.0',
|
|
1785
|
+
'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003'})
|
|
1786
|
+
filter_folders = ET.SubElement(root, 'ItemGroup')
|
|
1787
|
+
filter_items = ET.SubElement(root, 'ItemGroup')
|
|
1788
|
+
mlog.debug(f'Generating vcxproj filters {target.name}.')
|
|
1789
|
+
|
|
1790
|
+
def relative_to_defined_in(file):
|
|
1791
|
+
# Get the relative path to file's directory from the location of the meson.build that defines this target.
|
|
1792
|
+
return os.path.dirname(self.relpath(PureWindowsPath(file.subdir, file.fname), self.get_target_dir(target)))
|
|
1793
|
+
|
|
1794
|
+
found_folders_to_filter = {}
|
|
1795
|
+
all_files = target.sources + target.extra_files
|
|
1796
|
+
|
|
1797
|
+
# Build a dictionary of all used relative paths (i.e. from the meson.build defining this target)
|
|
1798
|
+
# for all sources.
|
|
1799
|
+
for i in all_files:
|
|
1800
|
+
if not os.path.isabs(i.fname):
|
|
1801
|
+
dirname = relative_to_defined_in(i)
|
|
1802
|
+
if dirname:
|
|
1803
|
+
found_folders_to_filter[dirname] = ''
|
|
1804
|
+
|
|
1805
|
+
# Now walk up each of those relative paths checking for empty intermediate dirs to generate the filter.
|
|
1806
|
+
for folder in found_folders_to_filter:
|
|
1807
|
+
dirname = folder
|
|
1808
|
+
filter = ''
|
|
1809
|
+
|
|
1810
|
+
while dirname:
|
|
1811
|
+
basename = os.path.basename(dirname)
|
|
1812
|
+
|
|
1813
|
+
if filter == '':
|
|
1814
|
+
filter = basename
|
|
1815
|
+
else:
|
|
1816
|
+
# Use '/' to squash empty dirs. To actually get a '\', use '%255c'.
|
|
1817
|
+
filter = basename + ('\\' if dirname in found_folders_to_filter else '/') + filter
|
|
1818
|
+
|
|
1819
|
+
dirname = os.path.dirname(dirname)
|
|
1820
|
+
|
|
1821
|
+
# Don't add an empty filter, breaks all other (?) filters.
|
|
1822
|
+
if filter != '':
|
|
1823
|
+
found_folders_to_filter[folder] = filter
|
|
1824
|
+
filter_element = ET.SubElement(filter_folders, 'Filter', {'Include': filter})
|
|
1825
|
+
uuid_element = ET.SubElement(filter_element, 'UniqueIdentifier')
|
|
1826
|
+
uuid_element.text = '{' + str(uuid.uuid4()).upper() + '}'
|
|
1827
|
+
|
|
1828
|
+
sources, headers, objects, _ = self.split_sources(all_files)
|
|
1829
|
+
down = self.target_to_build_root(target)
|
|
1830
|
+
|
|
1831
|
+
def add_element(type_name, elements):
|
|
1832
|
+
for i in elements:
|
|
1833
|
+
if not os.path.isabs(i.fname):
|
|
1834
|
+
dirname = relative_to_defined_in(i)
|
|
1835
|
+
|
|
1836
|
+
if dirname and dirname in found_folders_to_filter:
|
|
1837
|
+
relpath = os.path.join(down, i.rel_to_builddir(self.build_to_src))
|
|
1838
|
+
target_element = ET.SubElement(filter_items, type_name, {'Include': relpath})
|
|
1839
|
+
filter_element = ET.SubElement(target_element, 'Filter')
|
|
1840
|
+
filter_element.text = found_folders_to_filter[dirname]
|
|
1841
|
+
|
|
1842
|
+
add_element('ClCompile', sources)
|
|
1843
|
+
add_element('ClInclude', headers)
|
|
1844
|
+
add_element('Object', objects)
|
|
1845
|
+
|
|
1846
|
+
self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname + '.filters')
|
|
1847
|
+
|
|
1848
|
+
def gen_regenproj(self):
|
|
1849
|
+
# To fully adapt the REGEN work for a 'genvslite' solution, to check timestamps, settings, and regenerate the
|
|
1850
|
+
# '[builddir]_vs' solution/vcxprojs, as well as regenerating the accompanying buildtype-suffixed ninja build
|
|
1851
|
+
# directories (from which we need to first collect correct, updated preprocessor defs and compiler options in
|
|
1852
|
+
# order to fill in the regenerated solution's intellisense settings) would require some non-trivial intrusion
|
|
1853
|
+
# into the 'meson --internal regencheck ./meson-private' execution path (and perhaps also the '--internal
|
|
1854
|
+
# regenerate' and even 'meson setup --reconfigure' code). So, for now, we'll instead give the user a simpler
|
|
1855
|
+
# 'reconfigure' utility project that just runs 'meson setup --reconfigure [builddir]_[buildtype] [srcdir]' on
|
|
1856
|
+
# each of the ninja build dirs.
|
|
1857
|
+
#
|
|
1858
|
+
# FIXME: That will keep the building and compiling correctly configured but obviously won't update the
|
|
1859
|
+
# solution and vcxprojs, which may allow solution src files and intellisense options to go out-of-date; the
|
|
1860
|
+
# user would still have to manually 'meson setup --genvslite [vsxxxx] [builddir] [srcdir]' to fully regenerate
|
|
1861
|
+
# a complete and correct solution.
|
|
1862
|
+
if self.gen_lite:
|
|
1863
|
+
project_name = 'RECONFIGURE'
|
|
1864
|
+
ofname = os.path.join(self.environment.get_build_dir(), 'RECONFIGURE.vcxproj')
|
|
1865
|
+
conftype = 'Makefile'
|
|
1866
|
+
# I find the REGEN project doesn't work; it fails to invoke the appropriate -
|
|
1867
|
+
# python meson.py --internal regencheck builddir\meson-private
|
|
1868
|
+
# command, despite the fact that manually running such a command in a shell runs just fine.
|
|
1869
|
+
# Running/building the regen project produces the error -
|
|
1870
|
+
# ...Microsoft.CppBuild.targets(460,5): error MSB8020: The build tools for ClangCL (Platform Toolset = 'ClangCL') cannot be found. To build using the ClangCL build tools, please install ...
|
|
1871
|
+
# Not sure why but a simple makefile-style project that executes the full '...regencheck...' command actually works (and seems a little simpler).
|
|
1872
|
+
# Although I've limited this change to only happen under '--genvslite', perhaps ...
|
|
1873
|
+
# FIXME : Should all utility projects use the simpler and less problematic makefile-style project?
|
|
1874
|
+
else:
|
|
1875
|
+
project_name = 'REGEN'
|
|
1876
|
+
ofname = os.path.join(self.environment.get_build_dir(), 'REGEN.vcxproj')
|
|
1877
|
+
conftype = 'Utility'
|
|
1878
|
+
|
|
1879
|
+
guid = self.environment.coredata.regen_guid
|
|
1880
|
+
(root, type_config) = self.create_basic_project(project_name,
|
|
1881
|
+
temp_dir='regen-temp',
|
|
1882
|
+
guid=guid,
|
|
1883
|
+
conftype=conftype
|
|
1884
|
+
)
|
|
1885
|
+
|
|
1886
|
+
if self.gen_lite:
|
|
1887
|
+
(nmake_base_meson_command, exe_search_paths) = Vs2010Backend.get_nmake_base_meson_command_and_exe_search_paths()
|
|
1888
|
+
all_configs_prop_group = ET.SubElement(root, 'PropertyGroup')
|
|
1889
|
+
|
|
1890
|
+
# Multi-line command to reconfigure all buildtype-suffixed build dirs
|
|
1891
|
+
multi_config_buildtype_list = coredata.get_genvs_default_buildtype_list()
|
|
1892
|
+
(_, build_dir_tail) = os.path.split(self.src_to_build)
|
|
1893
|
+
proj_to_multiconfigured_builds_parent_dir = '..' # We know this RECONFIGURE.vcxproj will always be in the '[buildir]_vs' dir.
|
|
1894
|
+
proj_to_src_dir = self.build_to_src
|
|
1895
|
+
reconfigure_all_cmd = ''
|
|
1896
|
+
for buildtype in multi_config_buildtype_list:
|
|
1897
|
+
meson_build_dir_for_buildtype = build_dir_tail[:-2] + buildtype # Get the buildtype suffixed 'builddir_[debug/release/etc]' from 'builddir_vs', for example.
|
|
1898
|
+
proj_to_build_dir_for_buildtype = str(os.path.join(proj_to_multiconfigured_builds_parent_dir, meson_build_dir_for_buildtype))
|
|
1899
|
+
reconfigure_all_cmd += f'{nmake_base_meson_command} setup --reconfigure "{proj_to_build_dir_for_buildtype}" "{proj_to_src_dir}"\n'
|
|
1900
|
+
ET.SubElement(all_configs_prop_group, 'NMakeBuildCommandLine').text = reconfigure_all_cmd
|
|
1901
|
+
ET.SubElement(all_configs_prop_group, 'NMakeReBuildCommandLine').text = reconfigure_all_cmd
|
|
1902
|
+
ET.SubElement(all_configs_prop_group, 'NMakeCleanCommandLine').text = ''
|
|
1903
|
+
|
|
1904
|
+
#Need to set the 'ExecutablePath' element for the above NMake... commands to be able to execute
|
|
1905
|
+
ET.SubElement(all_configs_prop_group, 'ExecutablePath').text = exe_search_paths
|
|
1906
|
+
else:
|
|
1907
|
+
action = ET.SubElement(root, 'ItemDefinitionGroup')
|
|
1908
|
+
midl = ET.SubElement(action, 'Midl')
|
|
1909
|
+
ET.SubElement(midl, "AdditionalIncludeDirectories").text = '%(AdditionalIncludeDirectories)'
|
|
1910
|
+
ET.SubElement(midl, "OutputDirectory").text = '$(IntDir)'
|
|
1911
|
+
ET.SubElement(midl, 'HeaderFileName').text = '%(Filename).h'
|
|
1912
|
+
ET.SubElement(midl, 'TypeLibraryName').text = '%(Filename).tlb'
|
|
1913
|
+
ET.SubElement(midl, 'InterfaceIdentifierFilename').text = '%(Filename)_i.c'
|
|
1914
|
+
ET.SubElement(midl, 'ProxyFileName').text = '%(Filename)_p.c'
|
|
1915
|
+
regen_command = self.environment.get_build_command() + ['--internal', 'regencheck']
|
|
1916
|
+
cmd_templ = '''call %s > NUL
|
|
1917
|
+
"%s" "%s"'''
|
|
1918
|
+
regen_command = cmd_templ % \
|
|
1919
|
+
(self.get_vcvars_command(), '" "'.join(regen_command), self.environment.get_scratch_dir())
|
|
1920
|
+
self.add_custom_build(root, 'regen', regen_command, deps=self.get_regen_filelist(),
|
|
1921
|
+
outputs=[Vs2010Backend.get_regen_stampfile(self.environment.get_build_dir())],
|
|
1922
|
+
msg='Checking whether solution needs to be regenerated.')
|
|
1923
|
+
|
|
1924
|
+
ET.SubElement(root, 'Import', Project=r'$(VCTargetsPath)\Microsoft.Cpp.targets')
|
|
1925
|
+
ET.SubElement(root, 'ImportGroup', Label='ExtensionTargets')
|
|
1926
|
+
self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname)
|
|
1927
|
+
|
|
1928
|
+
def gen_testproj(self):
|
|
1929
|
+
project_name = 'RUN_TESTS'
|
|
1930
|
+
ofname = os.path.join(self.environment.get_build_dir(), f'{project_name}.vcxproj')
|
|
1931
|
+
guid = self.environment.coredata.test_guid
|
|
1932
|
+
if self.gen_lite:
|
|
1933
|
+
(root, type_config) = self.create_basic_project(project_name,
|
|
1934
|
+
temp_dir='install-temp',
|
|
1935
|
+
guid=guid,
|
|
1936
|
+
conftype='Makefile'
|
|
1937
|
+
)
|
|
1938
|
+
(nmake_base_meson_command, exe_search_paths) = Vs2010Backend.get_nmake_base_meson_command_and_exe_search_paths()
|
|
1939
|
+
multi_config_buildtype_list = coredata.get_genvs_default_buildtype_list()
|
|
1940
|
+
(_, build_dir_tail) = os.path.split(self.src_to_build)
|
|
1941
|
+
proj_to_multiconfigured_builds_parent_dir = '..' # We know this .vcxproj will always be in the '[buildir]_vs' dir.
|
|
1942
|
+
# Add appropriate 'test' commands for the 'build' action of this project, for all buildtypes
|
|
1943
|
+
for buildtype in multi_config_buildtype_list:
|
|
1944
|
+
meson_build_dir_for_buildtype = build_dir_tail[:-2] + buildtype # Get the buildtype suffixed 'builddir_[debug/release/etc]' from 'builddir_vs', for example.
|
|
1945
|
+
proj_to_build_dir_for_buildtype = str(os.path.join(proj_to_multiconfigured_builds_parent_dir, meson_build_dir_for_buildtype))
|
|
1946
|
+
test_cmd = f'{nmake_base_meson_command} test -C "{proj_to_build_dir_for_buildtype}" --no-rebuild'
|
|
1947
|
+
if not self.environment.coredata.get_option(OptionKey('stdsplit')):
|
|
1948
|
+
test_cmd += ' --no-stdsplit'
|
|
1949
|
+
if self.environment.coredata.get_option(OptionKey('errorlogs')):
|
|
1950
|
+
test_cmd += ' --print-errorlogs'
|
|
1951
|
+
condition = f'\'$(Configuration)|$(Platform)\'==\'{buildtype}|{self.platform}\''
|
|
1952
|
+
prop_group = ET.SubElement(root, 'PropertyGroup', Condition=condition)
|
|
1953
|
+
ET.SubElement(prop_group, 'NMakeBuildCommandLine').text = test_cmd
|
|
1954
|
+
#Need to set the 'ExecutablePath' element for the NMake... commands to be able to execute
|
|
1955
|
+
ET.SubElement(prop_group, 'ExecutablePath').text = exe_search_paths
|
|
1956
|
+
else:
|
|
1957
|
+
(root, type_config) = self.create_basic_project(project_name,
|
|
1958
|
+
temp_dir='test-temp',
|
|
1959
|
+
guid=guid)
|
|
1960
|
+
|
|
1961
|
+
action = ET.SubElement(root, 'ItemDefinitionGroup')
|
|
1962
|
+
midl = ET.SubElement(action, 'Midl')
|
|
1963
|
+
ET.SubElement(midl, "AdditionalIncludeDirectories").text = '%(AdditionalIncludeDirectories)'
|
|
1964
|
+
ET.SubElement(midl, "OutputDirectory").text = '$(IntDir)'
|
|
1965
|
+
ET.SubElement(midl, 'HeaderFileName').text = '%(Filename).h'
|
|
1966
|
+
ET.SubElement(midl, 'TypeLibraryName').text = '%(Filename).tlb'
|
|
1967
|
+
ET.SubElement(midl, 'InterfaceIdentifierFilename').text = '%(Filename)_i.c'
|
|
1968
|
+
ET.SubElement(midl, 'ProxyFileName').text = '%(Filename)_p.c'
|
|
1969
|
+
# FIXME: No benchmarks?
|
|
1970
|
+
test_command = self.environment.get_build_command() + ['test', '--no-rebuild']
|
|
1971
|
+
if not self.environment.coredata.get_option(OptionKey('stdsplit')):
|
|
1972
|
+
test_command += ['--no-stdsplit']
|
|
1973
|
+
if self.environment.coredata.get_option(OptionKey('errorlogs')):
|
|
1974
|
+
test_command += ['--print-errorlogs']
|
|
1975
|
+
self.serialize_tests()
|
|
1976
|
+
self.add_custom_build(root, 'run_tests', '"%s"' % ('" "'.join(test_command)))
|
|
1977
|
+
|
|
1978
|
+
ET.SubElement(root, 'Import', Project=r'$(VCTargetsPath)\Microsoft.Cpp.targets')
|
|
1979
|
+
self.add_regen_dependency(root)
|
|
1980
|
+
self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname)
|
|
1981
|
+
|
|
1982
|
+
def gen_installproj(self):
|
|
1983
|
+
project_name = 'RUN_INSTALL'
|
|
1984
|
+
ofname = os.path.join(self.environment.get_build_dir(), f'{project_name}.vcxproj')
|
|
1985
|
+
guid = self.environment.coredata.install_guid
|
|
1986
|
+
if self.gen_lite:
|
|
1987
|
+
(root, type_config) = self.create_basic_project(project_name,
|
|
1988
|
+
temp_dir='install-temp',
|
|
1989
|
+
guid=guid,
|
|
1990
|
+
conftype='Makefile'
|
|
1991
|
+
)
|
|
1992
|
+
(nmake_base_meson_command, exe_search_paths) = Vs2010Backend.get_nmake_base_meson_command_and_exe_search_paths()
|
|
1993
|
+
multi_config_buildtype_list = coredata.get_genvs_default_buildtype_list()
|
|
1994
|
+
(_, build_dir_tail) = os.path.split(self.src_to_build)
|
|
1995
|
+
proj_to_multiconfigured_builds_parent_dir = '..' # We know this .vcxproj will always be in the '[buildir]_vs' dir.
|
|
1996
|
+
# Add appropriate 'install' commands for the 'build' action of this project, for all buildtypes
|
|
1997
|
+
for buildtype in multi_config_buildtype_list:
|
|
1998
|
+
meson_build_dir_for_buildtype = build_dir_tail[:-2] + buildtype # Get the buildtype suffixed 'builddir_[debug/release/etc]' from 'builddir_vs', for example.
|
|
1999
|
+
proj_to_build_dir_for_buildtype = str(os.path.join(proj_to_multiconfigured_builds_parent_dir, meson_build_dir_for_buildtype))
|
|
2000
|
+
install_cmd = f'{nmake_base_meson_command} install -C "{proj_to_build_dir_for_buildtype}" --no-rebuild'
|
|
2001
|
+
condition = f'\'$(Configuration)|$(Platform)\'==\'{buildtype}|{self.platform}\''
|
|
2002
|
+
prop_group = ET.SubElement(root, 'PropertyGroup', Condition=condition)
|
|
2003
|
+
ET.SubElement(prop_group, 'NMakeBuildCommandLine').text = install_cmd
|
|
2004
|
+
#Need to set the 'ExecutablePath' element for the NMake... commands to be able to execute
|
|
2005
|
+
ET.SubElement(prop_group, 'ExecutablePath').text = exe_search_paths
|
|
2006
|
+
else:
|
|
2007
|
+
self.create_install_data_files()
|
|
2008
|
+
|
|
2009
|
+
(root, type_config) = self.create_basic_project(project_name,
|
|
2010
|
+
temp_dir='install-temp',
|
|
2011
|
+
guid=guid)
|
|
2012
|
+
|
|
2013
|
+
action = ET.SubElement(root, 'ItemDefinitionGroup')
|
|
2014
|
+
midl = ET.SubElement(action, 'Midl')
|
|
2015
|
+
ET.SubElement(midl, "AdditionalIncludeDirectories").text = '%(AdditionalIncludeDirectories)'
|
|
2016
|
+
ET.SubElement(midl, "OutputDirectory").text = '$(IntDir)'
|
|
2017
|
+
ET.SubElement(midl, 'HeaderFileName').text = '%(Filename).h'
|
|
2018
|
+
ET.SubElement(midl, 'TypeLibraryName').text = '%(Filename).tlb'
|
|
2019
|
+
ET.SubElement(midl, 'InterfaceIdentifierFilename').text = '%(Filename)_i.c'
|
|
2020
|
+
ET.SubElement(midl, 'ProxyFileName').text = '%(Filename)_p.c'
|
|
2021
|
+
install_command = self.environment.get_build_command() + ['install', '--no-rebuild']
|
|
2022
|
+
self.add_custom_build(root, 'run_install', '"%s"' % ('" "'.join(install_command)))
|
|
2023
|
+
|
|
2024
|
+
ET.SubElement(root, 'Import', Project=r'$(VCTargetsPath)\Microsoft.Cpp.targets')
|
|
2025
|
+
self.add_regen_dependency(root)
|
|
2026
|
+
self._prettyprint_vcxproj_xml(ET.ElementTree(root), ofname)
|
|
2027
|
+
|
|
2028
|
+
def add_custom_build(self, node: ET.Element, rulename: str, command: str, deps: T.Optional[T.List[str]] = None,
|
|
2029
|
+
outputs: T.Optional[T.List[str]] = None, msg: T.Optional[str] = None, verify_files: bool = True) -> None:
|
|
2030
|
+
igroup = ET.SubElement(node, 'ItemGroup')
|
|
2031
|
+
rulefile = os.path.join(self.environment.get_scratch_dir(), rulename + '.rule')
|
|
2032
|
+
if not os.path.exists(rulefile):
|
|
2033
|
+
with open(rulefile, 'w', encoding='utf-8') as f:
|
|
2034
|
+
f.write("# Meson regen file.")
|
|
2035
|
+
custombuild = ET.SubElement(igroup, 'CustomBuild', Include=rulefile)
|
|
2036
|
+
if msg:
|
|
2037
|
+
message = ET.SubElement(custombuild, 'Message')
|
|
2038
|
+
message.text = msg
|
|
2039
|
+
if not verify_files:
|
|
2040
|
+
ET.SubElement(custombuild, 'VerifyInputsAndOutputsExist').text = 'false'
|
|
2041
|
+
|
|
2042
|
+
# If a command ever were to change the current directory or set local
|
|
2043
|
+
# variables this would need to be more complicated, as msbuild by
|
|
2044
|
+
# default executes all CustomBuilds in a project using the same
|
|
2045
|
+
# shell. Right now such tasks are all done inside the meson_exe
|
|
2046
|
+
# wrapper. The trailing newline appears to be necessary to allow
|
|
2047
|
+
# parallel custom builds to work.
|
|
2048
|
+
ET.SubElement(custombuild, 'Command').text = f"{command}\n"
|
|
2049
|
+
|
|
2050
|
+
if not outputs:
|
|
2051
|
+
# Use a nonexistent file to always consider the target out-of-date.
|
|
2052
|
+
outputs = [self.nonexistent_file(os.path.join(self.environment.get_scratch_dir(),
|
|
2053
|
+
'outofdate.file'))]
|
|
2054
|
+
ET.SubElement(custombuild, 'Outputs').text = ';'.join(outputs)
|
|
2055
|
+
if deps:
|
|
2056
|
+
ET.SubElement(custombuild, 'AdditionalInputs').text = ';'.join(deps)
|
|
2057
|
+
|
|
2058
|
+
@staticmethod
|
|
2059
|
+
def nonexistent_file(prefix: str) -> str:
|
|
2060
|
+
i = 0
|
|
2061
|
+
file = prefix
|
|
2062
|
+
while os.path.exists(file):
|
|
2063
|
+
file = '%s%d' % (prefix, i)
|
|
2064
|
+
return file
|
|
2065
|
+
|
|
2066
|
+
def generate_debug_information(self, link: ET.Element) -> None:
|
|
2067
|
+
# valid values for vs2015 is 'false', 'true', 'DebugFastLink'
|
|
2068
|
+
ET.SubElement(link, 'GenerateDebugInformation').text = 'true'
|
|
2069
|
+
|
|
2070
|
+
def add_regen_dependency(self, root: ET.Element) -> None:
|
|
2071
|
+
# For now, with 'genvslite' solutions, REGEN is replaced by the lighter-weight RECONFIGURE utility that is
|
|
2072
|
+
# no longer a forced build dependency. See comment in 'gen_regenproj'
|
|
2073
|
+
if not self.gen_lite:
|
|
2074
|
+
regen_vcxproj = os.path.join(self.environment.get_build_dir(), 'REGEN.vcxproj')
|
|
2075
|
+
self.add_project_reference(root, regen_vcxproj, self.environment.coredata.regen_guid)
|
|
2076
|
+
|
|
2077
|
+
def generate_lang_standard_info(self, file_args: T.Dict[str, CompilerArgs], clconf: ET.Element) -> None:
|
|
2078
|
+
pass
|