Skip to content

Commit

Permalink
Version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gregoiresage committed Jun 28, 2016
2 parents cbb23a0 + ec59602 commit 45c17b5
Show file tree
Hide file tree
Showing 18 changed files with 873 additions and 295 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ dist.zip
node_modules/

*.pyc

tests/include/pebble
tests/include/linked-list
tests/generated/
tests/linked-list.c
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sudo: false
language: c
install:
- pip install --user -r requirements.txt
- ./tests/travis-install.sh
script: make test
8 changes: 8 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2016 Grégoire Sage

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
PEBBLE_HEADERS=tests/include/pebble/

CC=gcc
ifeq ($(TRAVIS), true)
CC_TEST=$(CC)
CFLAGS=-std=c99
AR=ar
else
CC_TEST=arm-none-eabi-gcc
CFLAGS=-std=c11
AR=arm-none-eabi-ar
endif
CINCLUDES=-I $(PEBBLE_HEADERS) -I tests/ -I tests/generated/ -I tests/include/ -I tests/include/linked-list

TEST_FILES=tests/enamel.c
SRC_FILES=tests/generated/enamel.c tests/linked-list.c
TEST_EXTRAS=tests/pebble_stub.c tests/pebble-events_stub.c

all: test

test:
@$(CC) $(CFLAGS) $(CINCLUDES) $(TEST_FILES) $(SRC_FILES) $(TEST_EXTRAS) -o tests/run
@tests/run
@rm tests/run
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Enamel
# Enamel [![Build Status](https://travis-ci.org/gregoiresage/enamel.svg?branch=master)](https://travis-ci.org/gregoiresage/enamel) [![MIT License](http://img.shields.io/badge/license-MIT-lightgray.svg)](./LICENSE)

Enamel is a python script that generates C helpers from a [Clay](https://github.com/pebble/clay) configuration file to easily get the value of your settings.

Enamel will :
Expand Down
12 changes: 12 additions & 0 deletions enamel.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ def maxdictsize(item):
size = max(size, len(str(option['value'])) + 1)
return size

def getFirstMessageKey(settings):
count = 0
for setting in settings :
if setting['type'] == 'section':
messageKey = getFirstMessageKey(setting['items'])
if messageKey != '' :
return messageKey
elif 'messageKey' in setting :
return getmessagekey(setting)
return ''

def removeComments(string):
"""From http://stackoverflow.com/questions/2319019/using-regex-to-remove-comments-from-source-files"""
string = re.sub(re.compile("/\*.*?\*/",re.DOTALL ) ,"" ,string) # remove all occurance streamed comments (/*COMMENT */) from string
Expand All @@ -129,6 +140,7 @@ def generate(configFile='src/js/config.json', outputDir='src/generated'):
env.filters['settingscount'] = settingscount
env.filters['getOptionArray'] = getOptionArray
env.filters['hasStringOptions'] = hasStringOptions
env.filters['getFirstMessageKey'] = getFirstMessageKey

# load config file
config_content=open(configFile)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "enamel",
"author": "Grégoire Sage",
"version": "1.0.9",
"version": "1.1.0",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit 45c17b5

Please sign in to comment.