Gpr file, do not include all directory in source - ada

There is my project.gpr file :
project Test is
Project_Source_Dirs := ("Dir1")
& ("src")
& ("../../lib_all");
for Object_Dir is "lib";
for Main use ("Main_file.adb");
for Languages use ("Ada");
for Source_Dirs use Project_Source_Dirs & project'Object_Dir;
-- [...]
end Test;
There is my "../../lib_all" folder :
lib_all
|- file1.adb
|- file1.ads
|- file2.adb
|- file2.ads
|- file3.adb
|- file3.ads
|- file4.adb
|- file4.ads
I only want to use file3, how can I modify my .gpr file to not compile all other files each time ?

You can use Source_Files or Excluded_Source_Files settings, as described here: https://docs.adacore.com/gprbuild-docs/html/gprbuild_ug/gnat_project_manager.html#source-files-and-directories
But I think, the easier way could be simply moving unneeded files to separated directory and adding that directory with its content on demand (based on variables, etc.).

Related

How do I iterate over subfolders for SCSS files to compile?

I need to iterate over a subfolder for SCSS files in a variety of locations to compile in CSS (obviously). However, I have no idea how to do this, not being skilled in that area. I am also hampered by the fact I have to try to do this using NPM, and SASS (not node-sass).
Could someone give me a whistle-stop tour on how to achieve what I want?
It might also be worth pointing out that the SCSS files may reside in the SRC folder on the odd occasion, and I need to create the CSS files in the folder the SCSS was found in :(
As an example my folder structure looks a little like this;
Root
|
|- Components
| |- src
| |- styles
| |- buttons.scss
|
|- package.json
The end result would look like this
Root
|
|- Components
| |- src
| |- styles
| |- buttons.scss
| |- buttons.css
|
|- package.json
Any help would be greatly appreciated as I would like to learn how to do this once and for all ;)

Compiling watch SCSS Many-to-One CSS

I'm trying to find a way to compile my multiple scss files into one css file.
scripts are in package.json using node-sass
The best I've found for the moment is : sass --watch .assets/css/scss/:assets/css
The problem is it creates one css file for each scss file plus a css map file.
I was previously working without watch node-sass --include-path scss .assets/css/scss/style.scss assets/css/style.css but had to run the command at each save.
Using sass --watch .assets/css/scss/style.scss:assets/css/style.css with style.scss like this :
#import 'test1.scss';
#import 'test2.scss'
is not working but console say :
Compiled style.scss to style.css.
Compiled test1.scss to test1.css
Am i missing something?
EDIT : for some reasons, running only sass without node on a subsystem linux is causing some blue screen. Using node-sass --watch ./assets/css/scss/style.scss:assets/css/style.css or node-sass --watch ./assets/css/scss:assets/css return a npm error : code ELIFECYCLE errno 1
I've tried different solutions and the one that worked for what i wanted was that one : Using node sass watch with npm
Had the remove the dependencies and the directory bacause i have to write on only one file.
have to run this one to make it work
"css-watch: node-sass --include-path scss ./assets/css/scss/style.scss -w /assets/css/style.css"
including files in the style.scss without _ in the name is working fine with a simple import and detect all updates in the imported files.
Given the following directory structure
root
|- src
| |- collect
| | |-collect.scss
| |- pack-a
| | |-a.scss
| |- pack-b
| | |-b.scss
|- build (generated)
| |- collect
| | |-collect.css
| |- pack-a
| | |-a.css
| |- pack-b
| | |-b.css
and collect.css with the following content
// ./src/collect/collect.scss
#import "../pack-a/a.scss";
#import "../pack-b/b.scss";
(i) run sass ./src/collect:./bld/collect to generate ./bld/collect/collect.css
(ii) run sass ./src:./bld to generate all
All your SASS partials should be renamed to begin with an underscore character: _.
From the SASS Basics guide:
A partial is a Sass file named with a leading underscore. You might name it something like _partial.scss. The underscore lets Sass know that the file is only a partial file and that it should not be generated into a CSS file.
You can continue to import the partial files into your main styles.scss file the same way, using their normal names and omitting the underscore character. You can also omit the '.scss' if you'd like. To follow the new SASS syntax version you should be using #use to import partial SASS files as a module, rather than #import.
Then you just transpile that main build file and it should work fine.

Whats a good way to set up a QT-Subdir project with Plugins? (outputdir/includes)

My questions breack down in subquestions, but since all of them concern the same toppic of subdir-projekt setup and some decissions might influence the other questions i ask them all in one post.
1) Can i avoid writing the same include ines in every part using the same libs.
INCLUDEPATH += $$PWD/../MyLib1 # add header for usage
# Adds the QtQuickSampleLib.lib to the linker
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../MyLib1/release/ -lMyLib1
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../MyLib1/debug/ -lMyLib1
2) How to set up the output paths, so the dynamic-libs and Plugins can be loaded easely.
3) Can the Interface-Definition be placed in e seperate projekt, generating a static output so i can import it easely?
As i understand the Sourceprojekt-Folders schould be setup like this:
MainProjekt
+Main-Runner <generates the ELF>
+CoreLib (Most logic in a Lib for easyer tests, might make it a Plugin)
| +SRC
| +Test
+PluginInterface (currently .pri file)
+Plugins
| +PluginA
| | +SRC (Most logic in a Lib for easyer tests)
| | +Test
| +PluginB
| | +SRC (Most logic in a Lib for easyer tests)
| | +Test
| +PluginC <Depends on PluginA & PluginB being loaded>
| | +SRC (Most logic in a Lib for easyer tests)
| | +Test
PS: The idear is something like:
PluginA being hardwareInteraction (if possible having a "Fake-Version" for the test in PluginC)
PluginB Handles a Visible Data-Modell
PluginC is a Control-System Talking to the hardware and writing out Data.
The trick is to create a top-level .qmake.conf file and use it to define global paths:
CONFIG += c++11 #example, now it is set in every pro file
PROJ_VERSION = 1.0.0
OUT_ROOT = $$shadowed($$PWD)
LIB_OUT = $$OUT_ROOT/lib
PLG_OUT = $$OUT_ROOT/plugins
# ...
create that file as .qmake.conf in the MainProject folder. As long as you compile the project by using the MainProject.pro file, it is used for all sub pro files as well (recursively)
Now for the actual questions:
1.) Create a small pri file in the project root folder as:
INCLUDEPATH += $$PWD/MyLib1
win32:CONFIG(release, debug|release): LIBS += -L$$LIB_OUT -lMyLib1
else:win32:CONFIG(debug, debug|release): LIBS += -L$$LIB_OUT -lMyLib1d
you can include it in all the sub projects that need it. $$PWD is always the pri files directory itself, not where it is included. $$LIB_OUT is taken from the .qmake.conf
2.) As you might have noticed I defined a few variables in the conf file. You can now use these as DESTDIR in the actual pro files. For example, in your lib pro file you can use:
VERSION = $$PROJ_VERSION #optionally use the globally defined version
DESTDIR = $$LIB_OUT
You can do the same for plugins, binaries, etc.

Stylus, right order of subdirectory import

everybody.
I have a problem with stylus import.
In my project I'am using such methode of import:
#import "project/**/*.styl"
And also i have this bem folder structure:
Project/
|- Project.styl
|- Block1/
| |- Block1.styl
| |- _Element1/
| | |- _Element1.styl
| | |- __Modificator1/
| | | |- __Modificator1.styl
|- Block2/
|- Block3/
In general, the problem is that when bundle.css is ready, styles in it goes in wrong way. First in it goes modificators, then elements and only then blocks, so modificator always overwrites by elements, and finnaly they don't work ... that how looks my code:
HTML:
<div class="block1_element1 block1_element1__modificator1"></div>
CSS:
.block1_element1__modificator1{font-size: 14px}
.block1_element1{font-size: 16px}
In result will be 16px font size ...
If someone know how to change order from end of branch to the start, please give me advice how to make it.s
The Problem
Wrong order of Stylus imported files.
The Reason
When using File Globing in Stylus i.e. **/* Stylus engine orders files by names so the order of imported files becomes __Modificator(n).styl then _Element(n).styl then Block(n).styl and that of course what is causing wrong CSS styles.
Possible Solution
Use index.styl file in each directory/subdirectory, inside each index.styl file import all the files in the current directory then all index.styl files of all subdirectories.
Example
The project structure should be like below:
Project/
|- Project.styl
|- Block1/
| |- index.styl
| |- Block1.styl
| |- _Element1/
| | |- index.styl
| | |- _Element1.styl
| | |- __Modificator1/
| | | |- index.styl
| | | |- __Modificator1.styl
|- Block2/
|- Block3/
And here what should be inside the index.styl files
inside Project.styl
#import "Block1"
#import "Block2"
...
inside any Block directory index.styl file
#import "_Element1"
#import "_Element2"
#import "Block1.styl" // current parent block
...
inside any Element directory index.styl file
#import "__Modificator1"
#import "__Modificator2"
#import "_Element1.styl" // current parent Element
...

GNU Make global variables updated in sub-makes

I need some help with my Makefile for a project. The source directory looks something like this.
|-- Makefile
|-- drivers
| |-- Makefile
| |-- tty
| |-- Makefile
| |-- console.c
| |-- keyboard.c
|-- kernel
| |-- Makefile
| |-- kmain.c
In the top Makefile, I have exported a variable OBJECTS that I want to populate with object files so I can build and link them together in the top Makefile.
I want to update OBJECTS in, say, drivers/tty/Makefile by doing something like this:
OBJECTS += $(CURDIR)console.o
OBJECTS += $(CURDIR)keyboard.o
But the change to OBJECTS does not bubble up to the top Makefile. I've been looking at the Makefiles in the Linux source tree, and they seem to be doing something similar. However, I can't get it to work. Am I missing something here?
You appear to be using Make recursively, something like
# Makefile:
export OBJECTS :=
all:
$(MAKE) -C drivers/tty
#echo OBJECTS is $(OBJECTS)
# drivers/tty/Makefile:
OBJECTS += $(CURDIR)console.o
all:
whatever
This doesn't work, because each Make has its own OBJECTS; the child Make can't modify variables in the parent Make. It's export, not import/export or share (there's no such thing as import/export or share, I'm just trying to illustrate).
You can get the effect you want by including the other makefiles instead of invoking them:
# Makefile:
OBJECTS :=
all: DRIVERS_TTY
#echo OBJECTS is $(OBJECTS)
include drivers/tty/Makefile
# drivers/tty/Makefile:
OBJECTS += drivers/tty/console.o
DRIVERS_TTY:
whatever
You'll notice there is some unpleasant location-dependency there; drivers/tty/Makefile has "drivers/tty" spelled out inside it, which makes maintenance a pain. There are ways to fix that, once you have this basic include trick working.
When you recursively run make it opens a new subshell for each subsequent call to make so you can't go back up the chain with your exports. One method would be for each call to a submake to append to an object list file and then possibly include that file. A better solution is to probably do something along the lines of having your main makefile include each of these submake files directly instead of calling make on them. This method allows the OBJECTS variable to be built up using the each of the submake files with your OBJECTS += statements. Another added benefit is that you are running just one instance of make instead of multiple submakes which allows make to do better dependency generation. Take a look at "Recursive make considered harmful" http://aegis.sourceforge.net/auug97.pdf
One cool makefile build system that was posted up here before by user Dan Moulding https://stackoverflow.com/users/95706/dan-moulding really showed off a lot of the cool stuff you can do with submake files all while having just one master makefile. Dan's boilermake project is here: https://github.com/dmoulding/boilermake

Resources