meson: How to execute a run_command prior to building a target? - meson-build

I have a meson custom_target that builds a docker. Before it runs, I would like to remove some files. However, I cannot use a run_command in the depends: section. e.g. I'd like to add a 'clean_target' along with 'devbase' below. Is there a way to do that?
, output : meson.project_name() + '.iid'
, input : dev_docker_file
, depends : [devbase]
, command : [docker, 'build'
, '--tag', dev_tag
, '--iidfile', '#OUTPUT#'
, '--file', dev_docker_file
, meson.source_root()]
, console : true)

You can try to create another custom_target and add result (dependency object) to depends: :
clean_dep = custom_target('clean',
output : 'clean.done',
capture: true,
command : ['sh', '-c', 'rm', 'som_file'])
, since generating of some output is required, and then
custom_target('docker',
...
depends : [devbase, clean_dep]
...)

Related

project user.lua require statement only for project specific Modules

I have maintained my user.lua project folder specific. Is there anything in place where I can exclude Zerobrane's env path when I check a Module require statement with "Evaluate in Console"?
The reason for this is , i will ensure that everything is working within the plugin Engine himself.
This is what would be checked for a missing Module
lualibs and bin is cerobrane specific, if I see it right
Output
local toast = require("toast")
[string " local toast = require("toast")"]:1: module 'toast' not found:
no field package.preload['toast']
no file 'lualibs/toast.lua'
no file 'lualibs/toast/toast.lua'
no file 'lualibs/toast/init.lua'
no file './toast.lua'
no file '/usr/local/share/luajit-2.0.4/toast.lua'
no file '/usr/local/share/lua/5.1/toast.lua'
no file '/usr/local/share/lua/5.1/toast/init.lua'
no file '/Volumes/SSD2go PKT/X-Plane 11 stable/Resources/plugins/FlyWithLua/Internals/toast.lua'
no file '/Volumes/SSD2go PKT/X-Plane 11 stable/Resources/plugins/FlyWithLua/Internals/toast/init.lua'
no file '/Volumes/SSD2go PKT/X-Plane 11 stable/Resources/plugins/FlyWithLua/Modules/toast.lua'
no file '/Volumes/SSD2go PKT/X-Plane 11 stable/Resources/plugins/FlyWithLua/Modules/toast/init.lua'
no file 'bin/clibs/libtoast.dylib'
no file 'bin/clibs/toast.dylib'
no file './toast.so'
no file '/usr/local/lib/lua/5.1/toast.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file '/Volumes/SSD2go PKT/X-Plane 11 stable/Resources/plugins/FlyWithLua/Internals/libtoast_64.so'
Here is my user.lua file at this time
--[[--
Use this file to specify **User** preferences.
Review [examples](+/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio/cfg/user-sample.lua) or check [online documentation](http://studio.zerobrane.com/documentation.html) for details.
--]]--
--https://studio.zerobrane.com/doc-general-preferences#debugger
-- to automatically open files requested during debugging
editor.autoactivate = true
--enable verbose output
--debugger.verbose=true
--[[--
specify how print results should be redirected in the application being debugged (v0.39+). Use 'c' for ‘copying’ (appears in the application output and the Output panel), 'r' for ‘redirecting’ (only appears in the Output panel), or 'd' for ‘default’ (only appears in the application output). This is mostly useful for remote debugging to specify how the output should be redirected.
--]]--
debugger.redirect="c"
-- to force execution to continue immediately after starting debugging;
-- set to `false` to disable (the interpreter will stop on the first line or
-- when debugging starts); some interpreters may use `true` or `false`
-- by default, but can be still reconfigured with this setting.
debugger.runonstart = true
-- FlyWithLua.ini version 2.7.6 build 2018-10-24
-- Where to search for modules.
-- use this to evaluate your project folder , select the print function / right Mousebutton --> Evaluate in Console
--print(ide.filetree.projdir)
ZBSProjDir = "/Volumes/SSD2go PKT/X-Plane 11 stable/Resources/plugins/FlyWithLua"
INTERNALS_DIRECTORY = ZBSProjDir .. "/Internals/"
MODULES_DIRECTORY = ZBSProjDir .. "/Modules/"
package.path = table.concat({
package.path,
INTERNALS_DIRECTORY .. "?.lua",
INTERNALS_DIRECTORY .. "?/init.lua",
MODULES_DIRECTORY .. "?.lua",
MODULES_DIRECTORY .. "?/init.lua",
}, ";")
package.cpath = table.concat({
package.cpath,
INTERNALS_DIRECTORY .. "?.ext",
MODULES_DIRECTORY .. "?.ext",
}, ";")
-- Produce a correct name pattern for binary modules for OS and architecture.
-- This resolves clash between OS X and Linux binary modules by requiring "lib"
-- prefix for Linux ones.
local library_pattern = "?_64."
if SYSTEM == "IBM" then
library_pattern = library_pattern .. "dll"
elseif SYSTEM == "APL" then
library_pattern = library_pattern .. "so"
else
library_pattern = "lib" .. library_pattern .. "so"
end
package.cpath = package.cpath:gsub("?.ext", library_pattern)
Version --> ZeroBrane Studio (1.90; MobDebug 0.706)
Greetings Lars
You should get the desired effect if toast module file is located in your project directory. When a command is executed in the Console, the current directory is set to the project directory, so even though lualibs folder from the IDE may be in the path, it should make no difference (unless you copied the module to lualibs).

Passing a yaml array containing package data to puppet through Hiera

puppet version: 4.9.4
hiera version: 3.3.1
What i am trying to do is have httpd reload when a new version of package-x/y is installed, and it doesn't seem like the array from Hiera is being passed correctly.
for my httpd.pp file, I have:
class service::common::httpd (
$service_state = undef, # undef = unmanaged
$service_run_at_boot = undef,
$packages = undef
) {
service { 'httpd':
ensure => $service_state,
enable => $service_run_at_boot,
subscribe => $packages,
restart => "/usr/sbin/apachectl graceful"
}
}
and in the yaml file for hiera, I have:
service::common::httpd::packages: [Package['package-x'],Package['package-y']]
running puppet with this gives the error
Error: Evaluation Error: Error while evaluating a Function Call, Lookup of key 'allow_virtual_packages' failed: Unable to parse (/root/repos/puppet-config/data/nodes/<location of yaml file>): did not find expected ',' or ']' while parsing a flow sequence
also saying that its missing a comma between flow collection entries. I've tried many different combinations of spaces and commas as well..
I have also tried including the packages inside the class with an include statement.
What am i doing wrong?
The yamllint utility is quite useful for analysing Puppet Hiera YAML files. When I tried it on your file I got:
▶ yamllint spec/fixtures/hiera/data/common.yaml
spec/fixtures/hiera/data/common.yaml
2:25 error syntax error: expected ',' or ']', but got '['
2:39 error too few spaces after comma (commas)
The syntax error there reveals that the file is simply invalid YAML.
But how to fix it?
Confusingly, a line in a Puppet manifest like:
subscribe => [Package['package-x'], Package['package-y']]
When compiled into a JSON Puppet catalog becomes:
"subscribe": ["Package[package-x]", "Package[package-y]"]
And you can place the same JSON string in the YAML file to make valid YAML like this:
service::common::httpd::packages: ["Package[package-x]", "Package[package-y]"]
You can also use single quotes in the YAML i.e.
service::common::httpd::packages: ['Package[package-x]', 'Package[package-y]']
More info on how to compile the Puppet catalog in my blog post here.
quotes.
hiera doesn't know what Package is. just quote it, since its a string.
service::common::httpd::packages: [ "Package['package-x']",
"Package['package-y']" ]
works perfectly.
or you can just change [ "Package['package-x']", "Package['package-y']" ] to [ 'package-x', 'package-y' ]
works flawlessly. see below.
host01.yaml
beats::packetbeat::packages: [ acl, htop ]
packetbeat.pp
class beats::packetbeat (
$packages = undef
) {
package {
"packetbeat":
ensure => "$version",
subscribe => Package[$packages],
;
}
}
Notice: /Stage[main]/Beats::Packetbeat/Package[acl]/ensure:
current_value 'absent', should be '2.2.51-14.el7' (noop)
Notice: /Stage[main]/Beats::Packetbeat/Package[packetbeat]: Would have
triggered 'refresh' from 1 event
Notice: /Stage[main]/Beats::Packetbeat/Service[packetbeat]: Would have
triggered 'refresh' from 2 events
Notice: Class[Beats::Packetbeat]: Would have triggered 'refresh' from
3 events

How to chain two custom_targets in meson?

Two properly build my target, I need to chain two custom commands in meson:
gob2 - That translates a .gob file to a pair of .c and .h files
patch_src - A small python program that makes a small patch of the gob2 output.
But I can't figure out how to give the patch_src command the output of the gob2 program as input. If I do the following:
gob2 = find_program('gob2')
patch_src = find_program('patch_src')
gen_src = custom_target('gen-output',
output : ['gtk-image-viewer.h','gtk-image-viewer-private.h','gtk-image-viewer.c'],
input : 'gtk-image-viewer.gob',
command : [gob2, '-o', '#OUTDIR#', '#INPUT#'],
)
fixed_src = custom_target('patch-output',
output : ['gtk-image-viewer-fixed.c'],
input : 'gtk-image-viewer.c',
command : [patch_src, 'gtk-image-viewer.c','#OUTPUT#'],
)
I obviously get the error that gtk-image-viewer.c is not found, which makes sense as it is written to #OUTPUTDIR#. But how do I specify to meson to look for gtk-image-viewer.c in #OUTPUTDIR#?
You can pass gen_src[3] for example as the input directly and meson will set up the dependencies and use the correct path to it.
fixed_src = custom_target('patch-output',
output : ['gtk-image-viewer-fixed.c'],
input : gen_src[3],
command : [patch_src, '#INPUT#','#OUTPUT#'],
)

Is there an option to list the targets (maybe with a description) in fake?

In Ruby (RAKE) you can document your tasks in the following way
# rakefile
desc "cleans ./temp"
task :clean do
p :cleaning
end
desc "compile the source"
task :compile => :clean do
p :compiling
end
$ rake -T # Display the tasks with descriptions, then exit.
rake clean # cleans ./temp
rake compile # compile the source
Is this possible with fake ?
The same is implemented in FAKE, as I found out when reading the source
// build.fsx
Description "remove temp/"
Target "Clean" (fun _ ->
CleanDirs [buildDir; deployDir]
)
// ....so on
Dependency graph is shown with .../fake.exe --listTargets or -lt
Available targets:
- Clean - remove temp/
Depends on: []
- Build
Depends on: ["Clean"]
- Deploy
Depends on: ["Test"]
- Test
Depends on: ["Build"]

Passing Parameter in pig

A = load '$path' using PigStorage('$Delimiter') as ($table_schema);
I want to pass these parameter in pig command dynamically.
Can any help me in this by showing an example?
Try this :
test.cfg
path=/input/file/path
delimiter=,
table_schema=requiredschema:chararray
N.B. Valid values to be given for above keys before test run.
test.pig
A = load '$path' using PigStorage('$delimiter') as ($table_schema);
DUMP A;
Invocation :
pig -f test.pig -m test.cfg
-f : To specify pig file name
-m : To specify the param file where
Ref : Error getting when passing parameter through pig script for a similar use case.