Commit 09f51911 authored by Andrey Filippov's avatar Andrey Filippov

added actual files

parent 9c355ed3
html/*
attic/*
/.project
/.cproject
/.pydevproject
/.externalToolBuilders
/.settings
.directory
generated*
sysroots
bitbake-logs
/temp
*.o
image
src/nmea2exif
src/log_imu
src/.depend
\ No newline at end of file
This diff is collapsed.
# Runs 'make', 'make install', and 'make clean' in specified subdirectories
SUBDIRS := src
INSTALLDIRS = $(SUBDIRS:%=install-%)
CLEANDIRS = $(SUBDIRS:%=clean-%)
#TARGETDIR=$(DESTDIR)/www/pages
all: $(SUBDIRS)
@echo "make all top"
$(SUBDIRS):
$(MAKE) -C $@
install: $(INSTALLDIRS)
@echo "make install top"
$(INSTALLDIRS):
$(MAKE) -C $(@:install-%=%) install
clean: $(CLEANDIRS)
@echo "make clean top"
$(CLEANDIRS):
$(MAKE) -C $(@:clean-%=%) clean
.PHONY: all install clean $(SUBDIRS) $(INSTALLDIRS) $(CLEANDIRS)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="0.1150476775">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1150476775" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1150476775" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="0.1150476775." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1042691196" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1042691196.1296727294" name=""/>
<builder arguments="apps-gps" command="${workspace_loc:/elphel-apps-editconf/run_bitbake.sh}" enableCleanBuild="false" id="org.eclipse.cdt.build.core.settings.default.builder.851629087" incrementalBuildTarget="-c compile -f -v" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.2089670226" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
<tool id="org.eclipse.cdt.build.core.settings.holder.1645067780" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1912421658" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/elphel-apps-gps/sysroots/elphel393/usr/include-uapi}&quot;"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.98116389" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1272302733" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1282220181" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/elphel-apps-gps/sysroots}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/elphel-apps-gps/sysroots/elphel393/usr/include-uapi}&quot;"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1122993166" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.605559330" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.515081863" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/elphel-apps-gps/sysroots}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/elphel-apps-gps/sysroots/elphel393/usr/include-uapi}&quot;"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.899853425" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1363226103" name="LLVM bytecode assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.513031495" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/elphel-apps-gps/sysroots}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/elphel-apps-gps/sysroots/elphel393/usr/include-uapi}&quot;"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.370831508" languageId="org.eclipse.cdt.managedbuilder.llvm.ui.llvmAssembly" languageName="LLVM bytecode assembly" sourceContentType="org.eclipse.cdt.managedbuilder.llvm.ui.llvmAssemblySource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1740441857" name="UPC" superClass="org.eclipse.cdt.build.core.settings.holder">
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.550102451" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/elphel-apps-gps/sysroots}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/elphel-apps-gps/sysroots/elphel393/usr/include-uapi}&quot;"/>
</option>
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1420737322" languageId="org.eclipse.cdt.core.parser.upc.upc" languageName="UPC" sourceContentType="org.eclipse.cdt.core.parser.upc.upcSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="elphel-apps-gps.null.420984123" name="elphel-apps-gps"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
<scannerConfigBuildInfo instanceId="0.1150476775">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Default">
<resource resourceType="PROJECT" workspacePath="/elphel-apps-gps"/>
</configuration>
</storageModule>
</cproject>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/elphel-apps-gps/run_bitbake.sh}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="apps-gps -c target_scp -f"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>elphel-apps-gps</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/SCP apps-gps to target.launch</value>
</dictionary>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
#!/bin/bash
args="$@"
while (( "$#" )); do
shift
done
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Launching bitbake $args"
cd $DIR/../../poky
. ./oe-init-build-env
bitbake $args | sed -u 's@| @@'
exit 0
WWW_PAGES = /www/pages
BINDIR = /usr/bin/
INSTMODE = 0755
INSTDOCS = 0644
INSTOWNER = root
INSTGROUP = root
PROGS = nmea2exif log_imu
SRCS = nmea2exif.c log_imu.c
OBJS = nmea2exif.o
PHPSCRIPTS= logger_launcher.php imu_setup.php start_gps_compass.php
CFLAGS += -Wall -I$(STAGING_DIR_HOST)/usr/include-uapi
LDLIBS += -lm
all: $(PROGS)
log_imu: log_imu.o
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
nmea2exif: nmea2exif.o
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
install: $(PROGS)
$(INSTALL) $(OWN) -d $(DESTDIR)
$(INSTALL) -d $(DESTDIR)$(BINDIR)
$(INSTALL) -d $(DESTDIR)$(WWW_PAGES)
$(INSTALL) -m $(INSTMODE) -o $(INSTOWNER) -g $(INSTGROUP) $(PROGS) $(DESTDIR)$(BINDIR)
$(INSTALL) -o $(INSTOWNER) -m $(INSTDOCS) $(PHPSCRIPTS) $(DESTDIR)$(WWW_PAGES)
clean:
rm -rf $(PROGS) *.o *~
depend: .depend
.depend: $(SRCS)
rm -f ./.depend
$(CC) $(CFLAGS) -MM $^ > ./.depend;
include .depend
This diff is collapsed.
/*!***************************************************************************
*! FILE NAME : log_imu.c
*! DESCRIPTION: Read IMU data, copy to stdout
*! Copyright (C) 2011 Elphel, Inc.
*! -----------------------------------------------------------------------------**
*! This program is free software: you can redistribute it and/or modify
*! it under the terms of the GNU General Public License as published by
*! the Free Software Foundation, either version 3 of the License, or
*! (at your option) any later version.
*!
*! This program is distributed in the hope that it will be useful,
*! but WITHOUT ANY WARRANTY; without even the implied warranty of
*! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*! GNU General Public License for more details.
*!
*! You should have received a copy of the GNU General Public License
*! along with this program. If not, see <http://www.gnu.org/licenses/>.
*! -----------------------------------------------------------------------------**
*! $Log: log_imu.c,v $
*! Revision 1.4 2012/04/14 05:51:19 elphel
*! lseek->lseek64
*!
*! Revision 1.3 2012/04/14 03:53:09 elphel
*! Added parameter to specify how much ahead of the current write pointer to open /dev/imu
*!
*! Revision 1.2 2012/04/13 00:49:59 dzhimiev
*! 1. added 'starting index' to logger
*!
*! Revision 1.1 2012/04/12 00:18:38 elphel
*! simple log program for IMU/GPS/camera output
*!
*/
#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <errno.h>
#include <elphel/exifa.h>
#include <signal.h>
#include <asm/byteorder.h> //endians
//#include <elphel/c313a.h>
#include <elphel/x393_devices.h>
//#include "exifgen.h"
//#define EXIF_DEV "/dev/imu"
#define D(x) x
int fd_imu=-1;
int fd_out=-1;
char outFileName [256];
const char dev_path[]=DEV393_PATH(DEV393_LOGGER);
void signalHandler (int signum){
printf ("Received signal %d\n",signum);
if (fd_imu>=0) {
printf ("Closing %s\n",dev_path);
close (fd_imu);
fd_imu=-1;
}
if (fd_out>=0) {
printf ("Closing output file %s\n",outFileName);
close (fd_out);
fd_out=-1;
}
exit(0);
}
int main(int argc, char *argv[]) {
const char usage[]= "Usage:\n%s outfile [start_file_index [number_of_records_per_file] [rewind_by_samples]]\n\n"
"Copy IMU data to the output files, start new file after i/o error or specified number_of_records_per_file (64 bytes each)\n"
"rewind_by_samples - start reading specified number of samples earlier than the last recorded (~2500 samples/sec,\n"
" each sample size is 64-byte, rewind is limited by the 1MB buffer).\n"
"Five-digit file number will be added to the specified output file name.\n\n";
int numFile=1;
int rewindSamples=2500; //~1 sec back
int buf_records=64;
char buffer[buf_records*64];
if (argc < 2) {
printf (usage,argv[0]);
return 0;
}
int numRecords=1000000; // 1 million records (64MB, ~400 seconds)
if (argc >2) numFile= strtol(argv[2], NULL, 10);
if (argc >3) numRecords= strtol(argv[3], NULL, 10);
if (argc >4) rewindSamples= strtol(argv[4], NULL, 10);
strncpy(outFileName,argv[1],249);
outFileName[249]='\0';
char * suffixP=&outFileName[strlen(outFileName)];
int readRecords;
off_t position;
signal (SIGINT,signalHandler);
signal (SIGHUP,signalHandler);
signal (SIGTERM,signalHandler);
while (1) {
if ((fd_imu = open(dev_path, O_RDONLY))<0) {printf("error opening %s\n",dev_path); return -1;}
position= lseek64(fd_imu,0,SEEK_CUR);
if (position == (off_t) -1) {
printf("Error in lseek %s, returned %d, errno=%d - %s, position=0x%llx\n",dev_path,(int) position,errno,strerror(errno), (long long) position);
} else {
printf("Opened %s at position 0x%llx\n",dev_path, (long long) position);
int thisRewind=(position<(64*rewindSamples))?position:(64*rewindSamples);
position= lseek64(fd_imu,-thisRewind,SEEK_CUR);
printf("Rewind back by %d to 0x%llx\r\n",thisRewind, (long long) position);
}
int imu_OK=1;
while (imu_OK) { // will break on error
sprintf(suffixP,"-%05d",numFile);
fd_out=open(outFileName,O_WRONLY | O_CREAT, 0777);
if (fd_out<0) {printf("error opening %s for writing\n",outFileName); return -1;}
int records_left;
for (records_left=numRecords;records_left>0;records_left-=readRecords) {
readRecords=(records_left>buf_records)?buf_records:records_left;
int readBytes=64*readRecords;
int gotBytes=0;
int bp;
for (bp=0;bp<readBytes; bp+=gotBytes) {
gotBytes=read (fd_imu,&buffer[bp], readBytes-bp);
if (gotBytes<0) {
printf("Error reading %s, returned %d, errno=%d - %s, position=0x%llx\r\n", dev_path, gotBytes,errno,strerror(errno), (long long) lseek(fd_imu,0,SEEK_CUR));
imu_OK=0;
break;
}
}
if (!imu_OK) break;
write(fd_out,buffer,readBytes);
}
close (fd_out); // error or end of file
fd_out=-1;
numFile++;
if (!imu_OK) break;
}
close (fd_imu); // after errors
fd_imu=-1;
}
return 0;
}
<?php
/*!***************************************************************************
*! FILE NAME : logger_launcher.php
*! DESCRIPTION: launches the event logger (IMU/GPS/External trigger/Other sensor) a dies
*! Copyright (C) 2012 Elphel, Inc
*! -----------------------------------------------------------------------------**
*!
*! This program is free software: you can redistribute it and/or modify
*! it under the terms of the GNU General Public License as published by
*! the Free Software Foundation, either version 3 of the License, or
*! (at your option) any later version.
*!
*! This program is distributed in the hope that it will be useful,
*! but WITHOUT ANY WARRANTY; without even the implied warranty of
*! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*! GNU General Public License for more details.
*!
*! You should have received a copy of the GNU General Public License
*! along with this program. If not, see <http://www.gnu.org/licenses/>.
*! -----------------------------------------------------------------------------**
*! $Log: logger_launcher.php,v $
*! Revision 1.6 2013/05/29 18:43:01 dzhimiev
*! 1. sync instead of unmount at stop
*!
*! Revision 1.4 2012/10/10 22:44:52 dzhimiev
*! 1. added _help & _usage
*!
*! Revision 1.3 2012/07/09 23:49:26 dzhimiev
*! 1. added mount/umount options
*!
*! Revision 1.2 2012/04/13 00:49:59 dzhimiev
*! 1. added 'starting index' to logger
*!
*!
*! Revision 1.1 2012/04/13 00:22:51 dzhimiev
*! 1. added logger_launcher.php
*!
*!
*/
include 'show_source.inc';
//default parameters
$cmd = "start";
$file = "/usr/html/CF/imu_log.log";
$index = 1;
$n = 5000000;
$mount_point = "/usr/html/CF";
$force_dev = false;
$xml = "<Document>\n";
//get parameters
if (isset($_GET['cmd'])) $cmd = $_GET['cmd'];
if (isset($_GET['file'])) $file = $_GET['file'];
if (isset($_GET['index'])) $index = $_GET['index'];
if (isset($_GET['n'])) $n = $_GET['n'];
if (isset($_GET['mount_point'])) $mount_point = $_GET['mount_point'];
if (isset($_GET['dev'])) {
$dev = $_GET['dev'];
$force_dev = true;
}
if ($cmd=="start") {
if (!is_dir($mount_point)) mkdir($mount_point);
//detect devices
//$dev = "/dev/hda1";
if (!$force_dev) {
$hda1 = exec("cat /proc/diskstats | grep 'hda1'");
$hdb1 = exec("cat /proc/diskstats | grep 'hdb1'");
if (strlen($hda1)>0) $dev = "/dev/hda1";
else if (strlen($hdb1)>0) $dev = "/dev/hdb1";
else {
$xml .= "\t<error>CF cards not found</error>\n";
send_response($xml);
}
}
exec("mount $dev $mount_point");
exec("/usr/local/bin/log_imu $file $index $n >/dev/null 2>&1 &");
$xml .= "\t<result>ok</result>\n";
}
if ($cmd=="stop") {
exec("killall -1 log_imu");
//unmount
//exec("umount $mount_point");
exec("sync");
$xml .= "\t<result>ok</result>\n";
}
$xml .= "</Document>";
send_response($xml);
function send_response($xml){
header("Content-Type: text/xml");
header("Content-Length: ".strlen($xml)."\n");
header("Pragma: no-cache\n");
printf("%s", $xml);
flush();
}
function _help(){
echo "<pre>\n";
echo "Usage example: 'http://192.168.0.9/logger_launcher.php?file=/usr/html/CF/test.log&index=1&n=1000000&dev=/dev/hdb1', where\n";
echo "'file'- log name (includes absolute path), '/usr/html/CF/' is the 'dev's mount point\n";
echo "'index'- index added to the log name\n";
echo "'n'- max number of records in a single log file\n";
echo "'dev'- device name: '/dev/hda1' or '/dev/hdb1'\n";
}
function _usage(){
_help();
}
?>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
#!/usr/bin/env python
# encoding: utf-8
from __future__ import division
from __future__ import print_function
"""
# @file used_files.py
# @brief Extract file access data after build, modify CDT project configuration
# (.cproject) accordingly
# @copyright Copyright (C) 2016, Elphel.inc.
# @param <b>License</b>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
@author: Andrey Filippov
@license: GPLv3.0+
@contact: andrey@elphel.coml
@deffield updated: Updated
"""
__author__ = "Andrey Filippov"
__copyright__ = "Copyright 2016, Elphel, Inc."
__license__ = "GPL"
__version__ = "3.0+"
__maintainer__ = "Andrey Filippov"
__email__ = "andrey@elphel.com"
__status__ = "Development"
import sys
import os
import time
import xml.etree.ElementTree as ET
'''
TODO:Automate, find out why separate touch commands are needed
Run this program twice:
1-st run ./used_files.py linux -1
and save shown timestamp
Then run (some mystery here)
touch src/drivers/ata/ahci_elphel.c
touch src/drivers/elphel/sensor_common.c
Wait 5 seconds and run (in a different console with appropriate sourcing)
bitbake linux-xlnx -c compile -f
Then again
./used_files.py linux <timestamp_from_the_first_run>
If somethong went wrong you will need to resore .cproject from eclipse_project_setup directory
For php:
bitbake php -c cleansstate
bitbake php -c unpack -f
bitbake php -c configure -f
./used_files.py php -1
bitbake php -c compile -f
./used_files.py php 1471044836.8
Doing:
bitbake php -c compile -f
./used_files.py php -1
bitbake php -c compile -f
./used_files.py php 1471044836.8
Corrupts make process
'''
def file_tree(flist): # Each file in list is a file, no directories
ftree={}
for p in flist:
node = ftree
seg_list=p.split(os.sep)
last_i=len(seg_list)-1
for i,segm in enumerate(seg_list):
if not segm in node:
if i == last_i:
node[segm] = None
else:
node[segm] = {}
node=node[segm]
return ftree
def exclude_list(ftree, flist):
mark = "*" # no file/dir name can be "*"
def list_tree_recursive(root):
rslt = []
if not mark in root:
return [[""]] # convert to trailing "/" for directories
for n in root:
if not n == mark:
if root[n] is None:
rslt.append([n])
else:
for l in list_tree_recursive(root[n]):
rslt.append([n]+l)
return rslt
ftree[mark]=None # mark top level dir
for p in flist:
node = ftree
for segm in p.split(os.sep)[:-1]:
node=node[segm]
node[mark]=None # [mark] means used in flist
del node[p.split(os.sep)[-1]]
#print (ftree)
# for k in ftree:
# print(k)
#Now prune unused directories
#prune_recursive(ftree) # (assuming root is used)
# now create list
files_list_list = list_tree_recursive(ftree)
# print (files_list_list)
#converrt to file paths
pl = []
for l in files_list_list:
pl.append(os.path.join(*(l[1:])))
pl = sorted (pl)
return pl
def proc_tree():
DEBUG = True
extensions = [".h",".c",".cpp"]
exclude_start = ["linux"+os.sep+"scripts"+os.sep,"linux"+os.sep+"source"+os.sep+"scripts"+os.sep]
delta_t = 3 # seconds
try:
root_path = sys.argv[1]
except:
print ("Calling %s <root directory path> [timestamp]"%(os.path.basename(sys.argv[0])))
try:
start_time = float(sys.argv[2])
except:
start_time = 0.0
touch_files= start_time < 0.0
print ("root_path = %s"%(root_path))
# root_path = "/home/eyesis/git/poky/linux-elphel/linux/"
lstFiles = []
# Append files to a list
for path, _, files in os.walk(root_path, followlinks = True):
for f in files:
for ext in extensions:
if f.endswith(ext):
lstFiles.append(os.path.join(path, f))
break
all_tree= file_tree(sorted(lstFiles))
include_lst=[]
lst_a = []
latest_at=0
for p in lstFiles:
if touch_files:
if os.path.islink(p):
try:
os.utime(os.path.realpath(p), None)
except:
print("missing linked file: %s"%(os.path.realpath(p)))
else:
os.utime(p, None)
else:
# at = time.ctime(os.stat(p).st_atime)
try:
at = os.stat(p).st_atime
l = None
except:
at = 0
if os.path.islink(p):
try:
l = os.path.realpath(p)
at = os.stat(l).st_atime
except:
at = 0 # missing file
latest_at = max((latest_at,at))
if at > (start_time + delta_t):
#Scripts/lexers result in problems
exclude=False
for exStr in exclude_start:
if p.startswith(exStr):
exclude=True
break
if exclude:
break
#exclude_start
lst_a.append([p,at,l])
include_lst.append(p)
if touch_files:
print (len(lstFiles), "last time = ", time.time())
return
excluding = exclude_list(all_tree, include_lst)
# print (all_tree)
# print (sorted(include_lst))
# print ("|".join(excluding))
if DEBUG:
with open("all_sources.lst","w" ) as f:
for p in sorted(lstFiles):
try:
at = os.stat(p).st_atime
except:
at = 0
lnk=""
if os.path.islink(p):
try:
at = os.stat(os.path.realpath(p)).st_atime
except:
at = 0
lnk = os.path.realpath(p)
print (p,at,lnk, file=f)
with open("excluding.lst","w" ) as f:
for p in excluding:
print (p, file=f)
with open("including.lst","w" ) as f:
for p in include_lst:
print (p, file=f)
# include_tree= file_tree(sorted(include_lst))
# print(include_tree)
root_dir=include_lst[0].split(os.sep)[0]
print ("root_dir=",root_dir)
xml= ET.parse(".cproject")
root=xml.getroot()
# for child in root:
# print(child.tag, child.attrib)
for child in root.iter('sourceEntries'):
for gchild in child:
print(gchild.tag)
for child in root.iter('sourceEntries'):
for gchild in child:
if gchild.tag == 'entry':
attr = gchild.attrib
try:
if (attr['kind'] == 'sourcePath') and (attr['name'] == root_dir):
child.remove (gchild)
print ("Removed existing entry ",gchild.tag)
break
except:
print ("error matching attributes for ",gchild.tag)
pass
break #after first 'sourceEntries' - should be just one?
ET.SubElement(child, 'entry', {"flags":"VALUE_WORKSPACE_PATH", "kind":"sourcePath", "name":root_dir, "excluding":"|".join(excluding)})
for child in root.iter('sourceEntries'):
for gchild in child:
print(gchild.tag)
oneliner= ET.tostring(root)
#overwrites original .cproject, may change to somethong different
with open(".cproject", "wr") as f:
f.write("""<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?>""")
f.write(oneliner)
print (len(lstFiles), len(lst_a), "last access time = ",latest_at)
if __name__ == '__main__':
proc_tree()
"""
Usage for new applications:
1) add src to sources, remove root folder
2) Do not add sysroots to sources, just add include directory (sysroots/elphel393/usr/include-uapi) - sysroot created with 'bitbake -c unpack'
3) run following steps - they will add sysroots to .cproject, together with the exclude filter
make clean # otherwise compiled files are preserved
bitbake apps-editconf -c cleansstate
bitbake apps-editconf -c unpack -f
bitbake apps-editconf -c configure -f
./used_files.py sysroots -1
bitbake apps-editconf -c compile -f
./used_files.py sysroots 1473297567.42 # result of previous run
4)Add SCP <name> to target in "builders" "new" "program".
5) remove "configuration builder' in 2 steps - remove it from .externalToolBuilders, run Eclipse again and then remove from builders.
6) copy .externalToolBuilders (just 1 entry), .project and .cproject to eclipse_project_setup
7) make sure .gitignore ignores all what it should
"""
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment