How to activate and modify build configurations in cedet/ede? - emacs

I basically want to know how to turn off optimization so that gdb works correctly.
When I set up an Automake project from scratch, it seems like the defaults for CPPFLAGS are "-g -O2", but I just want "-g". There is an unrelated question where the answer shows Project.ede files that have the configuration-variables field set for the target here:
Setting up an emacs EDE-project with libraries
Based on this, I edited my target to produce the following Project.ede:
;; Object test3
;; EDE Project Files are auto generated: Do Not Edit
(ede-proj-project "test3"
:file "Project.ede"
:name "test3"
:targets (list
(ede-proj-target-makefile-program "test3"
:name "test3"
:path ""
:source '("main.cpp")
:configuration-variables '(("debug" ("CPPFLAGS" . "-g")) ("release" ("CPPFLAGS" . "-O3")))
:ldlibs '("boost_program_options" "boost_system")
)
)
:makefile-type 'Makefile.am
)
However, executing ede-compile-project and ede-compile-target after these edits still produces the same "-g -O2" values. How do I activate the "debug" configuration that I created? Also, how can I set this to be the default set of configurations for new projects so I don't need to change every new project that I create manually?

You can change current configuration in project settings.
M-x customize-project, then go to the Settings tab and change the Current Configuration value.

Related

How to display new Yocto image option after source poky/oe-init-env

let say i have a new yocto image call stargazer-cmd
what file should i edit so that every time i source poky/oe-init-env
it display as a build option to the user?
kj#kj-Aspire-V3-471G:~/stm32Yoctominimal$ source poky/oe-init-build-env build-mp1/
### Shell environment set up for builds. ###
You can now run 'bitbake <target>'
Common targets are:
core-image-minimal
core-image-sato
meta-toolchain
meta-ide-support
I wish to add stargazer-cmd on top of core-image-minimal, i am not sure what to google and what is the file i need to change.
Let me explain how to add a custom configuration to the OpenEmbedded build process.
First of all, here is the process that is done when running:
source poky/oe-init-build-env
The oe-init-build-env script initializes OEROOT variable to point to the location of the script itself.
The oe-init-build-env script sources another file $OEROOT/scripts/oe-buildenv-internal which will:
Check if OEROOT is set
Set BUILDDIR to your custom build directory name $1, or just build if you do not provide one
Set BBPATH to the poky/bitbake folder
Adds $BBPATH/bin and OEROOT/scripts to PATH (This will enable commands like bitbake and bitbake-layers ...)
Export BUILDDIR and PATH to the next file
The oe-init-build-env script continues by running the final build script with:
TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir
The oe-setup-builddir script will:
Check if BUILDDIR is set
Create the conf directory under $BUILDDIR
Sources a template file that will check if there is a TEMPLATECONF variable is set:
. $OEROOT/.templateconf
That file contains:
# Template settings
TEMPLATECONF=${TEMPLATECONF:-meta-poky/conf}
it means that if TEMPLATECONF variable is not set, set it to meta-poky/conf, and that is where the default local.conf and bblayers.conf are coming from.
Copy $TEMPLATECONF to $BUILDDIR/conf/templateconf.cfg
Set some variables pointing to custom local.conf and bblayers.conf:
OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample"
OECORELOCALCONF="$TEMPLATECONF/local.conf.sample"
OECORENOTESCONF="$TEMPLATECONF/conf-notes.txt"
In the oe-setup-builddir there is a comment saying that TEMPLATECONF can point to a directory:
#
# $TEMPLATECONF can point to a directory for the template local.conf & bblayers.conf
#
Copy local.conf.sample and bblayers.conf.sample from TEMPLATECONF directory into BUIDDIR/conf:
cp -f $OECORELOCALCONF "$BUILDDIR/conf/local.conf"
sed -e "s|##OEROOT##|$OEROOT|g" \
-e "s|##COREBASE##|$OEROOT|g" \
$OECORELAYERCONF > "$BUILDDIR/conf/bblayers.conf"
Finally it will print what is inside OECORENOTESCONF which points to TEMPLATECONF/conf-notes.txt:
[ ! -r "$OECORENOTESCONF" ] || cat $OECORENOTESCONF
and by default that is located under meta-poky/conf/conf-notes.txt:
### Shell environment set up for builds. ###
You can now run 'bitbake <target>'
Common targets are:
core-image-minimal
core-image-sato
meta-toolchain
meta-ide-support
You can also run generated qemu images with a command like 'runqemu qemux86'
Other commonly useful commands are:
- 'devtool' and 'recipetool' handle common recipe tasks
- 'bitbake-layers' handles common layer tasks
- 'oe-pkgdata-util' handles common target package tasks
So, now, after understanding all of that, here is what you can do:
Create a custom template directory for your project, containing:
local.conf.sample
bblayers.conf.sample
conf-notes.txt
Do not forget to set the path to poky in bblayers.conf to ##OEROOT## as it will be set automatically by the build script.
Set your custom message in conf-notes.txt
Before any new build, just set TEMPLATECONF:
TEMPLATECONF="<path/to/template-directory>" source poky/oe-init-build-env <build_name>
Then, you will find a build with your custom local.conf and bblayers.conf with additional file conf/templateconf.cfg containing the path of TEMPLATECONF
conf/conf-notes.txt in your layer.
OECORENOTESCONF should point to the file.

How do I set basic options with meson?

I'm trying to configure a project with meson. Specifically, I'm trying to set some of the options.
meson config tells me, among other things:
Core options:
Option Current Value Possible Values Description
------ ------------- --------------- -----------
buildtype debug [plain, debug, debugoptimized, release, minsize, custom] Build type to use
Base options:
Option Current Value Possible Values Description
------ ------------- --------------- -----------
b_lto false [true, false] Use link time optimization
(other options were clipped from this printout of course.)
So, I write:
meson build . --buildtype=release
in my build directory, and this goes fine - no warnings or errors (I double-checked that the option value had changed). Then I write:
meson build . --b_lto=true
but this gets me:
meson: error: unrecognized arguments: --b_lto=true
I also tried -b_lto=true, --b_lto true, b_lto=true and b_lto true. And all of those without the true value. No luck.
How do I set these "base options" then?
The --option=value, and --option value styles to pass arguments only applies to the universial options section in meson's manual...so not to base options, and others. Instead use the -Doption=value syntax to set options. It is the suggested way, since meson setup --help declares [-D option] to be used for setting all sorts of options. See this answer by the meson team. So, in your case run:
meson build . -Db_lto=true
but, better use this ordering, since its specified this way in the manual (man meson).
meson -Db_lto=true build .
or
meson configure build -Db_lto=true
If the build directory changed since the last configure use reconfigure instead.
meson reconfigure build -Db_lto=true
or explicitly:
meson setup --reconfigure -Db_lto=true build

SBT - How can I add/modify values to application.conf file based on an external source

I read that SBT has functionality to generate source code and resource files.
In my case I want to add/modify a field in an application.conf file during compilation/packaging of the project (leaving the others in place)
For instance my application.conf file has something like:
A {
B = "Some Value"
C = "Some value to be modified"
}
I would like in the SBT to read an external file and change or add the value of A.B or A.C
So if it is possible to do something along the lines of:
build.sbt
lazy val myProject = project.in(file('myproject')
// pseudo code - How do I do this?
.sourceGenerators in Compile += "Read file /path/to/external/file and add or replace the value of application.conf A.B = some external value"
You can replace the values with environment variable values provided while compiling / building your project. For that you'd have to
A {
B = "Some Value"
B = ${?B_ENV}
C = "Some value to be modified"
C = ${?C_ENV}
}
Where B_ENV and C_ENV are the environment variables you set in your terminal either before build or within the build command (before it)
$ B_ENV=1 C_ENV=2 sbt run
Source: https://www.playframework.com/documentation/2.6.x/ProductionConfiguration#using-environment-variables
In this case you can do without sbt and this approach would also work with maven or cradle.
The *.conf support orignates from typesafe config (https://github.com/lightbend/config).
There is a feature to get environment variables to be used in the configuration which should be a good fit to solve the problem.
There are two approaches I would suggest to use
1.) Fail on missing configuration
If configuration of this vallue is important and to prevent the deplyment of misconfigurated application the startup should fail on missing environment variables.
in application.conf
key=${TEST} // expects "TEST" to be set, fails otherwise
2.) Hardcoded value with override
If there is a sensible default behaviour that only in some circumstances should be changed.
in application.conf
key="test" // hardcoded key
key=${?TEST} // override "key" with 3nv "$TEST" value, when it is given

Emacs packages not loaded when adding to configuration.nix

I am following the documentation on https://nixos.org/nixos/manual/ to add packages to emacs. I installed emacs with nix-env -i emacs. As it describes I created a file called emacs.nix
{ pkgs ? import <nixpkgs> {} }:
let
myEmacs = pkgs.emacs;
emacsWithPackages = (pkgs.emacsPackagesNgGen myEmacs).emacsWithPackages;
in
emacsWithPackages (
epkgs: (with epkgs.melpaStablePackages; [
magit
labburn-theme
cider
company
flycheck
iedit
yasnippet
nix-mode
] )
)
And then run nix-build emacs.nix. After that I had a result symlink, as expected. Finally, I confirmed that my packages are working by running emacs with ./result/bin/emacs, run package-initialized and finally checked that the extensions are working.
Now the problem is after I try to add it to my global configuration. As suggested I added the following to my configuration.nix file:
{
environment.systemPackages = [
# [...]
(import ./emacs.nix { inherit pkgs; })
];
}
I run nixos-rebuild switch. This procedure doesn't give access to the packages on emacs.
I recently ran into this problem. Make sure you remove vanilla "pkgs.emacs" from your environment.systemPackages list. Once that is done it worked as expected for me.

Use csscomb for VS Code

I'm trying VS Code for a few days and I've installed csscomb extension. It works fine when I put .csscomb.json on my work directory.
But I wish it worked even on file I open outside of my work directory.
Could you tell me how to configure VS Code and/or csscomb to work like this?
I use Windows 10 Pro.
According to the csscomb page on VS Code's Marketplace...
They have "Supported settings"
csscomb.preset
Type: Object or String
Defaut: {}
Config's name. Should be one of the
following: csscomb, zen, yandex or an object containing custom
configuration or path to config.
And the following warning:
Warning!
If you want to specify a file in the current directory, the path must
begin with a ./ or ../ if relative to the current directory. Also you
can use HOME directory as ~ symbol.
In other words, since there is no default, you have to set either a preset config or path to a custom config.
To configure csscomb in VS Code:
Go to File > Preferences > Settings
Select the "User Settings" tab in the right window (to apply the config globally)
Expand the options for "CSScomb configuration"
Click the pencil to the left of "csscomb.preset"
Click "Copy to Settings"
Enter the path to your custom config or choose a preset
{
"csscomb.preset": "~/.vscode/.csscomb.json"
}
OR one of ("csscomb", "zen", "yandex")
{
"csscomb.preset": "csscomb"
}
Next, you need to create the .csscomb.json file in that location. I chose the C:\Users\username\.vscode directory because that's where VS Code also downloads extensions on Windows.
Here's the config I created using csscomb's config generator:
{
"always-semicolon": true,
"color-case": "upper",
"block-indent": " ",
"color-shorthand": true,
"element-case": "lower",
"eof-newline": false,
"leading-zero": false,
"quotes": "double",
"sort-order-fallback": "abc",
"space-before-colon": "",
"space-after-colon": " ",
"space-before-combinator": " ",
"space-after-combinator": " ",
"space-between-declarations": "\n",
"space-before-opening-brace": " ",
"space-after-opening-brace": "\n",
"space-after-selector-delimiter": " ",
"space-before-selector-delimiter": "",
"space-before-closing-brace": "\n",
"strip-spaces": true,
"tab-size": true,
"vendor-prefix-align": true
}
You can also include an option for sorting tags (or copy it from one of their presets on git):
{
"sort-order": [
[
"font",
"font-family",
"font-size",
"font-weight",
"font-style"
],
[
"position",
"z-index"
]
]
}
Now you should be able to format CSS within VS Code by typing ctrl+shift+p then typing "CSScomb" then enter.
"Formatter" extensions are supposed to be recognized by the default formatting keyboard shortcut shift+alt+f, however I haven't gotten that to work. I think it's something the developer has to configure.
Instead, you can create your own keyboard shortcut in VS Code:
Go to File > Preferences > Keyboard Shortcuts
Click the link at the top to edit keybindings.json
Add your custom keybinding
{
"key": "ctrl+shift+c",
"command": "csscomb.execute"
}
Now you should be all set!