Is there a way to run "make" from within a subdirectory of my project, with a makefile at its root?
In the same way that git will look for a .git folder in the current directory, and if it doesn't exist there, will check up one directory, etc... until it either finds a git repo or reaches the system root, I'd like to be able to have make look upwards for a makefile. Is this possible?
One solution would be to have a makefile in every directory that simply calls make in the directory above it... but that seems like an unnecessary amount of files and is very prone to error (forgetting to put it in a directory, etc...). Plus, I'd like to be able to send arguments to make (ie 'make this.file' or 'make clean'), and I'm not sure that'd be possible with this method...
I hope this is on the correct stackexchange site. Sorry if it isn't! And thanks for reading/answering!
There are many way to implement something like this. The following worked for me in the past:
At the top of the project I have files config.mk and Makefile. The latter defines a variable TOP as top project directory.
In each relevant subdirectory there is a Makefile that has the following directives:
TOP ?= ../..
include $(TOP)/config.mk
This is not a perfect solution but it allows significant reuse of make logic and both full and partial rebuilds.
Related
Please consider the following.
I like to structure my R projects with different subdirectories. Using bookdown or quarto seems to make this quite difficult since both like to have their source files (.Rmd or .qmd) in the project directory. I was hoping that this will get easier with quarto but this does not seem the case, although it should be possible according to this post.
Problem description (replicable example)
Start a new quarto book project in RStudio: File > New Project > New Directory > Quarto Book.
This will create several .qmd files in the R project directory. Now create new subdirectories. Starting from the R project directory: scripts/qmd.
If we put all .qmd files from the R project directory into scripts/qmd, we also need adapt their path in the _quarto.yml (e.g., from index.qmd to / scripts/qmd/index.qmd).
After doing so and pressing the Render button, we receive the ERROR: Book contents must include a home page (e.g. index.md).
Putting only the index.qmd file back into the R Project directory (and adapt the _quarto.yml), the book can be rendered.
Question
How can we put all .qmd files into a dedicated subdirectory?
Edit (ignore below)
Originally the below question was also asked but is now answered: quarto does not seem to have a "merge-knit" option like bookdown (see here). This unfortunately makes quarto useless for my use case.
If this is not possible, how can we make sure that object created in the R project directory are accessible for the .qmd files in the subdirectories? (setting execute-dir: project as suggested here did not work for me.
I'm assuming your purpose is just a specific personal preference for file organization.
You can have a large portion of your content in subdirectories (and that's my understanding of what Alison's blog post refers to), but you still need to have your index.qmd in the root. For example, you can have a subdirectory for projects, another one for posts, another one for tutorials, like Alison does.
In any case, one way of achieving what you want is by using pre- and post-render scripts.
You could move all the files from the scripts/qmd directory before rendering and then move them all back afterwards.
pre-render: mv scripts/qmd/*.qmd .
post-render: mv *.qmd scripts/qmd
Incidentally, that doesn't match my own personal preference ;-)
#Lucas A. Meyer, I tested the pre-render and post render options you suggested above, however, it throws an error after moving the file from my subdirectory to the project root:
ERROR: NotFound: The system cannot find the file specified. (os error 2)
Then, it fails to render the file and move it back to the original subdirectory location.
I then set execute-dir: project in my .yml file thinking it was trying to execute in the wrong folder, but it did not change anything.
P.S. I would have added as a comment, but my reputation is not high enough, yet. :(
UPDATE1:
I thinking I found a workaround for the time being. I've include the following project options beneath the project: header:
output-dir: subdir1/subdir2 Moves the html file, only.
post-render: xcopy *_files subdir1/subdir2 /E Copies the supporting files over.
The mv shell command can't be used for directories or you get the Directory Not Empty error.`
I have split my less/css into several files grouped by certain categories, so the single files stay easy to maintain. Though I only want to have one css file which gets imported into the layout.
For this I have - how I call it - a master less file which imports all the others like config, forms, layout and so on.
Now the problem is, that for example WinLess or all the other copilers i tried, only monitor the save of my master file, and only then compiles it. However this is stupid, because this file nearly never gets any changes. So what I would like to have is something, that detects changes on the imported less files and then only compiles the master file.
Does anyone know any tools, which are capable of that?
Or how do you manage your less files to bypass this problem?
Further Info: I have mapped the server directory locally via SSH and edit the files in there, i.e. the files are only pseudo local. They are on the server but accessible with a local path over a drive letter. The compiler should be able to work with that setup.
Thanks for the answers!
In all honesty, your best bet is to actually use Less's own compiler which will of course be the most up to date option. It will be done through command line but it's the best way to know that everything is correct, working and up-to-date.
All the information can be found in the Less Documentation Here
More information about compiling with imports can be found HERE
The latest version of WinLESS does report that it has automatic re-compiling when an #import file is changed so it could be that your version of WinLESS is out of date. (See HERE - 3rd bullet point under Features)
Alternatively, see if you can get it to work on purely local files. If this works, it may be an issue with the compiler not being able to do asynchronous checks over SSH.
I use Notepad++ with the NppExec-plugin on-save script. If you make a convention decision to always name your primary file "master.less" you can use this script:
NPP_CONSOLE 0
NPP_SAVE
if $(EXT_PART) != .less goto end
"C:\Node.JS\node_modules\.bin\lessc.cmd" -x "$(CURRENT_DIRECTORY)\master.less" > "$(CURRENT_DIRECTORY)\master.min.css"
:end
You can do something similar with any editor that supports batch scripting (like Stewartside suggests)
In my Qt application we can open a help file (chm) by doing the following:
QDesktopServices::openUrl(QUrl::fromLocalFile(_PathToTheCHMFile));
This seems to be the suggested way of doing things. And it has worked up until now.
However, the documentation team has now changed how the chm files work. Now we are referencing a "master" file which only contains references to other chm files. The directory structure of the chm files is as follows:
master.chm
SUBDIR/
-> child1.chm
-> child2.chm
...
If open the master.chm file with hh.exe (the default tool in windows), everything looks perfect. However, from my Qt application, the help file opens, but there are no sub topics, just the root node.
I assume this is a search path issue, and it can't resolve the relative paths. There doesn't seem to be any way to configure the openURL call to run from a certain directory, or anything like that.
Thanks in advance
If you need to be able to access those elements properly, then you may need to change your applications current directory on the fly.
http://qt-project.org/doc/qt-4.8/qdir.html#details
http://qt-project.org/doc/qt-4.8/qdir.html#setCurrent
If that doesn't work, you may want to look into using QProcess::startDetached
http://qt-project.org/doc/qt-4.8/qprocess.html#startDetached
and specifying the working directory to be exactly where your master.chm is located.
You may want to specify some command-line arguments, too.
http://www.help-info.de/en/Help_Info_HTMLHelp/hh_command.htm
Hope that helps.
I am using KDevelop 4.2.3 and in my project directory there are symbolic links to a large collection of test instances. I want to tell kdevelop to ignore these directories. There is the possibility to put a file named .kdev_ignore into the directory that should be ignored. Unfortunately this feature is not propagated into subdirectories.
So, is there any way to exclude a directory and all of its subdirectories without putting .kdev_ignore files everywhere?
Update with Makefile (not CMake):
I also found a four year old Makefile symlink recursive bug which was originally patched in Kdevelop 3.5 (plus a possible second reference to the same issue).
If you decide to file a new bug report, and personally I think that you should, you should reference those two links to demonstrate regression.
When you do a compass compile after renaming or deleting files the compiled files won't actually get removed. compass clean doesn't actually remove these files either since it only worries about cleaning up what is currently in use. That being said I don't want to do something like a rm -rf /css/* where css is my compiled folder either since that blows away all my files completely.
I am wondering if there is a way to just delete the "old" compiled files without touching anything currently in use.
Why?: if you have lots of scss files the generated files or sprite sheets might take some time to generate. This isn't too bad, but if you are then taking the generated files and creating some other derivative of it (maybe because you have some older build process or are generating docs or something else) then you need to completely regenerate all of it again. Blowing away all the files forces a complete regeneration; whereas, only removing un-needed files and then recompiling is extremely quick.
We are toying with the idea that blowing away all the files only on occasion by doing the following:
compass clean
rm -rf css/*
compass compile
But we are hoping for a better solution :).
A shell script to remove the CSS files and generate new ones would look like this:
#!/bin/sh
compass clean
compass compile
Note that this particular script needs to be in the same directory as your project to work. My script-fu is pretty weak, but I'm sure it could be modified to work anywhere without having to copy/paste it in every project.