Skip to content

Commit

Permalink
Add emacs local configuration generation
Browse files Browse the repository at this point in the history
  • Loading branch information
rbarzic committed Aug 16, 2015
1 parent 0d9b21d commit 579675c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ SDK_DRIVERS_NRF_HAL=yes
ifeq ($(DEVICE),NRF52)
SDK_DRIVERS_NRF_DELAY=yes
SDK_LIBRARIES_UTIL=yes

SDK_DRIVERS_NRF_GPIOTE=yes
# Fixme below - only if no Soft Device used
SDK_DRIVERS_NRF_NRF_SOC_NOSD=yes
endif
Expand Down
3 changes: 3 additions & 0 deletions misc/Main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ get_library:
echo-cflags:
@echo \"$(CFLAGS)\"

create_emacs_dir_locals:
python $(MISC)/flags2el.py --cflags=\\"$(CFLAGS)\\" --elisp=.dir-locals.el

clean:
rm -Rf $(OBJS) $(OBJS_AS) $(HEX) $(BIN) $(ELF)

Expand Down
32 changes: 31 additions & 1 deletion misc/flags2el.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/usr/bin/env python
import argparse
import pprint as pp
import re
import os

dir_local = """
((nil . ((company-clang-arguments . ({inc_dirs})))))
"""

def get_args():
"""
Expand All @@ -12,6 +19,8 @@ def get_args():
""")
parser.add_argument('--cflags', action='store', dest='cflags',
help='gcc/clang option line (quoted)')
parser.add_argument('--elisp', action='store', dest='elisp',
help='elisp file to be generated')

parser.add_argument('--version', action='version', version='%(prog)s 0.1')

Expand All @@ -20,4 +29,25 @@ def get_args():

if __name__ == '__main__':
args = get_args()
print ">" + args.cflags
#print ">" + args.cflags + "<"
cflags = args.cflags[1:-1]
# Remove the baskslah introduced in the Makefile

#print ">>" + cflags + "<<"
inc_dirs = re.findall(r"-I\s*\S+",cflags)
# remove -I
inc_dirs_noinc = [x.replace('-I','').strip() for x in inc_dirs ]
pp.pprint(inc_dirs)

inc_dirs_abs = [os.path.abspath(x) for x in inc_dirs_noinc ]
inc_dirs_quoted = ["\"-I" + x + "\"" for x in inc_dirs_abs ]

txt = dir_local.format(inc_dirs= '\n'.join(inc_dirs_quoted))
print(txt)
with open(args.elisp,'w') as fh:
fh.write(txt)
fh.close()




2 changes: 2 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <stdint.h>
#include "nrf_delay.h"
#include "nrf_gpio.h"
#include "nrf_drv_gpiote.h"
#include "boards.h"

const uint8_t leds_list[LEDS_NUMBER] = LEDS_LIST;
Expand All @@ -23,6 +24,7 @@ int main(void)
{
LEDS_INVERT(1 << leds_list[i]);
nrf_delay_ms(500);

}
}
}
Expand Down

0 comments on commit 579675c

Please sign in to comment.