[buildj] add the ability to load project files from subdirectories
- From: Abderrahim Kitouni <akitouni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [buildj] add the ability to load project files from subdirectories
- Date: Tue, 15 Jun 2010 18:30:00 +0000 (UTC)
commit 59cd76dcf8eb3961d099fc9fc5b7dfba9c9eee89
Author: Abderrahim Kitouni <a kitouni gmail com>
Date: Sun Mar 28 17:23:40 2010 +0100
add the ability to load project files from subdirectories
buildj.py | 22 +++++++--
gtk_program.c => cc/gtk_program.c | 0
lib.c => cc/lib.c | 0
lib.h => cc/lib.h | 0
program.c => cc/program.c | 0
.../program_with_defines.c | 2 +-
program_with_lib.c => cc/program_with_lib.c | 2 +-
cc/project.js | 52 ++++++++++++++++++++
project.js | 48 +------------------
9 files changed, 73 insertions(+), 53 deletions(-)
---
diff --git a/buildj.py b/buildj.py
index 0c19ad2..1278a40 100644
--- a/buildj.py
+++ b/buildj.py
@@ -48,8 +48,8 @@ class ProjectFile:
def __init__ (self, project="project.js"):
dec = json.decoder.JSONDecoder ()
prj = open(project)
- self._json = prj.read ()
- self._project = dec.decode (self._json)
+ data = prj.read ()
+ self._project = dec.decode (data)
prj.close ()
#TODO: try to raise some meaningful (and consistent) error
@@ -58,11 +58,25 @@ class ProjectFile:
self._targets = []
for target_name, target_data in self._project['targets'].iteritems():
- assert isinstance(target_data, dict), 'target must be a mapping, "%s" is %r' (target_name, target_data)
self._targets.append(ProjectTarget(target_name, target_data))
+ for subdir in self._project.get ('subdirs', []):
+ prj = open ('%s/%s' % (subdir, project))
+ data = prj.read ()
+ subproject = dec.decode (data)
+ for target_name, target_data in subproject['targets'].iteritems():
+ assert target_name not in self._project['targets']
+ if 'path' in target_data:
+ path = '%s/%s' % (subdir, target_data['path'])
+ else:
+ path = subdir
+ target_data['path'] = path
+ self._project['targets'] = target_data
+ self._targets.append(ProjectTarget(target_name, target_data))
+
def __repr__ (self):
- return str (self._json)
+ enc = json.encoder.JSONEncoder ()
+ return enc.encode (self._project)
def get_project_version (self):
return self._project_version
diff --git a/gtk_program.c b/cc/gtk_program.c
similarity index 100%
rename from gtk_program.c
rename to cc/gtk_program.c
diff --git a/lib.c b/cc/lib.c
similarity index 100%
rename from lib.c
rename to cc/lib.c
diff --git a/lib.h b/cc/lib.h
similarity index 100%
rename from lib.h
rename to cc/lib.h
diff --git a/program.c b/cc/program.c
similarity index 100%
rename from program.c
rename to cc/program.c
diff --git a/program_with_defines.c b/cc/program_with_defines.c
similarity index 81%
rename from program_with_defines.c
rename to cc/program_with_defines.c
index 908c90a..736107d 100644
--- a/program_with_defines.c
+++ b/cc/program_with_defines.c
@@ -3,7 +3,7 @@
#include <stdio.h>
int main (int argc, char** argv)
{
- printf (BAR "\n");
+ printf (BAR "\n");
}
#endif
#endif
diff --git a/program_with_lib.c b/cc/program_with_lib.c
similarity index 73%
rename from program_with_lib.c
rename to cc/program_with_lib.c
index 6a6fe78..dc2354d 100644
--- a/program_with_lib.c
+++ b/cc/program_with_lib.c
@@ -1,4 +1,4 @@
-#include "lib.h"
+#include <lib.h>
int main ()
{
dummy_function ();
diff --git a/cc/project.js b/cc/project.js
new file mode 100644
index 0000000..782e0ea
--- /dev/null
+++ b/cc/project.js
@@ -0,0 +1,52 @@
+{
+ "targets":
+ {
+ "my_program":
+ {
+ "type": "program",
+ "tool": "cc",
+ "input": ["program.c"]
+ },
+ "my_shared_lib":
+ {
+ "type": "sharedlib",
+ "tool": "cc",
+ "input": ["lib.c"],
+ "version": "1.2.3"
+ },
+ "my_static_lib":
+ {
+ "type": "staticlib",
+ "tool": "cc",
+ "input": ["lib.c"]
+ },
+ "my_static_program":
+ {
+ "type": "program",
+ "tool": "cc",
+ "input": ["program_with_lib.c"],
+ "uses": ["my_static_lib"]
+ },
+ "my_shared_program":
+ {
+ "type": "program",
+ "tool": "cc",
+ "input": ["program_with_lib.c"],
+ "uses": ["my_shared_lib"]
+ },
+ "my_gtk_program":
+ {
+ "type": "program",
+ "tool": "cc",
+ "input": ["gtk_program.c"],
+ "packages": ["gtk+-2.0"]
+ },
+ "my_program_with_defines":
+ {
+ "type": "program",
+ "tool": "cc",
+ "input": ["program_with_defines.c"],
+ "defines": ["FOO", "BAR=\"123\""]
+ }
+ }
+}
diff --git a/project.js b/project.js
index aa53e5d..1379a20 100644
--- a/project.js
+++ b/project.js
@@ -26,14 +26,9 @@
"mandatory": "${foo}"
}
},
+ "subdirs": ["cc"],
"targets":
{
- "my_program":
- {
- "type": "program",
- "tool": "cc",
- "input": ["program.c"]
- },
"my_cpp_program":
{
"type": "program",
@@ -42,47 +37,6 @@
"input": ["cpprogram.cpp"],
"uses": ["my_static_lib"]
},
- "my_shared_lib":
- {
- "type": "sharedlib",
- "tool": "cc",
- "input": ["lib.c"],
- "version": "1.2.3"
- },
- "my_static_lib":
- {
- "type": "staticlib",
- "tool": "cc",
- "input": ["lib.c"]
- },
- "my_static_program":
- {
- "type": "program",
- "tool": "cc",
- "input": ["program_with_lib.c"],
- "uses": ["my_static_lib"]
- },
- "my_shared_program":
- {
- "type": "program",
- "tool": "cc",
- "input": ["program_with_lib.c"],
- "uses": ["my_shared_lib"]
- },
- "my_gtk_program":
- {
- "type": "program",
- "tool": "cc",
- "input": ["gtk_program.c"],
- "packages": ["gtk+-2.0"]
- },
- "my_program_with_defines":
- {
- "type": "program",
- "tool": "cc",
- "input": ["program_with_defines.c"],
- "defines": ["FOO", "BAR=\"123\""]
- },
"my_vala_program":
{
"type": "program",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]