This is an automated email from the ASF dual-hosted git repository.
damjan pushed a commit to branch scons-build
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/scons-build by this push:
new 949f602 Parse StaticLibrary. Gets cosv to parse, increasing parsable
modules to 20.
949f602 is described below
commit 949f60276820d454397ac48bb13ce20cc5fa953c
Author: Damjan Jovanovic <[email protected]>
AuthorDate: Sun Feb 2 07:16:21 2020 +0200
Parse StaticLibrary.
Gets cosv to parse, increasing parsable modules to 20.
Patch by: me
---
.../openoffice/gotoSCons/SConsConverter.java | 19 ++++++
.../opeonoffice/gotoSCons/targets/Module.java | 10 +++
.../gotoSCons/targets/StaticLibrary.java | 74 ++++++++++++++++++++++
main/site_scons/platform/aooplatform.py | 4 ++
main/site_scons/platform/freebsd.py | 3 +
main/site_scons/platform/windows.py | 5 ++
main/site_scons/staticLibrary.py | 39 ++++++++++++
7 files changed, 154 insertions(+)
diff --git
a/gotoSCons/src/main/java/org/apache/openoffice/gotoSCons/SConsConverter.java
b/gotoSCons/src/main/java/org/apache/openoffice/gotoSCons/SConsConverter.java
index 9bdcef7..05b0f48 100644
---
a/gotoSCons/src/main/java/org/apache/openoffice/gotoSCons/SConsConverter.java
+++
b/gotoSCons/src/main/java/org/apache/openoffice/gotoSCons/SConsConverter.java
@@ -30,6 +30,7 @@ import org.apache.opeonoffice.gotoSCons.targets.Library;
import org.apache.opeonoffice.gotoSCons.targets.Module;
import org.apache.opeonoffice.gotoSCons.targets.Pkg;
import org.apache.opeonoffice.gotoSCons.targets.Repository;
+import org.apache.opeonoffice.gotoSCons.targets.StaticLibrary;
public class SConsConverter {
private Repository repo;
@@ -44,6 +45,10 @@ public class SConsConverter {
for (Library library : module.getLibraries().values()) {
convertLibrary(library);
}
+
+ for (StaticLibrary library : module.getStaticLibraries().values()) {
+ convertStaticLibrary(library);
+ }
for (Executable exe : module.getExecutables().values()) {
convertExecutable(exe);
@@ -108,6 +113,20 @@ public class SConsConverter {
out.println();
}
+ private void convertStaticLibrary(StaticLibrary library) throws Exception {
+ String objectsVariable = convertObjects(library);
+
+ String layer = repo.getLibraryLayer(library.getName());
+ out.println(String.format("%s = AOOStaticLibrary(",
library.getName()));
+ out.println(String.format(" '%s',", library.getName()));
+ out.println(String.format(" '%s',", layer));
+ out.println(String.format(" %s.objects", objectsVariable));
+ out.println(String.format(")"));
+
+ out.println(String.format("%s.InstallTo('${OUTDIR}/lib')",
library.getName()));
+ out.println();
+ }
+
private void convertExecutable(Executable exe) throws Exception {
String objectsVariable = convertObjects(exe);
diff --git
a/gotoSCons/src/main/java/org/apache/opeonoffice/gotoSCons/targets/Module.java
b/gotoSCons/src/main/java/org/apache/opeonoffice/gotoSCons/targets/Module.java
index 5d20234..f54e87b 100644
---
a/gotoSCons/src/main/java/org/apache/opeonoffice/gotoSCons/targets/Module.java
+++
b/gotoSCons/src/main/java/org/apache/opeonoffice/gotoSCons/targets/Module.java
@@ -40,6 +40,7 @@ public class Module extends BaseTarget {
private String name;
private Map<String, Library> libraries = new TreeMap<>();
private Map<String, Executable> executables = new TreeMap<>();
+ private Map<String, StaticLibrary> staticLibraries = new TreeMap<>();
private TreeSet<String> targets = new TreeSet<>();
private Map<String, Pkg> packages = new TreeMap<>();
@@ -100,6 +101,11 @@ public class Module extends BaseTarget {
if (libraries.put(arg, library) != null) {
throw new Exception("Duplicate add of target " + arg);
}
+ } else if (arg.startsWith("StaticLibrary_")) {
+ StaticLibrary staticLibrary = new StaticLibrary(new
File(filename.getParentFile(), arg + ".mk"));
+ if (staticLibraries.put(arg, staticLibrary) != null) {
+ throw new Exception("Duplicate add of target " + arg);
+ }
} else if (arg.startsWith("Package_")) {
Pkg pkg = new Pkg(new File(filename.getParentFile(), arg +
".mk"));
if (packages.put(arg, pkg) != null) {
@@ -123,6 +129,10 @@ public class Module extends BaseTarget {
return libraries;
}
+ public Map<String, StaticLibrary> getStaticLibraries() {
+ return staticLibraries;
+ }
+
public Map<String, Executable> getExecutables() {
return executables;
}
diff --git
a/gotoSCons/src/main/java/org/apache/opeonoffice/gotoSCons/targets/StaticLibrary.java
b/gotoSCons/src/main/java/org/apache/opeonoffice/gotoSCons/targets/StaticLibrary.java
new file mode 100644
index 0000000..d554574
--- /dev/null
+++
b/gotoSCons/src/main/java/org/apache/opeonoffice/gotoSCons/targets/StaticLibrary.java
@@ -0,0 +1,74 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+package org.apache.opeonoffice.gotoSCons.targets;
+
+import java.io.File;
+import java.util.Arrays;
+import org.apache.openoffice.gotoSCons.raw.Node;
+import org.apache.openoffice.gotoSCons.raw.ValueNode;
+
+public class StaticLibrary extends BaseBinary {
+ private File filename;
+
+ public StaticLibrary(File filename) throws Exception {
+ super(filename);
+ }
+
+ @Override
+ protected void parseCall(Node argsNode) throws Exception {
+ if (argsNode instanceof ValueNode) {
+ String value = ((ValueNode)argsNode).value;
+ String[] tokens = value.split(",");
+
+ String function = tokens[0].trim();
+ String[] args = Arrays.copyOfRange(tokens, 1, tokens.length);
+
+ if (function.equals("gb_StaticLibrary_StaticLibrary")) {
+ parseStaticLibraryStaticLibrary(args);
+ } else if (function.equals("gb_StaticLibrary_add_api")) {
+ parseAddApi(args);
+ } else if (function.equals("gb_StaticLibrary_add_defs")) {
+ parseAddDefs(args);
+ } else if
(function.equals("gb_StaticLibrary_add_exception_objects")) {
+ parseAddExceptionObjects(args);
+ } else if
(function.equals("gb_StaticLibrary_add_noexception_objects")) {
+ parseAddNoExceptionObjects(args);
+ } else if
(function.equals("gb_StaticLibrary_add_package_headers")) {
+ parseAddPackageHeaders(args);
+ } else if
(function.equals("gb_StaticLibrary_add_precompiled_header")) {
+ parseAddPrecompiledHeader(args);
+ } else if (function.equals("gb_StaticLibrary_set_include")) {
+ parseSetInclude(args);
+ } else {
+ throw new Exception("UNHANDLED FUNCTION " + function);
+ }
+ } else {
+ throw new Exception("Call args not a value");
+ }
+ }
+
+ private void parseStaticLibraryStaticLibrary(String[] args) throws
Exception {
+ if (args.length != 1) {
+ throw new Exception("Expected 1 arg, got " +
Arrays.toString(args));
+ }
+ this.name = args[0];
+ }
+}
diff --git a/main/site_scons/platform/aooplatform.py
b/main/site_scons/platform/aooplatform.py
index 11dfbb0..4fc6122 100644
--- a/main/site_scons/platform/aooplatform.py
+++ b/main/site_scons/platform/aooplatform.py
@@ -83,6 +83,10 @@ class Platform(ABC):
pass
@abstractmethod
+ def getStaticLibraryLDFlags(self, debugging, debugLevel):
+ pass
+
+ @abstractmethod
def getStandardLibs(self):
pass
diff --git a/main/site_scons/platform/freebsd.py
b/main/site_scons/platform/freebsd.py
index c1e845f..4fbd332 100644
--- a/main/site_scons/platform/freebsd.py
+++ b/main/site_scons/platform/freebsd.py
@@ -232,6 +232,9 @@ class FreeBSD(aooplatform.Platform):
]
return flags
+ def getStaticLibraryLDFlags(self, debugging, debugLevel):
+ return self.getLDFlags(soenv, debugging, debugLevel)
+
def getStandardLibs(self):
return []
diff --git a/main/site_scons/platform/windows.py
b/main/site_scons/platform/windows.py
index eeec1ad..751c47c 100644
--- a/main/site_scons/platform/windows.py
+++ b/main/site_scons/platform/windows.py
@@ -269,6 +269,11 @@ class Windows(aooplatform.Platform):
flags += ['-SAFESEH']
return flags
+ def getStaticLibraryLDFlags(self, debugging, debugLevel):
+ flags = self.getLDFlags(soenv, debugging, debugLevel)
+ flags += ['-LIB']
+ return flags
+
def getStandardLibs(self):
return [
'kernel32',
diff --git a/main/site_scons/staticLibrary.py b/main/site_scons/staticLibrary.py
new file mode 100644
index 0000000..4d3bed8
--- /dev/null
+++ b/main/site_scons/staticLibrary.py
@@ -0,0 +1,39 @@
+#**************************************************************
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+#**************************************************************
+
+from SCons.Script import *
+from config import soenv
+from globals import *
+
+class AOOStaticLibrary:
+ def __init__(self, target, group, sharedObjects):
+ self.env = DefaultEnvironment().Clone()
+ self.staticLib = self.env.StaticLibrary(
+ target,
+ source = sharedObjects
+ )
+ self.env['AOO_THIS'] = self.sharedLib[0]
+ self.env.Append(LINKFLAGS=platform.getStaticLibraryLDFlags(soenv,
DEBUGGING, DEBUGLEVEL))
+ self.env.Append(LIBPATH=platform.getLDPATH(soenv))
+ self.env['AOO_GROUP'] = group
+
+ def InstallTo(self, path):
+ self.env.Install(path, self.staticLib)