Skip to content

Commit

Permalink
Select ".ino" or ".pde" by existance
Browse files Browse the repository at this point in the history
Issue #22. Reported by irvined.
  • Loading branch information
suapapa committed Jul 2, 2012
1 parent 3123aea commit 0efe919
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
16 changes: 8 additions & 8 deletions SConstruct
Expand Up @@ -152,9 +152,9 @@ F_CPU = ARGUMENTS.get('F_CPU', getBoardConf('build.f_cpu'))


# There should be a file with the same name as the folder and # There should be a file with the same name as the folder and
# with the extension .pde or .ino # with the extension .pde or .ino
FILE_EXTENSION = ".pde" if ARDUINO_VER < 100 else ".ino"
TARGET = os.path.basename(os.path.realpath(os.curdir)) TARGET = os.path.basename(os.path.realpath(os.curdir))
assert(os.path.exists(TARGET + FILE_EXTENSION)) assert(os.path.exists(TARGET + '.ino') or os.path.exists(TARGET + '.pde'))
sketchExt = '.ino' if os.path.exists(TARGET + '.ino') else '.pde'


cFlags = ['-ffunction-sections', '-fdata-sections', '-fno-exceptions', cFlags = ['-ffunction-sections', '-fdata-sections', '-fno-exceptions',
'-funsigned-char', '-funsigned-bitfields', '-fpack-struct', '-funsigned-char', '-funsigned-bitfields', '-fpack-struct',
Expand Down Expand Up @@ -203,7 +203,7 @@ def fnProcessing(target, source, env):


prototypes = {} prototypes = {}


for file in glob(os.path.realpath(os.curdir) + "/*" + FILE_EXTENSION): for file in glob(os.path.realpath(os.curdir) + "/*" + sketchExt):
for line in open(file): for line in open(file):
result = re_signature.search(line) result = re_signature.search(line)
if result: if result:
Expand All @@ -213,9 +213,9 @@ def fnProcessing(target, source, env):
print "%s;" % name print "%s;" % name
wp.write("%s;\n" % name) wp.write("%s;\n" % name)


for file in glob(os.path.realpath(os.curdir) + "/*" + FILE_EXTENSION): for file in glob(os.path.realpath(os.curdir) + "/*" + sketchExt):
print file, TARGET print file, TARGET
if not os.path.samefile(file, TARGET + FILE_EXTENSION): if not os.path.samefile(file, TARGET + sketchExt):
wp.write('#line 1 "%s"\r\n' % file) wp.write('#line 1 "%s"\r\n' % file)
wp.write(open(file).read()) wp.write(open(file).read())


Expand All @@ -229,7 +229,7 @@ def fnCompressCore(target, source, env):
for file in core_files: for file in core_files:
run([AVR_BIN_PREFIX + 'ar', 'rcs', str(target[0]), file]) run([AVR_BIN_PREFIX + 'ar', 'rcs', str(target[0]), file])


bldProcessing = Builder(action = fnProcessing) #, suffix = '.cpp', src_suffix = FILE_EXTENSION) bldProcessing = Builder(action = fnProcessing) #, suffix = '.cpp', src_suffix = sketchExt)
bldCompressCore = Builder(action = fnCompressCore) bldCompressCore = Builder(action = fnCompressCore)
bldELF = Builder(action = AVR_BIN_PREFIX + 'gcc -mmcu=%s ' % MCU + bldELF = Builder(action = AVR_BIN_PREFIX + 'gcc -mmcu=%s ' % MCU +
'-Os -Wl,--gc-sections -lm -o $TARGET $SOURCES') '-Os -Wl,--gc-sections -lm -o $TARGET $SOURCES')
Expand All @@ -254,7 +254,7 @@ core_sources = [x.replace(ARDUINO_CORE, 'build/core/') for x
# add libraries # add libraries
libCandidates = [] libCandidates = []
ptnLib = re.compile(r'^[ ]*#[ ]*include [<"](.*)\.h[>"]') ptnLib = re.compile(r'^[ ]*#[ ]*include [<"](.*)\.h[>"]')
for line in open(TARGET + FILE_EXTENSION): for line in open(TARGET + sketchExt):
result = ptnLib.search(line) result = ptnLib.search(line)
if not result: if not result:
continue continue
Expand Down Expand Up @@ -296,7 +296,7 @@ if local_sources:
envArduino.Append(CPPPATH = 'build/local') envArduino.Append(CPPPATH = 'build/local')


# Convert sketch(.pde) to cpp # Convert sketch(.pde) to cpp
envArduino.Processing('build/' + TARGET + '.cpp', 'build/' + TARGET + FILE_EXTENSION) envArduino.Processing('build/' + TARGET + '.cpp', 'build/' + TARGET + sketchExt)
VariantDir('build', '.') VariantDir('build', '.')


sources = ['build/' + TARGET + '.cpp'] sources = ['build/' + TARGET + '.cpp']
Expand Down
1 change: 0 additions & 1 deletion arscons.ino

This file was deleted.

18 changes: 18 additions & 0 deletions arscons.ino
@@ -0,0 +1,18 @@
// This is just a mockup sketch for test scons works

#define PIN_LED 13

void setup(void)
{
pinMode(PIN_LED, OUTPUT);
}

void loop(void)
{
digitalWrite(PIN_LED, HIGH);
delay(1000);
digitalWrite(PIN_LED, LOW);
delay(1000);
}

/* vim: set sw=2 et: */
18 changes: 0 additions & 18 deletions arscons.pde

This file was deleted.

0 comments on commit 0efe919

Please sign in to comment.