how to include .hrl files across multiple modules rebar3 - erlang

I have several modules's directories. For each module, I have include (containing *.hrl files) and src (containing *.erl files) folder separeated. How can I share *.hrl file from a module to another without duplicating them?
With rebar, I added {erl_opts, [{i, "folderContainsIncludeFile"}]} and it worked.
But with rebar3, the compilation is failed by saying can't find include file "include/xx.hrl"

I take it then you don't have an umbrella project, you just have multiple directories at the same level, each one with its own project managed with rebar3.
Something like:
root_folder
|- project1
| |- src
| |- include
| | `- one.hrl
| `- rebar.config
|- project2
| |- src
| | `- two.erl
| |- include
| `- rebar.config
…
And you want to include one.hrl into two.erl.
If that's the case, you should consider one of these alternatives:
A. Moving to an umbrella project structure, like…
root_folder
|- rebar.config <<<<<<<< notice this file is here now
`- apps
|- project1
| |- src
| `- include
| `- one.hrl
|- project2
| |- src
| | `- two.erl
| `- include
…
B. Using individual repos for each project and configuring them as dependencies from each other. The structure is like the one you currently have, but now you have to add deps to rebar.config's. For instance, in our example, you should add the following line to project2's rebar.config:
{deps, [project1]}.
(if you manage to publish project1 in hex.pm)
C. Properly setting $ERL_LIBS so that it includes the paths where your apps are built with rebar3. Something like…
ERL_LIBS=$ERL_LIBS:/path/to/root_folder/project1/_build/lib:/path/to/root_folder/project2/_build/lib:…
Hope this helps :)

Related

Esbuild cannot resolve node_modules that contains relative paths

I have a node_module with the structure like this.
#module_name
+-- dist
| +-- folder1
| +-- folder2
| +-- file1.d.ts
| +-- src
| +-- file2.d.ts
|
The file1.dt.ts is to expose, through export, some types from the file file2.d.ts.
//file1.dt.ts
export * from '../../src/file2';
But when I try to run the esbuild I receive the error
✘ [ERROR] Could not resolve "../../src/file2"
I have seen this problem in different libraries that use relative paths.

Trying to integrate Google AdMob in libgdx game on iOS results in "framework not found GoogleUtilities"

I want to include google ads into my libgdx game. In android this is working straightforward. However in iOS there are some complications:
I updated the Info.plist.xml file with my ad-identifier.
Then I added the following entries to the robovm.xml file:
into the <frameworks> element:
<!--AdMob-->
<framework>GoogleAppMeasurement</framework>
<framework>GoogleMobileAds</framework>
<framework>GoogleUtilities</framework>
<framework>nanopb</framework>
before the <frameworks> element:
<frameworkPaths>
<path>libs</path>
</frameworkPaths>
In the main gradle.build file I added an entry allProjects.ext.robopodsVersion = "2.2.3" and added into the iOS project section implementation "com.mobidevelop.robovm:robopods-google-mobile-ads-ios:$robopodsVersion" so this section looks like this:
project(":ios") {
apply plugin: "java-library"
apply plugin: "robovm"
dependencies {
implementation project(":core")
implementation "com.mobidevelop.robovm:robopods-google-mobile-ads-ios:$robopodsVersion"
api "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
api "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
api "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
}
}
Then I downloaded the googlemobileadssdkios.zip file and put its contents under libs folder in the iOS project. The contents under ios/libs look like this:
|- nanopb.xcframework
|- Info.plist
|- ios-armv7_arm64
|- ...
|- ios-i386_x86_64-simulator
|- ...
|- ios-x86_64-maccatalyst
|- ...
|- PromisesObjC.xcframework
|- Info.plist
|- ios-armv7_arm64
|- ...
|- ios-i386_x86_64-simulator
|- ...
|- ios-x86_64-maccatalyst
|- ...
|- Licenses
|- ...
|- GoogleUtilities.xcframework
|- Info.plist
|- ios-armv7_arm64
|- ...
|- ios-i386_x86_64-simulator
|- ...
|- ios-x86_64-maccatalyst
|- ...
|- GoogleMobileAds.framework
|- GoogleMobileAds
|- ...
|- Headers
|- ...
|- Modules
|- ...
|- GoogleAppMeasurement.framework
|- GoogleAppMeasurement
|- ...
|- Modules
|- ...
So summarised: under each .xcframework directory there are, besides this Info.plist file, the directories os-armv7_arm64, ios-i386_x86_64-simulator and ios-x86_64-maccatalyst.
When I try to run the app on the simulator from Android Studio (using the robovm android studio plugin idea-2.3.10-SNAPSHOT.zip) I get the following error:
[ERROR] 09:12:34.831 ld: framework not found GoogleUtilities
[ERROR] 09:12:34.832 clang: error: linker command failed with exit code 1 (use -v to see invocation)
[ERROR] Couldn't compile app
I had the suspicion that this has something to do with the xcframework that are used by GoogeUtilities and was assured by the open issue https://github.com/MobiVM/robovm/issues/468 which basically tells that there is currently no support for xcframworks, but linking to issue https://github.com/MobiVM/robovm/pull/483 which is describing with little words that now a variant can be specified in the element of the <frameworkPaths> element.
The question for me is now: how to proceed with the libs and how to define path variants so that it can run both in a iOS device and in the simulator?
This solved the problem for me:
In the robovm.xml file replace the <frameworkPaths> element with the following part:
<frameworkPaths>
<path variant="device">arm_libs</path>
<path variant="simulator">sim_libs</path>
</frameworkPaths>
Note that (also in the robovm.xml file) in the frameworks section for me the following part had to be added:
<framework>PromisesObjC</framework>
Using the shell in ios subproject create two directories: arm_libs and sim_libs
Go into arm_libs directory and execute the following commands:
cp -r ../libs/GoogleUtilities.xcframework/ios-armv7_arm64/GoogleUtilities.framework .
cp -r ../libs/GoogleAppMeasurement.framework .
cp -r ../libs/GoogleMobileAds.framework .
cp -r ../libs/PromisesObjC.xcframework/ios-armv7_arm64/PromisesObjC.framework .
cp -r ../libs/nanopb.xcframework/ios-armv7_arm64/nanopb.framework .
cp -r ../libs/Licenses .
Go into sim_libs directory and execute the following commands:
cp -r ../libs/GoogleUtilities.xcframework/ios-i386_x86_64-simulator/GoogleUtilities.framework .
cp -r ../libs/GoogleAppMeasurement.framework .
cp -r ../libs/GoogleMobileAds.framework .
cp -r ../libs/Licenses .
cp -r ../libs/PromisesObjC.xcframework/ios-i386_x86_64-simulator/PromisesObjC.framework .
cp -r ../libs/nanopb.xcframework/ios-i386_x86_64-simulator/nanopb.framework .
This gives the following structure:
|- arm_libs
|- GoogleAppMeasurement.framework
|- ...
|- GoogleMobileAds.framework
|- ...
|- GoogleUtilities.framework
|- ...
|- Licenses
|- ...
|- PromisesObjC.framework
|- ...
|- nanopb.framework
|- ...
|- sim_libs
|- GoogleAppMeasurement.framework
|- ...
|- GoogleMobileAds.framework
|- ...
|- GoogleUtilities.framework
|- ...
|- Licenses
|- ...
|- PromisesObjC.framework
|- ...
|- nanopb.framework
|- ...
Now running in simulator and on iPhone works for me.

Global Header Staging in Bazel

Our current project structure is as follows:
thirdparty(ws_root)
|_WORKSPACE
|_comp1
| |_BUILD
| |_src
| |_ a.c
| |_include
| |_ a.h
|_comp2
| |_BUILD
| |_src
| |_ b.c
| |_include
| |_ b.h
|_inc
| |_comp1
| |_a.h
| |_comp2
| |_b.h
Contents of a.c :
#include <comp1/a.h>
With our current build system the header file under thirdparty/comp1/include/a.h is staged with the following path:
thirdparty/inc/comp1/a.h
Here the thirdparty/inc folder is a global location where all header files in the workspace are staged under the respective components.
I would like to know if Bazel provides a mechanism by which we can stage the header files in a similar manner.
I'm not sure I understand, by "global location" you mean a folder in each library (library in the Bazel sense, you might call it component or package)? That's what I understood from the example. If that is the case, and each library just provides a -isystem include to all its dependents, that is possible in bazel, look for includes attribute.

Log4j Configuration File path

We are working on grails and also have microservices. There is a logging service in grails folder and log4j2.xml in grails-app/conf. Now we want to migrate logging service to jar(means outside of grails to one of microservices). So added log4j.xml in our resources folder of maven project. But it is not detecting the configuration file, so logging only to consoles.
Tried several things like
1. Setting system property in code
2. renaming log4j.xml file as log4j2.xml (but it gives error in grails startup)
Edit: Project Structure
Project
|
+-- grails-app
| |
| +-- conf
| |
| +--log4j2.xml
| +-- services/OldLoggingService.groovy
|
+--logevent(mavenproject)
| |
| +-- src/main/groovy/com/log/LogEventProducer.groovy
| +-- src/main/resources/log4j.xml
xml configuration file link
it is not showing any error (just writing logs to console only)

How to add LESS files to a rails app

I can't seem to get this to work in my rails app. At a high level, I wan't to use LESS in my app and have it go through the asset pipeline.
This is what my assets look like:
assets
|
|--- javascript
|
|--- stylesheets
|
|-- reset.less
|-- my-mixins.less
|-- my-variables.less
|-- base.less
|
|--- images
|
|--- libs
|
|---foo
|
|--css
|
|--- foo-mixins.less
|
|--- bar.less
I would like to import "my-mixins.less", "my-variables.less" and "foo-mixins.less" into "base.less", as well as other files. "bar.less" should also be added to specific pages if needed.
How would I go about doing this?
This should work, assuming you're using the less-rails gem.
First, add this to somewhere in your configuration (I have mine in my environment.rb):
YourApp::Application.configure do
config.less.paths << File.join(Rails.root, 'app', 'assets', 'less')
end
Now, if you have a file setup like this:
assets
|
|--- javascript
|
|--- css
| |--- site-stylesheet.css.less
|
|--- less
|--- my-mixins.less
You can import my-mixins in site-stylesheet by using:
#import "my-mixins"
And import the stylesheet into your app with:
<%= stylesheet_link_tag "site-stylesheet" %>
You should be able to extrapolate from there for your specific directory structure.
In base.css.less you can write #import "my-variables.less"; and it should work.
The files have to be in the "vendor/assets" or "vendor/plugins" (both at the root level) folder in order to reference them with relative paths.

Resources