Skip to content

Commit 4825580

Browse files
committed
[amend] conditional build
Signed-off-by: schnittchen <schnittchen@das-labor.org>
1 parent 913e65c commit 4825580

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/platforms/esp32/components/avm_builtins/CMakeLists.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,16 @@ set(AVM_BUILTIN_COMPONENT_SRCS
3939

4040
if (IDF_VERSION_MAJOR GREATER_EQUAL 5)
4141
set(ADDITIONAL_PRIV_REQUIRES "esp_hw_support" "efuse" "esp_adc")
42-
set(AVM_BUILTIN_COMPONENT_SRCS "adc_driver.c" ${AVM_BUILTIN_COMPONENT_SRCS})
43-
if ((IDF_VERSION_MINOR GREATER_EQUAL 1) OR (IDF_VERSION_MAJOR GREATER_EQUAL 6))
44-
if ((IDF_VERSION_MINOR GREATER_EQUAL 3) OR (IDF_VERSION_MAJOR GREATER_EQUAL 6))
45-
set(ADDITIONAL_PRIV_REQUIRES "esp_driver_dac" ${ADDITIONAL_PRIV_REQUIRES})
46-
else()
47-
set(ADDITIONAL_PRIV_REQUIRES "driver" ${ADDITIONAL_PRIV_REQUIRES})
48-
endif()
42+
if(CONFIG_AVM_ENABLE_DAC_NIF)
43+
set(ADDITIONAL_PRIV_REQUIRES "esp_adc" ${ADDITIONAL_PRIV_REQUIRES})
44+
set(AVM_BUILTIN_COMPONENT_SRCS "adc_driver.c" ${AVM_BUILTIN_COMPONENT_SRCS})
45+
if ((IDF_VERSION_MINOR GREATER_EQUAL 1) OR (IDF_VERSION_MAJOR GREATER_EQUAL 6))
46+
if ((IDF_VERSION_MINOR GREATER_EQUAL 3) OR (IDF_VERSION_MAJOR GREATER_EQUAL 6))
47+
set(ADDITIONAL_PRIV_REQUIRES "esp_driver_dac" ${ADDITIONAL_PRIV_REQUIRES})
48+
else()
49+
set(ADDITIONAL_PRIV_REQUIRES "driver" ${ADDITIONAL_PRIV_REQUIRES})
50+
endif()
51+
endif()
4952
endif()
5053
else()
5154
set(ADDITIONAL_PRIV_REQUIRES "")

src/platforms/esp32/components/avm_builtins/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020

2121
menu "AtomVM Built-In Components"
2222

23+
config AVM_ENABLE_DAC_NIF
24+
bool "Enable DAC NIF"
25+
default "y" if IDF_TARGET_ESP32
26+
default "y" if IDF_TARGET_ESP32S2
27+
default n
28+
2329
config AVM_ENABLE_ADC_NIFS
2430
bool "Enable ADC NIFs"
2531
default y

src/platforms/esp32/components/avm_builtins/dac_driver.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
// https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/peripherals/dac.html
2424

2525
#include <context.h>
26+
#ifdef CONFIG_AVM_ENABLE_DAC_NIF
2627
#include <defaultatoms.h>
2728
#include <erl_nif_priv.h>
2829
#include <esp32_sys.h>
@@ -259,3 +260,4 @@ const struct Nif *atomvm_dac_get_nif(const char *nifname)
259260
};
260261

261262
REGISTER_NIF_COLLECTION(atomvm_dac, atomvm_dac_init, NULL, atomvm_dac_get_nif)
263+
#endif /* CONFIG_AVM_ENABLE_DAC_NIF */

0 commit comments

Comments
 (0)