Erlang outdir flag in "compile" module attribute - module

I know that to set the outdir from Erlang shell I need to do somethig like this:
c(some_module, [{outdir, "./beams"}]).
It works fine but now I want to set the outdir from the module using module attribute -compile. I'm doing:
-module(some_module).
-compile([export_all, {outdir, "./beams"}]).
%% here goes functions
But it doesn't work: folder "./beams is empty, but export_all flag is working. What am I doing wrong?

I am not sure if this is correct syntax. What is sure, it works with Emakefile:
{'src/*', [{outdir, "ebin"},
{i,"include"},
debug_info,
strict_record_tests,
netload]}.
mantain following directory tree:
.
├── Emakefile
├── ebin
├── include
└── src
and use:
erl -make
It will place beams in ebin.
What I recommend in general is switching to Rebar. It will do all for you, and make the package compatible with erlang deployment policy.

Related

Honour module's `config.yml` when dynamically importing modules into Snakemake workflow

Background
I'm new to scientific workflows, and am building my first more complex Snakemake workflow.
Setup & what I've tried
I'm importing modules dynamically. The scenario is that I have a root config.yml file that includes:
subworkflows:
- subwf-1
- subwf-2
- other-subwf
In the root Snakefile I'm doing:
configfile: 'config.yml'
ALL_SUBWFS = config['subworkflows']
# <omitted> Check for min version 6.0
for MODULE in ALL_SUBWFS:
module MODULE:
snakefile:
f'subworkflows/{MODULE}/Snakefile'
use rule * from MODULE as f'{MODULE}_*'
This works fine so far. However, I'd like to be able to configure the different submodules each in their own config.yml.
Assume the following directory structure:
.
├── Snakefile
├── config.yml
└── subworkflows/
├── subwf-1/
│   ├── Snakefile
│   └── config.yml
├── subwf-2/
│ ├── Snakefile
│ └── config.yml
└── other-subwf/
├── Snakefile
└── config.yml
As far as I understand, this isn't supported, and neither of these options work:
Define configfile: config.yml in main workflow and configfile: cf in subworkflows, where I've tried three options for cf:
cf = str(workflow.source_path('config.yml')) # 1
cf = f'{workflow.basedir}/config.yml' # 2
cf = 'config.yml' # 3
# With each of these options
configfile: cf
All give me KeyError in <...>/Snakefile: 'config'.
Using config: config in module import, and subworkflows' Snakefiles including something like VALUES = config['values'] gives me KeyError in <...>/Snakefile: 'values' using each option.
Actual question
Am I right in assuming that it isn't possible to honour the configfiles for modules at all, and that instead, I need to use a global config file, e.g. with keys for each subworkflow imported as config: config['<key-for-subworkflow-config-YAML-map>']?
Further experimentation seems to show that my dynamic import of modules doesn't work: While print()ing from the subworkflow Snakefiles works fine, onyl one of the subworkflows gets executed when rules are defined.
This renders the question unanswerable at this point.
Regarding your Actual question:
Rather than trying to pass or overwrite configfile you can try the intended approach for module of passing/overwriting the config dictionary used by the module.
The keyword here is config: <dict> in the module <name>: block which you might be able to combine with the load_config method of `snakemake:
from snakemake.io import load_configfile
for MODULE in ALL_SUBWFS:
module MODULE:
snakefile: f'subworkflows/{MODULE}/Snakefile'
config: load_configfile(f'subworkflows/{MODULE}/config.yml'
Note: Untested as you report other issues with your idea for loading external workflows dynamically.

Unable to include a .cmake file in another .cmake file from subdirectory

I have a third party .cmake file, that is used as a tool chain file, that I want to include in my own .cmake tool chain file. I want to do this so I can set some arguments and call some macros defined in the third party .cmake file.
My project setup looks like this:
MyProject
├── myFile.cmake
└── thirdparty
└── otherProject
└── otherFile.cmake
The otherFile.cmake is in the directory /thirdparty/otherProject relative to my project. So in my myFile.cmake I have among many things tried this:
include(otherFile.cmake)
and this
include(thirdparty/otherProject/otherFile.cmake)
and this
add_subdirectory(thirdparty/otherProject)
include(otherFile.cmake)
and this
include("${CMAKE_CURRENT_FILE}/thirdparty/otherProject/otherFile.cmake")
and many more such as include_directory(), but I always get:
include could not find load file
and I always do a clean build just to be sure.
I would think this is a simple task, but cmake continues to baffle me so I'm reaching out for help :)
I figured it out eventually:
include(${CMAKE_CURRENT_LIST_DIR}/thirdparty/otherProject/otherFile.cmake)

CMake adding files with ends with "*.a" [duplicate]

Clion: how add or (use) prebuilt static library in my Project?
You're probably asking about how to link your project to the pre-built static library. If so, you can do like this by calling target_link_libraries.
Assume your project called myProj and the pre-built library myLib.lib, you can do like this:
target_link_libraries(myProj myLib)
I had great difficulty making this work as I was completely new to CLion and CMake.
In my scenario I was taking a class that required us to use the course library in every project.
Assuming you have a library called libClassLibrary.a, do the following in the CMakeLists.txt at the project root:
First, find the library's location:
find_library(LIB_TO_INCLUDE ClassLibrary /path/to/your/library)
LIB_TO_INCLUDE will contain the location of the library assuming it is found. Note that hardcoding the path could be problematic if you'd like your solution to be portable to other systems. You can add additional search paths separated by a space if the library could exist in multiple locations. A typical example is to include common install locations such as /usr/bin /usr/local/bin etc.
Next, ensure that header files (if applicable) are included in the header search paths:
find_path (LIB_INCLUDES ClassLibrary.h /path/to/header/files)
Again, include multiple search paths if the headers could be loaded in multiple locations. If there is more than one header file, you'll need to include all of them.
Now, include the directories using the include_directories command:
include_directories(${LIB_INCLUDES})
The above will instruct the build system to search all directories contained in LIB_INCLUDES or whatever you decide to call it.
Finally, add the executable and use the target_link_libraries command to link the libClassLibrary.a.
add_executable(MyExecutable main.cpp)
target_link_libraries(MyExecutable ${LIB_TO_INCLUDE})
That's all. You'll notice that under "External Libraries" > "Header Search Paths" in the Project organizer window the directories containing your header files appears.
PS - The book Mastering CMake by Ken Martin and Bill Hoffmann is an invaluable resource.
I've linked my static lib test.a with the related header files as following:
Project
├── main.cpp
├── CmakeLists.txt
├── libs
│ ├── includes
│ │ ├── *.h
│ ├── lib
│ │ ├── test.a
I've added this to the ./CMakeLists.txt:
include_directories(${CMAKE_SOURCE_DIR}/libs/include)
find_library(Test_LIB test "${CMAKE_SOURCE_DIR}/libs/lib")
add_executable(TestApp main.cpp)
target_link_libraries(TestApp ${Test_LIB})
By adding message(${Test_LIB}), you can print out and check the path.
Your question is unrelated to CLion, it is pure CMake. Modify the CMakeLists.txt from your project and use add_library. The CMake documentation might be helpful.
I misunderstood the question, target_link_library is probably the answer to the question.

IntelliJ IDEA not picking up correct application-{}.properties file

I have a spring boot 1.5.1 project that uses profile properties file. In my /src/main/resources I have all my properties files
When using IntelliJ 2016.3.4 I set the
Run Configuration | Active Profile
to "local" and run it. I see this in the console:
The following profiles are active: local
But there is a value in the property file
data.count.users=2
and used as:
#Value("${data.count.users}")
private int userCount;
that is not being picked up and thus causing the error:
Caused by: java.lang.IllegalArgumentException: Could not resolve
placeholder 'data.count.users' in string value "${data.count.users}"
However, if I run this via gradle
bootRun {
systemProperty 'spring.profiles.active', System.properties['spring.profiles.active'] }
as
gradle bootRun -Dspring.profiles.active=local
then everything starts up using the local profile as expected. Can anyone see why this is not being properly picked up? In IntelliJ Project Structure I have my /src/main/resources defined as my Resource Folders.
UPDATE:
Adding screenshot of Configuration:
I could be wrong here but it doesn't look like the spring.profiles.active environment variable is actually set in your configuration, regardless of what you've selected as your Active Profile. This may be a bug with IntelliJ.
However, setting the environment variable in Run -> Edit Configurations definitely works for me.
Pease add Spring facet to your Spring Boot module to get full support
Is classpath of module heimdall the correct one, i.e. does it contain the shown resources folder with your application.properties?
If this doesn't help, please file a minimum sample project reproducing the exact structure of your project in our bugtracker, there are too many variables to investigate https://youtrack.jetbrains.com/issues/IDEA.
Using -Dspring.config.location in VM options in IntelliJ helped me.
-Dspring.config.location=file:/C:/Users/<project path>/src/main/resources/application-dev.properties
This could also be due to a non-standard configuration setup, for instance:
src/main/resources
├── application.properties
├── config1
│   ├── application-dev.properties
│   ├── application-prod.properties
│   ├── application.properties
│   └── logback-spring.xml
├── config2
│   ├── application-dev.properties
│   ├── application-prod.properties
│   ├── application.properties
│   └── logback-spring.xml
└── config3
├── application-dev.properties
├── application-prod.properties
├── application.properties
└── logback-spring.xml
This can be solved by passing using the parameters logging.config & spring.config.name for logback & spring respectively. For the above example:
java -jar \
-Dspring.profiles.active=dev \
-Dlogging.config=classpath:config1/logback-spring.xml \
-Dspring.config.name=application,config1/application \
target/my-application.0.0.1.jar
Here root application.properties is used, overridden by config1/application.properties, overridden by config1/application-dev.properties. The parameters (environment variables) can be specified in IDEA's run configuration in VM Options.
As far as advanced IDE support (highlighting, completion etc.) is concerned, there is an open issue for complex/custom configuration setups: IDEA-180498

msbuild: build as to a appxbundle (AppxBundle=Always not working)

I have a shared Windows8.1 project with a Phone and Desktop project in it. I defined different configurations to build x86/x64 for desktop and ARM for phone.
msbuild works fine without error, but there is no final *.appxbundle file on the output folder (or anywhere else) although i set the parameter AppxBundle=Always.
my command looks like this:
msbuild myApp.sln /p:OutputPath=%OUTPATH%;Configuration=Phone;Platform=ARM;AppxBundle=Always;AppxBundlePlatforms=ARM
/t:Rebuild,Publish
The output is:
OUTPATH
├── ForBundle
│ └── AppxManifest.xml
├── AppxManifest.xml
├── App.WindowsPhone.build.appxrecipe
├── App.WindowsPhone_3.2.1_ARM.appx
├── App.WindowsPhone_3.2.1_scale-100.appx
├── App.WindowsPhone_3.2.1_scale-140.appx
├── App.WindowsPhone_3.2.1_scale-180.appx
├── resources.pri
└── SomeDependency.winmd
I tried to pack this folder with makeappx.exe bundle but this didn't work and I realized the folder looks a bit different to what is into a appxbundle.
Creating a appxbundle via VS GUI is no problem, but I would like to automate that step!
Thanks in advance!
There's a hint comment in Microsoft.AppXPackage.Targets:
When building on the command line or in TFS (determined by looking at the $(BuildingInsideVisualStudio) property), if build is
invoked on an
app package-producing project, the package for the project will be produced as part of building the project without specifying
any additional
flags or targets. This is control by an MSBuild property named GenerateAppxPackageOnBuild which is set to true by default.
If $(BuildingInsideVisualStudio) = false and $(GenerateAppxPackageOnBuild) = true, then build will also produce a
package.
true
FYI, the file has moved for VS 2022, new location isL
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VisualStudio\v17.0\AppxPackage