Skip to content

Commit b393ca6

Browse files
committed
Add Solaris 9 support.
1 parent 4b71822 commit b393ca6

File tree

9 files changed

+40
-20
lines changed

9 files changed

+40
-20
lines changed

ChangeLog.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
07/06/2014 - 0.3
2+
1. Load libgcc_s.so.1 if it exists in tcc lib path.
3+
14
06/14/2014 - 0.2
25
1. Fixed libtcc.dylib and libtcc1.a error for Mac OS X.
36
2. Add Solaris x86 support.

build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project.name = TCC4Java
2-
project.version = 0.2
2+
project.version = 0.3
33
project.encoding = UTF-8
44

55
lib.dir = lib

readme.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ What is TCC4Java?
2828
FreeBSD 9.0 x86/x64 (The FreeBSD based os such as GhostBSD, PC-BSD, ArchBSD, MidnightBSD are also supported)
2929
NetBSD 6.1.4 x86/x64
3030
DragonFlyBSD 3.6.2 x86/x64
31-
Solaris 10/11 x86
31+
Solaris 9/10/11 x86
3232
4. Supported jdk:
3333
jdk 1.5 or later
3434
5. TCC4Java is released under Apache License 2.0.

runTest.bat

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
@echo off
22

3+
set TCC4JAVA_VERSION=0.3
4+
35
set CLASSPATH=.\lib\commons-io-2.2.jar
46
set CLASSPATH=%CLASSPATH%;.\lib\hamcrest-core-1.3.jar
57
set CLASSPATH=%CLASSPATH%;.\lib\jna-4.1.0.jar
68
set CLASSPATH=%CLASSPATH%;.\lib\junit-4.11.jar
79
set CLASSPATH=%CLASSPATH%;.\lib\slf4j-api-1.7.7.jar
810
set CLASSPATH=%CLASSPATH%;.\lib\slf4j-simple-1.7.7.jar
9-
set CLASSPATH=%CLASSPATH%;.\dist\0.2\TCC4Java-0.2.jar
10-
set CLASSPATH=%CLASSPATH%;.\dist\0.2\TCC4Java-0.2-test.jar
11+
set CLASSPATH=%CLASSPATH%;.\dist\%TCC4JAVA_VERSION%\TCC4Java-%TCC4JAVA_VERSION%.jar
12+
set CLASSPATH=%CLASSPATH%;.\dist\%TCC4JAVA_VERSION%\TCC4Java-%TCC4JAVA_VERSION%-test.jar
1113

1214
set TESTS=AllTests
1315
IF NOT "%1"=="" (

runTest.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#!/usr/bin/env bash
22

3+
TCC4JAVA_VERSION=0.3
4+
35
CLASSPATH=./lib/commons-io-2.2.jar
46
CLASSPATH=$CLASSPATH:./lib/hamcrest-core-1.3.jar
57
CLASSPATH=$CLASSPATH:./lib/junit-4.11.jar
68
CLASSPATH=$CLASSPATH:./lib/slf4j-api-1.7.7.jar
79
CLASSPATH=$CLASSPATH:./lib/slf4j-simple-1.7.7.jar
8-
CLASSPATH=$CLASSPATH:./dist/0.2/TCC4Java-0.2.jar
9-
CLASSPATH=$CLASSPATH:./dist/0.2/TCC4Java-0.2-test.jar
10+
CLASSPATH=$CLASSPATH:./dist/$TCC4JAVA_VERSION/TCC4Java-$TCC4JAVA_VERSION.jar
11+
CLASSPATH=$CLASSPATH:./dist/$TCC4JAVA_VERSION/TCC4Java-$TCC4JAVA_VERSION-test.jar
1012

1113
if [ "$(uname -s)" == "GNU/kFreeBSD" ]; then
1214
LIB_JNA=./lib/kFreeBSD/jna-3.2.7.jar

src/cn/com/tcc/State.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ public boolean setOptions(String options) {
141141
public boolean addIncludePath(String includePath) {
142142
logger.debug(String.format("Add include path %s.", includePath));
143143
checkStatus();
144-
return (tcc.tcc_add_include_path(tccState, includePath) != ERROR_RETURN_VALUE);
144+
return (tcc.tcc_add_include_path(tccState,
145+
new File(includePath).getAbsolutePath()) != ERROR_RETURN_VALUE);
145146
}
146147

147148
/**
@@ -153,7 +154,8 @@ public boolean addIncludePath(String includePath) {
153154
public boolean addSysIncludePath(String includePath) {
154155
logger.debug(String.format("Add system include path %s.", includePath));
155156
checkStatus();
156-
return (tcc.tcc_add_sysinclude_path(tccState, includePath) != ERROR_RETURN_VALUE);
157+
return (tcc.tcc_add_sysinclude_path(tccState,
158+
new File(includePath).getAbsolutePath()) != ERROR_RETURN_VALUE);
157159
}
158160

159161
/**
@@ -206,7 +208,8 @@ public void undefineSymbol(String sym) {
206208
public boolean addFile(String filePath) {
207209
logger.debug(String.format("Add file %s.", filePath));
208210
checkStatus();
209-
return (tcc.tcc_add_file(tccState, filePath) != ERROR_RETURN_VALUE);
211+
return (tcc
212+
.tcc_add_file(tccState, new File(filePath).getAbsolutePath()) != ERROR_RETURN_VALUE);
210213
}
211214

212215
/**

src/cn/com/tcc/TCC.java

+15-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ public final class TCC {
2424
protected static String tccPath = "";
2525

2626
/* TCC library name */
27-
private static final String DLL_LIB_NAME = "tcc";
27+
private static final String LIB_TCC = "tcc";
28+
29+
/* GCC library name */
30+
private static final String LIB_GCC = "libgcc_s.so.1";
2831

2932
private static final String ENV_CONFIG_TCC_DIR = "CONFIG_TCCDIR";
3033
private static final String ENV_CONFIG_OS = "CONFIG_OS";
@@ -59,7 +62,14 @@ public static void init(String tccPath) {
5962
if ((tccPath != null) && (tccPath.trim().length() > 0)
6063
&& !tccPath.equals(TCC.tccPath)) {
6164
TCC.tccPath = tccPath;
62-
logger.info(String.format("Set tccPath to %s.", tccPath));
65+
logger.debug(String.format("Set tccPath to %s.", tccPath));
66+
67+
File libGcc = new File(TCC.getSharedLibPath(), LIB_GCC);
68+
if (libGcc.isFile() && libGcc.exists()) {
69+
System.load(libGcc.getAbsolutePath());
70+
logger.debug(String.format("Load library %s successfully.",
71+
LIB_GCC));
72+
}
6373
}
6474
}
6575

@@ -72,7 +82,7 @@ protected TCCLibrary initialValue() {
7282
try {
7383
tcc = loadNativeLibrary();
7484

75-
logger.info(String.format("%s initialized for thread %s.",
85+
logger.debug(String.format("%s initialized for thread %s.",
7686
TCC.class.getSimpleName(), Thread.currentThread()
7787
.getName()));
7888
} catch (Throwable e) {
@@ -134,7 +144,7 @@ protected static String getLibPath() {
134144
.getAbsolutePath();
135145
}
136146

137-
protected static String getSharedLibPath() {
147+
public static String getSharedLibPath() {
138148
return new File(tccPath, getSharedLibPath(getOSName()))
139149
.getAbsolutePath();
140150
}
@@ -269,7 +279,7 @@ protected static String getNativeLibraryResourcePrefix(OS osType,
269279
private static TCCLibrary loadNativeLibrary() {
270280
try {
271281
// Get what the system "thinks" the library name should be.
272-
String libName = DLL_LIB_NAME;
282+
String libName = LIB_TCC;
273283
String libNativeName = System.mapLibraryName(libName);
274284

275285
// Slice up the library name.

tcc/sunos/x86/libgcc_s.so.1

43.3 KB
Binary file not shown.

test/cn/com/tcc/AllTests.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import org.junit.runners.Suite;
55

66
@RunWith(Suite.class)
7-
@Suite.SuiteClasses({ AddFileTest.class, AddFunctionTest.class, AddIncludePathTest.class,
8-
AddSysIncludePathTest.class, CompileStringTest.class,
9-
DefineSymbolTest.class, DeleteTest.class, GetVarTest.class,
10-
OutputFileTest.class, RunTest.class, SetErrorFuncTest.class,
11-
SetLibPathTest.class, SetOptionsTest.class, SetOutputTypeTest.class,
12-
UndefineSymbolTest.class })
7+
@Suite.SuiteClasses({ AddFileTest.class, AddFunctionTest.class,
8+
AddIncludePathTest.class, AddSysIncludePathTest.class,
9+
CompileStringTest.class, DefineSymbolTest.class, DeleteTest.class,
10+
GetVarTest.class, OutputFileTest.class, RunTest.class,
11+
SetErrorFuncTest.class, SetLibPathTest.class, SetOptionsTest.class,
12+
SetOutputTypeTest.class, UndefineSymbolTest.class })
1313
public class AllTests {
1414
}

0 commit comments

Comments
 (0)