Specify external directory to a project?

hi, i’m working on a project that requires libraries from an external project pulled from a github repo

essentially ClockController requires 2 files from libzamin repo

what i’m striving for is my project to use those files on one hand.
but be able to make changes to them that coudld tracked by git on the other

the libraries such as it is cannot be used in arduino, and requires some changes
for example:

  1. it uses _Bool data type so i need to somehow include stdbool.h
  2. some of it’s method signatures use int, which for arduino needs to be made into long int otherwise
    some calculations will go wrong due to casting
  3. one of it’s classes uses a crap load of strings (to hold date and festival descriptions) those would need to be refactord to use PSTR, otherwise it won’t fit into arduino memory, and yet i still need to retain the ability for the original library to function as before.

i’d like to do all those changes inside the original library so those could be tracked into a PR

my platfrom.ini has src_filter because i have several main methods i want to experiment with

so i thought about a possiblity that those files could copied automatically by platfrom.io everytime i do a build in the event of a special build flag. because trying to use them where they are creates several issues (for example not being able to find several other files they depend on, because that project relies on maketools)

my platfrom io ini is as follows:

[platformio]
default_envs = master

[env]
platform = atmelavr
board = nanoatmega328new
framework = arduino
monitor_port = COM6
upload_port = COM6
debug_port = \\.\COM6
monitor_speed = 115200
build_src_filter= +<*.h> +<main-${PIOENV}.cpp> 
build_flags=
	-D _WIN32 -D DEBUG_CON 
	-D_DEBUG_AVR
; debug_tool = avr-stub
; debug_build_flags = 
; 	-D AVR_DEBUG 
; 	-Og
; 	-g2
; 	-DDEBUG
; 	-DAVR8_BREAKPOINT_MODE=1		
lib_deps = 
	adafruit/RTClib@^2.1.1	
	adafruit/Adafruit BusIO @ ^1.14.1
	SPI
	mathertel/OneButton@^2.0.3
	jrullan/StateMachine @ ^1.0.11
	ivanseidel/LinkedList @ 0.0.0-alpha+sha.dac3874d28	
	https://werner.rothschopf.net/microcontroller/images/lcd/NoiascaLiquidCrystal.zip
[env:master]

[env:lcd]
lib_deps =
	jdolinay/avr-debugger@^1.5
	https://werner.rothschopf.net/microcontroller/images/lcd/NoiascaLiquidCrystal.zip
build_flags=
	-D _DEBUG_CON -DDEBUG_AVR
build_type = debug
debug_tool = avr-stub
debug_build_flags = 
	-D_DEBUG_AVR
	-Og
	-g2
	-DDEBUG
	; -DAVR8_BREAKPOINT_MODE=1		
[env:rtc]
[env:rgb]
[env:date]
build_type = debug
debug_tool = avr-stub
debug_build_flags = 
	-D _AVR_DEBUG 
	-Og
	-g2
	; -DDEBUG
	; -DAVR8_BREAKPOINT_MODE=1		
[env:debug]
lib_deps =	jdolinay/avr-debugger@^1.5	
build_type = debug
debug_tool = avr-stub
debug_build_flags = 
	-D AVR_DEBUG 
	-Og
	-g2
	-DDEBUG
	-DAVR8_BREAKPOINT_MODE=1		```

You need pio pkg install — PlatformIO latest documentation

So, refer to the existing pkg using symlink.

so i need to create a minimal library.json, i’ve been trying to do that, but i keep getting Error: Could not find one of ‘library.json, library.properties, module.json’ manifest files in the package
whne i do symlink://C:/Users/User/Documents/PlatformIO/Projects/JewishClock/libzmanim
under lib_deps
never mind i clearned my build dir thanks

now it seems i have an additional problem that library has an additional folder to be included (on top of the standard src include folders, how to i keep those and add this folder as well?
(it seems to be inlcuded only in the event of _WIN32 which i can’t undo as it’s from the compiler)

You need to configure build section in the library.json which you created for that library.

that’s what i thought but if i understnand correctly, i can only have one src folder and one include folder?

We have just updated docs for

The includeDir and srcDir are base directories. You can change them. Also, it is possible to add more relative include paths to the includeDir using flags field.

Did it help you?

well yes, and no… :slight_smile: yes, it most certeintly helped understand it better,

cause if i got this correcty srcFilter effects only the srcDir and flags -I will effect only the includeDir

so i would need to first include everyhing using includrDir :“.” but "cancel that wild card inclusion by using -I include to selectivly include only specific folder

i would also need to use srcDir “.” but then do the complete opppsite of -I and remove all the folders i don’t want in the srcFilter
btw it seems more consistent to do:

,“srcFilter”: "-<> +<src> +<windows*> "

 "build": {
    "includeDir": "."
    ,"flags": [
       "-I include"
      ,"-I windows"      
    ]
    ,"srcDir": "."
    ,"srcFilter": "+<*> -<extra> -<test> -<ffi-cdecl>"
  },

but i still the same errors as before :

C:\Users\User\AppData\Local\Temp\cc3mAJSl.ltrans0.ltrans.o: In function addchar.constprop.53': <artificial>:(.text+0x27e6): undefined reference to stpncpy’
which means if i understand correctly, that it can find stpncpy.h, but i can’t find stpncpy.c which is weird because they are in the same folder

one other thing the stpncpy.c does not contain a reference to the header files
so i’m wondering if somehow and because they are both located in the folder this is an issue.
thing is, if i change the build element to this, i get linkage errors where my own class can’t find any of the methods, so i can’t be sure of anything

 "build": {
    "includeDir": "."
    ,"flags": [
       "-I include"
      ,"-I windows"      
      
    ]
    ,"srcDir": "."
    ,"srcFilter": "+<.src/*.c*> +<.windows/*.c*>"
  },

turns out the only way i’ve gotten this to work at all is rename some of the files from c to cpp
basically i have this logical depdencny

  • ClockController.cpp - my own arduino class
    *hebrewcalender.c
    *hebdateformat.c
    *hebrewcalender.c
    *stpncpy.c

btw while we’re talking about hebdateformat.c
this is the most problematic class, because such as it is it consumes a lot of memory with string constants, that i would to wrap with PSTR , it also have a rather large array of strings that may need to have the same treatment.
but the same time it has many functions that can be reused
so i’m not sure exactly how it can be handled

can PROJECT_DIR be used with SIMLINK?
i tried using symlink://${PROJECT_DIR}/…/ext_libs/libzmanim but it says
Error: Can not create a symbolic link for ${PROJECT_DIR}/../ext_libs/libzmanim, not a directory
but specifcying
symlink://C:\Users\User\Documents\PlatformIO\Projects\JewishClock\ext_libs\libzmanim
does work

also the final answer it would appear to all my issues undefined reference with includes is that for the library.json i had to specify -std=c11 in th flags section

Have you tried the relative path?

[env:myenv]
lib_deps = 
   symlink://../…/ext_libs/libzmanim

oh thanks, kind of inconsistent but works.