Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PlatformIO library.json #31

Merged
merged 1 commit into from
Jul 15, 2021
Merged

Add PlatformIO library.json #31

merged 1 commit into from
Jul 15, 2021

Conversation

lopsided98
Copy link
Contributor

This PR allows this library to be included as a PlatformIO dependency. Only the basic library is supported, not any of the extras in the libraries directory. PlatformIO doesn't support multiple libraries in a single repo (https://community.platformio.org/t/how-to-install-libraries-from-a-github-repos-subfolders/13458), but I think basic support is better than none.

In the past (version <=0.5), the files were all in the base directory, so PlatformIO could figure out how to build it without any help. Since the headers are now in a subdirectory, a library.json file is necessary to allow PlatformIO to find them.

Since the headers are now in a subdirectory, a library.json file is
necessary to allow PlatformIO to find them.
@bxparks
Copy link
Owner

bxparks commented Jul 14, 2021

Thanks for the PR. But I'm confused because EpoxyDuino was never intended to run under PlatformIO. It was designed to allow Arduino programs to compile under a Unix-like environment, using Make. Can you help me understand how and why you are using EpoxyDuino under PlatformIO?

@lopsided98
Copy link
Contributor Author

PlatformIO supports the "native" platform, which tries to compile the Arduino program to target the development machine, just like your Makefile. I use this feature with EpoxyDuino to run unit tests.

@bxparks
Copy link
Owner

bxparks commented Jul 15, 2021

So I don't fully understand the advantages of using PlatformIO in native mode, but I am willing to merge this in, since it was important enough for you send me the PR. However, I will be adding a comment in the README.md to explain that this feature is unsupported by me. If I happen to break it in the future, I won't be maintaining it.

@bxparks bxparks merged commit e51c933 into bxparks:develop Jul 15, 2021
bxparks added a commit that referenced this pull request Jul 15, 2021
@lopsided98 lopsided98 deleted the platformio-library-json branch July 16, 2021 03:25
@lopsided98
Copy link
Contributor Author

Thanks for merging this! I build my firmware for my device using PlatformIO, and use it to manage all my dependencies and build settings, so using it for unit testing as well is convenient. This will also likely be useful to other users, since a couple of people have mentioned that they are using PlatformIO as well (#20, #6).

@bxparks
Copy link
Owner

bxparks commented Jul 16, 2021

When I looked into PlatformIO, about 2 years ago I think, there were many things that I liked about it, for example, using a platformio.ini file to configure the environment so that it can be version controlled properly. But the thing that threw me off was that PlatformIO requires a different file structure than a regular Arduino project. If I recall, it requires the *.ino file to be under the src/ subdirectory. Being forced to maintain 2 different file structure for every program (i.e. "sketch") seems like a huge amount of extra work. How do you handle that?

@lopsided98
Copy link
Contributor Author

I don't use the Arduino IDE or .ino files (which are just C++ with a few includes and other things automatically added), so putting the source in the src directory is not a problem. In fact, one of the main advantages of PlatformIO in my opinion is that I can use more powerful editors with features such as code completion and live error checking. Also, you can configure PlatformIO to look for the source in another directory using the src_dir option, although I'm not sure if you can use it to put the source files in the root directory of the project.

@bxparks
Copy link
Owner

bxparks commented Jul 20, 2021

Yeah, although I don't use the Arduino IDE for my own development, I have to maintain compatibility with the IDE to allow my Arduino libraries to be accessible by the general community. I cannot say, "Here are the example sketches that show how to use my libraries, but they compile only with PlatformIO".

I once tried to use a symlink to allow both PlatformIO and the IDE to work. That works on my machine, but the Arduino Library Manager silently rejects any git repo with a symlink, probably because symlinks are not compatible with Windows.

@bxparks bxparks mentioned this pull request Aug 8, 2021
@raibisch
Copy link

Thanks very much for merging this library.json. Using this makes it very easy to work with PlatformIO. As already mentioned in further posts the 'native' Platform is a standard platform (and not an unsupported feature) in PlatformIO. It uses built-in linux toolchains (preferable based on GCC).

Regarding the '.ino' vs '.cpp' ist is very easy:
keep the standard PlatformIO folder-stucture and rename your
'src/main.cpp' in 'src/mymain.cpp'

#include <Arduino.h>
int i=0;
void setup() {
  Serial.println("***START***");
}

void loop() {
  Serial.printf("Hello %d\r\n",i);
  i++;
  delay(500);
}

...and here my 'platform.ini' file:

[env:native]
platform = native

build_flags =
    -DEPOXY_DUINO
    -DEPOXY_CORE_ESP8266
  
lib_deps:
 https://github.com/bxparks/EpoxyDuino.git

the definition of the compiler switch 'EPOXY_DUINO' is important to use the predefined main-loop in the existing 'main.cpp', the 'EXOXY_CORE_ESP8255' is optional for my ESP simulation.

the 'lib_deps' definition automatic download the ExpoxyDuino-files from github

...that’s all ! (no further download or installation, no custom 'make' file, or any other modification)

complete demo-project is available at:
github.com/raibisch/EpoxyDuinoPlatformIO_Demo/

@bxparks: take a second look at PlatformIO...it is (as extention in VS-Code) a very powerful and user-friendly tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants