changeset 60:e5f099108a6e

fix cmake link argument
author anatofuz
date Thu, 11 Jul 2019 16:12:16 +0900
parents 8f435de13b91
children b3a3224e1823
files src/gearsTools/pmake.pl src/usr/CMakeLists.txt
diffstat 2 files changed, 106 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gearsTools/pmake.pl	Thu Jul 11 16:12:16 2019 +0900
@@ -0,0 +1,105 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+my ($cc,$cflags,$asm,$ld,$ldflags,$libgcc,$cmake);
+
+$cmake = 'cmake';
+
+if ($^O =~ /darwin/){
+    $cc      = $ENV{CBC_LANG_COMPILER};
+    $cflags  = qq|-Wall -g -arch arm -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -Werror -I. -g -O0 
+             -Wno-macro-redefined -Wno-gnu-designator -Wno-sometimes-uninitialized -Wno-tautological-compare 
+             -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include
+             -Wno-nullability-completeness -Wno-expansion-to-defined"|;
+    $ldflags = qq|-B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-  
+             -DCBCXV6=1 -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0|;
+} else {
+    $cc     = '/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc';
+    $asm    = $cc;
+    $cflags = qq|-B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-  
+             -DCBCXV6=1 -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0|;
+    $ld     = '/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-ld';
+    chomp($libgcc = `$cc --print-libgcc-file-name`);
+    $cflags .= " $libgcc";
+    $cmake  .= 3;
+    $ldflags = " -L. -T kernel-cmake.ld $libgcc -b binary initcode fs.img";
+}
+
+$cflags =~ s/\n//g;
+create_link_script();
+#cmake -DCMAKE_LINKER=/path/to/linker -DCMAKE_CXX_LINK_EXECUTABLE="<CMAKE_LINKER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"
+print_exec_system($cmake, "-DCBC_COM=$cc", "-DPMAKE_ARGS=\"$cflags\"","-DCMAKE_ASM_COMPILER=$cc","-DCMAKE_LINKER=$ld","-DCMAKE_C_LINK_EXECUTABLE=\"$ld $ldflags  <OBJECTS> -o kernel.elf\"","-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE",'.');
+system("make");
+system("sh","link.sh");
+
+sub create_link_script {
+  my @link_script;
+  while (my $line = <DATA>){
+    $line =~ s/LD/$ld/;
+    $line =~ s/LIBGCC/$libgcc/;
+    push @link_script,$line;
+  }
+  if ($^O =~ /darwin/){
+    for (@link_script){
+       s/CMakeFiles/build/;
+       s|kernel\.dir/||;
+    }
+  }
+  open my $fh, '>', 'link.sh';
+  print $fh "@link_script";
+}
+
+sub print_exec_system {
+  my @query = @_;
+  print(join(' ',@query), "\n");
+  system(join(' ',@query));
+}
+
+__DATA__
+cp  initcode ./CMakeFiles/kernel.dir/initcode 
+cp  fs.img ./CMakeFiles/kernel.dir/fs.img
+
+LD \
+-L. \
+-T \
+kernel-cmake.ld \
+-o \
+kernel.elf \
+ \
+CMakeFiles/kernel.dir/lib/string.c.o \
+CMakeFiles/kernel.dir/arm.c.o \
+CMakeFiles/kernel.dir/asm.S.o \
+CMakeFiles/kernel.dir/bio.c.o \
+CMakeFiles/kernel.dir/buddy.c.o \
+CMakeFiles/kernel.dir/c/console.c.o \
+CMakeFiles/kernel.dir/exec.c.o \
+CMakeFiles/kernel.dir/c/file.c.o \
+CMakeFiles/kernel.dir/fs.c.o \
+CMakeFiles/kernel.dir/log.c.o \
+CMakeFiles/kernel.dir/main.c.o \
+CMakeFiles/kernel.dir/memide.c.o \
+CMakeFiles/kernel.dir/c/pipe.c.o \
+CMakeFiles/kernel.dir/c/proc.c.o \
+CMakeFiles/kernel.dir/c/spinlock.c.o \
+CMakeFiles/kernel.dir/start.c.o \
+CMakeFiles/kernel.dir/swtch.S.o \
+CMakeFiles/kernel.dir/c/syscall.c.o \
+CMakeFiles/kernel.dir/c/sysfile.c.o \
+CMakeFiles/kernel.dir/sysproc.c.o \
+CMakeFiles/kernel.dir/trap_asm.S.o \
+CMakeFiles/kernel.dir/trap.c.o \
+CMakeFiles/kernel.dir/vm.c.o \
+CMakeFiles/kernel.dir/device/picirq.c.o \
+CMakeFiles/kernel.dir/device/timer.c.o \
+CMakeFiles/kernel.dir/device/uart.c.o \
+CMakeFiles/kernel.dir/entry.S.o \
+CMakeFiles/kernel.dir/c/kernel-context.c.o \
+ \
+ \
+LIBGCC \
+ \
+-b \
+binary \
+initcode \
+fs.img 
--- a/src/usr/CMakeLists.txt	Fri Jul 05 17:06:31 2019 +0900
+++ b/src/usr/CMakeLists.txt	Thu Jul 11 16:12:16 2019 +0900
@@ -58,7 +58,7 @@
 endforeach(cmd)
 
 add_custom_command(OUTPUT fs.img
-  COMMAND ./mkfs fs.img ${USR_COMMAND} UNIX
+  COMMAND ../tools/mkfs fs.img ${USR_COMMAND} UNIX
   DEPENDS ${USR_COMMANDS}
 )